ForcedResponseMessage.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;


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

  23. import org.openspcoop2.utils.transport.TransportUtils;
  24. import org.openspcoop2.utils.transport.http.HttpConstants;

  25. /**
  26.  * ForcedResponseMessage
  27.  *
  28.  * @author Lorenzo Nardi (nardi@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */

  32. public class ForcedResponseMessage {
  33.    
  34.     public ForcedResponseMessage() {}
  35.     public ForcedResponseMessage(AbstractBaseOpenSPCoop2Message msg) {
  36.         if(msg.forceTransportHeaders!=null && !msg.forceTransportHeaders.isEmpty()) {
  37.             this.headers = msg.forceTransportHeaders;
  38.         }
  39.     }
  40.    
  41.     private byte[] content;
  42.     private String contentType = HttpConstants.CONTENT_TYPE_APPLICATION_OCTET_STREAM;
  43.     private Map<String, List<String>> headers;
  44.     private String responseCode;
  45.    
  46.     public byte[] getContent() {
  47.         return this.content;
  48.     }
  49.     public void setContent(byte[] content) {
  50.         this.content = content;
  51.     }
  52.     public String getContentType() {
  53.         return this.contentType;
  54.     }
  55.     public void setContentType(String contentType) {
  56.         this.contentType = contentType;
  57.     }
  58.     @Deprecated
  59.     public Map<String, String> getHeaders() {
  60.         return TransportUtils.convertToMapSingleValue(this.headers);
  61.     }
  62.     public Map<String, List<String>> getHeadersValues() {
  63.         return this.headers;
  64.     }
  65.     @Deprecated
  66.     public void setHeaders(Map<String, String> headers) {
  67.         this.headers = TransportUtils.convertToMapListValues(headers);
  68.     }
  69.     public void setHeadersValues(Map<String, List<String>> headers) {
  70.         this.headers = headers;
  71.     }
  72.     public String getResponseCode() {
  73.         return this.responseCode;
  74.     }
  75.     public void setResponseCode(String responseCode) {
  76.         this.responseCode = responseCode;
  77.     }
  78.    
  79. }