DriverRegistroServiziWS.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.core.registry.driver.ws;

  21. import java.util.ArrayList;
  22. import java.util.Calendar;
  23. import java.util.GregorianCalendar;
  24. import java.util.List;

  25. import javax.xml.datatype.DatatypeFactory;
  26. import javax.xml.ws.BindingProvider;

  27. import org.openspcoop2.core.commons.CoreException;
  28. import org.openspcoop2.core.commons.IMonitoraggioRisorsa;
  29. import org.openspcoop2.core.id.IDAccordo;
  30. import org.openspcoop2.core.id.IDAccordoAzione;
  31. import org.openspcoop2.core.id.IDAccordoCooperazione;
  32. import org.openspcoop2.core.id.IDFruizione;
  33. import org.openspcoop2.core.id.IDGruppo;
  34. import org.openspcoop2.core.id.IDPortType;
  35. import org.openspcoop2.core.id.IDPortTypeAzione;
  36. import org.openspcoop2.core.id.IDResource;
  37. import org.openspcoop2.core.id.IDRuolo;
  38. import org.openspcoop2.core.id.IDScope;
  39. import org.openspcoop2.core.id.IDServizio;
  40. import org.openspcoop2.core.id.IDSoggetto;
  41. import org.openspcoop2.core.registry.AccordoCooperazione;
  42. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  43. import org.openspcoop2.core.registry.AccordoServizioParteSpecifica;
  44. import org.openspcoop2.core.registry.Azione;
  45. import org.openspcoop2.core.registry.Fruitore;
  46. import org.openspcoop2.core.registry.Gruppo;
  47. import org.openspcoop2.core.registry.CredenzialiSoggetto;
  48. import org.openspcoop2.core.registry.Documento;
  49. import org.openspcoop2.core.registry.IdAccordoCooperazione;
  50. import org.openspcoop2.core.registry.IdAccordoServizioParteComune;
  51. import org.openspcoop2.core.registry.IdAccordoServizioParteSpecifica;
  52. import org.openspcoop2.core.registry.IdGruppo;
  53. import org.openspcoop2.core.registry.IdPortaDominio;
  54. import org.openspcoop2.core.registry.IdRuolo;
  55. import org.openspcoop2.core.registry.IdScope;
  56. import org.openspcoop2.core.registry.IdSoggetto;
  57. import org.openspcoop2.core.registry.Operation;
  58. import org.openspcoop2.core.registry.PortType;
  59. import org.openspcoop2.core.registry.PortaDominio;
  60. import org.openspcoop2.core.registry.Resource;
  61. import org.openspcoop2.core.registry.Ruolo;
  62. import org.openspcoop2.core.registry.Scope;
  63. import org.openspcoop2.core.registry.Soggetto;
  64. import org.openspcoop2.core.registry.constants.CredenzialeTipo;
  65. import org.openspcoop2.core.registry.constants.TipiDocumentoLivelloServizio;
  66. import org.openspcoop2.core.registry.constants.TipiDocumentoSemiformale;
  67. import org.openspcoop2.core.registry.constants.TipiDocumentoSicurezza;
  68. import org.openspcoop2.core.registry.constants.TipologiaServizio;
  69. import org.openspcoop2.core.registry.driver.BeanUtilities;
  70. import org.openspcoop2.core.registry.driver.DriverRegistroServiziException;
  71. import org.openspcoop2.core.registry.driver.DriverRegistroServiziNotFound;
  72. import org.openspcoop2.core.registry.driver.FiltroRicerca;
  73. import org.openspcoop2.core.registry.driver.FiltroRicercaAccordi;
  74. import org.openspcoop2.core.registry.driver.FiltroRicercaAzioni;
  75. import org.openspcoop2.core.registry.driver.FiltroRicercaFruizioniServizio;
  76. import org.openspcoop2.core.registry.driver.FiltroRicercaGruppi;
  77. import org.openspcoop2.core.registry.driver.FiltroRicercaOperations;
  78. import org.openspcoop2.core.registry.driver.FiltroRicercaPortTypes;
  79. import org.openspcoop2.core.registry.driver.FiltroRicercaResources;
  80. import org.openspcoop2.core.registry.driver.FiltroRicercaRuoli;
  81. import org.openspcoop2.core.registry.driver.FiltroRicercaScope;
  82. import org.openspcoop2.core.registry.driver.FiltroRicercaServizi;
  83. import org.openspcoop2.core.registry.driver.FiltroRicercaSoggetti;
  84. import org.openspcoop2.core.registry.driver.IDAccordoCooperazioneFactory;
  85. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  86. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  87. import org.openspcoop2.core.registry.driver.IDriverRegistroServiziGet;
  88. import org.openspcoop2.core.registry.driver.ProtocolPropertiesUtilities;
  89. import org.openspcoop2.core.registry.ws.client.accordocooperazione.search.AccordoCooperazioneSoap11Service;
  90. import org.openspcoop2.core.registry.ws.client.accordocooperazione.search.SearchFilterAccordoCooperazione;
  91. import org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.AccordoServizioParteComuneSoap11Service;
  92. import org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.SearchFilterAccordoServizioParteComune;
  93. import org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.AccordoServizioParteSpecificaSoap11Service;
  94. import org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.SearchFilterAccordoServizioParteSpecifica;
  95. import org.openspcoop2.core.registry.ws.client.portadominio.search.PortaDominioSoap11Service;
  96. import org.openspcoop2.core.registry.ws.client.portadominio.search.SearchFilterPortaDominio;
  97. import org.openspcoop2.core.registry.ws.client.gruppo.search.GruppoSoap11Service;
  98. import org.openspcoop2.core.registry.ws.client.gruppo.search.SearchFilterGruppo;
  99. import org.openspcoop2.core.registry.ws.client.ruolo.search.RuoloSoap11Service;
  100. import org.openspcoop2.core.registry.ws.client.ruolo.search.SearchFilterRuolo;
  101. import org.openspcoop2.core.registry.ws.client.scope.search.ScopeSoap11Service;
  102. import org.openspcoop2.core.registry.ws.client.scope.search.SearchFilterScope;
  103. import org.openspcoop2.core.registry.ws.client.soggetto.search.SearchFilterSoggetto;
  104. import org.openspcoop2.core.registry.ws.client.soggetto.search.SoggettoSoap11Service;
  105. import org.openspcoop2.utils.LoggerWrapperFactory;
  106. import org.openspcoop2.utils.UtilsRuntimeException;
  107. import org.openspcoop2.utils.certificate.CertificateInfo;
  108. import org.openspcoop2.utils.crypt.CryptConfig;
  109. import org.openspcoop2.utils.crypt.CryptFactory;
  110. import org.openspcoop2.utils.crypt.ICrypt;
  111. import org.slf4j.Logger;



  112. /**
  113.  * Classe utilizzata per effettuare query ad un registro WS, riguardanti specifiche
  114.  * proprieta' di servizi presenti all'interno del registro.
  115.  *
  116.  *
  117.  * @author Poli Andrea (apoli@link.it)
  118.  * @author Lorenzo Nardi (nardi@link.it)
  119.  * @author $Author$
  120.  * @version $Rev$, $Date$
  121.  */

  122. public class DriverRegistroServiziWS extends BeanUtilities
  123.   implements IDriverRegistroServiziGet,IMonitoraggioRisorsa {



  124.     /* ********  F I E L D S  P R I V A T I  ******** */

  125.     /** Indicazione di una corretta creazione */
  126.     public boolean create = false;
  127.     public boolean isCreate() {
  128.         return this.create;
  129.     }
  130.    
  131.     /** Stub per invocazione del WS */
  132.     private org.openspcoop2.core.registry.ws.client.accordocooperazione.search.AccordoCooperazioneSoap11Service accordoCooperazioneService;
  133.     private org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.AccordoServizioParteComuneSoap11Service accordoServizioParteComuneService;
  134.     private org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.AccordoServizioParteSpecificaSoap11Service accordoServizioParteSpecificaService;
  135.     private org.openspcoop2.core.registry.ws.client.soggetto.search.SoggettoSoap11Service soggettoService;
  136.     private org.openspcoop2.core.registry.ws.client.portadominio.search.PortaDominioSoap11Service pddService;
  137.     private org.openspcoop2.core.registry.ws.client.gruppo.search.GruppoSoap11Service gruppoService;
  138.     private org.openspcoop2.core.registry.ws.client.ruolo.search.RuoloSoap11Service ruoloService;
  139.     private org.openspcoop2.core.registry.ws.client.scope.search.ScopeSoap11Service scopeService;
  140.    
  141.     private org.openspcoop2.core.registry.ws.client.accordocooperazione.search.AccordoCooperazione accordoCooperazionePort;
  142.     private org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.AccordoServizioParteComune accordoServizioParteComunePort;
  143.     private org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.AccordoServizioParteSpecifica accordoServizioParteSpecificaPort;
  144.     private org.openspcoop2.core.registry.ws.client.soggetto.search.Soggetto soggettoPort;
  145.     private org.openspcoop2.core.registry.ws.client.portadominio.search.PortaDominio pddPort;
  146.     private org.openspcoop2.core.registry.ws.client.gruppo.search.Gruppo gruppoPort;
  147.     private org.openspcoop2.core.registry.ws.client.ruolo.search.Ruolo ruoloPort;
  148.     private org.openspcoop2.core.registry.ws.client.scope.search.Scope scopePort;

  149.    
  150.     /** Logger utilizzato per info. */
  151.     private org.slf4j.Logger log = null;

  152.     private  DatatypeFactory dataTypeFactory = null;



  153.     /* ********  C O S T R U T T O R E  ******** */
  154.     /**
  155.      * Costruttore.
  156.      *
  157.      *
  158.      */
  159.     public DriverRegistroServiziWS(String prefixLocation,Logger alog){  
  160.         this(prefixLocation,null,null,alog);
  161.     }
  162.     /**
  163.      * Costruttore.
  164.      *
  165.      *
  166.      */
  167.     public DriverRegistroServiziWS(String prefixLocation,String username,String password,Logger alog){  
  168.        
  169.         if(alog==null)
  170.             this.log = LoggerWrapperFactory.getLogger(DriverRegistroServiziWS.class);
  171.         else
  172.             this.log = alog;
  173.         if(this.log==null) {
  174.             throw new UtilsRuntimeException("Logger unavailable");
  175.         }
  176.         try{    
  177.             // es. http://127.0.0.1:8080/openspcoop2Registry/
  178.             if(prefixLocation==null)
  179.                 throw new Exception("Location is null");
  180.             if(prefixLocation.endsWith("/")==false){
  181.                 prefixLocation = prefixLocation + "/";
  182.             }
  183.            
  184.             this.dataTypeFactory = DatatypeFactory.newInstance();
  185.            
  186.             this.accordoCooperazioneService = new AccordoCooperazioneSoap11Service();
  187.             this.accordoServizioParteComuneService = new AccordoServizioParteComuneSoap11Service();
  188.             this.accordoServizioParteSpecificaService = new AccordoServizioParteSpecificaSoap11Service();
  189.             this.soggettoService = new SoggettoSoap11Service();
  190.             this.pddService = new PortaDominioSoap11Service();
  191.             this.gruppoService = new GruppoSoap11Service();
  192.             this.ruoloService = new RuoloSoap11Service();
  193.             this.scopeService = new ScopeSoap11Service();
  194.            
  195.             this.accordoCooperazionePort = this.accordoCooperazioneService.getAccordoCooperazionePortSoap11();
  196.             this.accordoServizioParteComunePort = this.accordoServizioParteComuneService.getAccordoServizioParteComunePortSoap11();
  197.             this.accordoServizioParteSpecificaPort = this.accordoServizioParteSpecificaService.getAccordoServizioParteSpecificaPortSoap11();
  198.             this.soggettoPort = this.soggettoService.getSoggettoPortSoap11();
  199.             this.pddPort = this.pddService.getPortaDominioPortSoap11();
  200.             this.gruppoPort = this.gruppoService.getGruppoPortSoap11();
  201.             this.ruoloPort = this.ruoloService.getRuoloPortSoap11();
  202.             this.scopePort = this.scopeService.getScopePortSoap11();
  203.            
  204.             ((BindingProvider)this.accordoCooperazionePort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  205.                     prefixLocation+"AccordoCooperazione/Soap11");
  206.             ((BindingProvider)this.accordoServizioParteComunePort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  207.                     prefixLocation+"AccordoServizioParteComune/Soap11");
  208.             ((BindingProvider)this.accordoServizioParteSpecificaPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  209.                     prefixLocation+"AccordoServizioParteSpecifica/Soap11");
  210.             ((BindingProvider)this.soggettoPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  211.                     prefixLocation+"Soggetto/Soap11");
  212.             ((BindingProvider)this.pddPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  213.                     prefixLocation+"PortaDominio/Soap11");
  214.             ((BindingProvider)this.gruppoPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  215.                     prefixLocation+"Gruppo/Soap11");
  216.             ((BindingProvider)this.ruoloPort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  217.                     prefixLocation+"Ruolo/Soap11");
  218.             ((BindingProvider)this.scopePort).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
  219.                     prefixLocation+"Scope/Soap11");
  220.            
  221.             ((BindingProvider)this.accordoCooperazionePort).getRequestContext().put("schema-validation-enabled", true);
  222.             ((BindingProvider)this.accordoServizioParteComunePort).getRequestContext().put("schema-validation-enabled", true);
  223.             ((BindingProvider)this.accordoServizioParteSpecificaPort).getRequestContext().put("schema-validation-enabled", true);
  224.             ((BindingProvider)this.soggettoPort).getRequestContext().put("schema-validation-enabled", true);
  225.             ((BindingProvider)this.pddPort).getRequestContext().put("schema-validation-enabled", true);
  226.             ((BindingProvider)this.gruppoPort).getRequestContext().put("schema-validation-enabled", true);
  227.             ((BindingProvider)this.ruoloPort).getRequestContext().put("schema-validation-enabled", true);
  228.             ((BindingProvider)this.scopePort).getRequestContext().put("schema-validation-enabled", true);
  229.            
  230.             if(username !=null && password!=null){
  231.                 // to use Basic HTTP Authentication:
  232.                
  233.                 ((BindingProvider)this.accordoCooperazionePort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  234.                 ((BindingProvider)this.accordoCooperazionePort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  235.                
  236.                 ((BindingProvider)this.accordoServizioParteComunePort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  237.                 ((BindingProvider)this.accordoServizioParteComunePort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  238.                
  239.                 ((BindingProvider)this.accordoServizioParteSpecificaPort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  240.                 ((BindingProvider)this.accordoServizioParteSpecificaPort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  241.                
  242.                 ((BindingProvider)this.soggettoPort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  243.                 ((BindingProvider)this.soggettoPort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  244.                
  245.                 ((BindingProvider)this.pddPort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  246.                 ((BindingProvider)this.pddPort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  247.                
  248.                 ((BindingProvider)this.gruppoPort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  249.                 ((BindingProvider)this.gruppoPort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  250.                
  251.                 ((BindingProvider)this.ruoloPort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  252.                 ((BindingProvider)this.ruoloPort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  253.                
  254.                 ((BindingProvider)this.scopePort).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username);
  255.                 ((BindingProvider)this.scopePort).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);
  256.             }
  257.            
  258.             this.log.debug("GestoreRegistro: Inizializzato WebService. AccordoCooperazione: " + this.accordoCooperazioneService.getClass().getSimpleName());
  259.             this.log.debug("GestoreRegistro: Inizializzato WebService. AccordoServizioParteComune: " + this.accordoServizioParteComuneService.getClass().getSimpleName());
  260.             this.log.debug("GestoreRegistro: Inizializzato WebService. AccordoServizioParteSpecifica: " + this.accordoServizioParteSpecificaService.getClass().getSimpleName());
  261.             this.log.debug("GestoreRegistro: Inizializzato WebService. Soggetto: " + this.soggettoService.getClass().getSimpleName());
  262.             this.log.debug("GestoreRegistro: Inizializzato WebService. PortaDominio: " + this.pddService.getClass().getSimpleName());
  263.             this.log.debug("GestoreRegistro: Inizializzato WebService. Gruppo: " + this.gruppoService.getClass().getSimpleName());
  264.             this.log.debug("GestoreRegistro: Inizializzato WebService. Ruolo: " + this.ruoloService.getClass().getSimpleName());
  265.             this.log.debug("GestoreRegistro: Inizializzato WebService. Scope: " + this.scopeService.getClass().getSimpleName());
  266.            
  267.             this.create = true;
  268.         } catch(Exception e){
  269.             this.log.error("Inizializzazione fallita: "+e.getMessage());
  270.             this.create = false;
  271.         }
  272.     }
  273.    
  274.    
  275.    
  276.     // IS ALIVE
  277.    
  278.     @Override
  279.     public void isAlive() throws CoreException {
  280.         SearchFilterSoggetto filter = new SearchFilterSoggetto();
  281.         filter.setNome("ISALIVE");
  282.         try{
  283.             this.soggettoPort.count(new SearchFilterSoggetto());
  284.         }catch(Exception e){
  285.             throw new CoreException(e.getMessage(),e);
  286.         }
  287.     }
  288.    
  289.    
  290.    
  291.     // PORTE DOMINIO
  292.    
  293.     @Override
  294.     public PortaDominio getPortaDominio(String nomePdD)
  295.             throws DriverRegistroServiziException,
  296.             DriverRegistroServiziNotFound {
  297.         try{
  298.             return this.pddPort.get(new IdPortaDominio(nomePdD));
  299.         }catch(org.openspcoop2.core.registry.ws.client.portadominio.search.RegistryNotFoundException_Exception e){
  300.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  301.         }catch(Exception e){
  302.             throw new DriverRegistroServiziException(e.getMessage(),e);
  303.         }
  304.     }
  305.     @Override
  306.     public List<String> getAllIdPorteDominio(FiltroRicerca filtroRicerca)
  307.             throws DriverRegistroServiziException,
  308.             DriverRegistroServiziNotFound {
  309.         try{
  310.             SearchFilterPortaDominio filter = new SearchFilterPortaDominio();
  311.             if(filtroRicerca!=null){
  312.                 if(filtroRicerca.getTipo()!=null){
  313.                     // NOP
  314.                 }
  315.                 if(filtroRicerca.getNome()!=null){
  316.                     filter.setNome(filtroRicerca.getNome());
  317.                 }
  318.                 if(filtroRicerca.getMaxDate()!=null){
  319.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  320.                     cal.setTime(filtroRicerca.getMaxDate());
  321.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  322.                 }
  323.                 if(filtroRicerca.getMinDate()!=null){
  324.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  325.                     cal.setTime(filtroRicerca.getMinDate());
  326.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  327.                 }              
  328.             }
  329.             List<IdPortaDominio> ids = this.pddPort.findAllIds(filter);
  330.             if(ids==null || ids.size()<=0){
  331.                 throw new org.openspcoop2.core.registry.ws.client.portadominio.search.RegistryNotFoundException_Exception("La ricerca non ha trovato pdd");
  332.             }
  333.             List<String> idsOpenSPCoop = new ArrayList<>();
  334.             for (IdPortaDominio idPortaDominio : ids) {
  335.                 String idPortaDominioOpenSPCoop = idPortaDominio.getNome();
  336.                 idsOpenSPCoop.add(idPortaDominioOpenSPCoop);
  337.             }
  338.            
  339.             return idsOpenSPCoop;
  340.            
  341.         }catch(org.openspcoop2.core.registry.ws.client.portadominio.search.RegistryNotFoundException_Exception e){
  342.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  343.         }catch(Exception e){
  344.             throw new DriverRegistroServiziException(e.getMessage(),e);
  345.         }
  346.     }
  347.    
  348.    
  349.    
  350.     // GRUPPI

  351.     @Override
  352.     public Gruppo getGruppo(
  353.             IDGruppo idGruppo) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  354.         try{
  355.             return this.gruppoPort.get(new IdGruppo(idGruppo));
  356.         }catch(org.openspcoop2.core.registry.ws.client.gruppo.search.RegistryNotFoundException_Exception e){
  357.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  358.         }catch(Exception e){
  359.             throw new DriverRegistroServiziException(e.getMessage(),e);
  360.         }
  361.     }


  362.     @Override
  363.     public List<IDGruppo> getAllIdGruppi(
  364.             FiltroRicercaGruppi filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  365.         try{
  366.             SearchFilterGruppo filter = new SearchFilterGruppo();
  367.             if(filtroRicerca!=null){
  368.                 if(filtroRicerca.getNome()!=null){
  369.                     filter.setNome(filtroRicerca.getNome());
  370.                 }
  371.                 if(filtroRicerca.getServiceBinding()!=null){
  372.                     filter.setServiceBinding(filtroRicerca.getServiceBinding());
  373.                 }
  374.                 if(filtroRicerca.getMaxDate()!=null){
  375.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  376.                     cal.setTime(filtroRicerca.getMaxDate());
  377.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  378.                 }
  379.                 if(filtroRicerca.getMinDate()!=null){
  380.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  381.                     cal.setTime(filtroRicerca.getMinDate());
  382.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  383.                 }              
  384.             }
  385.             List<IdGruppo> ids = this.gruppoPort.findAllIds(filter);
  386.             if(ids==null || ids.size()<=0){
  387.                 throw new org.openspcoop2.core.registry.ws.client.gruppo.search.RegistryNotFoundException_Exception("La ricerca non ha trovato gruppi");
  388.             }
  389.             List<IDGruppo> idsOpenSPCoop = new ArrayList<IDGruppo>();
  390.             for (IdGruppo idGruppo : ids) {
  391.                 String idGruppoOpenSPCoop = idGruppo.getNome();
  392.                 idsOpenSPCoop.add(new IDGruppo(idGruppoOpenSPCoop));
  393.             }
  394.            
  395.             return idsOpenSPCoop;
  396.            
  397.         }catch(org.openspcoop2.core.registry.ws.client.gruppo.search.RegistryNotFoundException_Exception e){
  398.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  399.         }catch(Exception e){
  400.             throw new DriverRegistroServiziException(e.getMessage(),e);
  401.         }
  402.     }
  403.    
  404.    
  405.    
  406.    
  407.     // RUOLI

  408.     @Override
  409.     public Ruolo getRuolo(
  410.             IDRuolo idRuolo) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  411.         try{
  412.             return this.ruoloPort.get(new IdRuolo(idRuolo));
  413.         }catch(org.openspcoop2.core.registry.ws.client.ruolo.search.RegistryNotFoundException_Exception e){
  414.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  415.         }catch(Exception e){
  416.             throw new DriverRegistroServiziException(e.getMessage(),e);
  417.         }
  418.     }


  419.     @Override
  420.     public List<IDRuolo> getAllIdRuoli(
  421.             FiltroRicercaRuoli filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  422.         try{
  423.             SearchFilterRuolo filter = new SearchFilterRuolo();
  424.             if(filtroRicerca!=null){
  425.                 if(filtroRicerca.getNome()!=null){
  426.                     filter.setNome(filtroRicerca.getNome());
  427.                 }
  428.                 if(filtroRicerca.getTipologia()!=null){
  429.                     filter.setTipologia(filtroRicerca.getTipologia());
  430.                 }
  431.                 if(filtroRicerca.getContesto()!=null){
  432.                     filter.setContestoUtilizzo(filtroRicerca.getContesto());
  433.                 }
  434.                 if(filtroRicerca.getMaxDate()!=null){
  435.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  436.                     cal.setTime(filtroRicerca.getMaxDate());
  437.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  438.                 }
  439.                 if(filtroRicerca.getMinDate()!=null){
  440.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  441.                     cal.setTime(filtroRicerca.getMinDate());
  442.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  443.                 }              
  444.             }
  445.             List<IdRuolo> ids = this.ruoloPort.findAllIds(filter);
  446.             if(ids==null || ids.size()<=0){
  447.                 throw new org.openspcoop2.core.registry.ws.client.ruolo.search.RegistryNotFoundException_Exception("La ricerca non ha trovato ruoli");
  448.             }
  449.             List<IDRuolo> idsOpenSPCoop = new ArrayList<IDRuolo>();
  450.             for (IdRuolo idRuolo : ids) {
  451.                 String idRuoloOpenSPCoop = idRuolo.getNome();
  452.                 idsOpenSPCoop.add(new IDRuolo(idRuoloOpenSPCoop));
  453.             }
  454.            
  455.             return idsOpenSPCoop;
  456.            
  457.         }catch(org.openspcoop2.core.registry.ws.client.ruolo.search.RegistryNotFoundException_Exception e){
  458.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  459.         }catch(Exception e){
  460.             throw new DriverRegistroServiziException(e.getMessage(),e);
  461.         }
  462.     }
  463.    
  464.    
  465.    
  466.    
  467.     // SCOPE

  468.     @Override
  469.     public Scope getScope(
  470.             IDScope idScope) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  471.         try{
  472.             return this.scopePort.get(new IdScope(idScope));
  473.         }catch(org.openspcoop2.core.registry.ws.client.scope.search.RegistryNotFoundException_Exception e){
  474.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  475.         }catch(Exception e){
  476.             throw new DriverRegistroServiziException(e.getMessage(),e);
  477.         }
  478.     }


  479.     @Override
  480.     public List<IDScope> getAllIdScope(
  481.             FiltroRicercaScope filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  482.         try{
  483.             SearchFilterScope filter = new SearchFilterScope();
  484.             if(filtroRicerca!=null){
  485.                 if(filtroRicerca.getNome()!=null){
  486.                     filter.setNome(filtroRicerca.getNome());
  487.                 }
  488.                 if(filtroRicerca.getTipologia()!=null){
  489.                     filter.setTipologia(filtroRicerca.getTipologia());
  490.                 }
  491.                 if(filtroRicerca.getContesto()!=null){
  492.                     filter.setContestoUtilizzo(filtroRicerca.getContesto());
  493.                 }
  494.                 if(filtroRicerca.getMaxDate()!=null){
  495.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  496.                     cal.setTime(filtroRicerca.getMaxDate());
  497.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  498.                 }
  499.                 if(filtroRicerca.getMinDate()!=null){
  500.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  501.                     cal.setTime(filtroRicerca.getMinDate());
  502.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  503.                 }              
  504.             }
  505.             List<IdScope> ids = this.scopePort.findAllIds(filter);
  506.             if(ids==null || ids.size()<=0){
  507.                 throw new org.openspcoop2.core.registry.ws.client.scope.search.RegistryNotFoundException_Exception("La ricerca non ha trovato scope");
  508.             }
  509.             List<IDScope> idsOpenSPCoop = new ArrayList<IDScope>();
  510.             for (IdScope idScope : ids) {
  511.                 String idScopeOpenSPCoop = idScope.getNome();
  512.                 idsOpenSPCoop.add(new IDScope(idScopeOpenSPCoop));
  513.             }
  514.            
  515.             return idsOpenSPCoop;
  516.            
  517.         }catch(org.openspcoop2.core.registry.ws.client.scope.search.RegistryNotFoundException_Exception e){
  518.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  519.         }catch(Exception e){
  520.             throw new DriverRegistroServiziException(e.getMessage(),e);
  521.         }
  522.     }
  523.        
  524.    
  525.    
  526.    
  527.     // SOGGETTI
  528.    
  529.     @Override
  530.     public Soggetto getSoggetto(IDSoggetto idSoggetto)
  531.             throws DriverRegistroServiziException,
  532.             DriverRegistroServiziNotFound {
  533.         try{
  534.             return this.soggettoPort.get(new IdSoggetto(idSoggetto));
  535.         }catch(org.openspcoop2.core.registry.ws.client.soggetto.search.RegistryNotFoundException_Exception e){
  536.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  537.         }catch(Exception e){
  538.             throw new DriverRegistroServiziException(e.getMessage(),e);
  539.         }
  540.     }
  541.    
  542.     @Override
  543.     public Soggetto getSoggettoByCredenzialiBasic(
  544.             String user,String password,
  545.             CryptConfig config) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  546.         return this.getEngineSoggettoAutenticato(CredenzialeTipo.BASIC, user, password,
  547.                 null, null, null, false,
  548.                 null,
  549.                 config,
  550.                 false);
  551.     }
  552.    
  553.     @Override
  554.     public Soggetto getSoggettoByCredenzialiApiKey(
  555.             String user,String password, boolean appId,
  556.             CryptConfig config) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  557.         return this.getEngineSoggettoAutenticato(CredenzialeTipo.BASIC, user, password,
  558.                 null, null, null, false,
  559.                 null,
  560.                 config,
  561.                 appId);
  562.     }
  563.    
  564.     @Override
  565.     public Soggetto getSoggettoByCredenzialiSsl(
  566.             String subject, String issuer) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  567.         return this.getEngineSoggettoAutenticato(CredenzialeTipo.SSL, null, null,
  568.                 subject, issuer, null, false,
  569.                 null,
  570.                 null,
  571.                 false);
  572.     }
  573.    
  574.     @Override
  575.     public Soggetto getSoggettoByCredenzialiSsl(CertificateInfo certificate, boolean strictVerifier) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  576.         return this.getEngineSoggettoAutenticato(CredenzialeTipo.SSL, null, null,
  577.                 null, null, certificate, strictVerifier,
  578.                 null,
  579.                 null,
  580.                 false);
  581.     }
  582.    
  583.     @Override
  584.     public Soggetto getSoggettoByCredenzialiPrincipal(
  585.             String principal) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  586.         return this.getEngineSoggettoAutenticato(CredenzialeTipo.PRINCIPAL, null, null,
  587.                 null, null, null, false,
  588.                 principal,
  589.                 null,
  590.                 false);
  591.     }
  592.     private org.openspcoop2.core.registry.Soggetto getEngineSoggettoAutenticato(CredenzialeTipo tipoCredenziale, String user,String password,
  593.             String aSubject, String aIssuer, CertificateInfo aCertificate, boolean aStrictVerifier,
  594.             String principal,
  595.             CryptConfig config,
  596.             boolean appId) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  597.        
  598.         // conrollo consistenza
  599.         if (tipoCredenziale == null)
  600.             throw new DriverRegistroServiziException("[getSoggettoAutenticato] Parametro tipoCredenziale is null");

  601.         switch (tipoCredenziale) {
  602.         case BASIC:
  603.             if (user == null || "".equalsIgnoreCase(user))
  604.                 throw new DriverRegistroServiziException("[getSoggettoAutenticato] Parametro user is null (required for basic auth)");
  605.             if (password == null || "".equalsIgnoreCase(password))
  606.                 throw new DriverRegistroServiziException("[getSoggettoAutenticato] Parametro password is null (required for basic auth)");
  607.             break;
  608.         case APIKEY:
  609.             if (user == null || "".equalsIgnoreCase(user))
  610.                 throw new DriverRegistroServiziException("[getSoggettoAutenticato] Parametro user is null (required for apikey auth)");
  611.             if (password == null || "".equalsIgnoreCase(password))
  612.                 throw new DriverRegistroServiziException("[getSoggettoAutenticato] Parametro password is null (required for apikey auth)");
  613.             break;
  614.         case SSL:
  615.             if ( (aSubject == null || "".equalsIgnoreCase(aSubject)) && (aCertificate==null))
  616.                 throw new DriverRegistroServiziException("[getSoggettoAutenticato] Parametro subject/certificate is null (required for ssl auth)");
  617.             break;
  618.         case PRINCIPAL:
  619.             if (principal == null || "".equalsIgnoreCase(principal))
  620.                 throw new DriverRegistroServiziException("[getSoggettoAutenticato] Parametro principal is null (required for principal auth)");
  621.             break;
  622.         }

  623.         IDSoggetto idSoggetto = null;
  624.         try{
  625.             FiltroRicercaSoggetti filtroRicerca = new FiltroRicercaSoggetti();
  626.             CredenzialiSoggetto credenzialiSoggetto = new CredenzialiSoggetto();
  627.             credenzialiSoggetto.setTipo(tipoCredenziale);
  628.             switch (tipoCredenziale) {
  629.             case BASIC:
  630.                 credenzialiSoggetto.setUser(user);
  631.                 credenzialiSoggetto.setPassword(password);
  632.                 break;
  633.             case APIKEY:
  634.                 credenzialiSoggetto.setUser(user);
  635.                 credenzialiSoggetto.setPassword(password);
  636.                 credenzialiSoggetto.setAppId(appId);
  637.                 break;
  638.             case SSL:
  639.                 credenzialiSoggetto.setSubject(aSubject);
  640.                 credenzialiSoggetto.setIssuer(aIssuer);
  641.                 if(aCertificate!=null) {
  642.                     try {
  643.                         credenzialiSoggetto.setCertificate(aCertificate.getCertificate().getEncoded());
  644.                     }catch(Exception e) {
  645.                         throw new DriverRegistroServiziException(e.getMessage(),e);
  646.                     }
  647.                 }
  648.                 credenzialiSoggetto.setCertificateStrictVerification(aStrictVerifier);
  649.                 break;
  650.             case PRINCIPAL:
  651.                 credenzialiSoggetto.setUser(principal);
  652.                 break;
  653.             }
  654.             filtroRicerca.setCredenzialiSoggetto(credenzialiSoggetto, config);
  655.             List<IDSoggetto> l = this.getAllIdSoggetti(filtroRicerca);
  656.             if(l.size()>1){
  657.                 throw new DriverRegistroServiziException("Trovato più di un soggetto che possiede le credenziali '"+tipoCredenziale.toString()+"' fornite");
  658.             }
  659.             else if(l.size()==1){
  660.                 idSoggetto = l.get(0);
  661.             }
  662.         }catch(DriverRegistroServiziNotFound notFound){}
  663.        
  664.         if(idSoggetto==null){
  665.             throw new DriverRegistroServiziNotFound("Nessun soggetto trovato che possiede le credenziali '"+tipoCredenziale.toString()+"' fornite");
  666.         }
  667.         else{
  668.             return this.getSoggetto(idSoggetto);
  669.         }
  670.     }
  671.    
  672.     @Override
  673.     public List<IDSoggetto> getAllIdSoggetti(FiltroRicercaSoggetti filtroRicerca)
  674.             throws DriverRegistroServiziException,
  675.             DriverRegistroServiziNotFound {
  676.         try{
  677.             @SuppressWarnings("unused")
  678.             boolean testInChiaro = false;
  679.             @SuppressWarnings("unused")
  680.             ICrypt crypt = null;
  681.             if(filtroRicerca!=null && filtroRicerca.getCredenzialiSoggetto()!=null && filtroRicerca.getCredenzialiSoggetto().getPassword()!=null){
  682.                 CredenzialeTipo cTipo = filtroRicerca.getCredenzialiSoggetto().getTipo();
  683.                 if(CredenzialeTipo.BASIC.equals(cTipo)){
  684.                     CryptConfig config = filtroRicerca.getCryptConfig();
  685.                     if(config==null || config.isBackwardCompatibility()) {
  686.                         testInChiaro = true;
  687.                     }
  688.                     if(config!=null) {
  689.                         try {
  690.                             crypt = CryptFactory.getCrypt(this.log, config);
  691.                         }catch(Exception e) {
  692.                             throw new DriverRegistroServiziException(e.getMessage(),e);
  693.                         }
  694.                     }
  695.                 }
  696.                 else if(CredenzialeTipo.APIKEY.equals(cTipo)){
  697.                     CryptConfig config = filtroRicerca.getCryptConfig();
  698.                     if(config!=null) {
  699.                         try {
  700.                             crypt = CryptFactory.getCrypt(this.log, config);
  701.                         }catch(Exception e) {
  702.                             throw new DriverRegistroServiziException(e.getMessage(),e);
  703.                         }
  704.                     }
  705.                     else {
  706.                         testInChiaro = true;
  707.                     }
  708.                 }
  709.             }
  710.            
  711.             SearchFilterSoggetto filter = new SearchFilterSoggetto();
  712.             if(filtroRicerca!=null){
  713.                 if(filtroRicerca.getTipo()!=null){
  714.                     filter.setTipo(filtroRicerca.getTipo());
  715.                 }
  716.                 if(filtroRicerca.getNome()!=null){
  717.                     filter.setNome(filtroRicerca.getNome());
  718.                 }
  719.                 if(filtroRicerca.getNomePdd()!=null){
  720.                     filter.setPortaDominio(filtroRicerca.getNomePdd());
  721.                 }
  722.                 if(filtroRicerca.getMaxDate()!=null){
  723.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  724.                     cal.setTime(filtroRicerca.getMaxDate());
  725.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  726.                 }
  727.                 if(filtroRicerca.getMinDate()!=null){
  728.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  729.                     cal.setTime(filtroRicerca.getMinDate());
  730.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  731.                 }
  732.                 // Filtro By Ruolo
  733.                 if(filtroRicerca.getIdRuolo()!=null){
  734.                     throw new DriverRegistroServiziException("Not Implemented");
  735.                 }
  736.                 // Filtro By Credenziali
  737.                 if(filtroRicerca.getCredenzialiSoggetto()!=null){
  738.                     org.openspcoop2.core.registry.ws.client.soggetto.search.CredenzialiSoggetto credenziali = new
  739.                             org.openspcoop2.core.registry.ws.client.soggetto.search.CredenzialiSoggetto();
  740.                     if(filtroRicerca.getCredenzialiSoggetto().getTipo()!=null){
  741.                         credenziali.setTipo(filtroRicerca.getCredenzialiSoggetto().getTipo());
  742.                     }
  743.                     if(filtroRicerca.getCredenzialiSoggetto().getUser()!=null){
  744.                         credenziali.setUser(filtroRicerca.getCredenzialiSoggetto().getUser());
  745.                     }
  746.                     if(filtroRicerca.getCredenzialiSoggetto().getPassword()!=null){
  747.                         credenziali.setPassword(filtroRicerca.getCredenzialiSoggetto().getPassword());
  748.                     }
  749.                     if(filtroRicerca.getCredenzialiSoggetto().getSubject()!=null){
  750.                         credenziali.setSubject(filtroRicerca.getCredenzialiSoggetto().getSubject());
  751.                     }
  752.                     if(filtroRicerca.getCredenzialiSoggetto().getIssuer()!=null){
  753.                         credenziali.setSubject(filtroRicerca.getCredenzialiSoggetto().getIssuer());
  754.                     }
  755.                     if(filtroRicerca.getCredenzialiSoggetto().getCertificate()!=null){
  756.                         credenziali.setCertificate(filtroRicerca.getCredenzialiSoggetto().getCertificate());
  757.                         credenziali.setCertificateStrictVerification(filtroRicerca.getCredenzialiSoggetto().isCertificateStrictVerification());
  758.                     }
  759.                     if(filtroRicerca.getCredenzialiSoggetto().getCnSubject()!=null){
  760.                         credenziali.setCnSubject(filtroRicerca.getCredenzialiSoggetto().getCnSubject());
  761.                     }
  762.                     if(filtroRicerca.getCredenzialiSoggetto().getCnIssuer()!=null){
  763.                         credenziali.setCnIssuer(filtroRicerca.getCredenzialiSoggetto().getCnIssuer());
  764.                     }
  765.                     filter.setCredenziali(credenziali);
  766.                 }
  767.             }
  768.             List<IDSoggetto> idsOpenSPCoop = new ArrayList<IDSoggetto>();
  769.             if(filtroRicerca==null || filtroRicerca.getProtocolProperties()==null || filtroRicerca.getProtocolProperties().size()<=0){
  770.                 List<IdSoggetto> ids = this.soggettoPort.findAllIds(filter);
  771.                 if(ids==null || ids.size()<=0){
  772.                     throw new org.openspcoop2.core.registry.ws.client.soggetto.search.RegistryNotFoundException_Exception("La ricerca non ha trovato soggetti");
  773.                 }
  774.                 for (IdSoggetto idSoggetto : ids) {
  775.                     IDSoggetto idSoggettoOpenSPCoop = new IDSoggetto(idSoggetto.getTipo(), idSoggetto.getNome());
  776.                     idsOpenSPCoop.add(idSoggettoOpenSPCoop);
  777.                 }
  778.             }
  779.             else{
  780.                 List<Soggetto> ss = this.soggettoPort.findAll(filter);
  781.                 if(ss==null || ss.size()<=0){
  782.                     throw new org.openspcoop2.core.registry.ws.client.soggetto.search.RegistryNotFoundException_Exception("La ricerca non ha trovato soggetti");
  783.                 }
  784.                 for (Soggetto soggetto : ss) {
  785.                     // ProtocolProperties
  786.                     if(ProtocolPropertiesUtilities.isMatch(soggetto, filtroRicerca.getProtocolProperties())==false){
  787.                         continue;
  788.                     }
  789.                     IDSoggetto idSoggettoOpenSPCoop = new IDSoggetto(soggetto.getTipo(), soggetto.getNome());
  790.                     idsOpenSPCoop.add(idSoggettoOpenSPCoop);
  791.                 }
  792.                 if(idsOpenSPCoop==null || idsOpenSPCoop.size()<=0){
  793.                     throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  794.                 }
  795.             }
  796.            
  797.             return idsOpenSPCoop;
  798.            
  799.         }catch(org.openspcoop2.core.registry.ws.client.soggetto.search.RegistryNotFoundException_Exception e){
  800.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  801.         }catch(Exception e){
  802.             throw new DriverRegistroServiziException(e.getMessage(),e);
  803.         }
  804.     }
  805.    
  806.    
  807.    
  808.     // ACCORDI COOPERAZIONE
  809.    
  810.     @Override
  811.     public AccordoCooperazione getAccordoCooperazione(
  812.             IDAccordoCooperazione idAccordo)
  813.             throws DriverRegistroServiziException,
  814.             DriverRegistroServiziNotFound {
  815.         try{
  816.             return this.accordoCooperazionePort.get(new IdAccordoCooperazione(idAccordo));
  817.         }catch(org.openspcoop2.core.registry.ws.client.accordocooperazione.search.RegistryNotFoundException_Exception e){
  818.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  819.         }catch(Exception e){
  820.             throw new DriverRegistroServiziException(e.getMessage(),e);
  821.         }
  822.     }
  823.     @Override
  824.     public List<IDAccordoCooperazione> getAllIdAccordiCooperazione(
  825.             FiltroRicercaAccordi filtroRicerca)
  826.             throws DriverRegistroServiziException,
  827.             DriverRegistroServiziNotFound {
  828.         try{
  829.             SearchFilterAccordoCooperazione filter = new SearchFilterAccordoCooperazione();
  830.             if(filtroRicerca!=null){
  831.                 if(filtroRicerca.getVersione()!=null){
  832.                     filter.setVersione(Long.valueOf(filtroRicerca.getVersione()));
  833.                 }
  834.                 if(filtroRicerca.getTipoSoggettoReferente()!=null || filtroRicerca.getNomeSoggettoReferente()!=null){
  835.                     filter.setSoggettoReferente(new org.openspcoop2.core.registry.ws.client.accordocooperazione.search.IdSoggetto());
  836.                     if(filtroRicerca.getTipoSoggettoReferente()!=null){
  837.                         filter.getSoggettoReferente().setTipo(filtroRicerca.getTipoSoggettoReferente());
  838.                     }
  839.                     if(filtroRicerca.getNomeSoggettoReferente()!=null){
  840.                         filter.getSoggettoReferente().setNome(filtroRicerca.getNomeSoggettoReferente());
  841.                     }
  842.                 }
  843.                 if(filtroRicerca.getNomeAccordo()!=null){
  844.                     filter.setNome(filtroRicerca.getNomeAccordo());
  845.                 }
  846.                 if(filtroRicerca.getMaxDate()!=null){
  847.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  848.                     cal.setTime(filtroRicerca.getMaxDate());
  849.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  850.                 }
  851.                 if(filtroRicerca.getMinDate()!=null){
  852.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  853.                     cal.setTime(filtroRicerca.getMinDate());
  854.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  855.                 }              
  856.             }
  857.             List<IDAccordoCooperazione> idsOpenSPCoop = new ArrayList<IDAccordoCooperazione>();
  858.             if(filtroRicerca==null || filtroRicerca.getProtocolPropertiesAccordo()==null || filtroRicerca.getProtocolPropertiesAccordo().size()<=0){
  859.                 List<IdAccordoCooperazione> ids = this.accordoCooperazionePort.findAllIds(filter);
  860.                 if(ids==null || ids.size()<=0){
  861.                     throw new org.openspcoop2.core.registry.ws.client.accordocooperazione.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  862.                 }
  863.                 for (IdAccordoCooperazione idAccordoCooperazione : ids) {
  864.                     IDAccordoCooperazione idAccordoCooperazioneOpenSPCoop =
  865.                             IDAccordoCooperazioneFactory.getInstance().getIDAccordoFromValues(idAccordoCooperazione.getNome(),
  866.                                     new IDSoggetto(idAccordoCooperazione.getSoggettoReferente().getTipo(), idAccordoCooperazione.getSoggettoReferente().getNome()),
  867.                                     idAccordoCooperazione.getVersione());
  868.                     idsOpenSPCoop.add(idAccordoCooperazioneOpenSPCoop);
  869.                 }
  870.             }
  871.             else{
  872.                 List<AccordoCooperazione> accordi = this.accordoCooperazionePort.findAll(filter);
  873.                 if(accordi==null || accordi.size()<=0){
  874.                     throw new org.openspcoop2.core.registry.ws.client.accordocooperazione.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  875.                 }
  876.                 for (AccordoCooperazione accordoCooperazione : accordi) {
  877.                     // ProtocolProperties
  878.                     if(ProtocolPropertiesUtilities.isMatch(accordoCooperazione, filtroRicerca.getProtocolPropertiesAccordo())==false){
  879.                         continue;
  880.                     }
  881.                     IDAccordoCooperazione idAccordoCooperazioneOpenSPCoop =
  882.                             IDAccordoCooperazioneFactory.getInstance().getIDAccordoFromValues(accordoCooperazione.getNome(),
  883.                                     new IDSoggetto(accordoCooperazione.getSoggettoReferente().getTipo(), accordoCooperazione.getSoggettoReferente().getNome()),
  884.                                     accordoCooperazione.getVersione());
  885.                     idsOpenSPCoop.add(idAccordoCooperazioneOpenSPCoop);
  886.                 }
  887.                 if(idsOpenSPCoop==null || idsOpenSPCoop.size()<=0){
  888.                     throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  889.                 }
  890.             }
  891.            
  892.             return idsOpenSPCoop;
  893.            
  894.         }catch(org.openspcoop2.core.registry.ws.client.accordocooperazione.search.RegistryNotFoundException_Exception e){
  895.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  896.         }catch(Exception e){
  897.             throw new DriverRegistroServiziException(e.getMessage(),e);
  898.         }
  899.     }
  900.    
  901.    
  902.    
  903.     // ACCORDI SERVIZIO PARTE COMUNE
  904.    
  905.     @Override
  906.     public AccordoServizioParteComune getAccordoServizioParteComune(
  907.             IDAccordo idAccordo) throws DriverRegistroServiziException,
  908.             DriverRegistroServiziNotFound {
  909.         try{
  910.             return this.accordoServizioParteComunePort.get(new IdAccordoServizioParteComune(idAccordo));
  911.         }catch(org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.RegistryNotFoundException_Exception e){
  912.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  913.         }catch(Exception e){
  914.             throw new DriverRegistroServiziException(e.getMessage(),e);
  915.         }
  916.     }
  917.     @Override
  918.     public List<IDAccordo> getAllIdAccordiServizioParteComune(
  919.             FiltroRicercaAccordi filtroRicerca)
  920.             throws DriverRegistroServiziException,
  921.             DriverRegistroServiziNotFound {
  922.         try{
  923.             SearchFilterAccordoServizioParteComune filter = new SearchFilterAccordoServizioParteComune();
  924.             if(filtroRicerca!=null){
  925.                 if(filtroRicerca.getVersione()!=null){
  926.                     filter.setVersione(Long.valueOf(filtroRicerca.getVersione()));
  927.                 }
  928.                 if(filtroRicerca.getTipoSoggettoReferente()!=null || filtroRicerca.getNomeSoggettoReferente()!=null){
  929.                     filter.setSoggettoReferente(new org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.IdSoggetto());
  930.                     if(filtroRicerca.getTipoSoggettoReferente()!=null){
  931.                         filter.getSoggettoReferente().setTipo(filtroRicerca.getTipoSoggettoReferente());
  932.                     }
  933.                     if(filtroRicerca.getNomeSoggettoReferente()!=null){
  934.                         filter.getSoggettoReferente().setNome(filtroRicerca.getNomeSoggettoReferente());
  935.                     }
  936.                 }
  937.                 if(filtroRicerca.getNomeAccordo()!=null){
  938.                     filter.setNome(filtroRicerca.getNomeAccordo());
  939.                 }
  940.                 if(filtroRicerca.getMaxDate()!=null){
  941.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  942.                     cal.setTime(filtroRicerca.getMaxDate());
  943.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  944.                 }
  945.                 if(filtroRicerca.getMinDate()!=null){
  946.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  947.                     cal.setTime(filtroRicerca.getMinDate());
  948.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  949.                 }          
  950.                 if(filtroRicerca.getIdAccordoCooperazione()!=null){
  951.                     // NOP
  952.                 }
  953.                 if(filtroRicerca.getServiceBinding()!=null){
  954.                     filter.setServiceBinding(filtroRicerca.getServiceBinding());
  955.                 }
  956.             }
  957.             List<IDAccordo> idsOpenSPCoop = new ArrayList<IDAccordo>();
  958.             if(filtroRicerca==null || filtroRicerca.getProtocolPropertiesAccordo()==null || filtroRicerca.getProtocolPropertiesAccordo().size()<=0){
  959.                 List<IdAccordoServizioParteComune> ids = this.accordoServizioParteComunePort.findAllIds(filter);
  960.                 if(ids==null || ids.size()<=0){
  961.                     throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  962.                 }
  963.                 for (IdAccordoServizioParteComune idAccordoServizioParteComune : ids) {
  964.                     IDSoggetto idSoggetto = null;
  965.                     if(idAccordoServizioParteComune.getSoggettoReferente()!=null){
  966.                         idSoggetto = new IDSoggetto(idAccordoServizioParteComune.getSoggettoReferente().getTipo(), idAccordoServizioParteComune.getSoggettoReferente().getNome());
  967.                     }
  968.                     IDAccordo idAccordoServizioParteComuneOpenSPCoop =
  969.                             IDAccordoFactory.getInstance().getIDAccordoFromValues(idAccordoServizioParteComune.getNome(), idSoggetto, idAccordoServizioParteComune.getVersione());
  970.                     idsOpenSPCoop.add(idAccordoServizioParteComuneOpenSPCoop);
  971.                 }
  972.             }
  973.             else{
  974.                 List<AccordoServizioParteComune> accordi = this.accordoServizioParteComunePort.findAll(filter);
  975.                 if(accordi==null || accordi.size()<=0){
  976.                     throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  977.                 }
  978.                 for (AccordoServizioParteComune accordoServizioParteComune : accordi) {
  979.                     // ProtocolProperties
  980.                     if(ProtocolPropertiesUtilities.isMatch(accordoServizioParteComune, filtroRicerca.getProtocolPropertiesAccordo())==false){
  981.                         continue;
  982.                     }
  983.                     IDSoggetto idSoggetto = null;
  984.                     if(accordoServizioParteComune.getSoggettoReferente()!=null){
  985.                         idSoggetto = new IDSoggetto(accordoServizioParteComune.getSoggettoReferente().getTipo(), accordoServizioParteComune.getSoggettoReferente().getNome());
  986.                     }
  987.                     IDAccordo idAccordoServizioParteComuneOpenSPCoop =
  988.                             IDAccordoFactory.getInstance().getIDAccordoFromValues(accordoServizioParteComune.getNome(), idSoggetto, accordoServizioParteComune.getVersione());
  989.                     idsOpenSPCoop.add(idAccordoServizioParteComuneOpenSPCoop);
  990.                 }
  991.                 if(idsOpenSPCoop==null || idsOpenSPCoop.size()<=0){
  992.                     throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  993.                 }
  994.             }
  995.            
  996.             return idsOpenSPCoop;
  997.            
  998.         }catch(org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.RegistryNotFoundException_Exception e){
  999.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  1000.         }catch(Exception e){
  1001.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1002.         }
  1003.     }
  1004.    
  1005.    
  1006.     @Override
  1007.     public List<IDPortType> getAllIdPortType(FiltroRicercaPortTypes filtroRicerca) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1008.        
  1009.         List<IDPortType> list = new ArrayList<IDPortType>();
  1010.         _fillAllIdAccordiServizioParteComuneEngine("getAllIdPortType", filtroRicerca, filtroRicerca, null, null, null, list);
  1011.         return list;
  1012.        
  1013.     }
  1014.    
  1015.     @Override
  1016.     public List<IDPortTypeAzione> getAllIdAzionePortType(FiltroRicercaOperations filtroRicerca) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1017.    
  1018.         List<IDPortTypeAzione> list = new ArrayList<IDPortTypeAzione>();
  1019.         _fillAllIdAccordiServizioParteComuneEngine("getAllIdAzionePortType", filtroRicerca, null, filtroRicerca, null, null, list);
  1020.         return list;
  1021.        
  1022.     }
  1023.    
  1024.     @Override
  1025.     public List<IDAccordoAzione> getAllIdAzioneAccordo(FiltroRicercaAzioni filtroRicerca) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1026.        
  1027.         List<IDAccordoAzione> list = new ArrayList<IDAccordoAzione>();
  1028.         _fillAllIdAccordiServizioParteComuneEngine("getAllIdAzioneAccordo", filtroRicerca, null, null, filtroRicerca, null, list);
  1029.         return list;
  1030.        
  1031.     }
  1032.    
  1033.     @Override
  1034.     public List<IDResource> getAllIdResource(FiltroRicercaResources filtroRicerca) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1035.        
  1036.         List<IDResource> list = new ArrayList<IDResource>();
  1037.         _fillAllIdAccordiServizioParteComuneEngine("getAllIdResource", filtroRicerca, null, null, null, filtroRicerca, list);
  1038.         return list;
  1039.        
  1040.     }
  1041.    
  1042.     @SuppressWarnings("unchecked")
  1043.     public <T> void _fillAllIdAccordiServizioParteComuneEngine(String nomeMetodo,
  1044.             FiltroRicercaAccordi filtroRicercaBase,
  1045.             FiltroRicercaPortTypes filtroPT, FiltroRicercaOperations filtroOP, FiltroRicercaAzioni filtroAZ,
  1046.             FiltroRicercaResources filtroResource,
  1047.             List<T> listReturn) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1048.        
  1049.         try{
  1050.             SearchFilterAccordoServizioParteComune filter = new SearchFilterAccordoServizioParteComune();
  1051.             if(filtroRicercaBase!=null){
  1052.                 if(filtroRicercaBase.getVersione()!=null){
  1053.                     filter.setVersione(Long.valueOf(filtroRicercaBase.getVersione()));
  1054.                 }
  1055.                 if(filtroRicercaBase.getTipoSoggettoReferente()!=null || filtroRicercaBase.getNomeSoggettoReferente()!=null){
  1056.                     filter.setSoggettoReferente(new org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.IdSoggetto());
  1057.                     if(filtroRicercaBase.getTipoSoggettoReferente()!=null){
  1058.                         filter.getSoggettoReferente().setTipo(filtroRicercaBase.getTipoSoggettoReferente());
  1059.                     }
  1060.                     if(filtroRicercaBase.getNomeSoggettoReferente()!=null){
  1061.                         filter.getSoggettoReferente().setNome(filtroRicercaBase.getNomeSoggettoReferente());
  1062.                     }
  1063.                 }
  1064.                 if(filtroRicercaBase.getNomeAccordo()!=null){
  1065.                     filter.setNome(filtroRicercaBase.getNomeAccordo());
  1066.                 }
  1067.                 if(filtroRicercaBase.getMaxDate()!=null){
  1068.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  1069.                     cal.setTime(filtroRicercaBase.getMaxDate());
  1070.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  1071.                 }
  1072.                 if(filtroRicercaBase.getMinDate()!=null){
  1073.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  1074.                     cal.setTime(filtroRicercaBase.getMinDate());
  1075.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  1076.                 }          
  1077.                 if(filtroRicercaBase.getIdAccordoCooperazione()!=null){
  1078.                     // NOP
  1079.                 }
  1080.                 if(filtroRicercaBase.getServiceBinding()!=null){
  1081.                     filter.setServiceBinding(filtroRicercaBase.getServiceBinding());
  1082.                 }
  1083.             }
  1084.            
  1085.             List<AccordoServizioParteComune> accordi = this.accordoServizioParteComunePort.findAll(filter);
  1086.             if(accordi==null || accordi.size()<=0){
  1087.                 throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  1088.             }
  1089.             for (AccordoServizioParteComune as : accordi) {
  1090.                
  1091.                 // ProtocolProperties
  1092.                 if(ProtocolPropertiesUtilities.isMatch(as, filtroRicercaBase.getProtocolPropertiesAccordo())==false){
  1093.                     continue;
  1094.                 }
  1095.                
  1096.                 IDSoggetto idSoggetto = null;
  1097.                 if(as.getSoggettoReferente()!=null){
  1098.                     idSoggetto = new IDSoggetto(as.getSoggettoReferente().getTipo(), as.getSoggettoReferente().getNome());
  1099.                 }
  1100.                 IDAccordo idAccordo =
  1101.                         IDAccordoFactory.getInstance().getIDAccordoFromValues(as.getNome(), idSoggetto, as.getVersione());
  1102.                
  1103.                
  1104.                 if(filtroPT!=null){
  1105.                     for (PortType pt : as.getPortTypeList()) {
  1106.                         // Nome PT
  1107.                         if(filtroPT.getNomePortType()!=null){
  1108.                             if(pt.getNome().equals(filtroPT.getNomePortType()) == false){
  1109.                                 continue;
  1110.                             }
  1111.                         }
  1112.                         // ProtocolProperties PT
  1113.                         if(ProtocolPropertiesUtilities.isMatch(pt, filtroPT.getProtocolPropertiesPortType())==false){
  1114.                             continue;
  1115.                         }
  1116.                        
  1117.                         IDPortType idPT = new IDPortType();
  1118.                         idPT.setIdAccordo(idAccordo);
  1119.                         idPT.setNome(pt.getNome());
  1120.                         listReturn.add((T)idPT);
  1121.                     }
  1122.                 }
  1123.                 else if(filtroOP!=null){
  1124.                     for (PortType pt : as.getPortTypeList()) {
  1125.                        
  1126.                         // Nome PT
  1127.                         if(filtroOP.getNomePortType()!=null){
  1128.                             if(pt.getNome().equals(filtroOP.getNomePortType()) == false){
  1129.                                 continue;
  1130.                             }
  1131.                         }
  1132.                         // ProtocolProperties PT
  1133.                         if(ProtocolPropertiesUtilities.isMatch(pt, filtroOP.getProtocolPropertiesPortType())==false){
  1134.                             continue;
  1135.                         }
  1136.                        
  1137.                         for (Operation op : pt.getAzioneList()) {
  1138.                            
  1139.                             // Nome OP
  1140.                             if(filtroOP.getNomeAzione()!=null){
  1141.                                 if(op.getNome().equals(filtroOP.getNomeAzione()) == false){
  1142.                                     continue;
  1143.                                 }
  1144.                             }
  1145.                             // ProtocolProperties OP
  1146.                             if(ProtocolPropertiesUtilities.isMatch(pt, filtroOP.getProtocolPropertiesAzione())==false){
  1147.                                 continue;
  1148.                             }
  1149.                        
  1150.                             IDPortTypeAzione idAzione = new IDPortTypeAzione();
  1151.                             IDPortType idPT = new IDPortType();
  1152.                             idPT.setIdAccordo(idAccordo);
  1153.                             idPT.setNome(pt.getNome());
  1154.                             idAzione.setIdPortType(idPT);
  1155.                             idAzione.setNome(op.getNome());
  1156.                             listReturn.add((T)idAzione);
  1157.                         }
  1158.                     }
  1159.                 }
  1160.                 else if(filtroAZ!=null){
  1161.                     for (Azione az : as.getAzioneList()) {
  1162.                        
  1163.                         // Nome AZ
  1164.                         if(filtroAZ.getNomeAzione()!=null){
  1165.                             if(az.getNome().equals(filtroAZ.getNomeAzione()) == false){
  1166.                                 continue;
  1167.                             }
  1168.                         }
  1169.                         // ProtocolProperties PT
  1170.                         if(ProtocolPropertiesUtilities.isMatch(az, filtroAZ.getProtocolPropertiesAzione())==false){
  1171.                             continue;
  1172.                         }
  1173.                        
  1174.                         IDAccordoAzione idAzione = new IDAccordoAzione();
  1175.                         idAzione.setIdAccordo(idAccordo);
  1176.                         idAzione.setNome(az.getNome());
  1177.                         listReturn.add((T)idAzione);
  1178.                     }
  1179.                 }
  1180.                 else if(filtroResource!=null){
  1181.                     for (Resource resource : as.getResourceList()) {
  1182.                         // Nome Risorsa
  1183.                         if(filtroResource.getResourceName()!=null){
  1184.                             if(resource.getNome().equals(filtroResource.getResourceName()) == false){
  1185.                                 continue;
  1186.                             }
  1187.                         }
  1188.                         // ProtocolProperties PT
  1189.                         if(ProtocolPropertiesUtilities.isMatch(resource, filtroResource.getProtocolPropertiesResources())==false){
  1190.                             continue;
  1191.                         }
  1192.                        
  1193.                         IDResource idResource = new IDResource();
  1194.                         idResource.setIdAccordo(idAccordo);
  1195.                         idResource.setNome(resource.getNome());
  1196.                         listReturn.add((T)idResource);
  1197.                     }
  1198.                 }
  1199.                
  1200.             }
  1201.            
  1202.             if(listReturn==null || listReturn.size()<=0){
  1203.                 throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  1204.             }
  1205.            
  1206.         }catch(org.openspcoop2.core.registry.ws.client.accordoserviziopartecomune.search.RegistryNotFoundException_Exception e){
  1207.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  1208.         }catch(Exception e){
  1209.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1210.         }
  1211.        
  1212.     }
  1213.    
  1214.     @Override
  1215.     public Documento getAllegato(IDAccordo idAccordo, String nome) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1216.         throw new DriverRegistroServiziException("Not Implemented");
  1217.     }
  1218.     @Override
  1219.     public Documento getSpecificaSemiformale(IDAccordo idAccordo, TipiDocumentoSemiformale tipo, String nome)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1220.         throw new DriverRegistroServiziException("Not Implemented");
  1221.     }
  1222.    
  1223.    
  1224.    
  1225.    
  1226.     // ACCORDI SERVIZIO PARTE SPECIFICA
  1227.    
  1228.     @Override
  1229.     public AccordoServizioParteSpecifica getAccordoServizioParteSpecifica(
  1230.             IDServizio idServizio) throws DriverRegistroServiziException,
  1231.             DriverRegistroServiziNotFound {
  1232.         try{
  1233.             SearchFilterAccordoServizioParteSpecifica filter = new SearchFilterAccordoServizioParteSpecifica();
  1234.             filter.setTipo(idServizio.getTipo());
  1235.             filter.setNome(idServizio.getNome());
  1236.             filter.setVersione(Long.valueOf(idServizio.getVersione()));
  1237.             if(idServizio.getSoggettoErogatore()!=null){
  1238.                 filter.setTipoSoggettoErogatore(idServizio.getSoggettoErogatore().getTipo());
  1239.                 filter.setNomeSoggettoErogatore(idServizio.getSoggettoErogatore().getNome());
  1240.             }
  1241.             return this.accordoServizioParteSpecificaPort.find(filter);
  1242.         }catch(org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.RegistryNotFoundException_Exception e){
  1243.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  1244.         }catch(Exception e){
  1245.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1246.         }
  1247.     }
  1248.     @Override
  1249.     public AccordoServizioParteSpecifica getAccordoServizioParteSpecifica_ServizioCorrelato(
  1250.             IDSoggetto idSoggetto, IDAccordo idAccordoServizioParteComune)
  1251.             throws DriverRegistroServiziException,
  1252.             DriverRegistroServiziNotFound {
  1253.         try{
  1254.             SearchFilterAccordoServizioParteSpecifica filter = new SearchFilterAccordoServizioParteSpecifica();
  1255.             filter.setAccordoServizioParteComune(IDAccordoFactory.getInstance().getUriFromIDAccordo(idAccordoServizioParteComune));
  1256.             if(idSoggetto!=null){
  1257.                 filter.setTipoSoggettoErogatore(idSoggetto.getTipo());
  1258.                 filter.setNomeSoggettoErogatore(idSoggetto.getNome());
  1259.                 filter.setTipologiaServizio(TipologiaServizio.CORRELATO);
  1260.             }
  1261.             return this.accordoServizioParteSpecificaPort.find(filter);
  1262.         }catch(org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.RegistryNotFoundException_Exception e){
  1263.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  1264.         }catch(Exception e){
  1265.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1266.         }
  1267.     }
  1268.    
  1269.     @Override
  1270.     public List<IDServizio> getAllIdServizi(FiltroRicercaServizi filtroRicerca)
  1271.             throws DriverRegistroServiziException,
  1272.             DriverRegistroServiziNotFound {
  1273.         try{
  1274.             SearchFilterAccordoServizioParteSpecifica filter = new SearchFilterAccordoServizioParteSpecifica();
  1275.             if(filtroRicerca!=null){
  1276.                 if(filtroRicerca.getIdAccordoServizioParteComune()!=null){
  1277.                     filter.setAccordoServizioParteComune(IDAccordoFactory.getInstance().getUriFromIDAccordo(filtroRicerca.getIdAccordoServizioParteComune()));
  1278.                 }
  1279.                 if(filtroRicerca.getNome()!=null || filtroRicerca.getTipo()!=null || filtroRicerca.getVersione()!=null ||
  1280.                         filtroRicerca.getPortType()!=null ||
  1281.                         filtroRicerca.getNomeSoggettoErogatore()!=null ||
  1282.                         filtroRicerca.getTipoSoggettoErogatore()!=null ||
  1283.                         filtroRicerca.getTipologia()!=null){
  1284.                     filter.setTipo(filtroRicerca.getTipo());
  1285.                     filter.setNome(filtroRicerca.getNome());
  1286.                     filter.setVersione(Long.valueOf(filtroRicerca.getVersione()));
  1287.                     filter.setPortType(filtroRicerca.getPortType());
  1288.                     filter.setTipoSoggettoErogatore(filtroRicerca.getTipoSoggettoErogatore());
  1289.                     filter.setNomeSoggettoErogatore(filtroRicerca.getNomeSoggettoErogatore());
  1290.                     if(filtroRicerca.getTipologia()!=null){
  1291.                         filter.setTipologiaServizio(TipologiaServizio.toEnumConstant(filtroRicerca.getTipologia().getValue()));
  1292.                     }
  1293.                 }
  1294.                 if(filtroRicerca.getMaxDate()!=null){
  1295.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  1296.                     cal.setTime(filtroRicerca.getMaxDate());
  1297.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  1298.                 }
  1299.                 if(filtroRicerca.getMinDate()!=null){
  1300.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  1301.                     cal.setTime(filtroRicerca.getMinDate());
  1302.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  1303.                 }
  1304.                 // Filtro By Tipo e/o Nome Soggetto Fruitore
  1305.                 if(filtroRicerca.getTipoSoggettoFruitore()!=null || filtroRicerca.getNomeSoggettoFruitore()!=null){
  1306.                     throw new DriverRegistroServiziException("Not Implemented");
  1307.                 }
  1308.             }
  1309.             List<IDServizio> idsOpenSPCoop = new ArrayList<IDServizio>();
  1310.             if(filtroRicerca==null || filtroRicerca.getProtocolProperties()==null || filtroRicerca.getProtocolProperties().size()<=0){
  1311.                 List<IdAccordoServizioParteSpecifica> ids = this.accordoServizioParteSpecificaPort.findAllIds(filter);
  1312.                 if(ids==null || ids.size()<=0){
  1313.                     throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  1314.                 }
  1315.                 for (IdAccordoServizioParteSpecifica idAccordoServizioParteSpecifica : ids) {
  1316.                     AccordoServizioParteSpecifica asps = this.accordoServizioParteSpecificaPort.get(idAccordoServizioParteSpecifica);
  1317.                     IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(asps.getTipo(), asps.getNome(),
  1318.                             new IDSoggetto(asps.getTipoSoggettoErogatore(), asps.getNomeSoggettoErogatore()),
  1319.                             asps.getVersione());
  1320.                     idsOpenSPCoop.add(idServizio);
  1321.                 }
  1322.             }
  1323.             else{
  1324.                 List<AccordoServizioParteSpecifica> accordi = this.accordoServizioParteSpecificaPort.findAll(filter);
  1325.                 if(accordi==null || accordi.size()<=0){
  1326.                     throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  1327.                 }
  1328.                 for (AccordoServizioParteSpecifica asps : accordi) {
  1329.                    
  1330.                     // ProtocolProperties
  1331.                     if(ProtocolPropertiesUtilities.isMatch(asps, filtroRicerca.getProtocolProperties())==false){
  1332.                         continue;
  1333.                     }
  1334.                    
  1335.                     IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(asps.getTipo(), asps.getNome(),
  1336.                             new IDSoggetto(asps.getTipoSoggettoErogatore(), asps.getNomeSoggettoErogatore()),
  1337.                             asps.getVersione());
  1338.                     idsOpenSPCoop.add(idServizio);
  1339.                 }
  1340.                 if(idsOpenSPCoop==null || idsOpenSPCoop.size()<=0){
  1341.                     throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  1342.                 }
  1343.             }
  1344.            
  1345.             return idsOpenSPCoop;
  1346.            
  1347.         }catch(org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.RegistryNotFoundException_Exception e){
  1348.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  1349.         }catch(Exception e){
  1350.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1351.         }
  1352.     }

  1353.     @Override
  1354.     public List<IDFruizione> getAllIdFruizioniServizio(
  1355.             FiltroRicercaFruizioniServizio filtroRicerca) throws DriverRegistroServiziException, DriverRegistroServiziNotFound{
  1356.        
  1357.         try{
  1358.             SearchFilterAccordoServizioParteSpecifica filter = new SearchFilterAccordoServizioParteSpecifica();
  1359.             if(filtroRicerca!=null){
  1360.                 if(filtroRicerca.getIdAccordoServizioParteComune()!=null){
  1361.                     filter.setAccordoServizioParteComune(IDAccordoFactory.getInstance().getUriFromIDAccordo(filtroRicerca.getIdAccordoServizioParteComune()));
  1362.                 }
  1363.                 if(filtroRicerca.getNome()!=null || filtroRicerca.getTipo()!=null || filtroRicerca.getVersione()!=null ||
  1364.                         filtroRicerca.getPortType()!=null ||
  1365.                         filtroRicerca.getNomeSoggettoErogatore()!=null ||
  1366.                         filtroRicerca.getTipoSoggettoErogatore()!=null ||
  1367.                         filtroRicerca.getTipologia()!=null){
  1368.                     filter.setTipo(filtroRicerca.getTipo());
  1369.                     filter.setNome(filtroRicerca.getNome());
  1370.                     filter.setVersione(Long.valueOf(filtroRicerca.getVersione()));
  1371.                     filter.setPortType(filtroRicerca.getPortType());
  1372.                     filter.setTipoSoggettoErogatore(filtroRicerca.getTipoSoggettoErogatore());
  1373.                     filter.setNomeSoggettoErogatore(filtroRicerca.getNomeSoggettoErogatore());
  1374.                     if(filtroRicerca.getTipologia()!=null){
  1375.                         filter.setTipologiaServizio(TipologiaServizio.toEnumConstant(filtroRicerca.getTipologia().getValue()));
  1376.                     }
  1377.                 }
  1378.                 if(filtroRicerca.getMaxDate()!=null){
  1379.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  1380.                     cal.setTime(filtroRicerca.getMaxDate());
  1381.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  1382.                 }
  1383.                 if(filtroRicerca.getMinDate()!=null){
  1384.                     GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance();
  1385.                     cal.setTime(filtroRicerca.getMinDate());
  1386.                     filter.setOraRegistrazioneMax(this.dataTypeFactory.newXMLGregorianCalendar(cal));
  1387.                 }  
  1388.             }
  1389.             List<IDFruizione> idsOpenSPCoop = new ArrayList<IDFruizione>();
  1390.            
  1391.             List<AccordoServizioParteSpecifica> accordi = this.accordoServizioParteSpecificaPort.findAll(filter);
  1392.             if(accordi==null || accordi.size()<=0){
  1393.                 throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  1394.             }
  1395.             for (AccordoServizioParteSpecifica asps : accordi) {
  1396.                
  1397.                 // ProtocolProperties
  1398.                 if(ProtocolPropertiesUtilities.isMatch(asps, filtroRicerca.getProtocolProperties())==false){
  1399.                     continue;
  1400.                 }
  1401.                
  1402.                 IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(asps.getTipo(), asps.getNome(),
  1403.                         new IDSoggetto(asps.getTipoSoggettoErogatore(), asps.getNomeSoggettoErogatore()),
  1404.                         asps.getVersione());
  1405.                
  1406.                 for (Fruitore fruitore : asps.getFruitoreList()) {
  1407.                    
  1408.                     // Tipo
  1409.                     if(filtroRicerca.getTipoSoggettoFruitore()!=null){
  1410.                         if(fruitore.getTipo().equals(filtroRicerca.getTipoSoggettoFruitore()) == false){
  1411.                             continue;
  1412.                         }
  1413.                     }
  1414.                     // Nome
  1415.                     if(filtroRicerca.getNomeSoggettoFruitore()!=null){
  1416.                         if(fruitore.getNome().equals(filtroRicerca.getNomeSoggettoFruitore()) == false){
  1417.                             continue;
  1418.                         }
  1419.                     }
  1420.                     // ProtocolProperties
  1421.                     if(ProtocolPropertiesUtilities.isMatch(fruitore, filtroRicerca.getProtocolPropertiesFruizione())==false){
  1422.                         continue;
  1423.                     }
  1424.                    
  1425.                     IDFruizione idFruizione = new IDFruizione();
  1426.                     idFruizione.setIdServizio(idServizio);
  1427.                     idFruizione.setIdFruitore(new IDSoggetto(fruitore.getTipo(), fruitore.getNome()));
  1428.                     idsOpenSPCoop.add(idFruizione);
  1429.                 }

  1430.             }
  1431.             if(idsOpenSPCoop==null || idsOpenSPCoop.size()<=0){
  1432.                 throw new org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.RegistryNotFoundException_Exception("La ricerca non ha trovato accordi");
  1433.             }
  1434.            
  1435.             return idsOpenSPCoop;
  1436.            
  1437.         }catch(org.openspcoop2.core.registry.ws.client.accordoserviziopartespecifica.search.RegistryNotFoundException_Exception e){
  1438.             throw new DriverRegistroServiziNotFound(e.getMessage(),e);
  1439.         }catch(Exception e){
  1440.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1441.         }
  1442.        
  1443.     }

  1444.    
  1445.     @Override
  1446.     public Documento getAllegato(IDServizio idASPS, String nome)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1447.         throw new DriverRegistroServiziException("Not Implemented");
  1448.     }
  1449.     @Override
  1450.     public Documento getSpecificaSemiformale(IDServizio idASPS, TipiDocumentoSemiformale tipo, String nome)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1451.         throw new DriverRegistroServiziException("Not Implemented");
  1452.     }
  1453.     @Override
  1454.     public Documento getSpecificaSicurezza(IDServizio idASPS, TipiDocumentoSicurezza tipo, String nome)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1455.         throw new DriverRegistroServiziException("Not Implemented");
  1456.     }
  1457.     @Override
  1458.     public Documento getSpecificaLivelloServizio(IDServizio idASPS, TipiDocumentoLivelloServizio tipo, String nome)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1459.         throw new DriverRegistroServiziException("Not Implemented");
  1460.     }
  1461. }