UDDILib.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.uddi;

  21. import java.util.Vector;

  22. import org.openspcoop2.core.id.IDAccordo;
  23. import org.openspcoop2.core.id.IDAccordoCooperazione;
  24. import org.openspcoop2.core.id.IDServizio;
  25. import org.openspcoop2.core.id.IDSoggetto;
  26. import org.openspcoop2.core.registry.driver.DriverRegistroServiziException;
  27. import org.openspcoop2.core.registry.driver.DriverRegistroServiziNotFound;
  28. import org.openspcoop2.core.registry.driver.IDAccordoCooperazioneFactory;
  29. import org.openspcoop2.core.registry.driver.IDAccordoFactory;
  30. import org.uddi4j.UDDIException;
  31. import org.uddi4j.client.UDDIProxy;
  32. import org.uddi4j.datatype.Name;
  33. import org.uddi4j.datatype.OverviewDoc;
  34. import org.uddi4j.datatype.OverviewURL;
  35. import org.uddi4j.datatype.binding.AccessPoint;
  36. import org.uddi4j.datatype.binding.BindingTemplate;
  37. import org.uddi4j.datatype.binding.BindingTemplates;
  38. import org.uddi4j.datatype.binding.TModelInstanceDetails;
  39. import org.uddi4j.datatype.binding.TModelInstanceInfo;
  40. import org.uddi4j.datatype.business.BusinessEntity;
  41. import org.uddi4j.datatype.service.BusinessService;
  42. import org.uddi4j.datatype.service.BusinessServices;
  43. import org.uddi4j.datatype.tmodel.TModel;
  44. import org.uddi4j.response.AuthToken;
  45. import org.uddi4j.response.BindingDetail;
  46. import org.uddi4j.response.BusinessDetail;
  47. import org.uddi4j.response.BusinessInfo;
  48. import org.uddi4j.response.BusinessList;
  49. import org.uddi4j.response.ServiceDetail;
  50. import org.uddi4j.response.ServiceInfo;
  51. import org.uddi4j.response.ServiceList;
  52. import org.uddi4j.response.TModelDetail;
  53. import org.uddi4j.response.TModelInfo;
  54. import org.uddi4j.response.TModelList;
  55. import org.uddi4j.transport.TransportException;
  56. import org.uddi4j.util.CategoryBag;
  57. import org.uddi4j.util.FindQualifier;
  58. import org.uddi4j.util.FindQualifiers;
  59. import org.uddi4j.util.IdentifierBag;
  60. import org.uddi4j.util.KeyedReference;
  61. import org.uddi4j.util.TModelBag;
  62. import org.uddi4j.util.TModelKey;


  63. /**
  64.  * Classe utilizzata per interagire con un registro UDDI che implementa le specifiche SICA.
  65.  *
  66.  * @author Anedda Valentino
  67.  * @author Poli Andrea (apoli@link.it)
  68.  * @author $Author$
  69.  * @version $Rev$, $Date$
  70.  */

  71. public class UDDILib
  72. {
  73.     /* ********  F I E L D S  P R I V A T I  ******** */

  74.     /** Dichiarazione delle chiavi di tassonomia*/  
  75.     protected String tmkID="uuid:b6ba2f0c-b4e5-40c4-a4f4-6212aa8d389f";//chiave di tassonomia per identificazione

  76.     /** Numero massimo di oggetti da ritornare */
  77.     private static int MAX_SEARCH = Integer.MAX_VALUE;
  78.    
  79.     /** UDDI Proxy */
  80.     protected UDDIProxy proxy=null;
  81.     /** Username */
  82.     protected String username;
  83.     /** Password */
  84.     protected String password;


  85.     /** Indicazione di una corretta creazione */
  86.     public boolean create = false;
  87.     /** Motivo di errore di una scorretta creazione */
  88.     protected String error;

  89.     /** TModel di OpenSPCoop */
  90.     public static final String TMODEL_OPENSPCOOP = "OpenSPCoop:SPCoopIdentifier";
  91.    
  92.     public static final String ACCORDO_SERVIZIO = "AccordoServizio";
  93.     public static final String PORTA_DOMINIO = "PortaDominio";
  94.     public static final String PORTA_DOMINIO_PREFIX = "PdD@";
  95.     public static final String GRUPPO = "Gruppo";
  96.     public static final String GRUPPO_PREFIX = "Gruppo@";
  97.     public static final String RUOLO = "Ruolo";
  98.     public static final String RUOLO_PREFIX = "Ruolo@";
  99.     public static final String SCOPE = "Scope";
  100.     public static final String SCOPE_PREFIX = "Scope@";
  101.     public static final String ACCORDO_COOPERAZIONE = "AccordoCooperazione";
  102.     public static final String ACCORDO_COOPERAZIONE_PREFIX = "AccordoCooperazione@";
  103.    
  104.     // Factory
  105.     private IDAccordoFactory idAccordoFactory = IDAccordoFactory.getInstance();
  106.     private IDAccordoCooperazioneFactory idAccordoCooperazioneFactory = IDAccordoCooperazioneFactory.getInstance();

  107.    
  108.     /**
  109.      * In caso di avvenuto errore nel costruttore, questo metodo ritorna il motivo dell'errore.
  110.      *
  111.      * @return motivo dell'errore (se avvenuto in fase di consegna).
  112.      *
  113.      */
  114.     public String getErrore(){
  115.         return this.error;
  116.     }


  117.     /* ********  C O S T R U T T O R E  ******** */

  118.     /**
  119.      * Costruttore.
  120.      *
  121.      * @param inquiry URL utilizzata per interrogare il registro UDDI.
  122.      * @param publish URL utilizzata per pubblicare sul registro UDDI.
  123.      * @param user UserID necessaria per l'autorizzazione della pubblicazione
  124.      * @param password Password necessaria per l'autorizzazione della pubblicazione
  125.      */    
  126.     public UDDILib(String inquiry, String publish, String user, String password){
  127.         try{
  128.             this.proxy = new UDDIProxy();
  129.             if(inquiry != null)
  130.                 this.proxy.setInquiryURL(inquiry);
  131.             if(publish != null)
  132.                 this.proxy.setPublishURL(publish);

  133.             this.username = user;
  134.             this.password = password;

  135.             // per verificare il corretto funzionamento
  136.             //this.create = checkProxy();
  137.             this.create = true;
  138.         }
  139.         catch (java.net.MalformedURLException e){
  140.             this.error = e.getMessage();
  141.             this.create = false;
  142.         }
  143.         catch (Exception e){
  144.             this.error = e.getMessage();
  145.             this.create = false;
  146.         }
  147.     }  
  148.     /**
  149.      * Costruttore.
  150.      *
  151.      * @param inquiry URL utilizzata per interrogare il registro UDDI.
  152.      * @param user UserID necessaria per l'autorizzazione della pubblicazione
  153.      * @param password Password necessaria per l'autorizzazione della pubblicazione
  154.      */    
  155.     public UDDILib(String inquiry, String user, String password){
  156.         this(inquiry,null,user,password);
  157.     }  
  158.     /**
  159.      * Costruttore.
  160.      *
  161.      * @param inquiry URL utilizzata per interrogare il registro UDDI.
  162.      */
  163.     public UDDILib(String inquiry){
  164.         this(inquiry,null,null,null);
  165.     }  







  166.    
  167.    
  168.    
  169.    
  170.    
  171.    
  172.    
  173.    
  174.     /* ******** UTILITY GENERICHE   ******** */
  175.    
  176.     protected TModel getTModel(String tipoOggetto,String nome) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  177.         if ( nome==null )
  178.             throw new DriverRegistroServiziException("[UDDILib.getTModel("+tipoOggetto+")]: Alcuni parametri non definiti");
  179.        
  180.         TModel tm=null;
  181.         try{
  182.             // Filtro per nome esatto della TModel
  183.             FindQualifiers findQualifiers = new FindQualifiers();
  184.             Vector<FindQualifier> qualifier = new Vector<FindQualifier>();
  185.             qualifier.add(new FindQualifier(FindQualifier.exactNameMatch));
  186.             qualifier.add(new FindQualifier(FindQualifier.caseSensitiveMatch));
  187.             findQualifiers.setFindQualifierVector(qualifier);
  188.            
  189.             TModelList tmodelList = this.proxy.find_tModel(nome,null,null,findQualifiers,1);
  190.             if(tmodelList.getTModelInfos()==null || tmodelList.getTModelInfos().size()==0)
  191.                 throw new DriverRegistroServiziNotFound("TModel("+tipoOggetto+") non trovata");
  192.             Vector<?> tmodelInfoVector = tmodelList.getTModelInfos().getTModelInfoVector();
  193.             TModelInfo tmodelInfo=(TModelInfo) tmodelInfoVector.elementAt(0);
  194.             TModelDetail tmd = this.proxy.get_tModelDetail(tmodelInfo.getTModelKey());
  195.             Vector<?> tmv = tmd.getTModelVector();
  196.             tm = (TModel) tmv.elementAt(0);
  197.         }
  198.         catch (DriverRegistroServiziNotFound e){
  199.             throw e;
  200.         }
  201.         catch (UDDIException e){
  202.             throw new DriverRegistroServiziException("[UDDILib.getTModel("+tipoOggetto+")]: "+e.getMessage(),e);
  203.         }
  204.         catch (TransportException e){
  205.             throw new DriverRegistroServiziException("[UDDILib.getTModel("+tipoOggetto+")]: "+e.getMessage(),e);
  206.         }
  207.         catch (Exception e){
  208.             throw new DriverRegistroServiziException("[UDDILib.getTModel("+tipoOggetto+")]: "+e.getMessage(),e);
  209.         }
  210.         return tm;
  211.     }
  212.    
  213.     private TModel[] getTModelByFilter(String tipoOggetto,String searchNome,String urlRepository,boolean ricercaEsatta) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  214.         try{
  215.             String nomeRicerca = null;
  216.             if(searchNome!=null)
  217.                 nomeRicerca = searchNome;
  218.             else
  219.                 nomeRicerca = "%";
  220.            
  221.             // Filtro per nome esatto della TModel
  222.             FindQualifiers findQualifiers = null;
  223.             if( ricercaEsatta && nomeRicerca.equals("%")==false){
  224.                 findQualifiers = new FindQualifiers();
  225.                 Vector<FindQualifier> qualifier = new Vector<FindQualifier>();
  226.                 qualifier.add(new FindQualifier(FindQualifier.exactNameMatch));
  227.                 qualifier.add(new FindQualifier(FindQualifier.caseSensitiveMatch));
  228.                 findQualifiers.setFindQualifierVector(qualifier);
  229.             }
  230.            
  231.             TModelList tmodelList = this.proxy.find_tModel(nomeRicerca,null,null,findQualifiers,UDDILib.MAX_SEARCH);
  232.             Vector<TModel> tmodels = new Vector<TModel>();
  233.             // TModel vector lista.
  234.             if(tmodelList.getTModelInfos()!=null){
  235.                 Vector<?> tmodelInfoVector = tmodelList.getTModelInfos().getTModelInfoVector();
  236.                 for(int i=0; i<tmodelInfoVector.size(); i++){
  237.                     TModelInfo tmodelInfo=(TModelInfo) tmodelInfoVector.elementAt(i);
  238.                     TModelDetail tmd = this.proxy.get_tModelDetail(tmodelInfo.getTModelKey());
  239.                     Vector<?> tmv = tmd.getTModelVector();
  240.                     TModel t = (TModel) tmv.elementAt(0);
  241.                     // Filtro le tmodel per il repository
  242.                     if(urlRepository!=null){
  243.                         if(t.getOverviewDoc()!=null  && t.getOverviewDoc().getOverviewURLString()!=null &&
  244.                                 t.getOverviewDoc().getOverviewURLString().startsWith(urlRepository) ){
  245.                             if(UDDILib.ACCORDO_SERVIZIO.equals(tipoOggetto)){
  246.                                 if(t.getNameString().startsWith(UDDILib.ACCORDO_COOPERAZIONE_PREFIX)==false  &&  t.getNameString().startsWith(UDDILib.PORTA_DOMINIO_PREFIX)==false){
  247.                                     tmodels.add(t);
  248.                                 }
  249.                             }else{
  250.                                 tmodels.add(t);
  251.                             }
  252.                         }
  253.                     }else{
  254.                         if(UDDILib.ACCORDO_SERVIZIO.equals(tipoOggetto)){
  255.                             if(t.getNameString().startsWith(UDDILib.ACCORDO_COOPERAZIONE_PREFIX)==false  &&  t.getNameString().startsWith(UDDILib.PORTA_DOMINIO_PREFIX)==false){
  256.                                 tmodels.add(t);
  257.                             }
  258.                         }else{
  259.                             tmodels.add(t);
  260.                         }
  261.                     }
  262.                 }
  263.             }
  264.             if(tmodels.size()>0){
  265.                 TModel[] tm = new TModel[1];
  266.                 tm = tmodels.toArray(tm);
  267.                 return tm;
  268.             }else{
  269.                 throw new DriverRegistroServiziNotFound("Non sono state trovate TModelByFilter("+tipoOggetto+") nel registro UDDI con nome: "+searchNome);
  270.             }
  271.         }
  272.         catch (UDDIException e){
  273.             throw new DriverRegistroServiziException("[UDDILib.getTModelByFilter("+tipoOggetto+")]: "+e.getMessage(),e);
  274.         }
  275.         catch (TransportException e){
  276.             throw new DriverRegistroServiziException("[UDDILib.getTModelByFilter("+tipoOggetto+")]: "+e.getMessage(),e);
  277.         }
  278.         catch (DriverRegistroServiziNotFound e){
  279.             throw e;
  280.         }
  281.         catch (Exception e){
  282.             throw new DriverRegistroServiziException("[UDDILib.getTModelByFilter("+tipoOggetto+")]: "+e.getMessage(),e);
  283.         }
  284.     }

  285.     private void createTModel(String tipoOggetto,String nome, String url) throws DriverRegistroServiziException{

  286.         if ( (nome==null) || (url==null) )
  287.             throw new DriverRegistroServiziException("[UDDILib.createTModel("+tipoOggetto+")]: Alcuni parametri non definiti");
  288.         try{
  289.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  290.             Vector<TModel> tms = new Vector<TModel>();
  291.             TModel tm = new TModel("", nome);
  292.            
  293.             OverviewDoc od = new OverviewDoc();
  294.             OverviewURL ou = new OverviewURL();
  295.             ou.setText(url);
  296.             od.setOverviewURL(ou);
  297.             tm.setOverviewDoc(od);

  298.             tms.add(tm);
  299.             this.proxy.save_tModel(token.getAuthInfoString(),tms);
  300.         }
  301.         catch (UDDIException e){
  302.             throw new DriverRegistroServiziException("[UDDILib.createTModel("+tipoOggetto+")]: "+e.getMessage(),e);
  303.         }
  304.         catch (TransportException e){
  305.             throw new DriverRegistroServiziException("[UDDILib.createTModel("+tipoOggetto+")]: "+e.getMessage(),e);
  306.         }
  307.         catch (Exception e){
  308.             throw new DriverRegistroServiziException("[UDDILib.createTModel("+tipoOggetto+")]: "+e.getMessage(),e);
  309.         }
  310.     }
  311.    
  312.     private void updateTModel(String tipoOggetto,String nomeOLD,String nomeNEW,String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  313.         if ( (nomeOLD==null) || (url==null) || (nomeNEW==null))
  314.             throw new DriverRegistroServiziException("[UDDILib.updateTModel("+tipoOggetto+")]: Alcuni parametri non definiti");
  315.    
  316.         TModel tm=null;
  317.         try{
  318.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  319.             tm = getTModel(tipoOggetto, nomeOLD);

  320.             OverviewDoc od = tm.getOverviewDoc();
  321.             OverviewURL ou = od.getOverviewURL();
  322.             ou.setText(url);
  323.             od.setOverviewURL(ou);
  324.             tm.setOverviewDoc(od);

  325.             tm.setName(nomeNEW);
  326.             Vector<TModel> tms = new Vector<TModel>();
  327.             tms.add(tm);
  328.             this.proxy.save_tModel(token.getAuthInfoString(),tms);
  329.         }
  330.         catch(DriverRegistroServiziNotFound e){
  331.             throw e;
  332.         }
  333.         catch (UDDIException e){
  334.             throw new DriverRegistroServiziException("[UDDILib.updateTModel("+tipoOggetto+")]: "+e.getMessage(),e);
  335.         }
  336.         catch (TransportException e){
  337.             throw new DriverRegistroServiziException("[UDDILib.updateTModel("+tipoOggetto+")]: "+e.getMessage(),e);
  338.         }
  339.         catch (Exception e){
  340.             throw new DriverRegistroServiziException("[UDDILib.updateTModel("+tipoOggetto+")]: "+e.getMessage(),e);
  341.         }
  342.     }
  343.    
  344.     private void deleteTModel(String tipoOggetto,String nome) throws DriverRegistroServiziException{

  345.         if ( nome==null )
  346.             throw new DriverRegistroServiziException("[UDDILib.deleteTModel("+tipoOggetto+")]: Alcuni parametri non definiti");
  347.        
  348.         try{
  349.             AuthToken token = this.proxy.get_authToken(this.username,this.password);
  350.            
  351.             // Filtro per nome esatto della TModel
  352.             FindQualifiers findQualifiers = new FindQualifiers();
  353.             Vector<FindQualifier> qualifier = new Vector<FindQualifier>();
  354.             qualifier.add(new FindQualifier(FindQualifier.exactNameMatch));
  355.             qualifier.add(new FindQualifier(FindQualifier.caseSensitiveMatch));
  356.             findQualifiers.setFindQualifierVector(qualifier);
  357.            
  358.             TModelList tmodelList = this.proxy.find_tModel(nome,null,null,findQualifiers,1);
  359.             Vector<?> tmodelInfoVector = tmodelList.getTModelInfos().getTModelInfoVector();
  360.             TModelInfo tmodelInfo=(TModelInfo) tmodelInfoVector.elementAt(0);
  361.             this.proxy.delete_tModel(token.getAuthInfoString(),tmodelInfo.getTModelKey());
  362.        
  363.         }catch(Exception e){
  364.             throw new DriverRegistroServiziException("[UDDILib.deleteTModel("+tipoOggetto+")]: "+e.getMessage(),e);
  365.         }
  366.     }
  367.    
  368.     private void updateUrlXmlTModel(String tipoOggetto,String nome, String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  369.        
  370.         if ( (nome==null) || (url==null) )
  371.             throw new DriverRegistroServiziException("[UDDILib.updateUrlXmlTModel("+tipoOggetto+")]: Alcuni parametri non definiti");
  372.    
  373.         try{
  374.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  375.             TModel tm = getTModel(tipoOggetto,nome);
  376.             Vector<TModel> tms = new Vector<TModel>();
  377.             OverviewDoc od = tm.getOverviewDoc();
  378.             OverviewURL ou = od.getOverviewURL();
  379.             ou.setText(url);
  380.             od.setOverviewURL(ou);
  381.             tm.setOverviewDoc(od);
  382.             tms.add(tm);
  383.             this.proxy.save_tModel(token.getAuthInfoString(),tms);
  384.         }catch(DriverRegistroServiziNotFound e){
  385.             throw e;
  386.         }catch(Exception e){
  387.             throw new DriverRegistroServiziException("[UDDILib.updateUrlXmlTModel("+tipoOggetto+")]: "+e.getMessage(),e);
  388.         }
  389.     }
  390.    
  391.    



  392.    
  393.    
  394.    
  395.    
  396.    
  397.    
  398.    
  399.     /* ******** M E T O D I   A C C O R D O    D I    C O O P E R A Z I O N E   ******** */


  400.    
  401.     /**
  402.      * Si occupa di recuperare il TModel che registra l'accordo di cooperazione con nome <var>nome</var>
  403.      *
  404.      * @param idAccordo ID che identifica l'accordo di cooperazione
  405.      * @return la TModel che registra l'accordo di cooperazione
  406.      */
  407.     public TModel getAccordoCooperazione(IDAccordoCooperazione idAccordo) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  408.         String uriAccordo = this.idAccordoCooperazioneFactory.getUriFromIDAccordo(idAccordo);
  409.         return this.getTModel(UDDILib.ACCORDO_COOPERAZIONE, UDDILib.ACCORDO_COOPERAZIONE_PREFIX+uriAccordo);
  410.     }
  411.    
  412.     /**
  413.      * Si occupa di recuperare le TModels che soddisfano il filtro
  414.      *
  415.      * @param urlRepository Url del Repository
  416.      * @return una lista di TModel che registra l'accordo di cooperazione
  417.      */
  418.     public TModel[] getAccordiCooperazione(String urlRepository) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  419.         return this.getTModelByFilter(UDDILib.ACCORDO_COOPERAZIONE, UDDILib.ACCORDO_COOPERAZIONE_PREFIX, urlRepository,false);
  420.     }
  421.    
  422.     /**
  423.      * Si occupa di registrare come TModel un'accordo di cooperazione con nome <var>nome</var>
  424.      *
  425.      * @param idAccordo ID che identifica l'accordo di cooperazione
  426.      * @param url url del file XML associato all'accordo di cooperazione
  427.      */
  428.     public void createAccordoCooperazione(IDAccordoCooperazione idAccordo, String url) throws DriverRegistroServiziException{
  429.         String uriAccordo = this.idAccordoCooperazioneFactory.getUriFromIDAccordo(idAccordo);
  430.         this.createTModel(UDDILib.ACCORDO_COOPERAZIONE, UDDILib.ACCORDO_COOPERAZIONE_PREFIX+uriAccordo, url);
  431.     }

  432.     /**
  433.      * Il metodo si occupa di verificare se nel registro e' regitrata una TModel identificata dal parametro
  434.      *
  435.      * @param idAccordo ID dell'accordo di cooperazione
  436.      * @return true se la TModel risulta registrata, false altrimenti
  437.      *
  438.      */
  439.     public boolean existsAccordoCooperazione(IDAccordoCooperazione idAccordo) throws DriverRegistroServiziException{
  440.        
  441.         if ( idAccordo==null )
  442.             throw new DriverRegistroServiziException("[UDDILib.existsAccordoCooperazione]: Alcuni parametri non definiti");
  443.         String uriAccordo = this.idAccordoCooperazioneFactory.getUriFromIDAccordo(idAccordo);
  444.         try{
  445.             TModel t = getTModel(UDDILib.ACCORDO_COOPERAZIONE,UDDILib.ACCORDO_COOPERAZIONE_PREFIX+uriAccordo);
  446.             if(t == null)
  447.                 throw new Exception("TModel is null");
  448.         }catch(DriverRegistroServiziNotFound e){
  449.             return false;
  450.         }catch(Exception e){
  451.             throw new DriverRegistroServiziException(e.getMessage(),e);
  452.         }
  453.         return true;    
  454.     }

  455.     /**
  456.      * Si occupa di modificare il nome della TModel che registra l'accordo di cooperazione con nome <var>nomeOLD</var>
  457.      *
  458.      * @param idAccordoOLD vecchio id che identifica l'accordo di cooperazione
  459.      * @param idAccordoNEW nuovo id che identifica l'accordo di cooperazione
  460.      * @param url nuova url del file XML associato all'accordo di cooperazione
  461.      */
  462.     public void updateAccordoCooperazione(IDAccordoCooperazione idAccordoOLD,IDAccordoCooperazione idAccordoNEW,String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  463.         String uriAccordoOLD = this.idAccordoCooperazioneFactory.getUriFromIDAccordo(idAccordoOLD);
  464.         String uriAccordoNEW = this.idAccordoCooperazioneFactory.getUriFromIDAccordo(idAccordoNEW);
  465.         this.updateTModel(UDDILib.ACCORDO_COOPERAZIONE, UDDILib.ACCORDO_COOPERAZIONE_PREFIX+uriAccordoOLD, UDDILib.ACCORDO_COOPERAZIONE_PREFIX+uriAccordoNEW, url);
  466.     }

  467.     /**
  468.      * Il metodo si occupa di cancellare la TModel identificata dal parametro
  469.      *
  470.      * @param idAccordo ID che identifica l'accordo di cooperazione
  471.      */
  472.     public void deleteAccordoCooperazione(IDAccordoCooperazione idAccordo) throws DriverRegistroServiziException{
  473.         String uriAccordo = this.idAccordoCooperazioneFactory.getUriFromIDAccordo(idAccordo);
  474.         this.deleteTModel(UDDILib.ACCORDO_COOPERAZIONE, UDDILib.ACCORDO_COOPERAZIONE_PREFIX+uriAccordo);
  475.     }

  476.     /**
  477.      * Il metodo si occupa di impostare la url del file XML della TModel
  478.      *
  479.      * @param idAccordo ID che identifica l'accordo di cooperazione
  480.      * @param url url del file XML associato all'accordo di cooperazione
  481.      */
  482.     public void updateUrlXmlAccordoCooperazione(IDAccordoCooperazione idAccordo, String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  483.         String uriAccordo = this.idAccordoCooperazioneFactory.getUriFromIDAccordo(idAccordo);
  484.         this.updateUrlXmlTModel(UDDILib.ACCORDO_COOPERAZIONE, UDDILib.ACCORDO_COOPERAZIONE_PREFIX+uriAccordo, url);
  485.     }
  486.     /**
  487.      * Si occupa di recuperare la URL dell'XML associato all'accordo di cooperazione
  488.      * registrato con il nome <var>nome</var>
  489.      *
  490.      * @param idAccordo ID che identifica l'accordo di cooperazione
  491.      * @return la url dell'XML associato all'accordo di cooperazione
  492.      *
  493.      */
  494.     public String getUrlXmlAccordoCooperazione(IDAccordoCooperazione idAccordo) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  495.         if ( idAccordo==null )
  496.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlAccordoCooperazione]: Alcuni parametri non definiti");
  497.         try{
  498.             String uriAccordo = this.idAccordoCooperazioneFactory.getUriFromIDAccordo(idAccordo);
  499.             TModel tm = getTModel(UDDILib.ACCORDO_COOPERAZIONE, UDDILib.ACCORDO_COOPERAZIONE_PREFIX+uriAccordo);
  500.             return tm.getOverviewDoc().getOverviewURLString();
  501.         }catch(DriverRegistroServiziNotFound e){
  502.             throw e;
  503.         }catch(Exception e){
  504.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlAccordoCooperazione]: "+e.getMessage(),e);
  505.         }
  506.     }
  507.    
  508.     /**
  509.      * Si occupa di recuperare la URL dell'XML associato all'accordo di cooperazione
  510.      * registrato con il nome <var>nome</var>
  511.      *
  512.      * @param idAccordo ID che identifica l'accordo di cooperazione
  513.      * @return la url dell'XML associato all'accordo di cooperazione
  514.      *
  515.      */
  516.     public String[] getUrlXmlAccordiCooperazione(IDAccordoCooperazione idAccordo,String urlPrefix) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  517.         try{
  518.             TModel[] tm = null;
  519.             if(idAccordo!=null) {
  520.                 String uriAccordo = this.idAccordoCooperazioneFactory.getUriFromIDAccordo(idAccordo);
  521.                 tm = getTModelByFilter(UDDILib.ACCORDO_COOPERAZIONE, UDDILib.ACCORDO_COOPERAZIONE_PREFIX+uriAccordo,urlPrefix,true);
  522.             }else{
  523.                 tm = getTModelByFilter(UDDILib.ACCORDO_COOPERAZIONE, UDDILib.ACCORDO_COOPERAZIONE_PREFIX,urlPrefix,false);
  524.             }
  525.             if(tm!=null){
  526.                 String[] url = new String[tm.length];
  527.                 for(int i=0; i<tm.length; i++){
  528.                     url[i] = tm[i].getOverviewDoc().getOverviewURLString();
  529.                 }
  530.                 return url;
  531.             }else{
  532.                 throw new DriverRegistroServiziNotFound("Accordi di Cooperazione (definizione XML) non trovati");
  533.             }
  534.         }
  535.         catch (DriverRegistroServiziNotFound e){
  536.             throw e;
  537.         }
  538.         catch(Exception e){
  539.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlAccordiCooperazione]: "+e.getMessage(),e);
  540.         }
  541.     }
  542.    
  543.    
  544.    
  545.    
  546.    









  547.     /* ******** M E T O D I   A C C O R D O    D I    S E R V I Z I O   ******** */


  548.    
  549.     /**
  550.      * Si occupa di recuperare il TModel che registra l'accordo di servizio con nome <var>nome</var>
  551.      *
  552.      * @param idAccordo ID che identifica l'accordo di servizio
  553.      * @return la TModel che registra l'accordo di servizio
  554.      */
  555.     public TModel getAccordoServizio(IDAccordo idAccordo) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  556.         String uriAccordo = this.idAccordoFactory.getUriFromIDAccordo(idAccordo);
  557.         return this.getTModel(UDDILib.ACCORDO_SERVIZIO, uriAccordo);
  558.     }
  559.    
  560.     /**
  561.      * Si occupa di recuperare le TModels che soddisfano il filtro
  562.      *
  563.      * @param urlRepository Url del Repository
  564.      * @return una lista di TModel che registra l'accordo di servizio
  565.      */
  566.     public TModel[] getAccordiServizio(String urlRepository) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  567.         return this.getTModelByFilter(UDDILib.ACCORDO_SERVIZIO, null, urlRepository,false);
  568.     }
  569.    
  570.     /**
  571.      * Si occupa di registrare come TModel un'accordo di servizio con nome <var>nome</var>
  572.      *
  573.      * @param idAccordo ID che identifica l'accordo di servizio
  574.      * @param url url del file XML associato all'accordo di servizio
  575.      */
  576.     public void createAccordoServizio(IDAccordo idAccordo, String url) throws DriverRegistroServiziException{
  577.         String uriAccordo = this.idAccordoFactory.getUriFromIDAccordo(idAccordo);
  578.         this.createTModel(UDDILib.ACCORDO_SERVIZIO, uriAccordo, url);
  579.     }

  580.     /**
  581.      * Il metodo si occupa di verificare se nel registro e' regitrata una TModel identificata dal parametro
  582.      *
  583.      * @param idAccordo ID dell'accordo di servizio
  584.      * @return true se la TModel risulta registrata, false altrimenti
  585.      *
  586.      */
  587.     public boolean existsAccordoServizio(IDAccordo idAccordo) throws DriverRegistroServiziException{
  588.        
  589.         if ( idAccordo==null )
  590.             throw new DriverRegistroServiziException("[UDDILib.existsAccordoServizio]: Alcuni parametri non definiti");
  591.         String uriAccordo = this.idAccordoFactory.getUriFromIDAccordo(idAccordo);
  592.         try{
  593.             TModel t = getTModel(UDDILib.ACCORDO_SERVIZIO,uriAccordo);
  594.             if(t == null)
  595.                 throw new Exception("TModel is null");
  596.         }catch(DriverRegistroServiziNotFound e){
  597.             return false;
  598.         }catch(Exception e){
  599.             throw new DriverRegistroServiziException(e.getMessage(),e);
  600.         }
  601.         return true;    
  602.     }

  603.     /**
  604.      * Si occupa di modificare il nome della TModel che registra l'accordo di servizio con nome <var>nomeOLD</var>
  605.      *
  606.      * @param idAccordoOLD vecchio id che identifica l'accordo di servizio
  607.      * @param idAccordoNEW nuovo id che identifica l'accordo di servizio
  608.      * @param url nuova url del file XML associato all'accordo di servizio
  609.      */
  610.     public void updateAccordoServizio(IDAccordo idAccordoOLD,IDAccordo idAccordoNEW,String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  611.         String uriAccordoOLD = this.idAccordoFactory.getUriFromIDAccordo(idAccordoOLD);
  612.         String uriAccordoNEW = this.idAccordoFactory.getUriFromIDAccordo(idAccordoNEW);
  613.         this.updateTModel(UDDILib.ACCORDO_SERVIZIO, uriAccordoOLD, uriAccordoNEW, url);
  614.     }

  615.     /**
  616.      * Il metodo si occupa di cancellare la TModel identificata dal parametro
  617.      *
  618.      * @param idAccordo ID che identifica l'accordo di servizio
  619.      */
  620.     public void deleteAccordoServizio(IDAccordo idAccordo) throws DriverRegistroServiziException{
  621.         String uriAccordo = this.idAccordoFactory.getUriFromIDAccordo(idAccordo);
  622.         this.deleteTModel(UDDILib.ACCORDO_SERVIZIO, uriAccordo);
  623.     }

  624.     /**
  625.      * Il metodo si occupa di impostare la url del file XML della TModel
  626.      *
  627.      * @param idAccordo ID che identifica l'accordo di servizio
  628.      * @param url url del file XML associato all'accordo di servizio
  629.      */
  630.     public void updateUrlXmlAccordoServizio(IDAccordo idAccordo, String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  631.         String uriAccordo = this.idAccordoFactory.getUriFromIDAccordo(idAccordo);
  632.         this.updateUrlXmlTModel(UDDILib.ACCORDO_SERVIZIO, uriAccordo, url);
  633.     }
  634.     /**
  635.      * Si occupa di recuperare la URL dell'XML associato all'accordo di servizio
  636.      * registrato con il nome <var>nome</var>
  637.      *
  638.      * @param idAccordo ID che identifica l'accordo di servizio
  639.      * @return la url dell'XML associato all'accordo di servizio
  640.      *
  641.      */
  642.     public String getUrlXmlAccordoServizio(IDAccordo idAccordo) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  643.         if ( idAccordo==null )
  644.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlAccordoServizio]: Alcuni parametri non definiti");
  645.         try{
  646.             String uriAccordo = this.idAccordoFactory.getUriFromIDAccordo(idAccordo);
  647.             TModel tm = getTModel(UDDILib.ACCORDO_SERVIZIO,uriAccordo);
  648.             return tm.getOverviewDoc().getOverviewURLString();
  649.         }catch(DriverRegistroServiziNotFound e){
  650.             throw e;
  651.         }catch(Exception e){
  652.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlAccordoServizio]: "+e.getMessage(),e);
  653.         }
  654.     }
  655.    
  656.     /**
  657.      * Si occupa di recuperare la URL dell'XML associato all'accordo di servizio
  658.      * registrato con il nome <var>nome</var>
  659.      *
  660.      * @param idAccordo ID che identifica l'accordo di servizio
  661.      * @return la url dell'XML associato all'accordo di servizio
  662.      *
  663.      */
  664.     public String[] getUrlXmlAccordiServizio(IDAccordo idAccordo,String urlRepository) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  665.         try{
  666.             TModel[] tm = null;
  667.             if(idAccordo!=null) {
  668.                 String uriAccordo = this.idAccordoFactory.getUriFromIDAccordo(idAccordo);
  669.                 tm = getTModelByFilter(UDDILib.ACCORDO_SERVIZIO, uriAccordo,urlRepository,true);
  670.             }else{
  671.                 tm = getTModelByFilter(UDDILib.ACCORDO_SERVIZIO, null,urlRepository,false);
  672.             }
  673.             if(tm!=null){
  674.                 String[] url = new String[tm.length];
  675.                 for(int i=0; i<tm.length; i++){
  676.                     url[i] = tm[i].getOverviewDoc().getOverviewURLString();
  677.                 }
  678.                 return url;
  679.             }else{
  680.                 throw new DriverRegistroServiziNotFound("Accordi di Servizio (definizione XML) non trovati");
  681.             }
  682.         }
  683.         catch (DriverRegistroServiziNotFound e){
  684.             throw e;
  685.         }
  686.         catch(Exception e){
  687.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlAccordoServizio]: "+e.getMessage(),e);
  688.         }
  689.     }

  690.    







  691.    
  692.    
  693.    
  694.    
  695.    
  696.    
  697.    
  698.    
  699.     /* ******** M E T O D I   P D D   ******** */


  700.    
  701.     /**
  702.      * Si occupa di recuperare il TModel che registra la porta di dominio con nome <var>nome</var>
  703.      *
  704.      * @param nome nome che identifica la porta di dominio
  705.      * @return la TModel che registra la porta di dominio
  706.      */
  707.     public TModel getPortaDominio(String nome) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  708.         return this.getTModel(UDDILib.PORTA_DOMINIO, UDDILib.PORTA_DOMINIO_PREFIX+nome);
  709.     }
  710.    
  711.     /**
  712.      * Si occupa di recuperare le TModels che soddisfano il filtro
  713.      *
  714.      * @param urlRepository Url del Repository
  715.      * @return una lista di TModel che registra la porta di dominio
  716.      */
  717.     public TModel[] getPorteDominio(String urlRepository) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  718.         return this.getTModelByFilter(UDDILib.PORTA_DOMINIO, UDDILib.PORTA_DOMINIO_PREFIX, urlRepository, false);
  719.     }
  720.    
  721.     /**
  722.      * Si occupa di registrare come TModel una porta di dominio con nome <var>nome</var>
  723.      *
  724.      * @param nome Nome che identifica la pdd
  725.      * @param url url del file XML associato alla pdd
  726.      */
  727.     public void createPortaDominio(String nome, String url) throws DriverRegistroServiziException{
  728.         this.createTModel(UDDILib.PORTA_DOMINIO, UDDILib.PORTA_DOMINIO_PREFIX+ nome, url);
  729.     }

  730.     /**
  731.      * Il metodo si occupa di verificare se nel registro e' regitrata una TModel identificata dal parametro
  732.      *
  733.      * @param nome Nome della porta di dominio
  734.      * @return true se la TModel risulta registrata, false altrimenti
  735.      *
  736.      */
  737.     public boolean existsPortaDominio(String nome) throws DriverRegistroServiziException{
  738.        
  739.         if ( nome==null )
  740.             throw new DriverRegistroServiziException("[UDDILib.existsPortaDominio]: Alcuni parametri non definiti");
  741.         try{
  742.             TModel t = getTModel(UDDILib.PORTA_DOMINIO, UDDILib.PORTA_DOMINIO_PREFIX+nome);
  743.             if(t == null)
  744.                 throw new Exception("TModel is null");
  745.         }catch(DriverRegistroServiziNotFound e){
  746.             return false;
  747.         }catch(Exception e){
  748.             throw new DriverRegistroServiziException(e.getMessage(),e);
  749.         }
  750.         return true;    
  751.     }

  752.     /**
  753.      * Si occupa di modificare il nome della TModel che registra la porta di dominio con nome <var>nomeOLD</var>
  754.      *
  755.      * @param nomeOLD vecchio nome che identifica la porta di dominio
  756.      * @param nomeNEW nuovo nome che identifica la porta di dominio
  757.      * @param url nuova url del file XML associato all'accordo di servizio
  758.      */
  759.     public void updatePortaDominio(String nomeOLD,String nomeNEW,String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  760.         this.updateTModel(UDDILib.PORTA_DOMINIO, UDDILib.PORTA_DOMINIO_PREFIX+nomeOLD, UDDILib.PORTA_DOMINIO_PREFIX+nomeNEW, url);
  761.     }

  762.     /**
  763.      * Il metodo si occupa di cancellare la TModel identificata dal parametro
  764.      *
  765.      * @param nome nome che identifica la porta di dominio
  766.      */
  767.     public void deletePortaDominio(String nome) throws DriverRegistroServiziException{
  768.         this.deleteTModel(UDDILib.PORTA_DOMINIO, UDDILib.PORTA_DOMINIO_PREFIX+nome);
  769.     }

  770.     /**
  771.      * Il metodo si occupa di impostare la url del file XML della TModel
  772.      *
  773.      * @param nome Nome che identifica la porta di dominio
  774.      * @param url url del file XML associato alla porta di dominio
  775.      */
  776.     public void updateUrlXmlPortaDominio(String nome, String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  777.         this.updateUrlXmlTModel(UDDILib.PORTA_DOMINIO, UDDILib.PORTA_DOMINIO_PREFIX+nome, url);
  778.     }
  779.     /**
  780.      * Si occupa di recuperare la URL dell'XML associato alla porta di dominio
  781.      * registrato con il nome <var>nome</var>
  782.      *
  783.      * @param nome Nome che identifica la porta di dominio
  784.      * @return la url dell'XML associato alla porta di dominio
  785.      *
  786.      */
  787.     public String getUrlXmlPortaDominio(String nome) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  788.         if ( nome==null )
  789.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlPortaDominio]: Alcuni parametri non definiti");
  790.         try{
  791.             TModel tm = getTModel(UDDILib.PORTA_DOMINIO, UDDILib.PORTA_DOMINIO_PREFIX+nome);
  792.             return tm.getOverviewDoc().getOverviewURLString();
  793.         }catch(DriverRegistroServiziNotFound e){
  794.             throw e;
  795.         }catch(Exception e){
  796.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlPortaDominio]: "+e.getMessage(),e);
  797.         }
  798.     }
  799.    
  800.     /**
  801.      * Si occupa di recuperare la URL dell'XML associato alla porta di dominio
  802.      * registrata con il nome <var>nome</var>
  803.      *
  804.      * @param searchNome Nome che identifica la porta di dominio
  805.      * @return la url dell'XML associato alla porta di dominio
  806.      *
  807.      */
  808.     public String[] getUrlXmlPortaDominio(String searchNome,String urlRepository) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  809.         try{
  810.             TModel[] tm = null;
  811.             if(searchNome!=null){
  812.                 tm = getTModelByFilter(UDDILib.PORTA_DOMINIO, UDDILib.PORTA_DOMINIO_PREFIX+searchNome,urlRepository,true);
  813.             }else{
  814.                 tm = getTModelByFilter(UDDILib.PORTA_DOMINIO, UDDILib.PORTA_DOMINIO_PREFIX,urlRepository,false);
  815.             }
  816.            
  817.             /*Vector<TModel> tmFiltratePerPdd = new Vector<TModel>();
  818.             for(int i=0; i<tm.length; i++){
  819.                 if(tm[i].getNameString().startsWith(PORTA_DOMINIO_PREFIX)){
  820.                     tmFiltratePerPdd.add(tm[i]);
  821.                 }
  822.             }
  823.             if(tmFiltratePerPdd.size()<=0){
  824.                 throw new DriverRegistroServiziNotFound("Porte di dominio non trovate, dopo il filtro per pdd");
  825.             }
  826.            
  827.             String[] url = new String[tmFiltratePerPdd.size()];
  828.             int i=0;
  829.             while(tmFiltratePerPdd.size()>0){
  830.                 TModel t = tmFiltratePerPdd.remove(0);
  831.                 url[i] = t.getOverviewDoc().getOverviewURLString();
  832.                 i++;
  833.             }
  834.             return url;
  835.             */
  836.            
  837.             if(tm!=null){
  838.                 String[] url = new String[tm.length];
  839.                 for(int i=0; i<tm.length; i++){
  840.                     url[i] = tm[i].getOverviewDoc().getOverviewURLString();
  841.                 }
  842.                 return url;
  843.             }else{
  844.                 throw new DriverRegistroServiziNotFound("Porte di Dominio (definizione XML) non trovate");
  845.             }
  846.         }
  847.         catch (DriverRegistroServiziNotFound e){
  848.             throw e;
  849.         }
  850.         catch(Exception e){
  851.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlPortaDominio]: "+e.getMessage(),e);
  852.         }
  853.     }
  854.    
  855.    
  856.    
  857.    
  858.    
  859.    
  860.    
  861.    
  862.    
  863.    
  864.    
  865.     /* ******** M E T O D I   G R U P P I   ******** */


  866.    
  867.     /**
  868.      * Si occupa di recuperare il TModel che registra il gruppo con nome <var>nome</var>
  869.      *
  870.      * @param nome nome che identifica il gruppo
  871.      * @return la TModel che registra il gruppo
  872.      */
  873.     public TModel getGruppo(String nome) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  874.         return this.getTModel(UDDILib.GRUPPO, UDDILib.GRUPPO_PREFIX+nome);
  875.     }
  876.    
  877.     /**
  878.      * Si occupa di recuperare le TModels che soddisfano il filtro
  879.      *
  880.      * @param urlRepository Url del Repository
  881.      * @return una lista di TModel che registra i gruppi
  882.      */
  883.     public TModel[] getGruppi(String urlRepository) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  884.         return this.getTModelByFilter(UDDILib.GRUPPO, UDDILib.GRUPPO_PREFIX, urlRepository, false);
  885.     }
  886.    
  887.     /**
  888.      * Si occupa di registrare come TModel un gruppo con nome <var>nome</var>
  889.      *
  890.      * @param nome Nome che identifica il gruppo
  891.      * @param url url del file XML associato al gruppo
  892.      */
  893.     public void createGruppo(String nome, String url) throws DriverRegistroServiziException{
  894.         this.createTModel(UDDILib.GRUPPO, UDDILib.GRUPPO_PREFIX+ nome, url);
  895.     }

  896.     /**
  897.      * Il metodo si occupa di verificare se nel registro e' regitrata una TModel identificata dal parametro
  898.      *
  899.      * @param nome Nome del gruppo
  900.      * @return true se la TModel risulta registrata, false altrimenti
  901.      *
  902.      */
  903.     public boolean existsGruppo(String nome) throws DriverRegistroServiziException{
  904.        
  905.         if ( nome==null )
  906.             throw new DriverRegistroServiziException("[UDDILib.existsGruppo]: Alcuni parametri non definiti");
  907.         try{
  908.             TModel t = getTModel(UDDILib.GRUPPO, UDDILib.GRUPPO_PREFIX+nome);
  909.             if(t == null)
  910.                 throw new Exception("TModel is null");
  911.         }catch(DriverRegistroServiziNotFound e){
  912.             return false;
  913.         }catch(Exception e){
  914.             throw new DriverRegistroServiziException(e.getMessage(),e);
  915.         }
  916.         return true;    
  917.     }

  918.     /**
  919.      * Si occupa di modificare il nome della TModel che registra il gruppo con nome <var>nomeOLD</var>
  920.      *
  921.      * @param nomeOLD vecchio nome che identifica il gruppo
  922.      * @param nomeNEW nuovo nome che identifica il gruppo
  923.      * @param url nuova url del file XML associato al gruppo
  924.      */
  925.     public void updateGruppo(String nomeOLD,String nomeNEW,String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  926.         this.updateTModel(UDDILib.GRUPPO, UDDILib.GRUPPO_PREFIX+nomeOLD, UDDILib.GRUPPO_PREFIX+nomeNEW, url);
  927.     }

  928.     /**
  929.      * Il metodo si occupa di cancellare la TModel identificata dal parametro
  930.      *
  931.      * @param nome nome che identifica il gruppo
  932.      */
  933.     public void deleteGruppo(String nome) throws DriverRegistroServiziException{
  934.         this.deleteTModel(UDDILib.GRUPPO, UDDILib.GRUPPO_PREFIX+nome);
  935.     }

  936.     /**
  937.      * Il metodo si occupa di impostare la url del file XML della TModel
  938.      *
  939.      * @param nome Nome che identifica il gruppo
  940.      * @param url url del file XML associato al gruppo
  941.      */
  942.     public void updateUrlXmlGruppo(String nome, String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  943.         this.updateUrlXmlTModel(UDDILib.GRUPPO, UDDILib.GRUPPO_PREFIX+nome, url);
  944.     }
  945.     /**
  946.      * Si occupa di recuperare la URL dell'XML associato al gruppo
  947.      * registrato con il nome <var>nome</var>
  948.      *
  949.      * @param nome Nome che identifica il gruppo
  950.      * @return la url dell'XML associato al gruppo
  951.      *
  952.      */
  953.     public String getUrlXmlGruppo(String nome) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  954.         if ( nome==null )
  955.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlGruppo]: Alcuni parametri non definiti");
  956.         try{
  957.             TModel tm = getTModel(UDDILib.GRUPPO, UDDILib.GRUPPO_PREFIX+nome);
  958.             return tm.getOverviewDoc().getOverviewURLString();
  959.         }catch(DriverRegistroServiziNotFound e){
  960.             throw e;
  961.         }catch(Exception e){
  962.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlGruppo]: "+e.getMessage(),e);
  963.         }
  964.     }
  965.    
  966.     /**
  967.      * Si occupa di recuperare la URL dell'XML associato al gruppo
  968.      * registrata con il nome <var>nome</var>
  969.      *
  970.      * @param searchNome Nome che identifica il gruppo
  971.      * @return la url dell'XML associato al gruppo
  972.      *
  973.      */
  974.     public String[] getUrlXmlGruppo(String searchNome,String urlRepository) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  975.         try{
  976.             TModel[] tm = null;
  977.             if(searchNome!=null){
  978.                 tm = getTModelByFilter(UDDILib.GRUPPO, UDDILib.GRUPPO_PREFIX+searchNome,urlRepository,true);
  979.             }else{
  980.                 tm = getTModelByFilter(UDDILib.GRUPPO, UDDILib.GRUPPO_PREFIX,urlRepository,false);
  981.             }
  982.            
  983.             if(tm!=null){
  984.                 String[] url = new String[tm.length];
  985.                 for(int i=0; i<tm.length; i++){
  986.                     url[i] = tm[i].getOverviewDoc().getOverviewURLString();
  987.                 }
  988.                 return url;
  989.             }else{
  990.                 throw new DriverRegistroServiziNotFound("Gruppo (definizione XML) non trovate");
  991.             }
  992.         }
  993.         catch (DriverRegistroServiziNotFound e){
  994.             throw e;
  995.         }
  996.         catch(Exception e){
  997.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlGruppo]: "+e.getMessage(),e);
  998.         }
  999.     }
  1000.    
  1001.    
  1002.    
  1003.    
  1004.    
  1005.    
  1006.    
  1007.    
  1008.    
  1009.    
  1010.     /* ******** M E T O D I   R U O L I   ******** */


  1011.    
  1012.     /**
  1013.      * Si occupa di recuperare il TModel che registra il ruolo con nome <var>nome</var>
  1014.      *
  1015.      * @param nome nome che identifica il ruolo
  1016.      * @return la TModel che registra il ruolo
  1017.      */
  1018.     public TModel getRuolo(String nome) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1019.         return this.getTModel(UDDILib.RUOLO, UDDILib.RUOLO_PREFIX+nome);
  1020.     }
  1021.    
  1022.     /**
  1023.      * Si occupa di recuperare le TModels che soddisfano il filtro
  1024.      *
  1025.      * @param urlRepository Url del Repository
  1026.      * @return una lista di TModel che registra i ruoli
  1027.      */
  1028.     public TModel[] getRuoli(String urlRepository) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1029.         return this.getTModelByFilter(UDDILib.RUOLO, UDDILib.RUOLO_PREFIX, urlRepository, false);
  1030.     }
  1031.    
  1032.     /**
  1033.      * Si occupa di registrare come TModel un ruolo con nome <var>nome</var>
  1034.      *
  1035.      * @param nome Nome che identifica il ruolo
  1036.      * @param url url del file XML associato al ruolo
  1037.      */
  1038.     public void createRuolo(String nome, String url) throws DriverRegistroServiziException{
  1039.         this.createTModel(UDDILib.RUOLO, UDDILib.RUOLO_PREFIX+ nome, url);
  1040.     }

  1041.     /**
  1042.      * Il metodo si occupa di verificare se nel registro e' regitrata una TModel identificata dal parametro
  1043.      *
  1044.      * @param nome Nome del ruolo
  1045.      * @return true se la TModel risulta registrata, false altrimenti
  1046.      *
  1047.      */
  1048.     public boolean existsRuolo(String nome) throws DriverRegistroServiziException{
  1049.        
  1050.         if ( nome==null )
  1051.             throw new DriverRegistroServiziException("[UDDILib.existsRuolo]: Alcuni parametri non definiti");
  1052.         try{
  1053.             TModel t = getTModel(UDDILib.RUOLO, UDDILib.RUOLO_PREFIX+nome);
  1054.             if(t == null)
  1055.                 throw new Exception("TModel is null");
  1056.         }catch(DriverRegistroServiziNotFound e){
  1057.             return false;
  1058.         }catch(Exception e){
  1059.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1060.         }
  1061.         return true;    
  1062.     }

  1063.     /**
  1064.      * Si occupa di modificare il nome della TModel che registra il ruolo con nome <var>nomeOLD</var>
  1065.      *
  1066.      * @param nomeOLD vecchio nome che identifica il ruolo
  1067.      * @param nomeNEW nuovo nome che identifica il ruolo
  1068.      * @param url nuova url del file XML associato al ruolo
  1069.      */
  1070.     public void updateRuolo(String nomeOLD,String nomeNEW,String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1071.         this.updateTModel(UDDILib.RUOLO, UDDILib.RUOLO_PREFIX+nomeOLD, UDDILib.RUOLO_PREFIX+nomeNEW, url);
  1072.     }

  1073.     /**
  1074.      * Il metodo si occupa di cancellare la TModel identificata dal parametro
  1075.      *
  1076.      * @param nome nome che identifica il ruolo
  1077.      */
  1078.     public void deleteRuolo(String nome) throws DriverRegistroServiziException{
  1079.         this.deleteTModel(UDDILib.RUOLO, UDDILib.RUOLO_PREFIX+nome);
  1080.     }

  1081.     /**
  1082.      * Il metodo si occupa di impostare la url del file XML della TModel
  1083.      *
  1084.      * @param nome Nome che identifica il ruolo
  1085.      * @param url url del file XML associato al ruolo
  1086.      */
  1087.     public void updateUrlXmlRuolo(String nome, String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1088.         this.updateUrlXmlTModel(UDDILib.RUOLO, UDDILib.RUOLO_PREFIX+nome, url);
  1089.     }
  1090.     /**
  1091.      * Si occupa di recuperare la URL dell'XML associato al ruolo
  1092.      * registrato con il nome <var>nome</var>
  1093.      *
  1094.      * @param nome Nome che identifica il ruolo
  1095.      * @return la url dell'XML associato al ruolo
  1096.      *
  1097.      */
  1098.     public String getUrlXmlRuolo(String nome) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1099.         if ( nome==null )
  1100.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlRuolo]: Alcuni parametri non definiti");
  1101.         try{
  1102.             TModel tm = getTModel(UDDILib.RUOLO, UDDILib.RUOLO_PREFIX+nome);
  1103.             return tm.getOverviewDoc().getOverviewURLString();
  1104.         }catch(DriverRegistroServiziNotFound e){
  1105.             throw e;
  1106.         }catch(Exception e){
  1107.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlRuolo]: "+e.getMessage(),e);
  1108.         }
  1109.     }
  1110.    
  1111.     /**
  1112.      * Si occupa di recuperare la URL dell'XML associato al ruolo
  1113.      * registrata con il nome <var>nome</var>
  1114.      *
  1115.      * @param searchNome Nome che identifica il ruolo
  1116.      * @return la url dell'XML associato al ruolo
  1117.      *
  1118.      */
  1119.     public String[] getUrlXmlRuolo(String searchNome,String urlRepository) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1120.         try{
  1121.             TModel[] tm = null;
  1122.             if(searchNome!=null){
  1123.                 tm = getTModelByFilter(UDDILib.RUOLO, UDDILib.RUOLO_PREFIX+searchNome,urlRepository,true);
  1124.             }else{
  1125.                 tm = getTModelByFilter(UDDILib.RUOLO, UDDILib.RUOLO_PREFIX,urlRepository,false);
  1126.             }
  1127.            
  1128.             if(tm!=null){
  1129.                 String[] url = new String[tm.length];
  1130.                 for(int i=0; i<tm.length; i++){
  1131.                     url[i] = tm[i].getOverviewDoc().getOverviewURLString();
  1132.                 }
  1133.                 return url;
  1134.             }else{
  1135.                 throw new DriverRegistroServiziNotFound("Ruolo (definizione XML) non trovate");
  1136.             }
  1137.         }
  1138.         catch (DriverRegistroServiziNotFound e){
  1139.             throw e;
  1140.         }
  1141.         catch(Exception e){
  1142.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlRuolo]: "+e.getMessage(),e);
  1143.         }
  1144.     }
  1145.    
  1146.    
  1147.    
  1148.    
  1149.    
  1150.    
  1151.    
  1152.    
  1153.    
  1154.    
  1155.    
  1156.    
  1157.    
  1158.    
  1159.    
  1160.    
  1161.     /* ******** M E T O D I   S C O P E   ******** */


  1162.    
  1163.     /**
  1164.      * Si occupa di recuperare il TModel che registra il scope con nome <var>nome</var>
  1165.      *
  1166.      * @param nome nome che identifica il scope
  1167.      * @return la TModel che registra il scope
  1168.      */
  1169.     public TModel getScope(String nome) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1170.         return this.getTModel(UDDILib.SCOPE, UDDILib.SCOPE_PREFIX+nome);
  1171.     }
  1172.    
  1173.     /**
  1174.      * Si occupa di recuperare le TModels che soddisfano il filtro
  1175.      *
  1176.      * @param urlRepository Url del Repository
  1177.      * @return una lista di TModel che registra i scope
  1178.      */
  1179.     public TModel[] getScopes(String urlRepository) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1180.         return this.getTModelByFilter(UDDILib.SCOPE, UDDILib.SCOPE_PREFIX, urlRepository, false);
  1181.     }
  1182.    
  1183.     /**
  1184.      * Si occupa di registrare come TModel un scope con nome <var>nome</var>
  1185.      *
  1186.      * @param nome Nome che identifica il scope
  1187.      * @param url url del file XML associato al scope
  1188.      */
  1189.     public void createScope(String nome, String url) throws DriverRegistroServiziException{
  1190.         this.createTModel(UDDILib.SCOPE, UDDILib.SCOPE_PREFIX+ nome, url);
  1191.     }

  1192.     /**
  1193.      * Il metodo si occupa di verificare se nel registro e' regitrata una TModel identificata dal parametro
  1194.      *
  1195.      * @param nome Nome del scope
  1196.      * @return true se la TModel risulta registrata, false altrimenti
  1197.      *
  1198.      */
  1199.     public boolean existsScope(String nome) throws DriverRegistroServiziException{
  1200.        
  1201.         if ( nome==null )
  1202.             throw new DriverRegistroServiziException("[UDDILib.existsScope]: Alcuni parametri non definiti");
  1203.         try{
  1204.             TModel t = getTModel(UDDILib.SCOPE, UDDILib.SCOPE_PREFIX+nome);
  1205.             if(t == null)
  1206.                 throw new Exception("TModel is null");
  1207.         }catch(DriverRegistroServiziNotFound e){
  1208.             return false;
  1209.         }catch(Exception e){
  1210.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1211.         }
  1212.         return true;    
  1213.     }

  1214.     /**
  1215.      * Si occupa di modificare il nome della TModel che registra il scope con nome <var>nomeOLD</var>
  1216.      *
  1217.      * @param nomeOLD vecchio nome che identifica il scope
  1218.      * @param nomeNEW nuovo nome che identifica il scope
  1219.      * @param url nuova url del file XML associato al scope
  1220.      */
  1221.     public void updateScope(String nomeOLD,String nomeNEW,String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1222.         this.updateTModel(UDDILib.SCOPE, UDDILib.SCOPE_PREFIX+nomeOLD, UDDILib.SCOPE_PREFIX+nomeNEW, url);
  1223.     }

  1224.     /**
  1225.      * Il metodo si occupa di cancellare la TModel identificata dal parametro
  1226.      *
  1227.      * @param nome nome che identifica il scope
  1228.      */
  1229.     public void deleteScope(String nome) throws DriverRegistroServiziException{
  1230.         this.deleteTModel(UDDILib.SCOPE, UDDILib.SCOPE_PREFIX+nome);
  1231.     }

  1232.     /**
  1233.      * Il metodo si occupa di impostare la url del file XML della TModel
  1234.      *
  1235.      * @param nome Nome che identifica il scope
  1236.      * @param url url del file XML associato al scope
  1237.      */
  1238.     public void updateUrlXmlScope(String nome, String url) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1239.         this.updateUrlXmlTModel(UDDILib.SCOPE, UDDILib.SCOPE_PREFIX+nome, url);
  1240.     }
  1241.     /**
  1242.      * Si occupa di recuperare la URL dell'XML associato al scope
  1243.      * registrato con il nome <var>nome</var>
  1244.      *
  1245.      * @param nome Nome che identifica il scope
  1246.      * @return la url dell'XML associato al scope
  1247.      *
  1248.      */
  1249.     public String getUrlXmlScope(String nome) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1250.         if ( nome==null )
  1251.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlScope]: Alcuni parametri non definiti");
  1252.         try{
  1253.             TModel tm = getTModel(UDDILib.SCOPE, UDDILib.SCOPE_PREFIX+nome);
  1254.             return tm.getOverviewDoc().getOverviewURLString();
  1255.         }catch(DriverRegistroServiziNotFound e){
  1256.             throw e;
  1257.         }catch(Exception e){
  1258.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlScope]: "+e.getMessage(),e);
  1259.         }
  1260.     }
  1261.    
  1262.     /**
  1263.      * Si occupa di recuperare la URL dell'XML associato al scope
  1264.      * registrata con il nome <var>nome</var>
  1265.      *
  1266.      * @param searchNome Nome che identifica il scope
  1267.      * @return la url dell'XML associato al scope
  1268.      *
  1269.      */
  1270.     public String[] getUrlXmlScope(String searchNome,String urlRepository) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1271.         try{
  1272.             TModel[] tm = null;
  1273.             if(searchNome!=null){
  1274.                 tm = getTModelByFilter(UDDILib.SCOPE, UDDILib.SCOPE_PREFIX+searchNome,urlRepository,true);
  1275.             }else{
  1276.                 tm = getTModelByFilter(UDDILib.SCOPE, UDDILib.SCOPE_PREFIX,urlRepository,false);
  1277.             }
  1278.            
  1279.             if(tm!=null){
  1280.                 String[] url = new String[tm.length];
  1281.                 for(int i=0; i<tm.length; i++){
  1282.                     url[i] = tm[i].getOverviewDoc().getOverviewURLString();
  1283.                 }
  1284.                 return url;
  1285.             }else{
  1286.                 throw new DriverRegistroServiziNotFound("Scope (definizione XML) non trovate");
  1287.             }
  1288.         }
  1289.         catch (DriverRegistroServiziNotFound e){
  1290.             throw e;
  1291.         }
  1292.         catch(Exception e){
  1293.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlScope]: "+e.getMessage(),e);
  1294.         }
  1295.     }
  1296.    
  1297.    
  1298.    
  1299.    
  1300.    
  1301.    
  1302.    
  1303.    
  1304.    
  1305.    
  1306.    
  1307.    
  1308.    
  1309.    




  1310.     /* ------------------- (Business Entity)  --------------------- */

  1311.     /**
  1312.      * Il metodo si occupa di cercare all'interno del registro le businessEntity che hanno un match con
  1313.      * i valori passati per parametro.
  1314.      *
  1315.      * @param idSogg del Soggetto.
  1316.      * @return un oggetto BusinessEntity se la ricerca ha successo, null altrimenti.
  1317.      */
  1318.     protected BusinessEntity getBusinessEntity(IDSoggetto idSogg) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1319.        
  1320.         if ( (idSogg==null) || (idSogg.getNome()==null) || (idSogg.getTipo()==null))
  1321.             throw new DriverRegistroServiziException("[UDDILib.getBusinessEntity]: Alcuni parametri non definiti");
  1322.        
  1323.         String keyBE = idSogg.getTipo() + "/" + idSogg.getNome();

  1324.         BusinessEntity be=null;
  1325.         try{
  1326.             Vector<Name> names = new Vector<Name>();
  1327.             names.add(new Name("%"));
  1328.             IdentifierBag identifierBag= new IdentifierBag();
  1329.             KeyedReference k1 = new KeyedReference();
  1330.             k1.setKeyValue(keyBE);
  1331.             k1.setTModelKey(this.tmkID);
  1332.             Vector<KeyedReference> keyedReferenceVector = new Vector<KeyedReference>();
  1333.             keyedReferenceVector.add(k1);
  1334.             identifierBag.setKeyedReferenceVector(keyedReferenceVector);
  1335.             BusinessList businessList = this.proxy.find_business(names, null, identifierBag, null, null, null, 1);
  1336.             if(businessList.getBusinessInfos()==null || businessList.getBusinessInfos().size()==0)
  1337.                 throw new DriverRegistroServiziNotFound("BusinessEntity non trovata");
  1338.             Vector<?> businessInfoVector  = businessList.getBusinessInfos().getBusinessInfoVector();
  1339.             BusinessInfo bi = (BusinessInfo) businessInfoVector.elementAt(0);
  1340.             BusinessDetail bd = this.proxy.get_businessDetail(bi.getBusinessKey());
  1341.             Vector<?> v = bd.getBusinessEntityVector();
  1342.             be = (BusinessEntity) v.elementAt(0);
  1343.         }
  1344.         catch (UDDIException e){
  1345.             throw new DriverRegistroServiziException("[UDDILib.getBusinessEntity]: "+e.getMessage(),e);
  1346.         }
  1347.         catch (TransportException e){
  1348.             throw new DriverRegistroServiziException("[UDDILib.getBusinessEntity]: "+e.getMessage(),e);
  1349.         }
  1350.         catch (DriverRegistroServiziNotFound e){
  1351.             throw e;
  1352.         }
  1353.         catch (Exception e){
  1354.             throw new DriverRegistroServiziException("[UDDILib.getBusinessEntity]: "+e.getMessage(),e);
  1355.         }
  1356.        
  1357.         return be;
  1358.     }
  1359.    
  1360.     /**
  1361.      * Il metodo si occupa di cercare all'interno del registro le businessEntity che hanno un match con
  1362.      * i valori passati per parametro.
  1363.      *
  1364.      * @return un oggetto BusinessEntity se la ricerca ha successo, null altrimenti.
  1365.      */
  1366.     protected BusinessEntity[] getBusinessEntities() throws DriverRegistroServiziException,DriverRegistroServiziNotFound{

  1367.         try{
  1368.             Vector<Name> names = new Vector<Name>();
  1369.             names.add(new Name("%"));
  1370.            
  1371.             Vector<BusinessEntity> bus = new Vector<BusinessEntity>();
  1372.             BusinessList businessList = this.proxy.find_business(names, null, null, null, null, null, UDDILib.MAX_SEARCH);
  1373.             if(businessList!=null && businessList.getBusinessInfos()!=null){
  1374.                 Vector<?> businessInfoVector  = businessList.getBusinessInfos().getBusinessInfoVector();
  1375.                 for(int i=0; i<businessInfoVector.size(); i++){
  1376.                     BusinessInfo bi = (BusinessInfo) businessInfoVector.elementAt(i);
  1377.                     BusinessDetail bd = this.proxy.get_businessDetail(bi.getBusinessKey());
  1378.                     Vector<?> v = bd.getBusinessEntityVector();
  1379.                     BusinessEntity be = (BusinessEntity) v.elementAt(0);
  1380.                     bus.add(be);
  1381.                 }
  1382.             }
  1383.            
  1384.             if(bus.size()>0){
  1385.                 BusinessEntity[] be = new BusinessEntity[1];
  1386.                 be = bus.toArray(be);
  1387.                 return be;
  1388.             }else{
  1389.                 throw new DriverRegistroServiziNotFound("Non sono state trovate BusinessEntity nel registro UDDI");
  1390.             }
  1391.         }
  1392.         catch (UDDIException e){
  1393.             throw new DriverRegistroServiziException("[UDDILib.getBusinessEntity]: "+e.getMessage(),e);
  1394.         }
  1395.         catch (TransportException e){
  1396.             throw new DriverRegistroServiziException("[UDDILib.getBusinessEntity]: "+e.getMessage(),e);
  1397.         }
  1398.         catch (DriverRegistroServiziNotFound e){
  1399.             throw e;
  1400.         }
  1401.         catch (Exception e){
  1402.             throw new DriverRegistroServiziException("[UDDILib.getBusinessEntity]: "+e.getMessage(),e);
  1403.         }
  1404.     }

  1405.     /**
  1406.      * Il metodo si occupa di aggiungere nel registro una nuova BusinessEntity
  1407.      * con tipo di identificativo 'tipo' e codice identificativo 'codice'.
  1408.      *  
  1409.      * @param idSogg del Soggetto.
  1410.      * @return la BusinessEntity inserita, se l'inserimento ha successo
  1411.      */
  1412.     protected BusinessEntity addBusinessEntity(IDSoggetto idSogg)throws DriverRegistroServiziException{
  1413.        
  1414.         if ( (idSogg==null) || (idSogg.getNome()==null) || (idSogg.getTipo()==null) || (idSogg.getCodicePorta()==null))
  1415.             throw new DriverRegistroServiziException("[UDDILib.addBusinessEntity]: Alcuni parametri non definiti");

  1416.         String keyBE =  idSogg.getTipo() + "/" + idSogg.getNome();

  1417.         try{
  1418.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  1419.             KeyedReference k1 = new KeyedReference();
  1420.             k1.setKeyName(idSogg.getCodicePorta());
  1421.             k1.setKeyValue(keyBE);  
  1422.             k1.setTModelKey(this.tmkID);

  1423.             Vector<KeyedReference> keyedReferenceVector1 = new Vector<KeyedReference>();
  1424.             keyedReferenceVector1.add(k1);

  1425.             BusinessEntity be = new BusinessEntity("",keyBE);

  1426.             IdentifierBag ib = new IdentifierBag();
  1427.             ib.setKeyedReferenceVector(keyedReferenceVector1);
  1428.             be.setIdentifierBag(ib);

  1429.             CategoryBag cb = new CategoryBag();
  1430.             be.setCategoryBag(cb);

  1431.             Vector<BusinessEntity> entities = new Vector<BusinessEntity>();
  1432.             entities.addElement(be);

  1433.             BusinessDetail bd = this.proxy.save_business(token.getAuthInfoString(),entities);

  1434.             Vector<?> businessEntities = bd.getBusinessEntityVector();
  1435.             be = (BusinessEntity) businessEntities.elementAt(0);

  1436.             return be;
  1437.         }
  1438.         catch (UDDIException e){
  1439.             throw new DriverRegistroServiziException("[UDDILib.addBusinessEntity]: "+e.getMessage(),e);
  1440.         }
  1441.         catch (TransportException e){
  1442.             throw new DriverRegistroServiziException("[UDDILib.addBusinessEntity]: "+e.getMessage(),e);
  1443.         }
  1444.         catch (Exception e){
  1445.             throw new DriverRegistroServiziException("[UDDILib.addBusinessEntity]: "+e.getMessage(),e);
  1446.         }

  1447.     }
  1448.    
  1449.     /**
  1450.      * Si occupa di cancellare la BusinessEntity identificata dai parametri
  1451.      *
  1452.      *@param idSogg Identificativo del soggetto
  1453.      */
  1454.     protected void deleteBusinessEntity(IDSoggetto idSogg) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1455.         if ( (idSogg==null) || (idSogg.getNome()==null) || (idSogg.getTipo()==null) )
  1456.             throw new DriverRegistroServiziException("[UDDILib.deleteBusinessEntity]: Alcuni parametri non definiti");

  1457.         try{
  1458.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  1459.             BusinessEntity be = getBusinessEntity(idSogg);
  1460.             this.proxy.delete_business(token.getAuthInfoString(), be.getBusinessKey());
  1461.         }catch (DriverRegistroServiziNotFound e){
  1462.             throw e;
  1463.         }catch(Exception e){
  1464.             throw new DriverRegistroServiziException("[UDDILib.deleteBusinessEntity]: "+e.getMessage(),e);
  1465.         }
  1466.     }
  1467.    
  1468.     /**
  1469.      * Il metodo assegna alla BusinessEntity <var>be</var> la descrizione <var>descrizione</var>
  1470.      *
  1471.      * @param be Business Entity
  1472.      * @param nome Nome da assegnare alla Business Entity
  1473.      * @return la BusinessEntity modificata, se la modifica ha successo
  1474.      */
  1475.     protected BusinessEntity updateNomeBusinessEntity(BusinessEntity be, String nome)throws DriverRegistroServiziException{
  1476.         if ( (be==null) || (nome==null) )
  1477.             throw new DriverRegistroServiziException("[UDDILib.updateNomeBusinessEntity]: Alcuni parametri non definiti");

  1478.         try{
  1479.             be.setDefaultName(new Name(nome));    
  1480.             Vector<BusinessEntity> entities = new Vector<BusinessEntity>();
  1481.             entities.addElement(be);
  1482.            
  1483.             AuthToken token = this.proxy.get_authToken(this.username,this.password);
  1484.             this.proxy.save_business(token.getAuthInfoString(),entities);
  1485.         }
  1486.         catch (UDDIException e){
  1487.             throw new DriverRegistroServiziException("[UDDILib.updateDescrizioneBusinessEntity]: "+e.getMessage(),e);
  1488.         }
  1489.         catch (TransportException e){
  1490.             throw new DriverRegistroServiziException("[UDDILib.updateDescrizioneBusinessEntity]: "+e.getMessage(),e);
  1491.         }
  1492.         catch (Exception e){
  1493.             throw new DriverRegistroServiziException("[UDDILib.updateDescrizioneBusinessEntity]: "+e.getMessage(),e);
  1494.         }
  1495.         return be;
  1496.     }
  1497.    
  1498.     /**
  1499.      * Il metodo si recuperare il nome della BusinessEntity <var>be</var>.
  1500.      *
  1501.      * @param be Business Entity
  1502.      * @return il nome della BusinessEntity.
  1503.      */
  1504.     protected String getNomeBusinessEntity(BusinessEntity be)throws DriverRegistroServiziException{
  1505.         if (be==null)
  1506.             throw new DriverRegistroServiziException("[UDDILib.getNomeBusinessEntity]: Alcuni parametri non definiti");
  1507.         try{
  1508.             return be.getDefaultName().getText();
  1509.         }catch (Exception e){
  1510.             throw new DriverRegistroServiziException("[UDDILib.getNomeBusinessEntity]: "+e.getMessage(),e);
  1511.         }
  1512.     }
  1513.    
  1514.     /**
  1515.      * Il metodo si occupa di aggiungere alla BusinessEntity <var>be</var> una maggiore descrizione
  1516.      * passata nel parametro <var>descrizione</var>.
  1517.      * @param be Business Entity
  1518.      * @param descrizione Descrizione associata al Soggetto
  1519.      * @return la BusinessEntity modificata se tutto e' andato bene.
  1520.      */
  1521.     protected BusinessEntity updateDescrizioneBusinessEntity(BusinessEntity be, String descrizione)throws DriverRegistroServiziException{
  1522.         if ( (be==null) || (descrizione==null) )
  1523.             throw new DriverRegistroServiziException("[UDDILib.updateDescrizioneBusinessEntity]: Alcuni parametri non definiti");

  1524.         try{
  1525.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  1526.             be.setDefaultDescriptionString(descrizione);

  1527.             Vector<BusinessEntity> entities = new Vector<BusinessEntity>();
  1528.             entities.addElement(be);

  1529.             this.proxy.save_business(token.getAuthInfoString(),entities);
  1530.         }
  1531.         catch (UDDIException e){
  1532.             throw new DriverRegistroServiziException("[UDDILib.updateDescrizioneBusinessEntity]: "+e.getMessage(),e);
  1533.         }
  1534.         catch (TransportException e){
  1535.             throw new DriverRegistroServiziException("[UDDILib.updateDescrizioneBusinessEntity]: "+e.getMessage(),e);
  1536.         }
  1537.         catch (Exception e){
  1538.             throw new DriverRegistroServiziException("[UDDILib.updateDescrizioneBusinessEntity]: "+e.getMessage(),e);
  1539.         }
  1540.         return be;
  1541.     }
  1542.    
  1543.     /**
  1544.      * Il metodo si occupa di settare nella BusinessEntity <var>be</var> una category bag
  1545.      * contenente come valore la url dell'xml associato al Soggetto.
  1546.      *
  1547.      * @param be Business Entity
  1548.      * @param url url del file XML associato al soggetto.
  1549.      * @return la BusinessEntity modificata in caso di successo, null altrimenti.
  1550.      */
  1551.     protected BusinessEntity updateUrlXmlBusinessEntity(BusinessEntity be, String url)throws DriverRegistroServiziException{
  1552.         if ( (be==null) || (url==null))
  1553.             throw new DriverRegistroServiziException("[UDDILib.updateUrlXmlBusinessEntity]: Alcuni parametri non definiti");

  1554.         try{
  1555.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  1556.             KeyedReference k1 = new KeyedReference();
  1557.             k1.setKeyName(org.openspcoop2.utils.Costanti.OPENSPCOOP2);
  1558.             k1.setKeyValue(url);
  1559.             Vector<BusinessEntity> entities = new Vector<BusinessEntity>();
  1560.             CategoryBag ib = be.getCategoryBag();
  1561.             if(ib == null)
  1562.                 ib = new CategoryBag();
  1563.             ib.add(k1);
  1564.             be.setCategoryBag(ib);
  1565.             entities.addElement(be);
  1566.             this.proxy.save_business(token.getAuthInfoString(),entities);      
  1567.         }
  1568.         catch (UDDIException e){
  1569.             throw new DriverRegistroServiziException("[UDDILib.updateUrlXmlBusinessEntity]: "+e.getMessage(),e);
  1570.         }
  1571.         catch (TransportException e){
  1572.             throw new DriverRegistroServiziException("[UDDILib.updateUrlXmlBusinessEntity]: "+e.getMessage(),e);
  1573.         }
  1574.         catch (Exception e){
  1575.             throw new DriverRegistroServiziException("[UDDILib.updateUrlXmlBusinessEntity]: "+e.getMessage(),e);
  1576.         }

  1577.         return be;
  1578.     }
  1579.    
  1580.     /**
  1581.      * Il metodo si occupa di impostare il keyName della category bag del soggetto
  1582.      *
  1583.      * @param idSogg Identificativo del Soggetto
  1584.      * @param categoryBagName
  1585.      */
  1586.     protected void updateCategoryBagKeyNameBusinessEntity(IDSoggetto idSogg,String categoryBagName) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1587.         if ( (idSogg==null) || (idSogg.getNome()==null) || (idSogg.getTipo()==null) || (categoryBagName==null))
  1588.             throw new DriverRegistroServiziException("[UDDILib.updateCategoryBagKeyNameBusinessEntity]: Alcuni parametri non definiti");

  1589.         try{
  1590.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  1591.             BusinessEntity be = getBusinessEntity(idSogg);  

  1592.             CategoryBag cb = be.getCategoryBag();
  1593.             Vector<?> krv = cb.getKeyedReferenceVector();
  1594.             KeyedReference kr = (KeyedReference) krv.elementAt(0);
  1595.             kr.setKeyName(categoryBagName);
  1596.             cb.setKeyedReferenceVector(krv);
  1597.             be.setCategoryBag(cb);
  1598.             Vector<BusinessEntity> entities = new Vector<BusinessEntity>();
  1599.             entities.addElement(be);

  1600.             this.proxy.save_business(token.getAuthInfoString(),entities);

  1601.         }catch (DriverRegistroServiziNotFound e){
  1602.             throw e;
  1603.         }
  1604.         catch (Exception e){
  1605.             throw new DriverRegistroServiziException("[UDDILib.updateCategoryBagKeyNameBusinessEntity]: "+e.getMessage(),e);
  1606.         }
  1607.     }
  1608.    
  1609.    
  1610.    
  1611.    
  1612.    
  1613.    
  1614.    
  1615.    
  1616.    
  1617.    
  1618.     /* --------------- Soggetto -------------------*/
  1619.    
  1620.     /**
  1621.      * Il metodo si occupa di aggiungere nel registro un nuovo Soggetto.
  1622.      *
  1623.      * @param idSogg Identificativo del soggetto
  1624.      * @param descrizione Descrizione da assegnare al Soggetto
  1625.      * @param urlXML url dell'XML associato al Soggetto.
  1626.      */
  1627.     public void createSoggetto(IDSoggetto idSogg,
  1628.             String descrizione, String urlXML)throws DriverRegistroServiziException{

  1629.         if ( (idSogg==null) || (idSogg.getNome()==null) || (idSogg.getTipo()==null)||
  1630.                 (descrizione==null) ||  (idSogg.getCodicePorta()==null) || (urlXML==null)){
  1631.             throw new DriverRegistroServiziException("[UDDILib.createSoggetto]: Alcuni parametri non definiti");
  1632.         }

  1633.         try{
  1634.             // add BusinessEntity
  1635.             BusinessEntity be = addBusinessEntity(idSogg);
  1636.            
  1637.             // set Descrizione in BusinessEntity
  1638.             try{
  1639.                 be=updateNomeBusinessEntity(be,descrizione);
  1640.             }catch(Exception e){
  1641.                 try{
  1642.                     //rollback quanto fatto prima
  1643.                     deleteBusinessEntity(idSogg);
  1644.                 }catch(Exception rollbackE){
  1645.                     // ignore
  1646.                 }
  1647.                 throw e; // rilancio l'eccezione
  1648.             }

  1649.             // set url XML nella BusinessEntity
  1650.             try{
  1651.                 updateUrlXmlBusinessEntity(be,urlXML);
  1652.             }catch(Exception e){
  1653.                 try{
  1654.                     //rollback quanto fatto prima
  1655.                     deleteBusinessEntity(idSogg);
  1656.                 }catch(Exception rollbackE){
  1657.                     // ignore
  1658.                 }
  1659.                 throw e; // rilancio l'eccezione
  1660.             }

  1661.         }catch(Exception e){
  1662.             throw new DriverRegistroServiziException("[UDDILib.createSoggetto]: "+e.getMessage(),e);
  1663.                     }
  1664.     }
  1665.    
  1666.     /**
  1667.      * Il metodo si occupa di verificare se nel registro e' regitrato un Soggetto identificato dai parametri
  1668.      *
  1669.      * @param idSogg del Soggetto
  1670.      * @return true se il Soggetto risulta registrato, false altrimenti
  1671.      */
  1672.     public boolean existsSoggetto(IDSoggetto idSogg)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1673.         if ( idSogg==null )
  1674.             throw new DriverRegistroServiziException("[UDDILib.existsSoggetto]: Alcuni parametri non definiti");
  1675.         BusinessEntity be = null;
  1676.         try{
  1677.             be = getBusinessEntity(idSogg);
  1678.             if(be == null)
  1679.                 throw new Exception("BusinessEntity is null");
  1680.         }catch (DriverRegistroServiziNotFound e){
  1681.             return false;
  1682.         }
  1683.         catch(Exception e){
  1684.             throw new DriverRegistroServiziException(e.getMessage(),e);
  1685.         }
  1686.         return true;
  1687.     }

  1688.     /**
  1689.      * Il metodo si occupa di recuperare l'url del file XML del Soggetto.
  1690.      *
  1691.      * @param idSogg Identificativo del Soggetto
  1692.      */
  1693.     public String getUrlXmlSoggetto(IDSoggetto idSogg)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1694.         if ( idSogg==null )
  1695.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlSoggetto]: Alcuni parametri non definiti");
  1696.         try
  1697.         {
  1698.             BusinessEntity be =  getBusinessEntity(idSogg);
  1699.             return be.getCategoryBag().get(0).getKeyValue();
  1700.         }
  1701.         catch (DriverRegistroServiziNotFound e){
  1702.             throw e;
  1703.         }
  1704.         catch (Exception e){
  1705.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlSoggetto]: "+e.getMessage(),e);
  1706.         }
  1707.     }      
  1708.    
  1709.     /**
  1710.      * Il metodo si occupa di recuperare l'url del file XML del Soggetto.
  1711.      *
  1712.      */
  1713.     public String[] getUrlXmlSoggetti()throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1714.         try
  1715.         {
  1716.             BusinessEntity[] be =  getBusinessEntities();
  1717.             String [] url = new String[be.length];
  1718.             for(int i=0; i<be.length; i++){
  1719.                 url[i] = be[i].getCategoryBag().get(0).getKeyValue();
  1720.             }
  1721.             return url;
  1722.         }
  1723.         catch (DriverRegistroServiziNotFound e){
  1724.             throw e;
  1725.         }
  1726.         catch (Exception e){
  1727.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlSoggetto]: "+e.getMessage(),e);
  1728.         }
  1729.     }      

  1730.     /**
  1731.      * Il metodo si occupa di impostare la url del file XML associato al Soggetto
  1732.      *
  1733.      * @param idSogg Identificativo del Soggetto
  1734.      * @param url Url da impostare
  1735.      */
  1736.     public void updateUrlXmlSoggetto(IDSoggetto idSogg,String url)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1737.         if ( idSogg==null  || url==null)
  1738.             throw new DriverRegistroServiziException("[UDDILib.updateUrlXmlSoggetto]: Alcuni parametri non definiti");
  1739.    
  1740.         try{
  1741.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  1742.             BusinessEntity be = getBusinessEntity(idSogg);  

  1743.             CategoryBag cb = be.getCategoryBag();
  1744.             Vector<?> krv = cb.getKeyedReferenceVector();
  1745.             KeyedReference kr = (KeyedReference) krv.elementAt(0);
  1746.             kr.setKeyValue(url);
  1747.             cb.setKeyedReferenceVector(krv);
  1748.             be.setCategoryBag(cb);
  1749.             Vector<BusinessEntity> entities = new Vector<BusinessEntity>();
  1750.             entities.addElement(be);

  1751.             this.proxy.save_business(token.getAuthInfoString(),entities);

  1752.         }catch (DriverRegistroServiziNotFound e){
  1753.             throw e;
  1754.         }
  1755.         catch (Exception e){
  1756.             throw new DriverRegistroServiziException("[UDDILib.updateUrlXmlSoggetto]: "+e.getMessage(),e);
  1757.         }
  1758.     }

  1759.     /**
  1760.      * Il metodo si occupa di impostare la descrizione associata al Soggetto
  1761.      *
  1762.      * @param idSogg Identificativo del Soggetto
  1763.      * @param descrizione Descrizione da associare al soggetto
  1764.      */
  1765.     public void updateDescrizioneSoggetto(IDSoggetto idSogg,String descrizione) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1766.         if ( idSogg==null  || descrizione==null)
  1767.             throw new DriverRegistroServiziException("[UDDILib.updateDescrizioneSoggetto]: Alcuni parametri non definiti");

  1768.         try{
  1769.             BusinessEntity be = getBusinessEntity(idSogg);
  1770.             updateNomeBusinessEntity(be,descrizione);
  1771.         }
  1772.         catch (DriverRegistroServiziNotFound e){
  1773.             throw e;
  1774.         }
  1775.         catch (Exception e){
  1776.             throw new DriverRegistroServiziException("[UDDILib.updateDescrizioneSoggetto]: "+e.getMessage(),e);
  1777.         }
  1778.     }

  1779.     /**
  1780.      * Il metodo si occupa di modificare il codice tipo/valore associato al Soggetto
  1781.      *
  1782.      * @param idSoggOLD Vecchio identificativo del Soggetto
  1783.      * @param idSoggNEW Nuovo identificativo del Soggetto
  1784.      */
  1785.     public void updateIdSoggetto(IDSoggetto idSoggOLD,IDSoggetto idSoggNEW)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1786.         if ( (idSoggOLD==null) || (idSoggOLD.getNome()==null) || (idSoggOLD.getTipo()==null) ||
  1787.              (idSoggNEW==null) || (idSoggNEW.getNome()==null) || (idSoggNEW.getTipo()==null))
  1788.             throw new DriverRegistroServiziException("[UDDILib.updateIdSoggetto]: Alcuni parametri non definiti");

  1789.         try{
  1790.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  1791.             BusinessEntity be = getBusinessEntity(idSoggOLD);
  1792.    
  1793.             IdentifierBag ib = be.getIdentifierBag();
  1794.             Vector<?> v = ib.getKeyedReferenceVector();
  1795.             KeyedReference kr = (KeyedReference) v.elementAt(0);

  1796.             String newValue = idSoggNEW.getTipo() + "/" + idSoggNEW.getNome();

  1797.             kr.setKeyValue(newValue);
  1798.             ib.setKeyedReferenceVector(v);
  1799.             be.setIdentifierBag(ib);

  1800.             Vector<BusinessEntity> entities = new Vector<BusinessEntity>();
  1801.             entities.addElement (be);

  1802.             BusinessDetail bd = this.proxy.save_business(token.getAuthInfoString(),entities);

  1803.             Vector<?> businessEntities = bd.getBusinessEntityVector();
  1804.             be = (BusinessEntity) businessEntities.elementAt (0);
  1805.         }
  1806.         catch (DriverRegistroServiziNotFound e){
  1807.             throw e;
  1808.         }
  1809.         catch (Exception e){
  1810.             throw new DriverRegistroServiziException("[UDDILib.updateIdSoggetto]: "+e.getMessage(),e);
  1811.         }
  1812.     }


  1813.     /**
  1814.      * Si occupa di cancellare il Soggetto identificata dai parametri
  1815.      *
  1816.      * @param idSogg Identificativo del soggetto
  1817.      */
  1818.     public void deleteSoggetto(IDSoggetto idSogg)throws DriverRegistroServiziException{
  1819.         if ( idSogg==null )
  1820.             throw new DriverRegistroServiziException("[UDDILib.deleteSoggetto]: Alcuni parametri non definiti");
  1821.         try{
  1822.             deleteBusinessEntity(idSogg);
  1823.         }catch(Exception e){
  1824.             throw new DriverRegistroServiziException("[UDDILib.deleteSoggetto]: "+e.getMessage(),e);
  1825.         }
  1826.     }

  1827.     /**
  1828.      * Il metodo si occupa di impostare il codice della porta di dominio associato al Soggetto
  1829.      *
  1830.      * @param idSogg Identificativo del Soggetto
  1831.      * @param newIdentificativoPorta Nuovo codice di dominio associare al soggetto
  1832.      */
  1833.     public void updateIdentificativoPortaSoggetto(IDSoggetto idSogg,String newIdentificativoPorta)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1834.         if ( idSogg==null || newIdentificativoPorta==null)
  1835.             throw new DriverRegistroServiziException("[UDDILib.updateIdentificativoPortaSoggetto]: Alcuni parametri non definiti");
  1836.    
  1837.         try{
  1838.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  1839.             BusinessEntity be = getBusinessEntity(idSogg);

  1840.             IdentifierBag ib = be.getIdentifierBag();
  1841.             Vector<?> v = ib.getKeyedReferenceVector();
  1842.             KeyedReference kr = (KeyedReference) v.elementAt(0);
  1843.             kr.setKeyName(newIdentificativoPorta);
  1844.             ib.setKeyedReferenceVector(v);
  1845.             be.setIdentifierBag(ib);

  1846.             Vector<BusinessEntity> entities = new Vector<BusinessEntity>();
  1847.             entities.addElement (be);

  1848.             BusinessDetail bd = this.proxy.save_business(token.getAuthInfoString(),entities);

  1849.             Vector<?> businessEntities = bd.getBusinessEntityVector();
  1850.             be = (BusinessEntity) businessEntities.elementAt (0);
  1851.         }
  1852.         catch (DriverRegistroServiziNotFound e){
  1853.             throw e;
  1854.         }
  1855.         catch (Exception e){
  1856.             throw new DriverRegistroServiziException("[UDDILib.updateIdentificativoPortaSoggetto]: Alcuni parametri non definiti");
  1857.         }
  1858.     }
























  1859.     /* ********  M E T O D I   PRIVATI    ******** */

  1860.     /**
  1861.      * Il metodo si occupa di cercare all'interno del registro il servizio associato
  1862.      * ad una BusinessEntity di nome <var>serviceName</var>
  1863.      * Ritorna null in caso il servizio risulti non registrato.
  1864.      *
  1865.      * @param be BusinessEntity.
  1866.      * @param idServ Identificativo del Servizio
  1867.      * @return un oggetto BusinessService se la ricerca ha successo
  1868.      */
  1869.     protected BusinessService getBusinessService(BusinessEntity be, IDServizio idServ) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  1870.         if ( be==null || idServ==null || idServ.getTipo()==null || idServ.getNome()==null || idServ.getVersione()==null)
  1871.             throw new DriverRegistroServiziException("[UDDILib.getBusinessService]: Alcuni parametri non definiti");
  1872.    
  1873.         try{    

  1874.             String keyService = idServ.getTipo() + "/" + idServ.getNome() + ":"+ idServ.getVersione();

  1875.             BusinessService bs=null;

  1876.             Name nome = new Name(keyService);
  1877.             Vector<Name> nomi = new Vector<Name>();
  1878.             nomi.add(nome);
  1879.            
  1880.             FindQualifiers findQualifiers = new FindQualifiers();
  1881.             Vector<FindQualifier> qualifier = new Vector<FindQualifier>();
  1882.             qualifier.add(new FindQualifier(FindQualifier.exactNameMatch));
  1883.             qualifier.add(new FindQualifier(FindQualifier.caseSensitiveMatch));
  1884.             findQualifiers.setFindQualifierVector(qualifier);

  1885.             ServiceList serviceList = this.proxy.find_service(be.getBusinessKey(), nomi, null, null, findQualifiers, 1);
  1886.             if(serviceList.getServiceInfos()==null || serviceList.getServiceInfos().size()==0)
  1887.                 throw new DriverRegistroServiziNotFound("BusinessService non trovata");
  1888.            
  1889.             Vector<?> serviceInfoVector = serviceList.getServiceInfos().getServiceInfoVector();
  1890.             ServiceInfo serviceInfo = (ServiceInfo) serviceInfoVector.elementAt(0);
  1891.             ServiceDetail sd = this.proxy.get_serviceDetail(serviceInfo.getServiceKey());
  1892.             Vector<?> v = sd.getBusinessServiceVector();
  1893.             bs = (BusinessService) v.elementAt(0);

  1894.             return bs;
  1895.         }
  1896.         catch (DriverRegistroServiziNotFound e){
  1897.             throw e;
  1898.         }
  1899.         catch (UDDIException e){
  1900.             throw new DriverRegistroServiziException("[UDDILib.getBusinessService]: "+e.getMessage(),e);
  1901.         }
  1902.         catch (TransportException e){
  1903.             throw new DriverRegistroServiziException("[UDDILib.getBusinessService]: "+e.getMessage(),e);
  1904.         }
  1905.         catch (Exception e){
  1906.             throw new DriverRegistroServiziException("[UDDILib.getBusinessService]: "+e.getMessage(),e);
  1907.         }

  1908.     }
  1909.    
  1910.    

  1911.     /**
  1912.      * Il metodo si occupa di aggiungere nel registro una nuovo servizio con nome <var>serviceName</var>
  1913.      * associandolo alla businessEntity <var>be</var>
  1914.      * In caso un servizio con lo stesso nome sia gia' registrato non non fa niente e ritorna null.
  1915.      *
  1916.      * @param be BusinessEntity.
  1917.      * @param idServ Identificativo del Servizio
  1918.      * @return il BusinessService inserito, se l'inserimento ha successo, null altrimenti.
  1919.      */
  1920.     protected BusinessService createBusinessService(BusinessEntity be, IDServizio idServ) throws DriverRegistroServiziException{
  1921.         if ( be==null || idServ==null || idServ.getTipo()==null || idServ.getNome()==null || idServ.getVersione()==null)
  1922.             throw new DriverRegistroServiziException("[UDDILib.createBusinessService]: Alcuni parametri non definiti");
  1923.    
  1924.         BusinessService bs = null;
  1925.         try{
  1926.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  1927.             String keyService = idServ.getTipo() + "/" + idServ.getNome()+ ":"+idServ.getVersione();

  1928.             String businessKey = be.getBusinessKey();  
  1929.            
  1930.             // verifico che non esista gia' un servizio associato a be
  1931.             try{
  1932.                 bs = getBusinessService(be,idServ);
  1933.             }catch(DriverRegistroServiziNotFound e){
  1934.                 // ignore
  1935.             }
  1936.            
  1937.             /*entro solo se il servizio non e' gia stato registrato*/
  1938.             if(bs==null){
  1939.                 bs = new BusinessService("");
  1940.                 bs.setDefaultNameString(keyService,null);
  1941.                 bs.setBusinessKey(businessKey);
  1942.                 Vector<BusinessService> services = new Vector<BusinessService>();
  1943.                 services.addElement(bs);

  1944.                 ServiceDetail sd = this.proxy.save_service(token.getAuthInfoString(),services);

  1945.                 Vector<?> businessServices = sd.getBusinessServiceVector();
  1946.                 bs = (BusinessService) businessServices.elementAt(0);

  1947.                 BusinessServices bds =  be.getBusinessServices();
  1948.                 bds.add(bs);

  1949.                 be.setBusinessServices(bds);
  1950.                 Vector<BusinessEntity> entities = new Vector<BusinessEntity>();
  1951.                 entities.addElement(be);
  1952.                 this.proxy.save_business(token.getAuthInfoString(),entities);
  1953.             }
  1954.         }
  1955.         catch (UDDIException e){
  1956.             throw new DriverRegistroServiziException("[UDDILib.createBusinessService]: "+e.getMessage(),e);
  1957.         }
  1958.         catch (TransportException e){
  1959.             throw new DriverRegistroServiziException("[UDDILib.createBusinessService]: "+e.getMessage(),e);
  1960.         }
  1961.         catch (Exception e){
  1962.             throw new DriverRegistroServiziException("[UDDILib.createBusinessService]: "+e.getMessage(),e);
  1963.         }
  1964.         return bs;
  1965.     }
  1966.    
  1967.     /**
  1968.      * Si occupa di cancellare il servizio <var>servizio</var> registrato nella BusinessEntity
  1969.      * identificata dai parametri <var>tipo</var> e <var>cod</var>.
  1970.      *
  1971.      * @param idServ Identificativo del Servizio
  1972.      */
  1973.     protected void deleteBusinessService(IDServizio idServ) throws DriverRegistroServiziException{
  1974.         if ( idServ==null || idServ.getTipo()==null || idServ.getNome()==null || idServ.getVersione()==null ||
  1975.                 idServ.getSoggettoErogatore()==null || idServ.getSoggettoErogatore().getTipo()==null || idServ.getSoggettoErogatore().getNome()==null)
  1976.             throw new DriverRegistroServiziException("[UDDILib.deleteBusinessService]: Alcuni parametri non definiti");
  1977.    
  1978.         try{
  1979.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  1980.             FindQualifiers findQualifiers = new FindQualifiers();
  1981.             Vector<FindQualifier> qualifier = new Vector<FindQualifier>();
  1982.             qualifier.add(new FindQualifier(FindQualifier.exactNameMatch));
  1983.             qualifier.add(new FindQualifier(FindQualifier.caseSensitiveMatch));
  1984.             findQualifiers.setFindQualifierVector(qualifier);

  1985.             IdentifierBag ib= new IdentifierBag();
  1986.             KeyedReference k1 = new KeyedReference();
  1987.             String keyBE =  idServ.getSoggettoErogatore().getTipo()+ "/" + idServ.getSoggettoErogatore().getNome();
  1988.             k1.setKeyValue(keyBE);
  1989.             k1.setTModelKey(this.tmkID);

  1990.             Vector<KeyedReference> keyedReferenceVector = new Vector<KeyedReference>();
  1991.             keyedReferenceVector.add(k1);
  1992.             ib.setKeyedReferenceVector(keyedReferenceVector);

  1993.             Vector<Name> names = new Vector<Name>();

  1994.             String keyService = idServ.getTipo() + "/" + idServ.getNome()+":"+idServ.getVersione();

  1995.             names.add(new Name(keyService));

  1996.             BusinessList businessList = this.proxy.find_business(null, null, ib, null, null, null,1);
  1997.             Vector<?> businessInfoVector  = businessList.getBusinessInfos().getBusinessInfoVector();
  1998.             BusinessInfo businessInfo = (BusinessInfo) businessInfoVector.elementAt(0);
  1999.             ServiceList serviceList = this.proxy.find_service(businessInfo.getBusinessKey(),names,null,null,findQualifiers,1);
  2000.             Vector<?> serviceInfoVector = serviceList.getServiceInfos().getServiceInfoVector();
  2001.             ServiceInfo serviceInfo = (ServiceInfo)serviceInfoVector.elementAt(0);

  2002.             this.proxy.delete_service(token.getAuthInfoString(), serviceInfo.getServiceKey());

  2003.         }catch(Exception e){
  2004.             throw new DriverRegistroServiziException("[UDDILib.deleteBusinessService]: "+e.getMessage(),e);
  2005.         }
  2006.     }
  2007.    
  2008.     /**
  2009.      * Il metodo si occupa di ritornare il nome del BusinessService <var>bs</var>.
  2010.      * @param bs BusinessService
  2011.      * @return il nome del servizio se la ricerca ha successo.
  2012.      */
  2013.     protected String getNomeBusinessService(BusinessService bs)throws DriverRegistroServiziException{
  2014.         if ( bs==null )
  2015.             throw new DriverRegistroServiziException("[UDDILib.getNomeBusinessService]: Alcuni parametri non definiti");
  2016.    
  2017.         try{
  2018.             return bs.getDefaultName().getText();
  2019.         }catch(Exception e){
  2020.             throw new DriverRegistroServiziException("[UDDILib.getNomeBusinessService]: "+e.getMessage(),e);
  2021.         }
  2022.     }
  2023.    
  2024.     /**
  2025.      * Il metodo si occupa di assegnare al servizio <var>bs</var> il nome <var>nome</var>
  2026.      *
  2027.      * @param bs BusinessService
  2028.      * @param idServ Identificativo del Servizio
  2029.      * @return la BusinessService modificata, se la modifica ha successo, null altrimenti.
  2030.      */
  2031.     protected BusinessService updateNomeBusinessService(BusinessService bs, IDServizio idServ)throws DriverRegistroServiziException{
  2032.         if (bs==null || idServ==null || idServ.getTipo()==null || idServ.getNome()==null || idServ.getVersione()==null){
  2033.             throw new DriverRegistroServiziException("[UDDILib.updateNomeBusinessService]: Alcuni parametri non definiti");
  2034.         }

  2035.         try{
  2036.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  2037.             String keyService = idServ.getTipo() + "/" + idServ.getNome() + ":" + idServ.getVersione();


  2038.             bs.setDefaultName(new Name(keyService));

  2039.             Vector<BusinessService> services = new Vector<BusinessService>();
  2040.             services.addElement(bs);
  2041.             this.proxy.save_service(token.getAuthInfoString(),services);
  2042.         }
  2043.         catch (UDDIException e){
  2044.             throw new DriverRegistroServiziException("[UDDILib.updateNomeBusinessService]: "+e.getMessage(),e);
  2045.         }
  2046.         catch (TransportException e){
  2047.             throw new DriverRegistroServiziException("[UDDILib.updateNomeBusinessService]: "+e.getMessage(),e);
  2048.         }
  2049.         catch (Exception e){
  2050.             throw new DriverRegistroServiziException("[UDDILib.updateNomeBusinessService]: "+e.getMessage(),e);
  2051.         }

  2052.         return bs;
  2053.     }
  2054.    
  2055.     /**
  2056.      * Il metodo si occupa di cercare all'interno del registro il bindingTemplate che definisce il servizio <var>bs</var>.
  2057.      *
  2058.      * @param bs BusinessService.
  2059.      * @return un BindingTemplate
  2060.      */
  2061.     protected BindingTemplate getBindingTemplate(BusinessService bs)throws DriverRegistroServiziException{
  2062.         if ( bs==null )
  2063.             throw new DriverRegistroServiziException("[UDDILib.getBindingTemplate]: Alcuni parametri non definiti");
  2064.    
  2065.         BindingTemplate bt=null;
  2066.         try{
  2067.            
  2068.             BindingDetail bindingDetailReturned = this.proxy.find_binding(null, bs.getServiceKey(), null, 1);
  2069.             Vector<?> bindingTemplatesFound = bindingDetailReturned.getBindingTemplateVector();
  2070.             bt = (BindingTemplate)(bindingTemplatesFound.elementAt(0));
  2071.         }catch (TransportException e){
  2072.             throw new DriverRegistroServiziException("[UDDILib.getBindingTemplate]: "+e.getMessage(),e);
  2073.         }
  2074.         catch (Exception e){
  2075.             throw new DriverRegistroServiziException("[UDDILib.getBindingTemplate]: "+e.getMessage(),e);
  2076.         }
  2077.         return bt;
  2078.     }
  2079.    
  2080.     /**
  2081.      * Il metodo si occupa di aggiungere nel registro una nuovo bindingTemplate associato al servizio <var>bs</var>      
  2082.      *
  2083.      * @param bs BusinessService.
  2084.      * @return il BindingTemplate inserito, se l'inserimento ha successo
  2085.      */
  2086.     protected BindingTemplate createBindingTemplate(BusinessService bs)throws DriverRegistroServiziException{
  2087.         if ( bs==null )
  2088.             throw new DriverRegistroServiziException("[UDDILib.createBindingTemplate]: Alcuni parametri non definiti");

  2089.         try{
  2090.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  2091.             BindingTemplate bt = null;
  2092.             //BindingTemplates bts = bs.getBindingTemplates();
  2093.             BindingTemplates bts = new BindingTemplates();
  2094.             String serviceKey = bs.getServiceKey();
  2095.             bt = new BindingTemplate();
  2096.             bt.setServiceKey(serviceKey);
  2097.             AccessPoint ap = new AccessPoint();
  2098.             ap.setText("url di default");
  2099.             bt.setAccessPoint(ap);

  2100.             Vector<BindingTemplate> templates = new Vector<BindingTemplate>();
  2101.             templates.addElement(bt);

  2102.             BindingDetail bindingDetail = this.proxy.save_binding(token.getAuthInfoString(),templates);
  2103.             Vector<?> bd = bindingDetail.getBindingTemplateVector();
  2104.             bt = (BindingTemplate) bd.elementAt(bd.size()-1);
  2105.             bts.add(bt);
  2106.             bs.setBindingTemplates(bts);

  2107.             Vector<BusinessService> services = new Vector<BusinessService>();
  2108.             services.addElement(bs);
  2109.             this.proxy.save_service(token.getAuthInfoString(),services);

  2110.             return bt;
  2111.         }
  2112.         catch (UDDIException e){
  2113.             throw new DriverRegistroServiziException("[UDDILib.createBindingTemplate]: "+e.getMessage(),e);
  2114.         }
  2115.         catch (TransportException e){
  2116.             throw new DriverRegistroServiziException("[UDDILib.createBindingTemplate]: "+e.getMessage(),e);
  2117.         }
  2118.         catch (Exception e){
  2119.             throw new DriverRegistroServiziException("[UDDILib.createBindingTemplate]: "+e.getMessage(),e);
  2120.         }
  2121.     }
  2122.    
  2123.     /**
  2124.      * Il metodo si occupa di cercare all'interno del registro il TModel che definisce il servizio a cui e' associato<var>bt</var>
  2125.      * @param bt BindingTemplate.
  2126.      * @return un oggetto Tmodel se la ricerca ha successo
  2127.      */
  2128.     protected TModel getTModel(BindingTemplate bt)throws DriverRegistroServiziException{
  2129.         if ( bt==null )
  2130.             throw new DriverRegistroServiziException("[UDDILib.getTModel]: Alcuni parametri non definiti");
  2131.    
  2132.         TModel tm = null;
  2133.         try{
  2134.             TModelInstanceDetails tmid = bt.getTModelInstanceDetails();
  2135.             TModelInstanceInfo tmii = tmid.get(0);
  2136.             TModelDetail tmd = this.proxy.get_tModelDetail(tmii.getTModelKey());
  2137.             Vector<?> v = tmd.getTModelVector();
  2138.             tm = (TModel) v.elementAt(0);
  2139.         }
  2140.         catch (UDDIException e){
  2141.             throw new DriverRegistroServiziException("[UDDILib.getTModel]: "+e.getMessage(),e);
  2142.         }
  2143.         catch (TransportException e){
  2144.             throw new DriverRegistroServiziException("[UDDILib.getTModel]: "+e.getMessage(),e);
  2145.         }
  2146.         catch (Exception e){
  2147.             throw new DriverRegistroServiziException("[UDDILib.getTModel]: "+e.getMessage(),e);
  2148.         }
  2149.         return tm;
  2150.     }
  2151.    
  2152.     /**
  2153.      * Il metodo si occupa di aggiungere nel registro un TModel associato al bindingTemplate <var>bt</var>
  2154.      *
  2155.      * @param bt BindingTemplate.
  2156.      * @param idAccordo ID dell'accordo di Servizio
  2157.      */
  2158.     protected void createTModelServizio(BindingTemplate bt,IDAccordo idAccordo)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  2159.         if ( bt==null || (idAccordo==null))
  2160.             throw new DriverRegistroServiziException("[UDDILib.createTModelServizio]: Alcuni parametri non definiti");
  2161.    
  2162.         TModel tm = null;
  2163.         try{
  2164.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  2165.             tm = getAccordoServizio(idAccordo);

  2166.             TModelInstanceInfo tmii = new TModelInstanceInfo(tm.getTModelKey());
  2167.             TModelInstanceDetails tmids = new TModelInstanceDetails();
  2168.             tmids.add(tmii);

  2169.             bt.setTModelInstanceDetails(tmids);
  2170.             Vector<BindingTemplate> templates = new Vector<BindingTemplate>();
  2171.             templates.addElement(bt);

  2172.             this.proxy.save_binding(token.getAuthInfoString(),templates);
  2173.         }
  2174.         catch(DriverRegistroServiziNotFound e){
  2175.             throw e;
  2176.         }
  2177.         catch (UDDIException e){
  2178.             throw new DriverRegistroServiziException("[UDDILib.createTModelServizio]: "+e.getMessage(),e);
  2179.         }
  2180.         catch (TransportException e){
  2181.             throw new DriverRegistroServiziException("[UDDILib.createTModelServizio]: "+e.getMessage(),e);
  2182.         }
  2183.         catch (Exception e){
  2184.             throw new DriverRegistroServiziException("[UDDILib.createTModelServizio]: "+e.getMessage(),e);
  2185.         }
  2186.     }
  2187.    
  2188.     /**
  2189.      * Il metodo si occupa di recuperarie l'access point dal BindingTemplate <var>bt</var>.
  2190.      * @param bt BindingTemplate
  2191.      * @return una stringa contenente l'url all'XML del Servizio.
  2192.      */      
  2193.     protected String getAccessPoint(BindingTemplate bt)throws DriverRegistroServiziException{
  2194.         if ( bt==null  )
  2195.             throw new DriverRegistroServiziException("[UDDILib.getAccessPoint]: Alcuni parametri non definiti");
  2196.    
  2197.         try{
  2198.             return bt.getAccessPoint().getText();
  2199.         }catch(Exception e){
  2200.             throw new DriverRegistroServiziException("[UDDILib.getAccessPoint]: "+e.getMessage(),e);
  2201.         }
  2202.     }  
  2203.    
  2204.     /**
  2205.      * Il metodo si occupa di settare l'access point specificato nel parametro<var>URL</var>  
  2206.      * nel BindingTemplate <var>bt</var>.
  2207.      * @param bt BindingTemplate
  2208.      * @param URL URL dell'XML associato al Servizio
  2209.      * @return l'oggetto bindingTemplate modificato se tutto e' andato bene.
  2210.      */    
  2211.     protected BindingTemplate updateAccessPoint(BindingTemplate bt, String URL)throws DriverRegistroServiziException{
  2212.         if ( bt==null || (URL==null) )
  2213.             throw new DriverRegistroServiziException("[UDDILib.updateAccessPoint]: Alcuni parametri non definiti");
  2214.    
  2215.         try{
  2216.             AuthToken token = this.proxy.get_authToken(this.username,this.password);

  2217.             AccessPoint ap = bt.getAccessPoint();

  2218.             ap.setText(URL);
  2219.             bt.setAccessPoint(ap);

  2220.             Vector<BindingTemplate> templates = new Vector<BindingTemplate>();
  2221.             templates.addElement(bt);
  2222.             this.proxy.save_binding(token.getAuthInfoString(),templates);

  2223.         }
  2224.         catch (UDDIException e){
  2225.             throw new DriverRegistroServiziException("[UDDILib.updateAccessPoint]: "+e.getMessage(),e);
  2226.         }
  2227.         catch (TransportException e){
  2228.             throw new DriverRegistroServiziException("[UDDILib.updateAccessPoint]: "+e.getMessage(),e);
  2229.         }
  2230.         catch (Exception e){
  2231.             throw new DriverRegistroServiziException("[UDDILib.updateAccessPoint]: "+e.getMessage(),e);
  2232.         }

  2233.         return bt;
  2234.     }
  2235.    
  2236.     /**
  2237.      * Il metodo si occupa di rimuovere l'accessoPoint dal BindingTemplate <var>bt</var> passato per parametro.
  2238.      * @param bt BindingTemplate
  2239.      * @return il BindingTemplate modificato
  2240.      */    
  2241.     protected BindingTemplate deleteAccessPoint(BindingTemplate bt)throws DriverRegistroServiziException{
  2242.         if ( bt==null  )
  2243.             throw new DriverRegistroServiziException("[UDDILib.deleteAccessPoint]: Alcuni parametri non definiti");

  2244.         try{
  2245.             bt = updateAccessPoint(bt,"");
  2246.             return bt;
  2247.         }catch(Exception e){
  2248.             throw new DriverRegistroServiziException("[UDDILib.deleteAccessPoint]: "+e.getMessage(),e);
  2249.         }
  2250.     }
  2251.    
  2252.    
  2253.    
  2254.    
  2255.    
  2256.    
  2257.    
  2258.    
  2259.    
  2260.     /* ********  M E T O D I    S E R V I Z I    ******** */

  2261.     /**
  2262.      * Il metodo si occupa di verificare se alla BusinessEntity identificata dai parametri
  2263.      * e' stato registrato il servizio <var>servizio</var>.
  2264.      *
  2265.      * @param idServ Identificativo del servizio
  2266.      * @return true se il servizio risulta registrato, false altrimenti
  2267.      */
  2268.     public boolean existsServizio(IDServizio idServ) throws DriverRegistroServiziException{
  2269.         if ( idServ==null || idServ.getSoggettoErogatore()==null)
  2270.             throw new DriverRegistroServiziException("[UDDILib.existsServizio]: Alcuni parametri non definiti");
  2271.        
  2272.         BusinessService bs = null;
  2273.         try{
  2274.             BusinessEntity be=getBusinessEntity(idServ.getSoggettoErogatore());
  2275.             if(be==null)
  2276.                 throw new Exception("BusinessEntity is null");
  2277.             bs=getBusinessService(be,idServ);
  2278.             if(bs==null)
  2279.                 throw new Exception("BusinessService is null");
  2280.         }catch (DriverRegistroServiziNotFound e){
  2281.             return false;
  2282.         }
  2283.         catch(Exception e){
  2284.             throw new DriverRegistroServiziException(e.getMessage(),e);
  2285.         }
  2286.         return true;
  2287.            
  2288.     }

  2289.     /**
  2290.      * Il metodo si occupa di aggiungere nel registro un nuovo Servizio
  2291.      * associato al soggetto identificato dai parametri <var>tipo</var> e <var>codice</var>.
  2292.      *
  2293.      * @param idServ Identificativo del servizio
  2294.      * @param urlXML url dell'XML associato al Servizio.
  2295.      * @param idAccordo ID dell'accordo di Servizio
  2296.      */
  2297.     public void createServizio(IDServizio idServ,
  2298.             String urlXML,IDAccordo idAccordo)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  2299.         if ( idServ==null || idServ.getSoggettoErogatore()==null || (urlXML==null) || (idAccordo==null))
  2300.             throw new DriverRegistroServiziException("[UDDILib.createServizio]: Alcuni parametri non definiti");
  2301.        
  2302.         try{

  2303.             // get Business Enity
  2304.             BusinessEntity be = getBusinessEntity(idServ.getSoggettoErogatore());

  2305.             // Add Business Service
  2306.             BusinessService bs = createBusinessService(be,idServ);

  2307.             // Add template (url servizio.xml)
  2308.             BindingTemplate bt = null;
  2309.             try{
  2310.                 bt = createBindingTemplate(bs);
  2311.             }catch(Exception e){
  2312.                 // rollback
  2313.                 try{
  2314.                     deleteBusinessService(idServ);
  2315.                 }catch(Exception eRollback){
  2316.                     // ignore
  2317.                 }
  2318.                 throw e; // rilancio
  2319.             }

  2320.             // set Template (url servizio.xml)
  2321.             try{
  2322.                 bt=updateAccessPoint(bt,urlXML);
  2323.             }catch(Exception e){
  2324.                 // rollback
  2325.                 try{
  2326.                     deleteBusinessService(idServ);
  2327.                 }catch(Exception eRollback){
  2328.                     // ignore
  2329.                 }
  2330.                 throw e; // rilancio
  2331.             }
  2332.            
  2333.             // Add TModel per Accordo di Servizio
  2334.             try{
  2335.                 createTModelServizio(bt,idAccordo);
  2336.             }catch(Exception e){
  2337.                 // rollback
  2338.                 try{
  2339.                     deleteBusinessService(idServ);
  2340.                 }catch(Exception eRollback){
  2341.                     // ignore
  2342.                 }
  2343.                 throw e; // rilancio
  2344.             }

  2345.         }catch (DriverRegistroServiziNotFound e){
  2346.             throw e;
  2347.         }catch(Exception e){
  2348.             throw new DriverRegistroServiziException("[UDDILib.createServizio]: "+e.getMessage(),e);
  2349.         }
  2350.     }

  2351.     /**
  2352.      * Si occupa di recuperare la URL dell'XML associato alla porta di dominio
  2353.      * registrata con il codice <var>codice</var>
  2354.      *
  2355.      * @param idServ Identificativo del servizio
  2356.      * @return la url dell'XML associato alla porta di dominio
  2357.      */
  2358.     public String getUrlXmlServizio(IDServizio idServ) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  2359.         if ( idServ==null || idServ.getSoggettoErogatore()==null )
  2360.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlServizio]: Alcuni parametri non definiti");
  2361.        
  2362.         try{
  2363.        
  2364.             BusinessEntity be = getBusinessEntity(idServ.getSoggettoErogatore());
  2365.             BusinessService bs= getBusinessService(be,idServ);
  2366.             BindingTemplate bt = getBindingTemplate(bs);
  2367.             return getAccessPoint(bt);
  2368.         }catch (DriverRegistroServiziNotFound e){
  2369.             throw e;
  2370.         }catch(Exception e){
  2371.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlServizio]: "+e.getMessage(),e);
  2372.         }
  2373.     }

  2374.     /**
  2375.      * Il metodo si occupa di impostare la url del file XML associato al Servizio
  2376.      *
  2377.      * @param idServ Identificativo del servizio
  2378.      * @param url Url da impostare
  2379.      */
  2380.     public void updateUrlXmlServizio(IDServizio idServ, String url)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  2381.         if ( url==null || idServ==null || idServ.getSoggettoErogatore()==null )
  2382.             throw new DriverRegistroServiziException("[UDDILib.updateUrlXmlServizio]: Alcuni parametri non definiti");
  2383.         try{
  2384.             BusinessEntity be = getBusinessEntity(idServ.getSoggettoErogatore());
  2385.             BusinessService bs = getBusinessService(be,idServ);
  2386.             BindingTemplate bt = getBindingTemplate(bs);
  2387.             bt=updateAccessPoint(bt,url);
  2388.         }
  2389.         catch (DriverRegistroServiziNotFound e){
  2390.             throw e;
  2391.         }catch (Exception e){
  2392.             throw new DriverRegistroServiziException("[UDDILib.updateUrlXmlServizio]: "+e.getMessage(),e);
  2393.         }
  2394.     }


  2395.     /**
  2396.      * Il metodo si occupa di modificare il nome di un Servizio
  2397.      *
  2398.      * @param idServOLD Vecchio Identificativo del Servizio
  2399.      * @param idServNEW Nuovo Identificativo del Servizio
  2400.      */
  2401.     public void updateIdServizio(IDServizio idServOLD,IDServizio idServNEW)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  2402.         if ( idServOLD==null || idServOLD.getTipo()==null || idServOLD.getNome()==null || idServOLD.getVersione()==null ||
  2403.                 idServOLD.getSoggettoErogatore()==null || idServOLD.getSoggettoErogatore().getTipo()==null || idServOLD.getSoggettoErogatore().getNome()==null)
  2404.             throw new DriverRegistroServiziException("[UDDILib.modificaNomeServizio]: Alcuni parametri non definiti");
  2405.    
  2406.         if ( idServNEW==null || idServNEW.getTipo()==null || idServNEW.getNome()==null || idServNEW.getVersione()==null ||
  2407.                 idServNEW.getSoggettoErogatore()==null || idServNEW.getSoggettoErogatore().getTipo()==null || idServNEW.getSoggettoErogatore().getNome()==null)
  2408.             throw new DriverRegistroServiziException("[UDDILib.modificaNomeServizio]: Alcuni parametri non definiti");
  2409.    
  2410.         try{
  2411.             BusinessEntity be = getBusinessEntity(idServOLD.getSoggettoErogatore());
  2412.             BusinessService bs = getBusinessService(be, idServOLD);
  2413.             updateNomeBusinessService(bs,idServNEW);
  2414.         }      
  2415.         catch (DriverRegistroServiziNotFound e){
  2416.             throw e;
  2417.         }catch (Exception e){
  2418.             throw new DriverRegistroServiziException("[UDDILib.modificaNomeServizio]: "+e.getMessage(),e);
  2419.         }

  2420.     }

  2421.     /**
  2422.      * Si occupa di cancellare il servizio <var>servizio</var> registrato nel registro,
  2423.      * identificato dai parametri.
  2424.      *
  2425.      * @param idServ Identificativo del servizio
  2426.      */
  2427.     public void deleteServizio(IDServizio idServ) throws DriverRegistroServiziException{
  2428.         if ( idServ==null || idServ.getSoggettoErogatore()==null )
  2429.             throw new DriverRegistroServiziException("[UDDILib.deleteServizio]: Alcuni parametri non definiti");
  2430.         try{    
  2431.             deleteBusinessService(idServ);
  2432.         }
  2433.         catch (Exception e){
  2434.             throw new DriverRegistroServiziException("[UDDILib.deleteServizio]: "+e.getMessage(),e);
  2435.         }
  2436.     }


  2437.    
  2438.    
  2439.    
  2440.    
  2441.    
  2442.    
  2443.     /**
  2444.      * Il metodo si occupa di modificare la TModel associata al servizio
  2445.      *
  2446.      * @param idServ Identificativo del servizio
  2447.      * @param newIDAccordoServizio Nuovo accordo di servizio
  2448.      */
  2449.     public void updateAccordoServizio(IDServizio idServ, IDAccordo newIDAccordoServizio)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  2450.         if ( idServ==null || idServ.getSoggettoErogatore()==null || newIDAccordoServizio==null)
  2451.             throw new DriverRegistroServiziException("[UDDILib.updateAccordoServizio]: Alcuni parametri non definiti");
  2452.         try{

  2453.             BusinessEntity be = getBusinessEntity(idServ.getSoggettoErogatore());
  2454.             BusinessService bs = getBusinessService(be, idServ);
  2455.             BindingTemplate bt = getBindingTemplate(bs);
  2456.             createTModelServizio(bt,newIDAccordoServizio);
  2457.         }      
  2458.         catch (DriverRegistroServiziNotFound e){
  2459.             throw e;
  2460.         }catch (Exception e){
  2461.             throw new DriverRegistroServiziException("[UDDILib.updateAccordoServizio]: "+e.getMessage(),e);
  2462.         }
  2463.     }

  2464.     /**
  2465.      * Si occupa di recuperare un array di URL che puntano a XML di servizi presente
  2466.      * nel soggetto identificato dai parametri, che possiedeno l'accordo di servizio <var>accordo</var>.
  2467.      *
  2468.      * @param idSogg Identificativo del Soggetto erogatore
  2469.      * @param idAccordo Accordo di Servizio
  2470.      * @return Array di url di XML dei servizi
  2471.      */
  2472.     public String[] getUrlXmlServizi(IDSoggetto idSogg, IDAccordo idAccordo)throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  2473.         if(idSogg==null || idAccordo==null)
  2474.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlServizi]: Alcuni parametri non definiti");
  2475.        
  2476.         try{
  2477.             // Soggetto
  2478.             BusinessEntity be = getBusinessEntity(idSogg);
  2479.    
  2480.             // Filtro per Accordi
  2481.             TModelBag bagAccordo = new TModelBag();
  2482.             TModel accordoS = getAccordoServizio(idAccordo);
  2483.             bagAccordo.add(new TModelKey(accordoS.getTModelKey()));
  2484.        
  2485.             FindQualifiers findQualifiers = new FindQualifiers();
  2486.             Vector<FindQualifier> qualifier = new Vector<FindQualifier>();
  2487.             qualifier.add(new FindQualifier(FindQualifier.exactNameMatch));
  2488.             qualifier.add(new FindQualifier(FindQualifier.caseSensitiveMatch));
  2489.             findQualifiers.setFindQualifierVector(qualifier);
  2490.            
  2491.             // l'ultimo parametro lo lascerei indefinito.
  2492.             // Richiede un intero che stabilisce il numero di risultati che la ricerca find_service deve produrre.
  2493.             // Ma noi a priori non lo possiamo sapere (anche se la ricerca dovrebbe essere sempre 1 o 2).
  2494.             // Effettuo il filtro per bagAccordo
  2495.             ServiceList serviceList = this.proxy.find_service(be.getBusinessKey(), null, null, bagAccordo, findQualifiers, -1);
  2496.             if(serviceList.getServiceInfos()==null || serviceList.getServiceInfos().size()==0)
  2497.                 throw new DriverRegistroServiziNotFound("BusinessServices non trovate");
  2498.            
  2499.            
  2500.             //questo vettore contiene tutti i servizi della businessEntity
  2501.             Vector<?> serviceInfoVector = serviceList.getServiceInfos().getServiceInfoVector();
  2502.          
  2503.             if(serviceInfoVector.size()==0)
  2504.                 throw new Exception("Servizi non trovati");
  2505.            
  2506.             //e ora vado ad analizzare un servizio alla volta
  2507.             String[]url = new String[serviceInfoVector.size()];
  2508.             for (int i=0; i<serviceInfoVector.size(); i++){
  2509.                 ServiceInfo serviceInfo = (ServiceInfo) serviceInfoVector.elementAt(i);
  2510.                 //System.out.println("SERVIZIO ["+serviceInfo.getServiceKey()+"]");
  2511.                 ServiceDetail sd = this.proxy.get_serviceDetail(serviceInfo.getServiceKey());
  2512.                 Vector<?> v = sd.getBusinessServiceVector();
  2513.                 BusinessService bs = (BusinessService) v.elementAt(0);          
  2514.                 BindingTemplate bt=getBindingTemplate(bs);
  2515.                 url[i] = getAccessPoint(bt);
  2516.                 if(url[i]==null)
  2517.                     throw new Exception("access point non presente?");
  2518.             }
  2519.             return url;
  2520.         }
  2521.         catch(DriverRegistroServiziNotFound e){
  2522.             throw e;
  2523.         }
  2524.         catch(TransportException e){
  2525.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlServizi]: "+e.getMessage(),e);
  2526.         }catch(Exception e){
  2527.             throw new DriverRegistroServiziException("[UDDILib.getUrlXmlServizi]: "+e.getMessage(),e);
  2528.         }
  2529.        

  2530.        
  2531.     }


  2532.     /**
  2533.      * @param idAccordo
  2534.      * @param soggettoErogatore
  2535.      * @param tipoServizio
  2536.      * @param nomeServizio
  2537.      * @return URL XML dei servizi che rispettano la ricerca
  2538.      * @throws DriverRegistroServiziException
  2539.      * @throws DriverRegistroServiziNotFound
  2540.      */
  2541.     protected String[] getUrlXMLServiziBySearch(IDAccordo idAccordo,IDSoggetto soggettoErogatore,String tipoServizio,String nomeServizio) throws DriverRegistroServiziException,DriverRegistroServiziNotFound{
  2542.        
  2543.         try{    

  2544.             // Filtro Soggetto
  2545.             String businessKey = null;
  2546.             if(soggettoErogatore!=null && soggettoErogatore.getTipo()!=null && soggettoErogatore.getNome()!=null){
  2547.                 try{
  2548.                     BusinessEntity be = this.getBusinessEntity(soggettoErogatore);
  2549.                     if(be!=null)
  2550.                         businessKey = be.getBusinessKey();
  2551.                 }catch(DriverRegistroServiziNotFound e){
  2552.                     throw new DriverRegistroServiziNotFound("[getBusinessServices] Soggetto ["+soggettoErogatore+"] usato come filtro non presente",e);
  2553.                 }
  2554.             }
  2555.                
  2556.             // Filtro accordo
  2557.             TModelBag bagAccordo = null;
  2558.             if(idAccordo!=null){
  2559.                 try{
  2560.                     bagAccordo = new TModelBag();
  2561.                     TModel accordoS = getAccordoServizio(idAccordo);
  2562.                     bagAccordo.add(new TModelKey(accordoS.getTModelKey()));
  2563.                 }catch(DriverRegistroServiziNotFound e){
  2564.                     throw new DriverRegistroServiziNotFound("[getBusinessServices] Accordo ["+idAccordo.toString()+"] usato come filtro non presente",e);
  2565.                 }  
  2566.             }
  2567.            
  2568.             // Filtro Servizio
  2569.             String keyService = null;
  2570.             if(tipoServizio!=null && nomeServizio!=null){
  2571.                 keyService = tipoServizio+ "/" + nomeServizio;
  2572.             }else if(tipoServizio!=null){
  2573.                 keyService = tipoServizio+ "/%";
  2574.             }else if(nomeServizio!=null){
  2575.                 keyService = "%/"+nomeServizio;
  2576.             }else{
  2577.                 keyService = "%/%";
  2578.             }
  2579.             Name nome = new Name(keyService);
  2580.             Vector<Name> nomi = new Vector<Name>();
  2581.             nomi.add(nome);
  2582.            
  2583.             // FindQualifiers
  2584.             FindQualifiers findQualifiers = null;
  2585.             if("%/%".equals(keyService)==false){
  2586.                 findQualifiers = new FindQualifiers();
  2587.                 Vector<FindQualifier> qualifier = new Vector<FindQualifier>();
  2588.                 qualifier.add(new FindQualifier(FindQualifier.exactNameMatch));
  2589.                 qualifier.add(new FindQualifier(FindQualifier.caseSensitiveMatch));
  2590.                 findQualifiers.setFindQualifierVector(qualifier);
  2591.             }
  2592.            
  2593.             // l'ultimo parametro lo lascerei indefinito.
  2594.             // Richiede un intero che stabilisce il numero di risultati che la ricerca find_service deve produrre.
  2595.             // Ma noi a priori non lo possiamo sapere (anche se la ricerca dovrebbe essere sempre 1 o 2).
  2596.             // Effettuo il filtro per bagAccordo
  2597.             ServiceList serviceList = this.proxy.find_service(businessKey, nomi, null, bagAccordo, findQualifiers, UDDILib.MAX_SEARCH);
  2598.          
  2599.             //questo vettore contiene tutti i servizi della businessEntity
  2600.             Vector<?> serviceInfoVector = serviceList.getServiceInfos().getServiceInfoVector();
  2601.          
  2602.             if(serviceInfoVector.size()==0){
  2603.                 throw new DriverRegistroServiziNotFound("Non esistono BusinessService che rispettano il filtro selezionato accordo["+idAccordo+"] soggetto["+soggettoErogatore+"] tipo_servizio["+tipoServizio+"] nome_servizio["+nomeServizio+"]");
  2604.             }
  2605.            
  2606.             //e ora vado ad analizzare un servizio alla volta
  2607.             String[]url = new String[serviceInfoVector.size()];
  2608.             for (int i=0; i<serviceInfoVector.size(); i++){
  2609.                 ServiceInfo serviceInfo = (ServiceInfo) serviceInfoVector.elementAt(i);
  2610.                 //System.out.println("SERVIZIO ["+serviceInfo.getServiceKey()+"]");
  2611.                 ServiceDetail sd = this.proxy.get_serviceDetail(serviceInfo.getServiceKey());
  2612.                 Vector<?> v = sd.getBusinessServiceVector();
  2613.                 BusinessService bs = (BusinessService) v.elementAt(0);          
  2614.                 BindingTemplate bt=getBindingTemplate(bs);
  2615.                 url[i] = getAccessPoint(bt);
  2616.                 if(url[i]==null)
  2617.                     throw new Exception("access point non presente?");
  2618.             }
  2619.             return url;
  2620.         }
  2621.         catch (UDDIException e){
  2622.             throw new DriverRegistroServiziException("[UDDILib.getBusinessService]: "+e.getMessage(),e);
  2623.         }
  2624.         catch (TransportException e){
  2625.             throw new DriverRegistroServiziException("[UDDILib.getBusinessService]: "+e.getMessage(),e);
  2626.         }
  2627.         catch( DriverRegistroServiziNotFound de){
  2628.             throw de;
  2629.         }
  2630.         catch (Exception e){
  2631.             throw new DriverRegistroServiziException("[UDDILib.getBusinessService]: "+e.getMessage(),e);
  2632.         }

  2633.     }
  2634.    
  2635. }