sarvenyanik commited on
Commit
18fe515
·
2 Parent(s): bb369a7bc17e28

Merged in feature/sarvenDev (pull request #12)

Browse files
src/main/java/com/artandscience/webbff/webbff/common/exception/ForbiddenException.java DELETED
@@ -1,23 +0,0 @@
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 ForbiddenException 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 ForbiddenException(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/ProviderValidateException.java CHANGED
@@ -10,11 +10,14 @@ public class ProviderValidateException extends RuntimeException implements Seria
10
 
11
  @Serial
12
  private static final long serialVersionUID = -7123456789012345678L;
13
-
14
  private final String serviceName;
 
15
 
16
- public ProviderValidateException(String serviceName) {
 
17
  this.serviceName = serviceName;
 
18
  }
19
 
20
  }
 
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/interceptor/ResponseErrorHandler.java CHANGED
@@ -8,7 +8,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.ForbiddenException;
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;
@@ -96,10 +96,10 @@ public class ResponseErrorHandler extends BaseController {
96
  return responseFail(messageBoxList);
97
  }
98
 
99
- @ExceptionHandler(value = ForbiddenException.class)
100
  @ResponseStatus(HttpStatus.FORBIDDEN)
101
- public BaseValidResponse handleForbiddenExceptionError(ForbiddenException e) {
102
- log.error("Forbidden exception occurred: " + e.getMessage() + " ErrorCode: " + e.getCode(), e);
103
  BaseValidResponse baseValidResponse = new BaseValidResponse();
104
  baseValidResponse.setErrorFunction(e.getCode());
105
  baseValidResponse.setErrorDescription(e.getMessage());
 
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;
 
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());
src/main/java/com/artandscience/webbff/webbff/integration/decoder/FeignSecurityErrorDecoder.java CHANGED
@@ -1,6 +1,6 @@
1
  package com.artandscience.webbff.webbff.integration.decoder;
2
 
3
- import com.artandscience.webbff.webbff.common.exception.ForbiddenException;
4
  import com.artandscience.webbff.webbff.common.helper.JsonMapper;
5
  import com.artandscience.webbff.webbff.integration.service.response.base.BaseProviderValidClientResponse;
6
  import com.artandscience.webbff.webbff.integration.service.util.DecoderUtil;
@@ -50,7 +50,7 @@ public class FeignSecurityErrorDecoder implements ErrorDecoder {
50
  BaseProviderValidClientResponse.class
51
  );
52
 
53
- return new ForbiddenException(
54
  baseResponse.getErrorFunction(),
55
  baseResponse.getServiceName(),
56
  baseResponse.getErrorDescription()
@@ -59,7 +59,7 @@ public class FeignSecurityErrorDecoder implements ErrorDecoder {
59
  } catch (Exception exception) {
60
  log.error("Feign error body parse failed. Raw body: {}", responseBody, exception);
61
 
62
- return new ForbiddenException(
63
  "PROVIDER_VALIDATE",
64
  serviceName,
65
  responseBody
 
1
  package com.artandscience.webbff.webbff.integration.decoder;
2
 
3
+ import com.artandscience.webbff.webbff.common.exception.ProviderValidateException;
4
  import com.artandscience.webbff.webbff.common.helper.JsonMapper;
5
  import com.artandscience.webbff.webbff.integration.service.response.base.BaseProviderValidClientResponse;
6
  import com.artandscience.webbff.webbff.integration.service.util.DecoderUtil;
 
50
  BaseProviderValidClientResponse.class
51
  );
52
 
53
+ return new ProviderValidateException(
54
  baseResponse.getErrorFunction(),
55
  baseResponse.getServiceName(),
56
  baseResponse.getErrorDescription()
 
59
  } catch (Exception exception) {
60
  log.error("Feign error body parse failed. Raw body: {}", responseBody, exception);
61
 
62
+ return new ProviderValidateException(
63
  "PROVIDER_VALIDATE",
64
  serviceName,
65
  responseBody