Spaces:
Sleeping
Sleeping
Merged in release/dev (pull request #14)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- Dockerfile +21 -0
- README.md +5 -0
- bitbucket-pipelines.yml +15 -0
- pom.xml +10 -0
- src/main/java/com/artandscience/webbff/webbff/WebbffApplication.java +2 -0
- src/main/java/com/artandscience/webbff/webbff/api/controller/BackOfficeController.java +4 -0
- src/main/java/com/artandscience/webbff/webbff/api/controller/CampaignController.java +31 -0
- src/main/java/com/artandscience/webbff/webbff/api/controller/HomepageController.java +26 -0
- src/main/java/com/artandscience/webbff/webbff/api/model/response/GetCampaignResponse.java +17 -0
- src/main/java/com/artandscience/webbff/webbff/api/model/response/GetHomepageResponse.java +17 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/controller/BaseController.java +30 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/model/BaseModel.java +12 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/model/MessageModel.java +15 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/model/RequestHeader.java +24 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/BaseValidResponse.java +27 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageBox.java +26 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageBoxAction.java +24 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageResponse.java +42 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/builder/MsgResponseBuilder.java +28 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageBoxActionType.java +9 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageBoxActionUiStyle.java +10 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageType.java +7 -0
- src/main/java/com/artandscience/webbff/webbff/common/constants/ButtonTypeConstants.java +23 -0
- src/main/java/com/artandscience/webbff/webbff/common/constants/HeaderConstant.java +17 -0
- src/main/java/com/artandscience/webbff/webbff/common/constants/HtmlTypeConstants.java +16 -0
- src/main/java/com/artandscience/webbff/webbff/common/constants/MessageBoxActionTypeConstants.java +18 -0
- src/main/java/com/artandscience/webbff/webbff/common/constants/MessageBoxActionUiConstants.java +15 -0
- src/main/java/com/artandscience/webbff/webbff/common/constants/MessageTypeConstants.java +9 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/BusinessException.java +23 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/CoreException.java +14 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/ProviderValidateException.java +23 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/SessionException.java +25 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/enums/BaseErrorType.java +8 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/enums/BusinessErrorType.java +21 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/enums/SessionErrorType.java +22 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/enums/UnhandledErrorType.java +22 -0
- src/main/java/com/artandscience/webbff/webbff/common/helper/JsonMapper.java +36 -0
- src/main/java/com/artandscience/webbff/webbff/common/interceptor/ResponseErrorHandler.java +127 -0
- src/main/java/com/artandscience/webbff/webbff/common/interceptor/TransactionFilter.java +72 -0
- src/main/java/com/artandscience/webbff/webbff/common/scope/RequestHeaderScope.java +20 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/ExternalAttributeService.java +13 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/MainButtonService.java +11 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/MessageBoxService.java +12 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/ModelConfigService.java +5 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/ResourceService.java +6 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/StateManagementService.java +21 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/impl/ExternalAttributeServiceImpl.java +101 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/impl/MainButtonServiceImpl.java +50 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/impl/MessageBoxServiceImpl.java +98 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/impl/ModelConfigServiceImpl.java +47 -0
Dockerfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM eclipse-temurin:17-jdk-jammy AS build
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY mvnw .
|
| 6 |
+
COPY .mvn .mvn
|
| 7 |
+
COPY pom.xml .
|
| 8 |
+
COPY src src
|
| 9 |
+
|
| 10 |
+
RUN chmod +x mvnw && ./mvnw -q -DskipTests package
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
FROM eclipse-temurin:17-jre-jammy
|
| 14 |
+
|
| 15 |
+
WORKDIR /app
|
| 16 |
+
|
| 17 |
+
COPY --from=build /app/target/*.jar app.jar
|
| 18 |
+
|
| 19 |
+
EXPOSE 9494
|
| 20 |
+
|
| 21 |
+
ENV JAVA_OPTS=""
|
README.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: webbff-service
|
| 3 |
+
sdk: docker
|
| 4 |
+
app_port: 9494
|
| 5 |
+
---
|
bitbucket-pipelines.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
image: alpine/git:latest
|
| 2 |
+
|
| 3 |
+
pipelines:
|
| 4 |
+
custom:
|
| 5 |
+
deploy-test-to-huggingface:
|
| 6 |
+
- step:
|
| 7 |
+
name: Deploy release/test to Hugging Face Organization Space
|
| 8 |
+
script:
|
| 9 |
+
- git config --global user.email "bitbucket-pipeline@artandscience.local"
|
| 10 |
+
- git config --global user.name "Bitbucket Pipeline"
|
| 11 |
+
|
| 12 |
+
- git remote remove hf || true
|
| 13 |
+
- git remote add hf https://sarvenyanik:${HF_TOKEN}@huggingface.co/spaces/artandscience/webbff-test
|
| 14 |
+
|
| 15 |
+
- git push --force hf HEAD:main
|
pom.xml
CHANGED
|
@@ -58,6 +58,16 @@
|
|
| 58 |
<artifactId>spring-boot-starter-web</artifactId>
|
| 59 |
</dependency>
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
<!-- OpenFeign -->
|
| 62 |
<dependency>
|
| 63 |
<groupId>org.springframework.cloud</groupId>
|
|
|
|
| 58 |
<artifactId>spring-boot-starter-web</artifactId>
|
| 59 |
</dependency>
|
| 60 |
|
| 61 |
+
<dependency>
|
| 62 |
+
<groupId>org.springframework.boot</groupId>
|
| 63 |
+
<artifactId>spring-boot-starter-actuator</artifactId>
|
| 64 |
+
</dependency>
|
| 65 |
+
|
| 66 |
+
<dependency>
|
| 67 |
+
<groupId>io.micrometer</groupId>
|
| 68 |
+
<artifactId>micrometer-registry-prometheus</artifactId>
|
| 69 |
+
</dependency>
|
| 70 |
+
|
| 71 |
<!-- OpenFeign -->
|
| 72 |
<dependency>
|
| 73 |
<groupId>org.springframework.cloud</groupId>
|
src/main/java/com/artandscience/webbff/webbff/WebbffApplication.java
CHANGED
|
@@ -2,8 +2,10 @@ package com.artandscience.webbff.webbff;
|
|
| 2 |
|
| 3 |
import org.springframework.boot.SpringApplication;
|
| 4 |
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
|
| 5 |
|
| 6 |
@SpringBootApplication
|
|
|
|
| 7 |
public class WebbffApplication {
|
| 8 |
|
| 9 |
public static void main(String[] args) {
|
|
|
|
| 2 |
|
| 3 |
import org.springframework.boot.SpringApplication;
|
| 4 |
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
| 5 |
+
import org.springframework.cloud.openfeign.EnableFeignClients;
|
| 6 |
|
| 7 |
@SpringBootApplication
|
| 8 |
+
@EnableFeignClients
|
| 9 |
public class WebbffApplication {
|
| 10 |
|
| 11 |
public static void main(String[] args) {
|
src/main/java/com/artandscience/webbff/webbff/api/controller/BackOfficeController.java
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.api.controller;
|
| 2 |
+
|
| 3 |
+
public class BackOfficeController {
|
| 4 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/api/controller/CampaignController.java
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.api.controller;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.api.model.response.GetCampaignResponse;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.controller.BaseController;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageResponse;
|
| 6 |
+
import com.artandscience.webbff.webbff.domain.service.CampaignService;
|
| 7 |
+
import lombok.RequiredArgsConstructor;
|
| 8 |
+
import org.springframework.web.bind.annotation.GetMapping;
|
| 9 |
+
import org.springframework.web.bind.annotation.RequestMapping;
|
| 10 |
+
import org.springframework.web.bind.annotation.RestController;
|
| 11 |
+
|
| 12 |
+
@RequiredArgsConstructor
|
| 13 |
+
@RestController
|
| 14 |
+
@RequestMapping("/campaign-service")
|
| 15 |
+
public class CampaignController extends BaseController {
|
| 16 |
+
|
| 17 |
+
private final CampaignService campaignService;
|
| 18 |
+
|
| 19 |
+
@GetMapping("/sessionStart")
|
| 20 |
+
public MessageResponse<Void> sessionStart() {
|
| 21 |
+
campaignService.startSession();
|
| 22 |
+
return responseSuccess(null);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
@GetMapping("/getCampaign")
|
| 26 |
+
public MessageResponse<GetCampaignResponse> getCampaign() {
|
| 27 |
+
var output = campaignService.getCampaign();
|
| 28 |
+
return responseSuccess(output.toResponse());
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/api/controller/HomepageController.java
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.api.controller;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.api.model.response.GetHomepageResponse;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.controller.BaseController;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageResponse;
|
| 6 |
+
import com.artandscience.webbff.webbff.domain.service.HomepageService;
|
| 7 |
+
import lombok.RequiredArgsConstructor;
|
| 8 |
+
import org.springframework.web.bind.annotation.GetMapping;
|
| 9 |
+
import org.springframework.web.bind.annotation.RequestMapping;
|
| 10 |
+
import org.springframework.web.bind.annotation.RestController;
|
| 11 |
+
|
| 12 |
+
@RequiredArgsConstructor
|
| 13 |
+
@RestController
|
| 14 |
+
@RequestMapping("/homepage")
|
| 15 |
+
public class HomepageController extends BaseController {
|
| 16 |
+
|
| 17 |
+
private final HomepageService homepageService;
|
| 18 |
+
|
| 19 |
+
// hero-banner (slider, banner içerikleri)
|
| 20 |
+
@GetMapping
|
| 21 |
+
public MessageResponse<GetHomepageResponse> getHomepage() {
|
| 22 |
+
var output = homepageService.getHomepage();
|
| 23 |
+
return responseSuccess(output.toResponse());
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/api/model/response/GetCampaignResponse.java
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.api.model.response;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.domain.model.state.CampaignStateList;
|
| 4 |
+
import lombok.AllArgsConstructor;
|
| 5 |
+
import lombok.Builder;
|
| 6 |
+
import lombok.Data;
|
| 7 |
+
import lombok.NoArgsConstructor;
|
| 8 |
+
|
| 9 |
+
@Data
|
| 10 |
+
@Builder
|
| 11 |
+
@AllArgsConstructor
|
| 12 |
+
@NoArgsConstructor
|
| 13 |
+
public class GetCampaignResponse {
|
| 14 |
+
|
| 15 |
+
private CampaignStateList campaignStateList;
|
| 16 |
+
|
| 17 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/api/model/response/GetHomepageResponse.java
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.api.model.response;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.domain.model.contentModel.ContentModel;
|
| 4 |
+
import com.artandscience.webbff.webbff.domain.model.heroModel.HeroModel;
|
| 5 |
+
import lombok.AllArgsConstructor;
|
| 6 |
+
import lombok.Builder;
|
| 7 |
+
import lombok.Data;
|
| 8 |
+
import lombok.NoArgsConstructor;
|
| 9 |
+
|
| 10 |
+
@Data
|
| 11 |
+
@Builder
|
| 12 |
+
@AllArgsConstructor
|
| 13 |
+
@NoArgsConstructor
|
| 14 |
+
public class GetHomepageResponse {
|
| 15 |
+
private HeroModel heroBanner;
|
| 16 |
+
private ContentModel contentModel;
|
| 17 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/controller/BaseController.java
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.controller;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.BaseValidResponse;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 6 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageResponse;
|
| 7 |
+
import com.artandscience.webbff.webbff.common.base.response.builder.MsgResponseBuilder;
|
| 8 |
+
|
| 9 |
+
import java.util.List;
|
| 10 |
+
|
| 11 |
+
public abstract class BaseController {
|
| 12 |
+
|
| 13 |
+
protected MessageResponse<Void> responseFail(List<MessageBox> messageBox) {
|
| 14 |
+
return MsgResponseBuilder.build(false,messageBox);
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
protected <T> MessageResponse<T> responseSuccess(T data) {
|
| 18 |
+
return MsgResponseBuilder.build(true,data);
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
protected <T> MessageResponse<T> responseSuccess(T data, List<MessageBox> messageBox) {
|
| 22 |
+
return MsgResponseBuilder.build(true,messageBox,data);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
protected BaseValidResponse validResponseFail(BaseValidResponse baseValidResponse) {
|
| 26 |
+
return new BaseValidResponse(baseValidResponse.getErrorDescription(),
|
| 27 |
+
baseValidResponse.getErrorFunction());
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/model/BaseModel.java
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.model;
|
| 2 |
+
|
| 3 |
+
import lombok.Data;
|
| 4 |
+
|
| 5 |
+
import java.io.Serial;
|
| 6 |
+
import java.io.Serializable;
|
| 7 |
+
|
| 8 |
+
@Data
|
| 9 |
+
public class BaseModel implements Serializable {
|
| 10 |
+
@Serial
|
| 11 |
+
private static final Long serialVersionUID = -8494890402734747721L;
|
| 12 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/model/MessageModel.java
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.model;
|
| 2 |
+
|
| 3 |
+
import lombok.Builder;
|
| 4 |
+
import lombok.Data;
|
| 5 |
+
|
| 6 |
+
@Data
|
| 7 |
+
@Builder
|
| 8 |
+
public class MessageModel {
|
| 9 |
+
|
| 10 |
+
private final String code;
|
| 11 |
+
private final String type;
|
| 12 |
+
private final String message;
|
| 13 |
+
private final String handlerMethodName;
|
| 14 |
+
|
| 15 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/model/RequestHeader.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.model;
|
| 2 |
+
|
| 3 |
+
import lombok.Builder;
|
| 4 |
+
import lombok.Data;
|
| 5 |
+
|
| 6 |
+
@Data
|
| 7 |
+
@Builder
|
| 8 |
+
public class RequestHeader {
|
| 9 |
+
|
| 10 |
+
private String sessionId;
|
| 11 |
+
private String correlationId;
|
| 12 |
+
private String deviceAppVersion;
|
| 13 |
+
private String deviceAppName;
|
| 14 |
+
private String language;
|
| 15 |
+
private String role;
|
| 16 |
+
private String wafUsername;
|
| 17 |
+
private String wafPassword;
|
| 18 |
+
private String diamondUsername;
|
| 19 |
+
private String diamondPassword;
|
| 20 |
+
private String customerNumber;
|
| 21 |
+
private String requestFlowId;
|
| 22 |
+
private String deviceAppId;
|
| 23 |
+
|
| 24 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/BaseValidResponse.java
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response;
|
| 2 |
+
|
| 3 |
+
import lombok.AllArgsConstructor;
|
| 4 |
+
import lombok.Data;
|
| 5 |
+
import lombok.NoArgsConstructor;
|
| 6 |
+
|
| 7 |
+
import java.time.ZonedDateTime;
|
| 8 |
+
import java.time.format.DateTimeFormatter;
|
| 9 |
+
|
| 10 |
+
@Data
|
| 11 |
+
@AllArgsConstructor
|
| 12 |
+
@NoArgsConstructor
|
| 13 |
+
public class BaseValidResponse {
|
| 14 |
+
|
| 15 |
+
private Boolean isValid;
|
| 16 |
+
private String executionDate;
|
| 17 |
+
private String errorDescription;
|
| 18 |
+
private String errorFunction;
|
| 19 |
+
|
| 20 |
+
public BaseValidResponse(String errorDescription, String errorFunction) {
|
| 21 |
+
this.isValid = false;
|
| 22 |
+
this.errorFunction = errorFunction;
|
| 23 |
+
this.errorDescription = errorDescription;
|
| 24 |
+
this.executionDate = ZonedDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageBox.java
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.response.enums.MessageType;
|
| 4 |
+
import lombok.AllArgsConstructor;
|
| 5 |
+
import lombok.Builder;
|
| 6 |
+
import lombok.Data;
|
| 7 |
+
|
| 8 |
+
import java.io.Serial;
|
| 9 |
+
import java.io.Serializable;
|
| 10 |
+
import java.util.List;
|
| 11 |
+
|
| 12 |
+
@Builder
|
| 13 |
+
@Data
|
| 14 |
+
@AllArgsConstructor
|
| 15 |
+
public class MessageBox implements Serializable {
|
| 16 |
+
|
| 17 |
+
@Serial
|
| 18 |
+
private static final long serialVersionUID = -5828974365524339512L;
|
| 19 |
+
private String title;
|
| 20 |
+
private String subtitle;
|
| 21 |
+
private MessageType messageType;
|
| 22 |
+
private String message;
|
| 23 |
+
private String messageCode;
|
| 24 |
+
private List<MessageBoxAction> messageBoxAction;
|
| 25 |
+
|
| 26 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageBoxAction.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.response.enums.MessageBoxActionType;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.enums.MessageBoxActionUiStyle;
|
| 5 |
+
import lombok.AllArgsConstructor;
|
| 6 |
+
import lombok.Builder;
|
| 7 |
+
import lombok.Data;
|
| 8 |
+
|
| 9 |
+
import java.io.Serial;
|
| 10 |
+
import java.io.Serializable;
|
| 11 |
+
|
| 12 |
+
@Builder
|
| 13 |
+
@Data
|
| 14 |
+
@AllArgsConstructor
|
| 15 |
+
public class MessageBoxAction implements Serializable {
|
| 16 |
+
@Serial
|
| 17 |
+
private static final long serialVersionUID = -5828974365524339512L;
|
| 18 |
+
|
| 19 |
+
private MessageBoxActionType actionType;
|
| 20 |
+
private MessageBoxActionUiStyle uiStyle;
|
| 21 |
+
private String text;
|
| 22 |
+
private int orderNo;
|
| 23 |
+
|
| 24 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageResponse.java
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response;
|
| 2 |
+
|
| 3 |
+
import lombok.AllArgsConstructor;
|
| 4 |
+
import lombok.Getter;
|
| 5 |
+
import lombok.NoArgsConstructor;
|
| 6 |
+
import lombok.Setter;
|
| 7 |
+
|
| 8 |
+
import java.time.ZonedDateTime;
|
| 9 |
+
import java.time.format.DateTimeFormatter;
|
| 10 |
+
import java.util.List;
|
| 11 |
+
|
| 12 |
+
@Getter
|
| 13 |
+
@Setter
|
| 14 |
+
@NoArgsConstructor
|
| 15 |
+
@AllArgsConstructor
|
| 16 |
+
public class MessageResponse<T> {
|
| 17 |
+
|
| 18 |
+
private Boolean success;
|
| 19 |
+
private String executionDate;
|
| 20 |
+
private T data;
|
| 21 |
+
private List<MessageBox> messageBoxes;
|
| 22 |
+
|
| 23 |
+
public MessageResponse(boolean success, T data){
|
| 24 |
+
this.success = success;
|
| 25 |
+
this.data = data;
|
| 26 |
+
this.executionDate = ZonedDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
public MessageResponse(boolean success, T data, List<MessageBox> messageBoxes){
|
| 30 |
+
this.success = success;
|
| 31 |
+
this.data = data;
|
| 32 |
+
this.messageBoxes = messageBoxes;
|
| 33 |
+
this.executionDate = ZonedDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
public MessageResponse(boolean success, List<MessageBox> messageBoxes){
|
| 37 |
+
this.success = success;
|
| 38 |
+
this.messageBoxes = messageBoxes;
|
| 39 |
+
this.executionDate = ZonedDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/builder/MsgResponseBuilder.java
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response.builder;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageResponse;
|
| 6 |
+
|
| 7 |
+
import java.util.List;
|
| 8 |
+
|
| 9 |
+
public class MsgResponseBuilder {
|
| 10 |
+
|
| 11 |
+
private MsgResponseBuilder() {}
|
| 12 |
+
|
| 13 |
+
public static <T> MessageResponse<T> build(boolean success,
|
| 14 |
+
List<MessageBox> messageBox) {
|
| 15 |
+
return new MessageResponse<>(success, messageBox);
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
public static <T>MessageResponse<T> build(boolean success,
|
| 19 |
+
T data) {
|
| 20 |
+
return new MessageResponse<>(success, data);
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
public static <T>MessageResponse<T> build(boolean success, List<MessageBox> messageBox,
|
| 24 |
+
T data) {
|
| 25 |
+
return new MessageResponse<>(success,data,messageBox);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageBoxActionType.java
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response.enums;
|
| 2 |
+
|
| 3 |
+
import java.io.Serializable;
|
| 4 |
+
|
| 5 |
+
public enum MessageBoxActionType implements Serializable {
|
| 6 |
+
|
| 7 |
+
RETRY, POPUPTO, ACTION_HANDLER, DEEPLINK, NONE
|
| 8 |
+
|
| 9 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageBoxActionUiStyle.java
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response.enums;
|
| 2 |
+
|
| 3 |
+
import java.io.Serializable;
|
| 4 |
+
|
| 5 |
+
public enum MessageBoxActionUiStyle implements Serializable {
|
| 6 |
+
|
| 7 |
+
BUTTON,
|
| 8 |
+
TEXT
|
| 9 |
+
|
| 10 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageType.java
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response.enums;
|
| 2 |
+
|
| 3 |
+
import java.io.Serializable;
|
| 4 |
+
|
| 5 |
+
public enum MessageType implements Serializable {
|
| 6 |
+
INFORMATION,WARNING,ERROR,NONE
|
| 7 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/constants/ButtonTypeConstants.java
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.constants;
|
| 2 |
+
|
| 3 |
+
import lombok.extern.slf4j.Slf4j;
|
| 4 |
+
|
| 5 |
+
@Slf4j
|
| 6 |
+
public class ButtonTypeConstants {
|
| 7 |
+
|
| 8 |
+
public static final String PRIMARY_VIOLET = "PV";
|
| 9 |
+
public static final String SECONDARY = "SE";
|
| 10 |
+
public static final String OUTLINE_VIOLET = "OV";
|
| 11 |
+
public static final String GHOST = "G";
|
| 12 |
+
public static final String DANGER = "D";
|
| 13 |
+
public static final String SUCCESS = "S";
|
| 14 |
+
public static final String LINK = "L";
|
| 15 |
+
public static final String OUTLINE_SLATE = "OS";
|
| 16 |
+
public static final String TEXT_VIOLET = "TV";
|
| 17 |
+
public static final String PRIMARY_TEAL = "PT";
|
| 18 |
+
|
| 19 |
+
private ButtonTypeConstants() {
|
| 20 |
+
log.error("ButtonTypeConstants case create instance");
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/constants/HeaderConstant.java
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.constants;
|
| 2 |
+
|
| 3 |
+
public class HeaderConstant {
|
| 4 |
+
|
| 5 |
+
private HeaderConstant() {}
|
| 6 |
+
|
| 7 |
+
public static String HEADER_LANGUAGE = "x-language";
|
| 8 |
+
public static String HEADER_DEVICE_APP_NAME = "x-device-app-name";
|
| 9 |
+
public static String HEADER_DEVICE_APP_VERSION = "x-device-app-version";
|
| 10 |
+
public static String HEADER_SESSION_ID = "x-b3-session-id";
|
| 11 |
+
public static String HEADER_CORRELATION_ID = "x-correlation-id";
|
| 12 |
+
public static String HEADER_CUSTOMER_NUMBER = "x-customer-number";
|
| 13 |
+
public static String HEADER_DEVICE_APP_ID = "x-device-app-id";
|
| 14 |
+
public static String HEADER_REQUEST_FLOW_ID = "x-request-flow-id";
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/constants/HtmlTypeConstants.java
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.constants;
|
| 2 |
+
|
| 3 |
+
import lombok.extern.slf4j.Slf4j;
|
| 4 |
+
|
| 5 |
+
@Slf4j
|
| 6 |
+
public class HtmlTypeConstants {
|
| 7 |
+
|
| 8 |
+
public static final String BUTTON = "B";
|
| 9 |
+
public static final String RESET = "R";
|
| 10 |
+
public static final String SUBMIT = "S";
|
| 11 |
+
|
| 12 |
+
private HtmlTypeConstants() {
|
| 13 |
+
log.error("HtmlTypeConstants case create instance");
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/constants/MessageBoxActionTypeConstants.java
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.constants;
|
| 2 |
+
|
| 3 |
+
import lombok.extern.slf4j.Slf4j;
|
| 4 |
+
|
| 5 |
+
@Slf4j
|
| 6 |
+
public class MessageBoxActionTypeConstants {
|
| 7 |
+
|
| 8 |
+
public static final String RETRY = "R";
|
| 9 |
+
public static final String POPUPTO = "P";
|
| 10 |
+
public static final String ACTION_HANDLER = "A";
|
| 11 |
+
public static final String DEEPLINK = "D";
|
| 12 |
+
public static final String NONE = "N";
|
| 13 |
+
|
| 14 |
+
private MessageBoxActionTypeConstants() {
|
| 15 |
+
log.error("MessageBoxActionTypeConstants case create instance");
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/constants/MessageBoxActionUiConstants.java
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.constants;
|
| 2 |
+
|
| 3 |
+
import lombok.extern.slf4j.Slf4j;
|
| 4 |
+
|
| 5 |
+
@Slf4j
|
| 6 |
+
public class MessageBoxActionUiConstants {
|
| 7 |
+
|
| 8 |
+
public static final String BUTTON = "B";
|
| 9 |
+
public static final String TEXT = "T";
|
| 10 |
+
|
| 11 |
+
private MessageBoxActionUiConstants() {
|
| 12 |
+
log.error("MessageBoxActionUiConstants case create instance");
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/constants/MessageTypeConstants.java
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.constants;
|
| 2 |
+
|
| 3 |
+
public abstract class MessageTypeConstants {
|
| 4 |
+
|
| 5 |
+
public static final String INFORMATION = "I";
|
| 6 |
+
public static final String WARNING = "W";
|
| 7 |
+
public static final String ERROR = "E";
|
| 8 |
+
|
| 9 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/BusinessException.java
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.exception.enums.BaseErrorType;
|
| 4 |
+
import lombok.Getter;
|
| 5 |
+
|
| 6 |
+
import java.io.Serial;
|
| 7 |
+
import java.io.Serializable;
|
| 8 |
+
|
| 9 |
+
@Getter
|
| 10 |
+
public class BusinessException extends RuntimeException implements Serializable {
|
| 11 |
+
|
| 12 |
+
@Serial
|
| 13 |
+
private static final long serialVersionUID = -7123456789012345678L;
|
| 14 |
+
|
| 15 |
+
private final String code;
|
| 16 |
+
private final String message;
|
| 17 |
+
|
| 18 |
+
public BusinessException(BaseErrorType baseErrorType) {
|
| 19 |
+
this.code = baseErrorType.getCode();
|
| 20 |
+
this.message = baseErrorType.getMessage();
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/CoreException.java
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception;
|
| 2 |
+
|
| 3 |
+
import lombok.Getter;
|
| 4 |
+
|
| 5 |
+
import java.io.Serial;
|
| 6 |
+
import java.io.Serializable;
|
| 7 |
+
|
| 8 |
+
@Getter
|
| 9 |
+
public class CoreException extends RuntimeException implements Serializable {
|
| 10 |
+
|
| 11 |
+
@Serial
|
| 12 |
+
private static final Long serialVersionUID = -8494890402734747723L;
|
| 13 |
+
|
| 14 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/ProviderValidateException.java
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception;
|
| 2 |
+
|
| 3 |
+
import lombok.Getter;
|
| 4 |
+
|
| 5 |
+
import java.io.Serial;
|
| 6 |
+
import java.io.Serializable;
|
| 7 |
+
|
| 8 |
+
@Getter
|
| 9 |
+
public class ProviderValidateException extends RuntimeException implements Serializable {
|
| 10 |
+
|
| 11 |
+
@Serial
|
| 12 |
+
private static final long serialVersionUID = -7123456789012345678L;
|
| 13 |
+
private final String code;
|
| 14 |
+
private final String serviceName;
|
| 15 |
+
private final String message;
|
| 16 |
+
|
| 17 |
+
public ProviderValidateException(String code, String serviceName, String message) {
|
| 18 |
+
this.code = code;
|
| 19 |
+
this.serviceName = serviceName;
|
| 20 |
+
this.message = message;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/SessionException.java
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.exception.enums.BaseErrorType;
|
| 4 |
+
import lombok.Getter;
|
| 5 |
+
|
| 6 |
+
import java.io.Serial;
|
| 7 |
+
import java.io.Serializable;
|
| 8 |
+
|
| 9 |
+
@Getter
|
| 10 |
+
public class SessionException extends RuntimeException implements Serializable {
|
| 11 |
+
|
| 12 |
+
@Serial
|
| 13 |
+
private static final long serialVersionUID = -7123456789012345673L;
|
| 14 |
+
|
| 15 |
+
private final String code;
|
| 16 |
+
private final String message;
|
| 17 |
+
private final String[] parameters;
|
| 18 |
+
|
| 19 |
+
public SessionException(BaseErrorType baseErrorType, String... parameters) {
|
| 20 |
+
this.code = baseErrorType.getCode();
|
| 21 |
+
this.message = baseErrorType.getMessage();
|
| 22 |
+
this.parameters = parameters;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/enums/BaseErrorType.java
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception.enums;
|
| 2 |
+
|
| 3 |
+
public interface BaseErrorType {
|
| 4 |
+
|
| 5 |
+
String getCode();
|
| 6 |
+
String getMessage();
|
| 7 |
+
|
| 8 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/enums/BusinessErrorType.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception.enums;
|
| 2 |
+
|
| 3 |
+
import lombok.RequiredArgsConstructor;
|
| 4 |
+
|
| 5 |
+
@RequiredArgsConstructor
|
| 6 |
+
public enum BusinessErrorType implements BaseErrorType{
|
| 7 |
+
BACKOFFICE_DB_DUPLICATE("DUPLICATE_01","This data is found.");
|
| 8 |
+
|
| 9 |
+
private final String code;
|
| 10 |
+
private final String message;
|
| 11 |
+
|
| 12 |
+
@Override
|
| 13 |
+
public String getCode() {
|
| 14 |
+
return code;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
@Override
|
| 18 |
+
public String getMessage() {
|
| 19 |
+
return message;
|
| 20 |
+
}
|
| 21 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/enums/SessionErrorType.java
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception.enums;
|
| 2 |
+
|
| 3 |
+
import lombok.RequiredArgsConstructor;
|
| 4 |
+
|
| 5 |
+
@RequiredArgsConstructor
|
| 6 |
+
public enum SessionErrorType implements BaseErrorType{
|
| 7 |
+
|
| 8 |
+
SESSION_NOT_FOUND("SESSION_001", "Session Not Found");
|
| 9 |
+
|
| 10 |
+
private final String code;
|
| 11 |
+
private final String message;
|
| 12 |
+
|
| 13 |
+
@Override
|
| 14 |
+
public String getCode() {
|
| 15 |
+
return code;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
@Override
|
| 19 |
+
public String getMessage() {
|
| 20 |
+
return message;
|
| 21 |
+
}
|
| 22 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/enums/UnhandledErrorType.java
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception.enums;
|
| 2 |
+
|
| 3 |
+
import lombok.RequiredArgsConstructor;
|
| 4 |
+
|
| 5 |
+
@RequiredArgsConstructor
|
| 6 |
+
public enum UnhandledErrorType implements BaseErrorType {
|
| 7 |
+
|
| 8 |
+
UNHANDLED_ERROR_TYPE("GENERIC_001","Generic Exception");
|
| 9 |
+
|
| 10 |
+
private final String code;
|
| 11 |
+
private final String message;
|
| 12 |
+
|
| 13 |
+
@Override
|
| 14 |
+
public String getCode() {
|
| 15 |
+
return this.code;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
@Override
|
| 19 |
+
public String getMessage() {
|
| 20 |
+
return this.message;
|
| 21 |
+
}
|
| 22 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/helper/JsonMapper.java
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.helper;
|
| 2 |
+
|
| 3 |
+
import com.fasterxml.jackson.core.JsonProcessingException;
|
| 4 |
+
import com.fasterxml.jackson.databind.DeserializationFeature;
|
| 5 |
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 6 |
+
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
| 7 |
+
import lombok.extern.slf4j.Slf4j;
|
| 8 |
+
|
| 9 |
+
@Slf4j
|
| 10 |
+
public class JsonMapper {
|
| 11 |
+
|
| 12 |
+
private static final ObjectMapper MAPPER = new ObjectMapper()
|
| 13 |
+
.registerModule(new JavaTimeModule())
|
| 14 |
+
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
| 15 |
+
|
| 16 |
+
public static <T> T convertToData(String jsonBody, Class<T> clazz) {
|
| 17 |
+
try {
|
| 18 |
+
return MAPPER.readValue(jsonBody, clazz);
|
| 19 |
+
} catch (JsonProcessingException e) {
|
| 20 |
+
log.error("JSON convert error. targetClass: {}, body: {}, message: {}",
|
| 21 |
+
clazz.getSimpleName(), jsonBody, e.getMessage());
|
| 22 |
+
|
| 23 |
+
throw new IllegalArgumentException("JSON could not be converted to " + clazz.getSimpleName(), e);
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
public static <T> String convertToJson(T data) {
|
| 28 |
+
try {
|
| 29 |
+
return MAPPER.writeValueAsString(data);
|
| 30 |
+
} catch (JsonProcessingException e) {
|
| 31 |
+
log.error("An error has occurrence: {}",e.getMessage());
|
| 32 |
+
throw new IllegalArgumentException("An error has occurrence: {}",e);
|
| 33 |
+
}
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/interceptor/ResponseErrorHandler.java
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.interceptor;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.controller.BaseController;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.model.MessageModel;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.model.RequestHeader;
|
| 6 |
+
import com.artandscience.webbff.webbff.common.base.response.BaseValidResponse;
|
| 7 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 8 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageResponse;
|
| 9 |
+
import com.artandscience.webbff.webbff.common.exception.BusinessException;
|
| 10 |
+
import com.artandscience.webbff.webbff.common.exception.SessionException;
|
| 11 |
+
import com.artandscience.webbff.webbff.common.exception.ProviderValidateException;
|
| 12 |
+
import com.artandscience.webbff.webbff.common.exception.enums.UnhandledErrorType;
|
| 13 |
+
import com.artandscience.webbff.webbff.common.scope.RequestHeaderScope;
|
| 14 |
+
import com.artandscience.webbff.webbff.common.service.ExternalAttributeService;
|
| 15 |
+
import lombok.RequiredArgsConstructor;
|
| 16 |
+
import lombok.extern.slf4j.Slf4j;
|
| 17 |
+
import org.apache.commons.lang3.StringUtils;
|
| 18 |
+
import org.springframework.http.HttpStatus;
|
| 19 |
+
import org.springframework.validation.FieldError;
|
| 20 |
+
import org.springframework.web.bind.MethodArgumentNotValidException;
|
| 21 |
+
import org.springframework.web.bind.annotation.ExceptionHandler;
|
| 22 |
+
import org.springframework.web.bind.annotation.ResponseStatus;
|
| 23 |
+
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
| 24 |
+
import org.springframework.web.method.HandlerMethod;
|
| 25 |
+
|
| 26 |
+
import java.util.ArrayList;
|
| 27 |
+
import java.util.List;
|
| 28 |
+
import java.util.Objects;
|
| 29 |
+
import java.util.Optional;
|
| 30 |
+
|
| 31 |
+
@RestControllerAdvice
|
| 32 |
+
@RequiredArgsConstructor
|
| 33 |
+
@Slf4j
|
| 34 |
+
public class ResponseErrorHandler extends BaseController {
|
| 35 |
+
|
| 36 |
+
private final ExternalAttributeService externalAttributeService;
|
| 37 |
+
private final RequestHeaderScope requestHeaderScope;
|
| 38 |
+
|
| 39 |
+
@ExceptionHandler(value = Exception.class)
|
| 40 |
+
@ResponseStatus(HttpStatus.OK)
|
| 41 |
+
public MessageResponse<Void> handleExceptionError(Exception e, HandlerMethod handlerMethod) {
|
| 42 |
+
RequestHeader requestHeader = requestHeaderScope.getRequestHeader();
|
| 43 |
+
log.error("Exception occurred: " + e.getMessage(), e);
|
| 44 |
+
var messageModel = getDefaultMessageModel(handlerMethod);
|
| 45 |
+
MessageBox messageBox = externalAttributeService.getMessageBox(messageModel);
|
| 46 |
+
if (Objects.isNull(messageBox)) {
|
| 47 |
+
messageBox = getDefaultMessageBox();
|
| 48 |
+
}
|
| 49 |
+
List<MessageBox> messageBoxList = new ArrayList<>();
|
| 50 |
+
messageBoxList.add(messageBox);
|
| 51 |
+
return responseFail(messageBoxList);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
@ExceptionHandler(value = SessionException.class)
|
| 55 |
+
@ResponseStatus(HttpStatus.OK)
|
| 56 |
+
public MessageResponse<Void> handleSessionExceptionError(SessionException e) {
|
| 57 |
+
log.error("SessionException occurred: " + e.getMessage() + " Error code: " + e.getCode(), e);
|
| 58 |
+
var messageModel = MessageModel.builder().code(e.getCode()).build();
|
| 59 |
+
var messageBox = externalAttributeService.getMessageBox(messageModel);
|
| 60 |
+
if (Objects.isNull(messageBox)) {
|
| 61 |
+
messageBox = getDefaultMessageBox();
|
| 62 |
+
}
|
| 63 |
+
List<MessageBox> messageBoxList = new ArrayList<>();
|
| 64 |
+
messageBoxList.add(messageBox);
|
| 65 |
+
return responseFail(messageBoxList);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
@ExceptionHandler(value = BusinessException.class)
|
| 69 |
+
@ResponseStatus(HttpStatus.OK)
|
| 70 |
+
public MessageResponse<Void> handleBusinessExceptionError(BusinessException e) {
|
| 71 |
+
log.error("BusinessException occurred: " + e.getMessage() + " Error code: " + e.getCode(), e);
|
| 72 |
+
var messageModel = MessageModel.builder().code(e.getCode()).build();
|
| 73 |
+
var messageBox = externalAttributeService.getMessageBox(messageModel);
|
| 74 |
+
if (Objects.isNull(messageBox)) {
|
| 75 |
+
messageBox = getDefaultMessageBox();
|
| 76 |
+
}
|
| 77 |
+
List<MessageBox> messageBoxList = new ArrayList<>();
|
| 78 |
+
messageBoxList.add(messageBox);
|
| 79 |
+
return responseFail(messageBoxList);
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
@ExceptionHandler(value = MethodArgumentNotValidException.class)
|
| 83 |
+
@ResponseStatus(HttpStatus.OK)
|
| 84 |
+
public MessageResponse<Void> handleValidationExceptionHandler(MethodArgumentNotValidException e) {
|
| 85 |
+
Optional<FieldError> fieldError = Optional.ofNullable(e.getFieldError());
|
| 86 |
+
String fieldErrorMessage = fieldError.map(error -> Optional.ofNullable(error.getDefaultMessage()).get())
|
| 87 |
+
.orElseGet(UnhandledErrorType.UNHANDLED_ERROR_TYPE::getCode);
|
| 88 |
+
log.error("MethodArgumentNotValidException occurred: " + fieldErrorMessage);
|
| 89 |
+
var messageModel = MessageModel.builder().code(fieldErrorMessage).build();
|
| 90 |
+
var messageBox = externalAttributeService.getMessageBox(messageModel);
|
| 91 |
+
if (Objects.isNull(messageBox)) {
|
| 92 |
+
messageBox = getDefaultMessageBox();
|
| 93 |
+
}
|
| 94 |
+
List<MessageBox> messageBoxList = new ArrayList<>();
|
| 95 |
+
messageBoxList.add(messageBox);
|
| 96 |
+
return responseFail(messageBoxList);
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
@ExceptionHandler(value = ProviderValidateException.class)
|
| 100 |
+
@ResponseStatus(HttpStatus.FORBIDDEN)
|
| 101 |
+
public BaseValidResponse handleProviderValidateExceptionError(ProviderValidateException e) {
|
| 102 |
+
log.error("ProviderValidation exception occurred: " + e.getMessage() + " ErrorCode: " + e.getCode(), e);
|
| 103 |
+
BaseValidResponse baseValidResponse = new BaseValidResponse();
|
| 104 |
+
baseValidResponse.setErrorFunction(e.getCode());
|
| 105 |
+
baseValidResponse.setErrorDescription(e.getMessage());
|
| 106 |
+
return validResponseFail(baseValidResponse);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
private MessageModel getDefaultMessageModel(HandlerMethod handlerMethod){
|
| 110 |
+
var methodName = getErrorFunction(handlerMethod);
|
| 111 |
+
return StringUtils.isNotEmpty(methodName) ?
|
| 112 |
+
MessageModel.builder().code("DEFAULT_MESSAGE_BOX" + "." + methodName).build() :
|
| 113 |
+
MessageModel.builder().code(UnhandledErrorType.UNHANDLED_ERROR_TYPE.getCode()).build();
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
private String getErrorFunction(HandlerMethod handlerMethod) {
|
| 117 |
+
String controllerName = handlerMethod.getMethod().getDeclaringClass().getName();
|
| 118 |
+
controllerName = controllerName.substring(controllerName.lastIndexOf('.') + 1);
|
| 119 |
+
return controllerName.replace("Controller","") + "_" + handlerMethod.getMethod().getName();
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
private MessageBox getDefaultMessageBox() {
|
| 123 |
+
var messageModel = MessageModel.builder().code("DEFAULT_MESSAGE_BOX").build();
|
| 124 |
+
return externalAttributeService.getMessageBox(messageModel);
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/interceptor/TransactionFilter.java
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.interceptor;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.model.RequestHeader;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.scope.RequestHeaderScope;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.utils.ProviderValidUtil;
|
| 6 |
+
import jakarta.servlet.FilterChain;
|
| 7 |
+
import jakarta.servlet.ServletException;
|
| 8 |
+
import jakarta.servlet.annotation.WebFilter;
|
| 9 |
+
import jakarta.servlet.http.HttpServletRequest;
|
| 10 |
+
import jakarta.servlet.http.HttpServletResponse;
|
| 11 |
+
import lombok.RequiredArgsConstructor;
|
| 12 |
+
import lombok.extern.slf4j.Slf4j;
|
| 13 |
+
import org.springframework.core.annotation.Order;
|
| 14 |
+
import org.springframework.stereotype.Component;
|
| 15 |
+
import org.springframework.web.filter.OncePerRequestFilter;
|
| 16 |
+
import org.springframework.web.servlet.HandlerExceptionResolver;
|
| 17 |
+
|
| 18 |
+
import java.io.IOException;
|
| 19 |
+
|
| 20 |
+
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_LANGUAGE;
|
| 21 |
+
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_DEVICE_APP_NAME;
|
| 22 |
+
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_DEVICE_APP_VERSION;
|
| 23 |
+
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_SESSION_ID;
|
| 24 |
+
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_CORRELATION_ID;
|
| 25 |
+
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_CUSTOMER_NUMBER;
|
| 26 |
+
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_REQUEST_FLOW_ID;
|
| 27 |
+
import static com.artandscience.webbff.webbff.common.constants.HeaderConstant.HEADER_DEVICE_APP_ID;
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
@Slf4j
|
| 32 |
+
@Order(1)
|
| 33 |
+
@Component
|
| 34 |
+
@RequiredArgsConstructor
|
| 35 |
+
@WebFilter(filterName = "transactionFilter")
|
| 36 |
+
public class TransactionFilter extends OncePerRequestFilter {
|
| 37 |
+
|
| 38 |
+
private final RequestHeaderScope requestHeaderScope;
|
| 39 |
+
private final ProviderValidUtil providerValidUtil;
|
| 40 |
+
private final HandlerExceptionResolver handlerExceptionResolver;
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
@Override
|
| 44 |
+
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
|
| 45 |
+
throws ServletException, IOException {
|
| 46 |
+
|
| 47 |
+
try {
|
| 48 |
+
//providerValidUtil.valid(request.getHeader(HEADER_REQUEST_FLOW_ID),request.getHeader(HEADER_DEVICE_APP_ID));
|
| 49 |
+
RequestHeader requestHeader = fillRequestHeader(request);
|
| 50 |
+
requestHeaderScope.setRequestHeader(requestHeader);
|
| 51 |
+
} catch (Exception e) {
|
| 52 |
+
log.error("Transaction Filter exception " + e.getMessage(), e);
|
| 53 |
+
handlerExceptionResolver.resolveException(request,response,null,e);
|
| 54 |
+
return;
|
| 55 |
+
}
|
| 56 |
+
filterChain.doFilter(request,response);
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
private RequestHeader fillRequestHeader(HttpServletRequest request) {
|
| 60 |
+
return RequestHeader.builder()
|
| 61 |
+
.language(request.getHeader(HEADER_LANGUAGE))
|
| 62 |
+
.deviceAppName(request.getHeader(HEADER_DEVICE_APP_NAME))
|
| 63 |
+
.deviceAppVersion(request.getHeader(HEADER_DEVICE_APP_VERSION))
|
| 64 |
+
.sessionId(request.getHeader(HEADER_SESSION_ID))
|
| 65 |
+
.correlationId(request.getHeader(HEADER_CORRELATION_ID))
|
| 66 |
+
.customerNumber(request.getHeader(HEADER_CUSTOMER_NUMBER))
|
| 67 |
+
.requestFlowId(request.getHeader(HEADER_REQUEST_FLOW_ID))
|
| 68 |
+
.deviceAppId(request.getHeader(HEADER_DEVICE_APP_ID))
|
| 69 |
+
.build();
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/scope/RequestHeaderScope.java
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.scope;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.model.RequestHeader;
|
| 4 |
+
import org.springframework.stereotype.Component;
|
| 5 |
+
import org.springframework.web.context.annotation.RequestScope;
|
| 6 |
+
|
| 7 |
+
@Component
|
| 8 |
+
@RequestScope
|
| 9 |
+
public class RequestHeaderScope {
|
| 10 |
+
|
| 11 |
+
private RequestHeader requestHeader;
|
| 12 |
+
|
| 13 |
+
public RequestHeader getRequestHeader() {
|
| 14 |
+
return requestHeader;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
public void setRequestHeader(RequestHeader requestHeader) {
|
| 18 |
+
this.requestHeader = requestHeader;
|
| 19 |
+
}
|
| 20 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/ExternalAttributeService.java
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.model.MessageModel;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 5 |
+
import com.artandscience.webbff.webbff.domain.model.buttonModel.ButtonModelList;
|
| 6 |
+
|
| 7 |
+
public interface ExternalAttributeService {
|
| 8 |
+
|
| 9 |
+
String getResource(String resourceKey, String... parameters);
|
| 10 |
+
MessageBox getMessageBox(MessageModel messageModel, String... parameters);
|
| 11 |
+
ButtonModelList getButtonModelList(String buttonCode);
|
| 12 |
+
String getConfigModel(String modelCode, String... parameters);
|
| 13 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/MainButtonService.java
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.domain.model.buttonModel.ButtonModelList;
|
| 4 |
+
|
| 5 |
+
import java.util.List;
|
| 6 |
+
|
| 7 |
+
public interface MainButtonService {
|
| 8 |
+
|
| 9 |
+
ButtonModelList getButtonModelList(String buttonCode);
|
| 10 |
+
|
| 11 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/MessageBoxService.java
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 5 |
+
import com.artandscience.webbff.webbff.dao.entity.ErrorMessageBox;
|
| 6 |
+
|
| 7 |
+
public interface MessageBoxService {
|
| 8 |
+
MessageBox getMessageBox(String errorCode);
|
| 9 |
+
void saveMessageBox(ErrorMessageBox errorMessageBox);
|
| 10 |
+
void removeMessageBox(String errorCode);
|
| 11 |
+
void updateMessageBox(ErrorMessageBox errorMessageBox);
|
| 12 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/ModelConfigService.java
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service;
|
| 2 |
+
|
| 3 |
+
public interface ModelConfigService {
|
| 4 |
+
String getModelConfig(String modelCode);
|
| 5 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/ResourceService.java
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service;
|
| 2 |
+
|
| 3 |
+
public interface ResourceService {
|
| 4 |
+
String getResource(String resourceKey);
|
| 5 |
+
|
| 6 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/StateManagementService.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service;
|
| 2 |
+
|
| 3 |
+
import java.util.Collection;
|
| 4 |
+
|
| 5 |
+
public interface StateManagementService {
|
| 6 |
+
|
| 7 |
+
<T> void setState(String key, String exTime, T object);
|
| 8 |
+
|
| 9 |
+
<T> void setStateBySession(String key, T object);
|
| 10 |
+
|
| 11 |
+
<T> T getState(String key, Class<T> returnType, boolean... isNullable);
|
| 12 |
+
|
| 13 |
+
<T> T getStateBySession(String key, Class<T> returnType, boolean... isNullable);
|
| 14 |
+
|
| 15 |
+
void removeState(String key);
|
| 16 |
+
|
| 17 |
+
void clearAllCache();
|
| 18 |
+
|
| 19 |
+
Collection<String> getAllCache();
|
| 20 |
+
|
| 21 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/impl/ExternalAttributeServiceImpl.java
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service.impl;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.model.MessageModel;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.model.RequestHeader;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 6 |
+
import com.artandscience.webbff.webbff.common.scope.RequestHeaderScope;
|
| 7 |
+
import com.artandscience.webbff.webbff.common.service.*;
|
| 8 |
+
import com.artandscience.webbff.webbff.domain.model.buttonModel.ButtonModelList;
|
| 9 |
+
import lombok.RequiredArgsConstructor;
|
| 10 |
+
import lombok.extern.slf4j.Slf4j;
|
| 11 |
+
import org.springframework.stereotype.Service;
|
| 12 |
+
|
| 13 |
+
@Slf4j
|
| 14 |
+
@Service
|
| 15 |
+
@RequiredArgsConstructor
|
| 16 |
+
public class ExternalAttributeServiceImpl implements ExternalAttributeService {
|
| 17 |
+
|
| 18 |
+
private final RequestHeaderScope requestHeaderScope;
|
| 19 |
+
private final MessageBoxService messageBoxService;
|
| 20 |
+
private final ResourceService resourceService;
|
| 21 |
+
private final MainButtonService mainButtonService;
|
| 22 |
+
private final ModelConfigService modelConfigService;
|
| 23 |
+
|
| 24 |
+
@Override
|
| 25 |
+
public String getResource(String resourceKey, String... parameters) {
|
| 26 |
+
try {
|
| 27 |
+
var requestHeader = requestHeaderScope.getRequestHeader();
|
| 28 |
+
var resource = resourceService.getResource(resourceKey + "." + requestHeader.getLanguage().toLowerCase());
|
| 29 |
+
if (resource != null && parameters != null && parameters.length != 0) {
|
| 30 |
+
return String.format(resource, parameters);
|
| 31 |
+
}
|
| 32 |
+
return resource;
|
| 33 |
+
} catch (Exception e) {
|
| 34 |
+
log.error("ExternalAttributeServiceImpl getResource() exception occurred for : " + resourceKey, e);
|
| 35 |
+
return "";
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
@Override
|
| 40 |
+
public MessageBox getMessageBox(MessageModel messageModel, String... parameters) {
|
| 41 |
+
try {
|
| 42 |
+
RequestHeader requestHeader = requestHeaderScope.getRequestHeader();
|
| 43 |
+
String messageKey = messageModel.getCode() + "." + requestHeader.getLanguage();
|
| 44 |
+
var messageBox = messageBoxService.getMessageBox(messageKey);
|
| 45 |
+
if (messageBox == null) {
|
| 46 |
+
if (!messageModel.getCode().contains("DEFAULT_MESSAGE_BOX")) {
|
| 47 |
+
log.error("MessageBoxService errorCode not found." + messageModel.getCode() + messageModel.getCode() + "." + requestHeader.getLanguage());
|
| 48 |
+
}
|
| 49 |
+
return getDefaultMessageBox(requestHeader.getLanguage(), messageModel);
|
| 50 |
+
} else {
|
| 51 |
+
log.info("MessageBoxService returning error message key {}", messageKey);
|
| 52 |
+
}
|
| 53 |
+
if (messageBox.getMessage() != null && parameters != null && parameters.length != 0) {
|
| 54 |
+
var formattedMessage = String.format(messageBox.getMessage(), parameters);
|
| 55 |
+
messageBox.setMessage(formattedMessage);
|
| 56 |
+
return messageBox;
|
| 57 |
+
}
|
| 58 |
+
return messageBox;
|
| 59 |
+
} catch (Exception e) {
|
| 60 |
+
log.error("ExternalAttributeServiceImpl getMessageBox() exception occurred for messageBoxCode: " + messageModel.getCode(), e);
|
| 61 |
+
return getDefaultMessageBox();
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
@Override
|
| 66 |
+
public ButtonModelList getButtonModelList(String buttonCode) {
|
| 67 |
+
try {
|
| 68 |
+
RequestHeader requestHeader = requestHeaderScope.getRequestHeader();
|
| 69 |
+
var buttonModelList = mainButtonService.getButtonModelList(buttonCode + "." + requestHeader.getLanguage().toLowerCase());
|
| 70 |
+
if (buttonModelList != null) {
|
| 71 |
+
return buttonModelList;
|
| 72 |
+
}
|
| 73 |
+
}catch (Exception e) {
|
| 74 |
+
log.error("ExternalAttributeServiceImpl getButtonModelList() exception occurred for : " + buttonCode, e);
|
| 75 |
+
}
|
| 76 |
+
return ButtonModelList.builder().build();
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
@Override
|
| 80 |
+
public String getConfigModel(String modelCode, String... parameters) {
|
| 81 |
+
try {
|
| 82 |
+
var jsonModel = modelConfigService.getModelConfig(modelCode);
|
| 83 |
+
if (jsonModel != null && parameters != null && parameters.length != 0) {
|
| 84 |
+
return String.format(jsonModel,parameters);
|
| 85 |
+
}
|
| 86 |
+
return jsonModel;
|
| 87 |
+
} catch (Exception e) {
|
| 88 |
+
log.error("ExternalAttributeServiceImpl getConfigModel() exception occurred for : " + modelCode, e);
|
| 89 |
+
return "";
|
| 90 |
+
}
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
private MessageBox getDefaultMessageBox() {
|
| 94 |
+
return null; //TODO: yazılacak
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
private MessageBox getDefaultMessageBox(String language, MessageModel messageModel) {
|
| 98 |
+
return null; //TODO: yazılacak.
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/impl/MainButtonServiceImpl.java
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service.impl;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.service.MainButtonService;
|
| 4 |
+
import com.artandscience.webbff.webbff.dao.entity.Button;
|
| 5 |
+
import com.artandscience.webbff.webbff.dao.entity.MainButton;
|
| 6 |
+
import com.artandscience.webbff.webbff.dao.repository.MainButtonRepository;
|
| 7 |
+
import com.artandscience.webbff.webbff.domain.model.buttonModel.ButtonModel;
|
| 8 |
+
import com.artandscience.webbff.webbff.domain.model.buttonModel.ButtonModelList;
|
| 9 |
+
import lombok.RequiredArgsConstructor;
|
| 10 |
+
import lombok.extern.slf4j.Slf4j;
|
| 11 |
+
import org.springframework.cache.annotation.CacheEvict;
|
| 12 |
+
import org.springframework.cache.annotation.Cacheable;
|
| 13 |
+
import org.springframework.scheduling.annotation.Scheduled;
|
| 14 |
+
import org.springframework.stereotype.Service;
|
| 15 |
+
|
| 16 |
+
import java.util.Comparator;
|
| 17 |
+
import java.util.List;
|
| 18 |
+
import java.util.Optional;
|
| 19 |
+
|
| 20 |
+
@Slf4j
|
| 21 |
+
@Service
|
| 22 |
+
@RequiredArgsConstructor
|
| 23 |
+
public class MainButtonServiceImpl implements MainButtonService {
|
| 24 |
+
|
| 25 |
+
private static final String CACHE_NAME_BUTTON_MODEL = "artandsciencewebbff-buttonModel";
|
| 26 |
+
private final MainButtonRepository mainButtonRepository;
|
| 27 |
+
|
| 28 |
+
@Override
|
| 29 |
+
@Cacheable(cacheNames = CACHE_NAME_BUTTON_MODEL, key = "#buttonCode", unless = "#result == null")
|
| 30 |
+
public ButtonModelList getButtonModelList(String buttonCode) {
|
| 31 |
+
Optional<MainButton> optMainButton = mainButtonRepository.findById(String.format("%s",buttonCode));
|
| 32 |
+
if (optMainButton.isPresent()) {
|
| 33 |
+
List<Button> buttons = optMainButton.get().getButtonModels();
|
| 34 |
+
var buttonModels = buttons.stream()
|
| 35 |
+
.map(Button::getButtonModel)
|
| 36 |
+
.sorted(Comparator.comparing(ButtonModel::getOrderNo)).toList();
|
| 37 |
+
return ButtonModelList.builder()
|
| 38 |
+
.buttonModels(buttonModels)
|
| 39 |
+
.build();
|
| 40 |
+
}
|
| 41 |
+
return null;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
@Scheduled(cron = "${artandscience-web.buttonmodel-cache-expire-time}")
|
| 45 |
+
@CacheEvict(value = CACHE_NAME_BUTTON_MODEL, allEntries = true)
|
| 46 |
+
public void clearCache() {
|
| 47 |
+
log.debug("Cache '{}' cleared.", CACHE_NAME_BUTTON_MODEL);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/impl/MessageBoxServiceImpl.java
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service.impl;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBoxAction;
|
| 6 |
+
import com.artandscience.webbff.webbff.common.base.response.enums.MessageType;
|
| 7 |
+
import com.artandscience.webbff.webbff.common.constants.MessageTypeConstants;
|
| 8 |
+
import com.artandscience.webbff.webbff.common.exception.BusinessException;
|
| 9 |
+
import com.artandscience.webbff.webbff.common.exception.enums.BusinessErrorType;
|
| 10 |
+
import com.artandscience.webbff.webbff.common.service.MessageBoxService;
|
| 11 |
+
import com.artandscience.webbff.webbff.dao.entity.ErrorMessageBox;
|
| 12 |
+
import com.artandscience.webbff.webbff.dao.entity.ErrorMessageBoxAction;
|
| 13 |
+
import com.artandscience.webbff.webbff.dao.repository.ErrorMessageBoxRepository;
|
| 14 |
+
import lombok.RequiredArgsConstructor;
|
| 15 |
+
import lombok.extern.slf4j.Slf4j;
|
| 16 |
+
import org.springframework.cache.annotation.CacheEvict;
|
| 17 |
+
import org.springframework.cache.annotation.Cacheable;
|
| 18 |
+
import org.springframework.scheduling.annotation.Scheduled;
|
| 19 |
+
import org.springframework.stereotype.Service;
|
| 20 |
+
|
| 21 |
+
import java.util.Comparator;
|
| 22 |
+
import java.util.Objects;
|
| 23 |
+
import java.util.Optional;
|
| 24 |
+
|
| 25 |
+
@Slf4j
|
| 26 |
+
@Service
|
| 27 |
+
@RequiredArgsConstructor
|
| 28 |
+
public class MessageBoxServiceImpl implements MessageBoxService {
|
| 29 |
+
|
| 30 |
+
private static final String CACHE_NAME_MESSAGE_BOX = "artandsciencewebbff-messageBox";
|
| 31 |
+
private final ErrorMessageBoxRepository errorMessageBoxRepository;
|
| 32 |
+
|
| 33 |
+
@Override
|
| 34 |
+
@Cacheable(cacheNames = CACHE_NAME_MESSAGE_BOX, key = "#errorCode", unless = "#result == null")
|
| 35 |
+
public MessageBox getMessageBox(String errorCode) {
|
| 36 |
+
Optional<ErrorMessageBox> optErrorMessageBox = errorMessageBoxRepository.findById(String.format("%s",errorCode));
|
| 37 |
+
if (optErrorMessageBox.isPresent()) {
|
| 38 |
+
ErrorMessageBox errorMessageBox = optErrorMessageBox.get();
|
| 39 |
+
return MessageBox.builder()
|
| 40 |
+
.messageCode(errorMessageBox.getMessageCode())
|
| 41 |
+
.messageType(getMessageType(errorMessageBox.getMessageType()))
|
| 42 |
+
.message(errorMessageBox.getMessage())
|
| 43 |
+
.title(errorMessageBox.getTitle())
|
| 44 |
+
.messageBoxAction(errorMessageBox.getErrorMessageBoxActions().stream()
|
| 45 |
+
.map(ErrorMessageBoxAction::toMessageBoxAction)
|
| 46 |
+
.sorted(Comparator.comparing(MessageBoxAction::getOrderNo)).toList())
|
| 47 |
+
.build();
|
| 48 |
+
}
|
| 49 |
+
return null;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
@Override
|
| 53 |
+
public void saveMessageBox(ErrorMessageBox errorMessageBox) {
|
| 54 |
+
if (!Objects.isNull(errorMessageBox)) {
|
| 55 |
+
var messageBox = getErrorMessageBox(errorMessageBox.getKey());
|
| 56 |
+
if (!Objects.isNull(messageBox))
|
| 57 |
+
throw new BusinessException(BusinessErrorType.BACKOFFICE_DB_DUPLICATE);
|
| 58 |
+
errorMessageBoxRepository.save(errorMessageBox);
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
@Override
|
| 63 |
+
public void removeMessageBox(String errorCode) {
|
| 64 |
+
ErrorMessageBox errorMessageBox = getErrorMessageBox(errorCode);
|
| 65 |
+
if (!Objects.isNull(errorMessageBox)) {
|
| 66 |
+
errorMessageBoxRepository.delete(errorMessageBox);
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
@Override
|
| 71 |
+
public void updateMessageBox(ErrorMessageBox errorMessageBox) {
|
| 72 |
+
ErrorMessageBox messageBox = getErrorMessageBox(errorMessageBox.getKey());
|
| 73 |
+
if (!Objects.isNull(messageBox)) {
|
| 74 |
+
errorMessageBoxRepository.saveAndFlush(errorMessageBox);
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
private ErrorMessageBox getErrorMessageBox(String errorCode) {
|
| 79 |
+
Optional<ErrorMessageBox> optErrorMessageBox = errorMessageBoxRepository.findById(String.format("%s",errorCode));
|
| 80 |
+
return optErrorMessageBox.orElse(null);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
private MessageType getMessageType(String type) {
|
| 84 |
+
return switch (type) {
|
| 85 |
+
case (MessageTypeConstants.WARNING) -> MessageType.WARNING;
|
| 86 |
+
case (MessageTypeConstants.ERROR) -> MessageType.ERROR;
|
| 87 |
+
case (MessageTypeConstants.INFORMATION) -> MessageType.INFORMATION;
|
| 88 |
+
default -> MessageType.NONE;
|
| 89 |
+
};
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
@Scheduled(cron = "${artandscience-web.messagebox-cache-expire-time}")
|
| 93 |
+
@CacheEvict(value = CACHE_NAME_MESSAGE_BOX, allEntries = true)
|
| 94 |
+
public void clearCache() {
|
| 95 |
+
log.debug("Cache '{}' cleared.", CACHE_NAME_MESSAGE_BOX);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/impl/ModelConfigServiceImpl.java
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service.impl;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.service.ModelConfigService;
|
| 4 |
+
import com.artandscience.webbff.webbff.dao.entity.ModelConfig;
|
| 5 |
+
import com.artandscience.webbff.webbff.dao.repository.ModelConfigRepository;
|
| 6 |
+
import lombok.RequiredArgsConstructor;
|
| 7 |
+
import lombok.extern.slf4j.Slf4j;
|
| 8 |
+
import org.springframework.cache.annotation.CacheEvict;
|
| 9 |
+
import org.springframework.cache.annotation.Cacheable;
|
| 10 |
+
import org.springframework.scheduling.annotation.Scheduled;
|
| 11 |
+
import org.springframework.stereotype.Service;
|
| 12 |
+
|
| 13 |
+
import java.util.Optional;
|
| 14 |
+
|
| 15 |
+
@Slf4j
|
| 16 |
+
@Service
|
| 17 |
+
@RequiredArgsConstructor
|
| 18 |
+
public class ModelConfigServiceImpl implements ModelConfigService {
|
| 19 |
+
|
| 20 |
+
private static final String CACHE_NAME_CONFIG_MODEL = "artandsciencewebbff-configModel";
|
| 21 |
+
private final ModelConfigRepository modelConfigRepository;
|
| 22 |
+
|
| 23 |
+
@Override
|
| 24 |
+
@Cacheable(cacheNames = CACHE_NAME_CONFIG_MODEL, key = "#modelCode", unless = "#result == null")
|
| 25 |
+
public String getModelConfig(String modelCode) {
|
| 26 |
+
try {
|
| 27 |
+
Optional<ModelConfig> optModelConfig = modelConfigRepository.findById(String.format("%s", modelCode));
|
| 28 |
+
if (optModelConfig.isPresent()) {
|
| 29 |
+
ModelConfig modelConfig = optModelConfig.get();
|
| 30 |
+
return modelConfig.getJsonDetail();
|
| 31 |
+
}
|
| 32 |
+
log.info("ModelConfigService modelCode not found " + modelCode);
|
| 33 |
+
return null;
|
| 34 |
+
} catch (Exception e) {
|
| 35 |
+
log.error("ModelConfigService - getModelConfig - exception" + e.getMessage() + " Model Code: " + modelCode, e);
|
| 36 |
+
return null;
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
@Scheduled(cron = "${artandscience-web.configmodel-cache-expire-time}")
|
| 41 |
+
@CacheEvict(value = CACHE_NAME_CONFIG_MODEL, allEntries = true)
|
| 42 |
+
public void clearCache() {
|
| 43 |
+
log.debug("Cache '{}' cleared.", CACHE_NAME_CONFIG_MODEL);
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
}
|