IDService.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 java.net.ProtocolException;
  23. import java.util.List;

  24. import org.openspcoop2.generic_project.beans.IEnumeration;

  25. /**    
  26.  * Enumeration dell'elemento MethodType xsd (tipo:string)
  27.  *
  28.  * @author Poli Andrea (poli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */
  32. public enum IDService implements IEnumeration , Serializable , Cloneable {

  33.     OPENSPCOOP2_SERVLET ("OpenSPCoop2Servlet"),
  34.    
  35.     PORTA_DELEGATA ("RicezioneContenutiApplicativi"),
  36.     PORTA_DELEGATA_NIO ("RicezioneContenutiApplicativiNIO"),
  37.    
  38.     PORTA_DELEGATA_XML_TO_SOAP ("RicezioneContenutiApplicativiHTTP"),
  39.     PORTA_DELEGATA_XML_TO_SOAP_NIO ("RicezioneContenutiApplicativiHTTPNIO"),
  40.    
  41.     PORTA_DELEGATA_INTEGRATION_MANAGER ("RicezioneContenutiApplicativiIntegrationManager"),
  42.    
  43.     PORTA_APPLICATIVA ("RicezioneBuste"),
  44.     PORTA_APPLICATIVA_NIO ("RicezioneBusteNIO"),
  45.    
  46.     INTEGRATION_MANAGER_SOAP ("IntegrationManager"),
  47.    
  48.     CHECK_PDD ("Check"),
  49.     PROXY ("Proxy");
  50.    
  51.    
  52.     // ID: 7 cifre (parlante)
  53.     private static final String ID_OPENSPCOOP_SERVLET = "OP20000";
  54.    
  55.     private static final String ID_PORTA_DELEGATA = "PD00000";
  56.     private static final String ID_PORTA_DELEGATA_NIO = "PDNIO00";
  57.    
  58.     private static final String ID_PORTA_DELEGATA_IMBUSTAMENTO_SOAP = "PD2SOAP";
  59.     private static final String ID_PORTA_DELEGATA_IMBUSTAMENTO_SOAP_NIO = "PD2SOAN";
  60.    
  61.     private static final String ID_PORTA_DELEGATA_INTEGRATION_MANAGER = "PDIM000";
  62.    
  63.     private static final String ID_PORTA_APPLICATIVA = "PA00000";
  64.     private static final String ID_PORTA_APPLICATIVA_NIO = "PANIO00";
  65.    
  66.     private static final String ID_INTEGRATION_MANAGER = "IM00000";
  67.    
  68.     private static final String ID_CHECK_PDD = "CHKPDD0";
  69.     private static final String ID_PROXY = "PROXY00";
  70.    
  71.     public String getCode() throws ProtocolException{
  72.         switch (this) {
  73.        
  74.         case OPENSPCOOP2_SERVLET:
  75.             return ID_OPENSPCOOP_SERVLET;
  76.            
  77.         case PORTA_DELEGATA:
  78.             return ID_PORTA_DELEGATA;
  79.         case PORTA_DELEGATA_NIO:
  80.             return ID_PORTA_DELEGATA_NIO;
  81.            
  82.         case PORTA_DELEGATA_XML_TO_SOAP:
  83.             return ID_PORTA_DELEGATA_IMBUSTAMENTO_SOAP;
  84.         case PORTA_DELEGATA_XML_TO_SOAP_NIO:
  85.             return ID_PORTA_DELEGATA_IMBUSTAMENTO_SOAP_NIO;
  86.            
  87.         case PORTA_DELEGATA_INTEGRATION_MANAGER:
  88.             return ID_PORTA_DELEGATA_INTEGRATION_MANAGER;
  89.            
  90.         case PORTA_APPLICATIVA:
  91.             return ID_PORTA_APPLICATIVA;
  92.         case PORTA_APPLICATIVA_NIO:
  93.             return ID_PORTA_APPLICATIVA_NIO;
  94.            
  95.         case INTEGRATION_MANAGER_SOAP:
  96.             return ID_INTEGRATION_MANAGER;
  97.            
  98.         case CHECK_PDD:
  99.             return ID_CHECK_PDD;
  100.         case PROXY:
  101.             return ID_PROXY;
  102.            
  103.         }
  104.         throw new ProtocolException("Service ["+this.name()+"] unsupported");
  105.     }
  106.    
  107.    
  108.    
  109.     /** Value */
  110.     private String value;
  111.     @Override
  112.     public String getValue()
  113.     {
  114.         return this.value;
  115.     }


  116.     /** Official Constructor */
  117.     IDService(String value)
  118.     {
  119.         this.value = value;
  120.     }


  121.    
  122.     @Override
  123.     public String toString(){
  124.         return this.value;
  125.     }
  126.     public boolean equals(String object){
  127.         if(object==null)
  128.             return false;
  129.         return object.equals(this.getValue());  
  130.     }
  131.    
  132.        
  133.    
  134.     /** compatibility with the generated bean (reflection) */
  135.     public boolean equals(Object object,List<String> fieldsNotCheck){
  136.         if( !(object instanceof IDService) ){
  137.             throw new RuntimeException("Wrong type: "+object.getClass().getName());
  138.         }
  139.         return this.equals(((IDService)object));
  140.     }
  141.     public String toString(boolean reportHTML){
  142.         return toString();
  143.     }
  144.     public String toString(boolean reportHTML,List<String> fieldsNotIncluded){
  145.         return toString();
  146.     }
  147.     public String diff(Object object,StringBuilder bf,boolean reportHTML){
  148.         return bf.toString();
  149.     }
  150.     public String diff(Object object,StringBuilder bf,boolean reportHTML,List<String> fieldsNotIncluded){
  151.         return bf.toString();
  152.     }
  153.    
  154.    
  155.     /** Utilities */
  156.    
  157.     public static String[] toArray(){
  158.         String[] res = new String[values().length];
  159.         int i=0;
  160.         for (IDService tmp : values()) {
  161.             res[i]=tmp.getValue();
  162.             i++;
  163.         }
  164.         return res;
  165.     }  
  166.     public static String[] toStringArray(){
  167.         String[] res = new String[values().length];
  168.         int i=0;
  169.         for (IDService tmp : values()) {
  170.             res[i]=tmp.toString();
  171.             i++;
  172.         }
  173.         return res;
  174.     }
  175.     public static String[] toEnumNameArray(){
  176.         String[] res = new String[values().length];
  177.         int i=0;
  178.         for (IDService tmp : values()) {
  179.             res[i]=tmp.name();
  180.             i++;
  181.         }
  182.         return res;
  183.     }
  184.    
  185.     public static boolean contains(String value){
  186.         return toEnumConstant(value)!=null;
  187.     }
  188.    
  189.     public static IDService toEnumConstant(String value){
  190.         IDService res = null;
  191.         for (IDService tmp : values()) {
  192.             if(tmp.getValue().equals(value)){
  193.                 res = tmp;
  194.                 break;
  195.             }
  196.         }
  197.         return res;
  198.     }
  199.    
  200.     public static IEnumeration toEnumConstantFromString(String value){
  201.         IDService res = null;
  202.         for (IDService tmp : values()) {
  203.             if(tmp.toString().equals(value)){
  204.                 res = tmp;
  205.                 break;
  206.             }
  207.         }
  208.         return res;
  209.     }
  210. }