IntegrationFunctionError.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.protocol.sdk.constants;

  21. import java.io.Serializable;

  22. import org.openspcoop2.message.constants.IntegrationError;

  23. /**
  24.  * IntegrationError
  25.  *
  26.  *
  27.  * @author Poli Andrea (apoli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public enum IntegrationFunctionError implements Serializable {
  32.    
  33.     // 400
  34.     CONTENT_TYPE_NOT_PROVIDED(true),
  35.     CONTENT_TYPE_NOT_SUPPORTED(true),
  36.     SOAP_MUST_UNDERSTAND_UNKNOWN(true),
  37.     SOAP_VERSION_MISMATCH(true),
  38.     UNPROCESSABLE_REQUEST_CONTENT(true),
  39.     REQUEST_TIMED_OUT(true),
  40.     NOT_SUPPORTED_BY_PROTOCOL(true),
  41.     CORRELATION_INFORMATION_NOT_FOUND(true),
  42.     APPLICATION_CORRELATION_IDENTIFICATION_REQUEST_FAILED(true),
  43.     INVALID_REQUEST_CONTENT(true),
  44.     INTEROPERABILITY_PROFILE_REQUEST_ALREADY_EXISTS(true),
  45.     INVALID_INTEROPERABILITY_PROFILE_REQUEST(true),
  46.     BAD_REQUEST(true),
  47.    
  48.     // 400 altri errori
  49.     ATTACHMENTS_PROCESSING_REQUEST_FAILED(true),
  50.     MESSAGE_SECURITY_REQUEST_FAILED(true),
  51.     INTEROPERABILITY_PROFILE_ENVELOPING_REQUEST_FAILED(true),
  52.     TRANSFORMATION_RULE_REQUEST_FAILED(true),
  53.     CONNECTOR_NOT_FOUND(true),
  54.     // Wrap
  55.     WRAP_400_INTERNAL_BAD_REQUEST(true),
  56.    
  57.     // 401
  58.     PROXY_AUTHENTICATION_CREDENTIALS_NOT_FOUND(true),
  59.     PROXY_AUTHENTICATION_INVALID_CREDENTIALS(true),
  60.     PROXY_AUTHENTICATION_FORWARDED_CREDENTIALS_NOT_FOUND(true),
  61.     AUTHENTICATION_CREDENTIALS_NOT_FOUND(true),
  62.     AUTHENTICATION_INVALID_CREDENTIALS(true),
  63.     TOKEN_NOT_FOUND(true),
  64.     TOKEN_INVALID(true),
  65.     TOKEN_EXPIRED(true),
  66.     TOKEN_NOT_USABLE_BEFORE(true),
  67.     TOKEN_IN_THE_FUTURE(true),
  68.     TOKEN_REQUIRED_CLAIMS_NOT_FOUND(true),
  69.     AUTHENTICATION(true),
  70.    
  71.     // 403
  72.     CONTENT_AUTHORIZATION_DENY(true),
  73.     CONTENT_AUTHORIZATION_POLICY_DENY(true),
  74.     AUTHORIZATION_DENY(true),
  75.     AUTHORIZATION_POLICY_DENY(true),
  76.     AUTHORIZATION_TOKEN_DENY(true),
  77.     AUTHORIZATION_MISSING_SCOPE(true),
  78.     AUTHORIZATION_MISSING_ROLE(true),
  79.     AUTHORIZATION(true),
  80.    
  81.     // 404
  82.     API_IN_UNKNOWN(true),
  83.     API_OUT_UNKNOWN(true),
  84.     OPERATION_UNDEFINED(true),
  85.     IM_MESSAGES_NOT_FOUND(true),
  86.     IM_MESSAGE_NOT_FOUND(true),
  87.     NOT_FOUND(true),
  88.    
  89.     // 409
  90.     CONFLICT_IN_QUEUE(true),
  91.     CONFLICT(true),
  92.    
  93.     // 413
  94.     REQUEST_SIZE_EXCEEDED(true),
  95.    
  96.     // 429
  97.     LIMIT_EXCEEDED_CONDITIONAL_CONGESTION(true),
  98.     LIMIT_EXCEEDED_CONDITIONAL_DETERIORATION_PERFORMANCE(true),
  99.     LIMIT_EXCEEDED(true),
  100.     TOO_MANY_REQUESTS_CONDITIONAL_CONGESTION(true),
  101.     TOO_MANY_REQUESTS_CONDITIONAL_DETERIORATION_PERFORMANCE(true),
  102.     TOO_MANY_REQUESTS(true),
  103.    
  104.     // 502
  105.     UNPROCESSABLE_RESPONSE_CONTENT(false),
  106.     ATTACHMENTS_PROCESSING_RESPONSE_FAILED(false),
  107.     APPLICATION_CORRELATION_IDENTIFICATION_RESPONSE_FAILED(false),
  108.     MESSAGE_SECURITY_RESPONSE_FAILED(false),
  109.     INVALID_RESPONSE_CONTENT(false),
  110.     INTEROPERABILITY_PROFILE_ENVELOPING_RESPONSE_FAILED(false),
  111.     INVALID_INTEROPERABILITY_PROFILE_RESPONSE(false),
  112.     INTEROPERABILITY_PROFILE_RESPONSE_ALREADY_EXISTS(false),
  113.     INTEROPERABILITY_PROFILE_RESPONSE_ERROR(false),
  114.     TRANSFORMATION_RULE_RESPONSE_FAILED(false),
  115.     EXPECTED_RESPONSE_NOT_FOUND(false),
  116.     CONFLICT_RESPONSE(false),
  117.     RESPONSE_SIZE_EXCEEDED(false),
  118.     BAD_RESPONSE(false),
  119.     INTERNAL_RESPONSE_ERROR(false),
  120.     // Wrap
  121.     WRAP_502_BAD_RESPONSE(false),
  122.     WRAP_502_INTERNAL_RESPONSE_ERROR(false),
  123.    
  124.     // 503
  125.     SERVICE_UNAVAILABLE(false),
  126.     API_SUSPEND(false),
  127.     GOVWAY_NOT_INITIALIZED(false),
  128.     GOVWAY_RESOURCES_NOT_AVAILABLE(false),
  129.     INTERNAL_REQUEST_ERROR(false),
  130.     // Wrap
  131.     WRAP_503_INTERNAL_ERROR(false),
  132.    
  133.     // 504
  134.     ENDPOINT_REQUEST_TIMED_OUT(false);
  135.    
  136.     private boolean clientError;
  137.     IntegrationFunctionError(boolean clientError){
  138.         this.clientError = clientError;
  139.     }
  140.    
  141.     public static IntegrationFunctionError[] wrappedValues() {
  142.         IntegrationFunctionError [] ife = new IntegrationFunctionError[4];
  143.         ife[0] = WRAP_400_INTERNAL_BAD_REQUEST;
  144.         ife[1] = WRAP_502_BAD_RESPONSE;
  145.         ife[2] = WRAP_502_INTERNAL_RESPONSE_ERROR;
  146.         ife[3] = WRAP_503_INTERNAL_ERROR;
  147.         return ife;
  148.     }
  149.    
  150.     public boolean isClientError() {
  151.         return this.clientError;
  152.     }
  153.     public boolean isServerError() {
  154.         return !this.clientError;
  155.     }
  156.    
  157.     public boolean isWrapBadRequest() {
  158.         return ATTACHMENTS_PROCESSING_REQUEST_FAILED.equals(this) || MESSAGE_SECURITY_REQUEST_FAILED.equals(this) ||
  159.                 INTEROPERABILITY_PROFILE_ENVELOPING_REQUEST_FAILED.equals(this) || TRANSFORMATION_RULE_REQUEST_FAILED.equals(this) ||
  160.                 CONNECTOR_NOT_FOUND.equals(this);
  161.     }
  162.     public boolean isWrapInternalError() {
  163.         return GOVWAY_NOT_INITIALIZED.equals(this) || GOVWAY_RESOURCES_NOT_AVAILABLE.equals(this) ||
  164.                 INTERNAL_REQUEST_ERROR.equals(this);
  165.     }
  166.     public boolean isWrapBadResponse(IntegrationError integrationError) {
  167.         // tutte tranne RESPONSE_SIZE_EXCEEDED
  168.         return IntegrationError.BAD_RESPONSE.equals(integrationError) &&  !RESPONSE_SIZE_EXCEEDED.equals(this);
  169.     }
  170.     public boolean isWrapInternalResponseError(IntegrationError integrationError) {
  171.         // tutte per adesso
  172.         return IntegrationError.INTERNAL_RESPONSE_ERROR.equals(integrationError);
  173.     }
  174. }