ArchiveFruitore.java

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

  21. import java.util.List;

  22. import org.openspcoop2.core.id.IDServizio;
  23. import org.openspcoop2.core.id.IDSoggetto;
  24. import org.openspcoop2.core.mapping.MappingFruizionePortaDelegata;
  25. import org.openspcoop2.core.registry.Fruitore;
  26. import org.openspcoop2.protocol.sdk.ProtocolException;

  27. /**
  28.  * ArchiveFruitore
  29.  *
  30.  * @author Poli Andrea (apoli@link.it)
  31.  * @author $Author$
  32.  * @version $Rev$, $Date$
  33.  */
  34. public class ArchiveFruitore implements IArchiveObject {

  35.     public static String buildKey(String tipoSoggettoFruitore,String nomeSoggettoFruitore,
  36.             String tipoSoggettoErogatore,String nomeSoggettoErogatore,String tipoServizio,String nomeServizio,Integer versione) throws ProtocolException{
  37.        
  38.         if(tipoSoggettoFruitore==null){
  39.             throw new ProtocolException("tipoSoggettoFruitore non fornito");
  40.         }
  41.         if(nomeSoggettoFruitore==null){
  42.             throw new ProtocolException("nomeSoggettoFruitore non fornito");
  43.         }
  44.        
  45.         if(tipoSoggettoErogatore==null){
  46.             throw new ProtocolException("tipoSoggettoErogatore non fornito");
  47.         }
  48.         if(nomeSoggettoErogatore==null){
  49.             throw new ProtocolException("nomeSoggettoErogatore non fornito");
  50.         }
  51.         if(tipoServizio==null){
  52.             throw new ProtocolException("tipoServizio non fornito");
  53.         }
  54.         if(nomeServizio==null){
  55.             throw new ProtocolException("nomeServizio non fornito");
  56.         }
  57.         if(versione==null){
  58.             throw new ProtocolException("versioneServizio non fornito");
  59.         }
  60.        
  61.         StringBuilder bf = new StringBuilder();
  62.         bf.append("Fruitore_");
  63.         bf.append(tipoSoggettoFruitore);
  64.         bf.append("/");
  65.         bf.append(nomeSoggettoFruitore);
  66.         bf.append("_AccordoServizioParteSpecifica_");
  67.         bf.append(tipoSoggettoErogatore);
  68.         bf.append("/");
  69.         bf.append(nomeSoggettoErogatore);
  70.         bf.append("_");
  71.         bf.append(tipoServizio);
  72.         bf.append("/");
  73.         bf.append(nomeServizio);
  74.         bf.append("_");
  75.         bf.append(versione);
  76.         return bf.toString();
  77.     }
  78.    
  79.     @Override
  80.     public String key() throws ProtocolException {
  81.         return ArchiveFruitore.buildKey(this.idSoggettoFruitore.getTipo(),this.idSoggettoFruitore.getNome(),
  82.                 this.idAccordoServizioParteSpecifica.getSoggettoErogatore().getTipo(), this.idAccordoServizioParteSpecifica.getSoggettoErogatore().getNome(),
  83.                 this.idAccordoServizioParteSpecifica.getTipo(),this.idAccordoServizioParteSpecifica.getNome(),this.idAccordoServizioParteSpecifica.getVersione());
  84.     }
  85.    
  86.    
  87.    
  88.     private IDSoggetto idSoggettoFruitore;
  89.     private IDServizio idAccordoServizioParteSpecifica;
  90.     private Fruitore fruitore;
  91.    
  92.     private List<MappingFruizionePortaDelegata> mappingPorteDelegateAssociate;
  93.     public List<MappingFruizionePortaDelegata> getMappingPorteDelegateAssociate() {
  94.         return this.mappingPorteDelegateAssociate;
  95.     }
  96.     public void setMappingPorteDelegateAssociate(List<MappingFruizionePortaDelegata> mappingPorteDelegateAssociate) {
  97.         this.mappingPorteDelegateAssociate = mappingPorteDelegateAssociate;
  98.     }



  99.     private ArchiveIdCorrelazione idCorrelazione; // permette di correlare più oggetti tra di loro
  100.    
  101.    
  102.     public ArchiveFruitore(IDServizio idAccordoServizioParteSpecifica, Fruitore fruitore, ArchiveIdCorrelazione idCorrelazione) throws ProtocolException{
  103.         this(idAccordoServizioParteSpecifica, fruitore, idCorrelazione, false);
  104.     }
  105.     public ArchiveFruitore(IDServizio idAccordoServizioParteSpecifica, Fruitore fruitore, ArchiveIdCorrelazione idCorrelazione, boolean informationMissingManagementEnabled) throws ProtocolException{
  106.         update(idAccordoServizioParteSpecifica, fruitore, informationMissingManagementEnabled);
  107.         this.idCorrelazione = idCorrelazione;
  108.     }
  109.    
  110.    
  111.    
  112.     public void update() throws ProtocolException{
  113.         this.update(this.idAccordoServizioParteSpecifica, this.fruitore, false);
  114.     }
  115.     public void update(IDServizio idAccordoServizioParteSpecifica, Fruitore fruitore) throws ProtocolException{
  116.         this.update(idAccordoServizioParteSpecifica, fruitore, false);
  117.     }
  118.     public void update(IDServizio idAccordoServizioParteSpecifica, Fruitore fruitore, boolean informationMissingManagementEnabled) throws ProtocolException{
  119.        
  120.         if(fruitore==null){
  121.             throw new ProtocolException("fruitore non definito");
  122.         }
  123.         if(fruitore.getTipo()==null){
  124.             throw new ProtocolException("fruitore.tipo non definito");
  125.         }
  126.         if(fruitore.getNome()==null){
  127.             throw new ProtocolException("fruitore.nome non definito");
  128.         }
  129.         this.idSoggettoFruitore = new IDSoggetto(fruitore.getTipo(), fruitore.getNome());
  130.        
  131.         this.fruitore = fruitore;
  132.        
  133.         if(idAccordoServizioParteSpecifica==null){
  134.             throw new ProtocolException("idAccordoServizioParteSpecifica non fornito");
  135.         }
  136.         if(idAccordoServizioParteSpecifica.getTipo()==null){
  137.             throw new ProtocolException("idAccordoServizioParteSpecifica.tipo non definito");
  138.         }
  139.         if(idAccordoServizioParteSpecifica.getNome()==null){
  140.             throw new ProtocolException("idAccordoServizioParteSpecifica.nome non definito");
  141.         }
  142.        
  143.         if(informationMissingManagementEnabled==false){
  144.            
  145.             if(idAccordoServizioParteSpecifica.getVersione()==null){
  146.                 throw new ProtocolException("idAccordoServizioParteSpecifica.versione non definito");
  147.             }
  148.             if(idAccordoServizioParteSpecifica.getSoggettoErogatore()==null){
  149.                 throw new ProtocolException("idAccordoServizioParteSpecifica.soggettoErogatore non definito");
  150.             }
  151.             if(idAccordoServizioParteSpecifica.getSoggettoErogatore().getTipo()==null){
  152.                 throw new ProtocolException("idAccordoServizioParteSpecifica.soggettoErogatore.tipo non definito");
  153.             }
  154.             if(idAccordoServizioParteSpecifica.getSoggettoErogatore().getNome()==null){
  155.                 throw new ProtocolException("idAccordoServizioParteSpecifica.soggettoErogatore.nome non definito");
  156.             }
  157.            
  158.         }
  159.        
  160.         this.idAccordoServizioParteSpecifica = idAccordoServizioParteSpecifica;
  161.        
  162.     }
  163.    
  164.    
  165.    
  166.    
  167.     public IDSoggetto getIdSoggettoFruitore() {
  168.         return this.idSoggettoFruitore;
  169.     }
  170.     public IDServizio getIdAccordoServizioParteSpecifica() {
  171.         return this.idAccordoServizioParteSpecifica;
  172.     }
  173.     public Fruitore getFruitore() {
  174.         return this.fruitore;
  175.     }

  176.     public ArchiveIdCorrelazione getIdCorrelazione() {
  177.         return this.idCorrelazione;
  178.     }
  179. }