IntegrationErrorCollection.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.message.config;

  21. import java.util.HashMap;
  22. import java.util.Map;

  23. import org.openspcoop2.message.constants.IntegrationError;
  24. import org.openspcoop2.message.constants.IntegrationErrorMessageType;

  25. /**
  26.  * IntegrationErrorConfiguration
  27.  *
  28.  *
  29.  * @author Poli Andrea (apoli@link.it)
  30.  * @author $Author$
  31.  * @version $Rev$, $Date$
  32.  */

  33. public class IntegrationErrorCollection implements java.io.Serializable {

  34.     /**
  35.      * serialVersionUID
  36.      */
  37.     private static final long serialVersionUID = 1L;

  38.    
  39.     private Map<String, org.openspcoop2.message.config.IntegrationErrorConfiguration> map = new HashMap<String, org.openspcoop2.message.config.IntegrationErrorConfiguration>();

  40.     private IntegrationErrorMessageType defaultError;
  41.    
  42.     public void addIntegrationError(ConfigurationRFC7807 rfc7807, IntegrationError errorType,
  43.             IntegrationErrorMessageType integrationErrorMessageType,
  44.             IntegrationErrorReturnConfiguration errorReturnConfig,
  45.             boolean useInternalFault){
  46.         if(this.map.containsKey(errorType.name())){
  47.             this.map.remove(errorType.name());
  48.         }
  49.         org.openspcoop2.message.config.IntegrationErrorConfiguration error =
  50.                 new org.openspcoop2.message.config.IntegrationErrorConfiguration(rfc7807, integrationErrorMessageType, errorReturnConfig, useInternalFault);
  51.         this.map.put(errorType.name(), error);
  52.         if(IntegrationError.DEFAULT.equals(errorType)){
  53.             this.defaultError = integrationErrorMessageType;
  54.         }
  55.     }
  56.    
  57.     public org.openspcoop2.message.config.IntegrationErrorConfiguration getIntegrationError(IntegrationError errorType){
  58.         if(this.map.containsKey(errorType.name())){
  59.             org.openspcoop2.message.config.IntegrationErrorConfiguration error = this.map.get(errorType.name());
  60.             error.setDefaultErrorType(this.defaultError);
  61.             return error;
  62.         }
  63.         return null;
  64.     }
  65. }