Skip to content

Commit

Permalink
feat(rest-api): create rest-api library for external services (#5) (#6)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: version bump for FINAL prod release
  • Loading branch information
vincejv authored Nov 3, 2022
1 parent ad558c7 commit c281af3
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@
@NoArgsConstructor
@RegisterForReflection
public class MsgrErrorApiResp extends AbsMongoField {
private String message;
private String type;
private Integer code;
@JsonProperty("fbtrace_id")
private String fbTraceId;

@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@RegisterForReflection
public static class ErrorField extends AbsMongoField {
private String message;
private String type;
private Integer code;
@JsonProperty("error_subcode")
private Integer subCode;
@JsonProperty("fbtrace_id")
private String fbTraceId;
}

private ErrorField error;

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class MsgrLog extends AbsMongoItem {
private String recipient;
private String pageId;
private String msgContent;
private MsgrErrorApiResp apiError;
private MsgrErrorApiResp.ErrorField apiError;
private List<MsgAttchmt> attachments;
private String fpiUser;
private String fpiSystem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.abavilla.fpi.msgr.ext.dto.MsgrMsgReqDto;
import com.abavilla.fpi.msgr.mapper.MsgrMsgReqMapper;
import com.abavilla.fpi.msgr.repo.MsgrLogRepo;
import io.quarkus.logging.Log;
import io.quarkus.security.identity.SecurityIdentity;
import io.smallrye.mutiny.Uni;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -59,7 +60,8 @@ public Uni<MsgrReqReply> postMsg(MsgrMsgReqDto msgReq, String appSource) {
})
.onFailure(ApiSvcEx.class).recoverWithUni(throwable -> {
var apiEx = (ApiSvcEx) throwable;
saved.setApiError(apiEx.getJsonResponse(MsgrErrorApiResp.class));
Log.error("metaMsgrApiSvc returned an error", apiEx);
saved.setApiError(apiEx.getJsonResponse(MsgrErrorApiResp.class).getError());
log.setDateUpdated(DateUtil.now());
return repo.update(saved);
})
Expand Down
4 changes: 3 additions & 1 deletion fpi-msgr-api-core/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ quarkus:
http:
port: ${PORT:8080}
arc:
exclude-types: com.abavilla.fpi.msgr.ext.rest.*
exclude-types:
- com.abavilla.fpi.msgr.ext.rest.*
- com.abavilla.fpi.login.ext.rest.*
mongodb:
connection-string:
${MONGO_CONN_STRING:mongodb://localhost}
Expand Down
10 changes: 10 additions & 0 deletions fpi-msgr-api-lib/.mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">

<extension>
<groupId>me.qoomon</groupId>
<artifactId>maven-git-versioning-extension</artifactId>
<version>9.3.1</version>
</extension>

</extensions>
20 changes: 20 additions & 0 deletions fpi-msgr-api-lib/.mvn/maven-git-versioning-extension.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<configuration xmlns="https://github.com/qoomon/maven-git-versioning-extension"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/qoomon/maven-git-versioning-extension https://qoomon.github.io/maven-git-versioning-extension/configuration-9.1.0.xsd">
<refs considerTagsOnBranches="true">
<ref type="branch">
<pattern>main</pattern> <!-- expects that main branch is 1 commit = 1 tag -->
<describeTagPattern><![CDATA[v(?<version>.*)]]></describeTagPattern>
<version>${describe.tag.version}</version>
</ref>
<ref type="branch">
<pattern>.+</pattern>
<describeTagPattern><![CDATA[v(?<version>.*)]]></describeTagPattern>
<version>${describe.tag.version}-${commit.short}-SNAPSHOT</version>
</ref>
</refs>
<!-- optional fallback configuration in case of no matching ref configuration-->
<rev>
<version>${commit}-SNAPSHOT</version>
</rev>
</configuration>
5 changes: 4 additions & 1 deletion fpi-msgr-api-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@
</properties>

<dependencies>

<dependency>
<groupId>com.abavilla</groupId>
<artifactId>fpi-meta-plugin-lib</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/******************************************************************************
* FPI Application - Abavilla *
* Copyright (C) 2022 Vince Jerald Villamora *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
******************************************************************************/

package com.abavilla.fpi.msgr.ext.rest;

import javax.ws.rs.Consumes;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.abavilla.fpi.fw.dto.impl.RespDto;
import com.abavilla.fpi.fw.exceptions.handler.ApiRepoExHandler;
import com.abavilla.fpi.fw.rest.IApi;
import com.abavilla.fpi.meta.ext.dto.msgr.MsgrReqReply;
import com.abavilla.fpi.msgr.ext.dto.MsgrMsgReqDto;
import io.smallrye.mutiny.Uni;
import org.eclipse.microprofile.rest.client.annotation.RegisterProvider;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

@RegisterRestClient(configKey = "load-api")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@RegisterProvider(value = ApiRepoExHandler.class)
public interface MsgrReqApi extends IApi {

Uni<RespDto<MsgrReqReply>> sendMsg(
MsgrMsgReqDto msgReq, @HeaderParam("X-FPI-System") String fpiSystem);

}

0 comments on commit c281af3

Please sign in to comment.