SPCoopValidazioneDocumenti.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */
  20. package org.openspcoop2.protocol.spcoop.validator;

  21. import org.openspcoop2.core.registry.AccordoServizioParteComune;
  22. import org.openspcoop2.protocol.basic.validator.ValidazioneDocumenti;
  23. import org.openspcoop2.protocol.sdk.IProtocolFactory;
  24. import org.openspcoop2.protocol.sdk.ProtocolException;
  25. import org.openspcoop2.protocol.sdk.validator.ValidazioneResult;

  26. /**
  27.  * SPCoopValidazioneDocumenti
  28.  *
  29.  * @author Poli Andrea (apoli@link.it)
  30.  * @author $Author$
  31.  * @version $Rev$, $Date$
  32.  */
  33. public class SPCoopValidazioneDocumenti extends ValidazioneDocumenti  {

  34.     public SPCoopValidazioneDocumenti(IProtocolFactory<?> factory) throws ProtocolException {
  35.         super(factory);
  36.     }

  37.    
  38.     @Override
  39.     public ValidazioneResult validaSpecificaConversazione(
  40.             AccordoServizioParteComune accordoServizioParteComune) {
  41.        
  42.        
  43.         String objectInEsame = null;
  44.         ValidazioneResult result = new ValidazioneResult();
  45.         result.setEsito(false);
  46.        
  47.        
  48.         // WSBL Concettuale
  49.         try{
  50.             objectInEsame = "[InterfacciaWSBL Concettuale] ";

  51.             byte[]wsblConcettuale = null;
  52.             if(accordoServizioParteComune.getByteSpecificaConversazioneConcettuale()!=null){
  53.                 wsblConcettuale = accordoServizioParteComune.getByteSpecificaConversazioneConcettuale();
  54.             }
  55.             else if(accordoServizioParteComune.getSpecificaConversazioneConcettuale()!=null){
  56.                 wsblConcettuale = this.readDocumento(accordoServizioParteComune.getSpecificaConversazioneConcettuale());        
  57.             }
  58.             if(wsblConcettuale!=null){
  59.                 // Verifico che sia un documento xml valido
  60.                 this.xmlUtils.newDocument(wsblConcettuale);

  61.                 if(it.gov.spcoop.sica.wsbl.driver.XMLUtils.isMessageBehavior(wsblConcettuale)){
  62.                     throw new Exception("La specifica di conversazione concettuale non e' un documento WSBL ConceptualBehavior, ma erroneamente un documento WSBL MessageBehavior");
  63.                 }
  64.                 it.gov.spcoop.sica.wsbl.driver.XMLUtils.getConceptualBehavior(this.log,wsblConcettuale);    
  65.             }  
  66.         }catch(Exception e){
  67.             result.setMessaggioErrore(objectInEsame+" Documento non valido: "+e.getMessage());
  68.             result.setException(e);
  69.             return result;
  70.         }
  71.        
  72.        
  73.        
  74.         // WSBL Erogatore
  75.         try{
  76.             objectInEsame = "[InterfacciaWSBL Erogatore] ";

  77.             byte[]wsblErogatore = null;
  78.             if(accordoServizioParteComune.getByteSpecificaConversazioneErogatore()!=null){
  79.                 wsblErogatore = accordoServizioParteComune.getByteSpecificaConversazioneErogatore();
  80.             }
  81.             else if(accordoServizioParteComune.getSpecificaConversazioneErogatore()!=null){
  82.                 wsblErogatore = this.readDocumento(accordoServizioParteComune.getSpecificaConversazioneErogatore());        
  83.             }
  84.             if(wsblErogatore!=null){
  85.                 // Verifico che sia un documento xml valido
  86.                 this.xmlUtils.newDocument(wsblErogatore);

  87.                 if(it.gov.spcoop.sica.wsbl.driver.XMLUtils.isConceptualBehavior(wsblErogatore)){
  88.                     throw new Exception("La specifica di conversazione logica erogatore non e' un documento WSBL MessageBehavior, ma erroneamente un documento WSBL ConceptualBehavior");
  89.                 }
  90.                 it.gov.spcoop.sica.wsbl.driver.XMLUtils.getMessageBehavior(this.log,wsblErogatore);
  91.             }  
  92.         }catch(Exception e){
  93.             result.setMessaggioErrore(objectInEsame+" Documento non valido: "+e.getMessage());
  94.             result.setException(e);
  95.             return result;
  96.         }
  97.        
  98.        
  99.        
  100.        
  101.         // WSBL Fruitore
  102.         try{
  103.             objectInEsame = "[InterfacciaWSBL Fruitore] ";

  104.             byte[]wsblFruitore = null;
  105.             if(accordoServizioParteComune.getByteSpecificaConversazioneFruitore()!=null){
  106.                 wsblFruitore = accordoServizioParteComune.getByteSpecificaConversazioneFruitore();
  107.             }
  108.             else if(accordoServizioParteComune.getSpecificaConversazioneFruitore()!=null){
  109.                 wsblFruitore = this.readDocumento(accordoServizioParteComune.getSpecificaConversazioneFruitore());      
  110.             }
  111.             if(wsblFruitore!=null){
  112.                 // Verifico che sia un documento xml valido
  113.                 this.xmlUtils.newDocument(wsblFruitore);

  114.                 if(it.gov.spcoop.sica.wsbl.driver.XMLUtils.isConceptualBehavior(wsblFruitore)){
  115.                     throw new Exception("La specifica di conversazione logica fruitore non e' un documento WSBL MessageBehavior, ma erroneamente un documento WSBL ConceptualBehavior");
  116.                 }                      
  117.                 it.gov.spcoop.sica.wsbl.driver.XMLUtils.getMessageBehavior(this.log,wsblFruitore);
  118.             }  
  119.         }catch(Exception e){
  120.             result.setMessaggioErrore(objectInEsame+" Documento non valido: "+e.getMessage());
  121.             result.setException(e);
  122.             return result;
  123.         }
  124.    
  125.        
  126.        
  127.        
  128.         // result
  129.         result.setEsito(true);
  130.         return result;
  131.     }
  132. }