ConnectorDispatcherErrorInfo.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.pdd.services.connector;

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

  23. import org.openspcoop2.message.OpenSPCoop2Message;
  24. import org.openspcoop2.protocol.sdk.IProtocolFactory;
  25. import org.openspcoop2.protocol.sdk.builder.EsitoTransazione;
  26. import org.openspcoop2.protocol.sdk.constants.EsitoTransazioneName;
  27. import org.openspcoop2.protocol.sdk.state.RequestInfo;

  28. /**
  29.  * ConnectorDispatcherErrorInfo
  30.  *
  31.  * @author Andrea Poli (apoli@link.it)
  32.  * @author $Author$
  33.  * @version $Rev$, $Date$
  34.  */
  35. public class ConnectorDispatcherErrorInfo extends ConnectorDispatcherInfo {

  36.     public static ConnectorDispatcherErrorInfo getGenericError(OpenSPCoop2Message errorMessage,int status, String contentType, Map<String, List<String>> trasporto,
  37.             RequestInfo requestInfo,IProtocolFactory<?> protocolFactory) throws Exception {
  38.         ConnectorDispatcherErrorInfo c = new ConnectorDispatcherErrorInfo();
  39.         EsitoTransazione esito = protocolFactory.createEsitoBuilder().getEsito(requestInfo.getProtocolContext(),EsitoTransazioneName.ERRORE_PROCESSAMENTO_PDD_5XX);
  40.         c.setMessage(errorMessage);
  41.         c.setEsitoTransazione(esito);
  42.         c.setStatus(status);
  43.         c.setContentType(contentType);
  44.         c.setTrasporto(trasporto);
  45.         return c;
  46.     }
  47.     public static ConnectorDispatcherErrorInfo getClientError(OpenSPCoop2Message errorMessage,int status, String contentType, Map<String, List<String>> trasporto,
  48.             RequestInfo requestInfo,IProtocolFactory<?> protocolFactory) throws Exception {
  49.         ConnectorDispatcherErrorInfo c = new ConnectorDispatcherErrorInfo();
  50.         EsitoTransazione esito = protocolFactory.createEsitoBuilder().getEsito(requestInfo.getProtocolContext(),EsitoTransazioneName.ERRORE_PROCESSAMENTO_PDD_4XX);
  51.         c.setMessage(errorMessage);
  52.         c.setEsitoTransazione(esito);
  53.         c.setStatus(status);
  54.         c.setContentType(contentType);
  55.         c.setTrasporto(trasporto);
  56.         return c;
  57.     }
  58.    
  59.     private ConnectorDispatcherErrorInfo() {
  60.        
  61.     }
  62. }