DriverConfigurazioneDB_porteApplicativeSearchDriver.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.config.driver.db;

  21. import java.sql.Connection;
  22. import java.sql.PreparedStatement;
  23. import java.sql.ResultSet;
  24. import java.util.ArrayList;
  25. import java.util.List;

  26. import org.apache.commons.lang.StringUtils;
  27. import org.openspcoop2.core.commons.Filtri;
  28. import org.openspcoop2.core.commons.ISearch;
  29. import org.openspcoop2.core.commons.Liste;
  30. import org.openspcoop2.core.commons.SearchUtils;
  31. import org.openspcoop2.core.config.CorrelazioneApplicativaElemento;
  32. import org.openspcoop2.core.config.CorrelazioneApplicativaRispostaElemento;
  33. import org.openspcoop2.core.config.MessageSecurityFlowParameter;
  34. import org.openspcoop2.core.config.MtomProcessorFlowParameter;
  35. import org.openspcoop2.core.config.PortaApplicativa;
  36. import org.openspcoop2.core.config.PortaApplicativaAutorizzazioneServizioApplicativo;
  37. import org.openspcoop2.core.config.PortaApplicativaAutorizzazioneSoggetto;
  38. import org.openspcoop2.core.config.PortaApplicativaAzione;
  39. import org.openspcoop2.core.config.Proprieta;
  40. import org.openspcoop2.core.config.ServizioApplicativo;
  41. import org.openspcoop2.core.config.constants.PortaApplicativaAzioneIdentificazione;
  42. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  43. import org.openspcoop2.core.config.driver.DriverConfigurazioneException;
  44. import org.openspcoop2.core.constants.CostantiDB;
  45. import org.openspcoop2.utils.jdbc.JDBCUtilities;
  46. import org.openspcoop2.utils.sql.ISQLQueryObject;
  47. import org.openspcoop2.utils.sql.SQLObjectFactory;

  48. /**
  49.  * DriverConfigurazioneDB_porteApplicativeSearchDriver
  50.  *
  51.  *
  52.  * @author Sandra Giangrandi (sandra@link.it)
  53.  * @author Stefano Corallo (corallo@link.it)
  54.  * @author $Author$
  55.  * @version $Rev$, $Date$
  56.  */
  57. public class DriverConfigurazioneDB_porteApplicativeSearchDriver {

  58.     private DriverConfigurazioneDB driver = null;
  59.     private DriverConfigurazioneDB_porteApplicativeDriver porteApplicativeDriver = null;
  60.    
  61.     protected DriverConfigurazioneDB_porteApplicativeSearchDriver(DriverConfigurazioneDB driver) {
  62.         this.driver = driver;
  63.         this.porteApplicativeDriver = new DriverConfigurazioneDB_porteApplicativeDriver(driver);
  64.     }
  65.    
  66.     protected List<String> portaApplicativaRuoliList(long idPA, ISearch ricerca) throws DriverConfigurazioneException {
  67.         String nomeMetodo = "portaApplicativaRuoliList";
  68.         int idLista = Liste.PORTE_APPLICATIVE_RUOLI;
  69.         String nomeTabella = CostantiDB.PORTE_APPLICATIVE_RUOLI;
  70.         return _portaApplicativaRuoliList(idPA, ricerca,
  71.                 nomeMetodo, nomeTabella, idLista);
  72.     }
  73.     protected List<String> portaApplicativaRuoliTokenList(long idPA, ISearch ricerca) throws DriverConfigurazioneException {
  74.         String nomeMetodo = "portaApplicativaRuoliTokenList";
  75.         int idLista = Liste.PORTE_APPLICATIVE_TOKEN_RUOLI;
  76.         String nomeTabella = CostantiDB.PORTE_APPLICATIVE_TOKEN_RUOLI;
  77.         return _portaApplicativaRuoliList(idPA, ricerca,
  78.                 nomeMetodo, nomeTabella, idLista);
  79.     }
  80.     private List<String> _portaApplicativaRuoliList(long idPA, ISearch ricerca,
  81.             String nomeMetodo, String nomeTabella, int idLista) throws DriverConfigurazioneException {
  82.         int offset;
  83.         int limit;
  84.         String search;
  85.         String queryString;

  86.         limit = ricerca.getPageSize(idLista);
  87.         offset = ricerca.getIndexIniziale(idLista);
  88.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));

  89.         Connection con = null;
  90.         PreparedStatement stmt = null;
  91.         ResultSet risultato = null;

  92.         if (this.driver.atomica) {
  93.             try {
  94.                 con = this.driver.getConnectionFromDatasource(nomeMetodo);
  95.             } catch (Exception e) {
  96.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  97.             }

  98.         } else
  99.             con = this.driver.globalConnection;

  100.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  101.         List<String> listIdRuoli = null;
  102.         try {

  103.             if (!search.equals("")) {
  104.                 //query con search
  105.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  106.                 sqlQueryObject.addFromTable(nomeTabella);
  107.                 sqlQueryObject.addSelectCountField("*", "cont");
  108.                 sqlQueryObject.addWhereCondition(nomeTabella+".id_porta=?");
  109.                 sqlQueryObject.addWhereLikeCondition(nomeTabella+".ruolo", search, true, true);
  110.                
  111.                 sqlQueryObject.setSelectDistinct(true);
  112.                 sqlQueryObject.setANDLogicOperator(true);
  113.                 queryString = sqlQueryObject.createSQLQuery();
  114.             } else {
  115.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  116.                 sqlQueryObject.addFromTable(nomeTabella);
  117.                 sqlQueryObject.addSelectCountField("*", "cont");
  118.                 sqlQueryObject.addWhereCondition(nomeTabella+".id_porta=?");

  119.                 sqlQueryObject.setSelectDistinct(true);
  120.                 sqlQueryObject.setANDLogicOperator(true);
  121.                 queryString = sqlQueryObject.createSQLQuery();
  122.             }
  123.             stmt = con.prepareStatement(queryString);
  124.             stmt.setLong(1, idPA);

  125.             risultato = stmt.executeQuery();
  126.             if (risultato.next())
  127.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  128.             risultato.close();
  129.             stmt.close();

  130.             // ricavo le entries
  131.             if (limit == 0) // con limit
  132.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  133.             if (!search.equals("")) { // con search
  134.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  135.                 sqlQueryObject.addFromTable(nomeTabella);
  136.                 sqlQueryObject.addSelectField(nomeTabella+".ruolo");
  137.                 sqlQueryObject.addWhereCondition(nomeTabella+".id_porta=?");
  138.                 sqlQueryObject.addWhereLikeCondition(nomeTabella+".ruolo", search, true, true);
  139.                
  140.                 sqlQueryObject.setSelectDistinct(true);
  141.                 sqlQueryObject.setANDLogicOperator(true);
  142.                 sqlQueryObject.addOrderBy(nomeTabella+".ruolo");
  143.                 sqlQueryObject.setSortType(true);
  144.                 sqlQueryObject.setLimit(limit);
  145.                 sqlQueryObject.setOffset(offset);
  146.                 queryString = sqlQueryObject.createSQLQuery();
  147.             } else {
  148.                 // senza search
  149.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  150.                 sqlQueryObject.addFromTable(nomeTabella);
  151.                 sqlQueryObject.addSelectField(nomeTabella+".ruolo");
  152.                 sqlQueryObject.addWhereCondition(nomeTabella+".id_porta=?");
  153.                
  154.                 sqlQueryObject.setSelectDistinct(true);
  155.                 sqlQueryObject.setANDLogicOperator(true);
  156.                 sqlQueryObject.addOrderBy(nomeTabella+".ruolo");
  157.                 sqlQueryObject.setSortType(true);
  158.                 sqlQueryObject.setLimit(limit);
  159.                 sqlQueryObject.setOffset(offset);
  160.                 queryString = sqlQueryObject.createSQLQuery();
  161.             }
  162.             stmt = con.prepareStatement(queryString);
  163.             stmt.setLong(1, idPA);

  164.             risultato = stmt.executeQuery();

  165.             listIdRuoli = new ArrayList<>();
  166.             while (risultato.next()) {

  167.                 listIdRuoli.add(risultato.getString(1));

  168.             }

  169.         } catch (Exception qe) {
  170.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  171.         } finally {

  172.             //Chiudo statement and resultset
  173.             JDBCUtilities.closeResources(risultato, stmt);

  174.             this.driver.closeConnection(con);
  175.         }
  176.        
  177.         return listIdRuoli;
  178.     }
  179.    
  180.     protected List<String> portaApplicativaScopeList(long idPA, ISearch ricerca) throws DriverConfigurazioneException {
  181.         String nomeMetodo = "portaApplicativaScopeList";
  182.         int idLista = Liste.PORTE_APPLICATIVE_SCOPE;
  183.         int offset;
  184.         int limit;
  185.         String search;
  186.         String queryString;

  187.         limit = ricerca.getPageSize(idLista);
  188.         offset = ricerca.getIndexIniziale(idLista);
  189.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));

  190.         Connection con = null;
  191.         PreparedStatement stmt = null;
  192.         ResultSet risultato = null;

  193.         if (this.driver.atomica) {
  194.             try {
  195.                 con = this.driver.getConnectionFromDatasource(nomeMetodo);
  196.             } catch (Exception e) {
  197.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  198.             }

  199.         } else
  200.             con = this.driver.globalConnection;

  201.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  202.         List<String> listIdScope = null;
  203.         try {

  204.             if (!search.equals("")) {
  205.                 //query con search
  206.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  207.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SCOPE);
  208.                 sqlQueryObject.addSelectCountField("*", "cont");
  209.                 sqlQueryObject.addWhereCondition(CostantiDB.PORTE_APPLICATIVE_SCOPE+".id_porta=?");
  210.                 sqlQueryObject.addWhereLikeCondition(CostantiDB.PORTE_APPLICATIVE_SCOPE+".scope", search, true, true);  
  211.                
  212.                 sqlQueryObject.setSelectDistinct(true);
  213.                 sqlQueryObject.setANDLogicOperator(true);
  214.                 queryString = sqlQueryObject.createSQLQuery();
  215.             } else {
  216.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  217.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SCOPE);
  218.                 sqlQueryObject.addSelectCountField("*", "cont");
  219.                 sqlQueryObject.addWhereCondition(CostantiDB.PORTE_APPLICATIVE_SCOPE+".id_porta=?");

  220.                 sqlQueryObject.setSelectDistinct(true);
  221.                 sqlQueryObject.setANDLogicOperator(true);
  222.                 queryString = sqlQueryObject.createSQLQuery();
  223.             }
  224.             stmt = con.prepareStatement(queryString);
  225.             stmt.setLong(1, idPA);

  226.             risultato = stmt.executeQuery();
  227.             if (risultato.next())
  228.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  229.             risultato.close();
  230.             stmt.close();

  231.             // ricavo le entries
  232.             if (limit == 0) // con limit
  233.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  234.             if (!search.equals("")) { // con search
  235.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  236.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SCOPE);
  237.                 sqlQueryObject.addSelectField(CostantiDB.PORTE_APPLICATIVE_SCOPE+".scope");
  238.                 sqlQueryObject.addWhereCondition(CostantiDB.PORTE_APPLICATIVE_SCOPE+".id_porta=?");
  239.                 sqlQueryObject.addWhereLikeCondition(CostantiDB.PORTE_APPLICATIVE_SCOPE+".scope", search, true, true);  
  240.                
  241.                 sqlQueryObject.setSelectDistinct(true);
  242.                 sqlQueryObject.setANDLogicOperator(true);
  243.                 sqlQueryObject.addOrderBy(CostantiDB.PORTE_APPLICATIVE_SCOPE+".scope");
  244.                 sqlQueryObject.setSortType(true);
  245.                 sqlQueryObject.setLimit(limit);
  246.                 sqlQueryObject.setOffset(offset);
  247.                 queryString = sqlQueryObject.createSQLQuery();
  248.             } else {
  249.                 // senza search
  250.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  251.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SCOPE);
  252.                 sqlQueryObject.addSelectField(CostantiDB.PORTE_APPLICATIVE_SCOPE+".scope");
  253.                 sqlQueryObject.addWhereCondition(CostantiDB.PORTE_APPLICATIVE_SCOPE+".id_porta=?");
  254.                
  255.                 sqlQueryObject.setSelectDistinct(true);
  256.                 sqlQueryObject.setANDLogicOperator(true);
  257.                 sqlQueryObject.addOrderBy(CostantiDB.PORTE_APPLICATIVE_SCOPE+".scope");
  258.                 sqlQueryObject.setSortType(true);
  259.                 sqlQueryObject.setLimit(limit);
  260.                 sqlQueryObject.setOffset(offset);
  261.                 queryString = sqlQueryObject.createSQLQuery();
  262.             }
  263.             stmt = con.prepareStatement(queryString);
  264.             stmt.setLong(1, idPA);

  265.             risultato = stmt.executeQuery();

  266.             listIdScope = new ArrayList<>();
  267.             while (risultato.next()) {

  268.                 listIdScope.add(risultato.getString(1));

  269.             }

  270.         } catch (Exception qe) {
  271.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  272.         } finally {

  273.             //Chiudo statement and resultset
  274.             JDBCUtilities.closeResources(risultato, stmt);

  275.             this.driver.closeConnection(con);
  276.         }
  277.        
  278.         return listIdScope;
  279.     }
  280.    
  281.    
  282.     protected List<PortaApplicativa> porteAppList(long idSoggetto, ISearch ricerca) throws DriverConfigurazioneException {
  283.         int offset;
  284.         int limit;
  285.         int idLista=Liste.PORTE_APPLICATIVE_BY_SOGGETTO;
  286.         String search;
  287.         String queryString;

  288.         limit = ricerca.getPageSize(idLista);
  289.         offset = ricerca.getIndexIniziale(idLista);
  290.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));

  291.         Connection con = null;
  292.         PreparedStatement stm=null;
  293.         ResultSet rs=null;
  294.         ArrayList<PortaApplicativa> lista = new ArrayList<>();

  295.         if (this.driver.atomica) {
  296.             try {
  297.                 con = this.driver.getConnectionFromDatasource("porteAppList");
  298.             } catch (Exception e) {
  299.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppList] Exception accedendo al datasource :" + e.getMessage(),e);

  300.             }

  301.         } else
  302.             con = this.driver.globalConnection;

  303.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  304.         try {

  305.             if (!search.equals("")) {
  306.                 //query con search
  307.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  308.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  309.                 sqlQueryObject.addSelectCountField("*", "cont");
  310.                 sqlQueryObject.addWhereCondition("id_soggetto = ?");
  311.                 sqlQueryObject.addWhereLikeCondition("nome_porta",search,true, true);
  312.                 sqlQueryObject.setANDLogicOperator(true);
  313.                 queryString = sqlQueryObject.createSQLQuery();
  314.             } else {
  315.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  316.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  317.                 sqlQueryObject.addSelectCountField("*", "cont");
  318.                 sqlQueryObject.addWhereCondition("id_soggetto = ?");
  319.                 queryString = sqlQueryObject.createSQLQuery();
  320.             }
  321.             stm = con.prepareStatement(queryString);
  322.             stm.setLong(1, idSoggetto);
  323.             rs = stm.executeQuery();
  324.             if (rs.next())
  325.                 ricerca.setNumEntries(idLista,rs.getInt(1));
  326.             rs.close();
  327.             stm.close();

  328.             // ricavo le entries
  329.             if (limit == 0) // con limit
  330.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  331.             if (!search.equals("")) { // con search
  332.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  333.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  334.                 sqlQueryObject.addSelectField("id");
  335.                 sqlQueryObject.addSelectField("nome_porta");
  336.                 sqlQueryObject.addSelectField("id_soggetto");
  337.                 sqlQueryObject.addWhereCondition("id_soggetto = ?");
  338.                 sqlQueryObject.addWhereLikeCondition("nome_porta",search,true, true);
  339.                 sqlQueryObject.setANDLogicOperator(true);
  340.                 sqlQueryObject.addOrderBy("nome_porta");
  341.                 sqlQueryObject.setSortType(true);
  342.                 sqlQueryObject.setLimit(limit);
  343.                 sqlQueryObject.setOffset(offset);
  344.                 queryString = sqlQueryObject.createSQLQuery();
  345.             } else {
  346.                 // senza search
  347.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  348.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  349.                 sqlQueryObject.addSelectField("id");
  350.                 sqlQueryObject.addSelectField("nome_porta");
  351.                 sqlQueryObject.addSelectField("id_soggetto");
  352.                 sqlQueryObject.addWhereCondition("id_soggetto = ?");
  353.                 sqlQueryObject.addOrderBy("nome_porta");
  354.                 sqlQueryObject.setSortType(true);
  355.                 sqlQueryObject.setLimit(limit);
  356.                 sqlQueryObject.setOffset(offset);
  357.                 queryString = sqlQueryObject.createSQLQuery();
  358.             }

  359.             stm = con.prepareStatement(queryString);
  360.             stm.setLong(1, idSoggetto);
  361.             rs = stm.executeQuery();

  362.             PortaApplicativa pa = null;
  363.             while (rs.next()) {
  364.                 pa = this.porteApplicativeDriver.getPortaApplicativa(rs.getLong("id"),con);
  365.                 lista.add(pa);
  366.             }

  367.             return lista;

  368.         } catch (Exception qe) {
  369.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppList] Errore : " + qe.getMessage(),qe);
  370.         } finally {
  371.             //Chiudo statement and resultset
  372.             JDBCUtilities.closeResources(rs, stm);

  373.             this.driver.closeConnection(con);
  374.         }

  375.     }
  376.     /**
  377.      * Ritorna la lista di tutte le Porte Applicative
  378.      * @param ricerca
  379.      * @return Una lista di Porte Applicative
  380.      * @throws DriverConfigurazioneException
  381.      */
  382.     protected List<PortaApplicativa> porteAppList(String superuser, ISearch ricerca) throws DriverConfigurazioneException {
  383.         int offset;
  384.         int limit;
  385.         int idLista=Liste.PORTE_APPLICATIVE;
  386.         String search;
  387.         String queryString;

  388.         limit = ricerca.getPageSize(idLista);
  389.         offset = ricerca.getIndexIniziale(idLista);
  390.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));

  391.         String filterProtocollo = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_PROTOCOLLO);
  392.         String filterProtocolli = SearchUtils.getFilter(ricerca, idLista, Filtri.FILTRO_PROTOCOLLI);
  393.         List<String> tipoSoggettiProtocollo = null;
  394.         try {
  395.             tipoSoggettiProtocollo = Filtri.convertToTipiSoggetti(filterProtocollo, filterProtocolli);
  396.         }catch(Exception e) {
  397.             throw new DriverConfigurazioneException(e.getMessage(),e);
  398.         }
  399.        
  400.         this.driver.logDebug("search : " + search);
  401.         this.driver.logDebug("filterProtocollo : " + filterProtocollo);
  402.         this.driver.logDebug("filterProtocolli : " + filterProtocolli);
  403.        
  404.         Connection con = null;
  405.         PreparedStatement stm=null;
  406.         ResultSet rs=null;
  407.         ArrayList<PortaApplicativa> lista = new ArrayList<>();

  408.         if (this.driver.atomica) {
  409.             try {
  410.                 con = this.driver.getConnectionFromDatasource("porteAppList");
  411.             } catch (Exception e) {
  412.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppList] Exception accedendo al datasource :" + e.getMessage(),e);

  413.             }

  414.         } else
  415.             con = this.driver.globalConnection;

  416.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  417.         try {

  418.             if (!search.equals("")) {
  419.                 //query con search
  420.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  421.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  422.                 sqlQueryObject.addFromTable(CostantiDB.SOGGETTI);
  423.                 sqlQueryObject.addSelectCountField("*", "cont");
  424.                 sqlQueryObject.addWhereCondition("id_soggetto = "+CostantiDB.SOGGETTI+".id");
  425.                 if(this.driver.useSuperUser && superuser!=null && (!"".equals(superuser)))
  426.                     sqlQueryObject.addWhereCondition(CostantiDB.SOGGETTI+".superuser = ?");
  427.                 sqlQueryObject.addWhereLikeCondition("nome_porta",search,true, true);
  428.                 if(tipoSoggettiProtocollo!=null && tipoSoggettiProtocollo.size()>0) {
  429.                     sqlQueryObject.addWhereINCondition("tipo_soggetto", true, tipoSoggettiProtocollo.toArray(new String[1]));
  430.                 }
  431.                 sqlQueryObject.setANDLogicOperator(true);
  432.                 queryString = sqlQueryObject.createSQLQuery();
  433.             } else {
  434.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  435.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  436.                 sqlQueryObject.addFromTable(CostantiDB.SOGGETTI);
  437.                 sqlQueryObject.addSelectCountField("*", "cont");
  438.                 sqlQueryObject.addWhereCondition("id_soggetto = "+CostantiDB.SOGGETTI+".id");
  439.                 if(this.driver.useSuperUser && superuser!=null && (!"".equals(superuser)))
  440.                     sqlQueryObject.addWhereCondition(CostantiDB.SOGGETTI+".superuser = ?");
  441.                 if(tipoSoggettiProtocollo!=null && tipoSoggettiProtocollo.size()>0) {
  442.                     sqlQueryObject.addWhereINCondition("tipo_soggetto", true, tipoSoggettiProtocollo.toArray(new String[1]));
  443.                 }
  444.                 sqlQueryObject.setANDLogicOperator(true);
  445.                 queryString = sqlQueryObject.createSQLQuery();
  446.             }
  447.             stm = con.prepareStatement(queryString);
  448.             if(this.driver.useSuperUser && superuser!=null && (!"".equals(superuser)))
  449.                 stm.setString(1, superuser);
  450.             rs = stm.executeQuery();
  451.             if (rs.next())
  452.                 ricerca.setNumEntries(idLista,rs.getInt(1));
  453.             rs.close();
  454.             stm.close();

  455.             // ricavo le entries
  456.             if (limit == 0) // con limit
  457.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  458.             if (!search.equals("")) { // con search
  459.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  460.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  461.                 sqlQueryObject.addFromTable(CostantiDB.SOGGETTI);
  462.                 sqlQueryObject.addSelectField(CostantiDB.PORTE_APPLICATIVE+".id");
  463.                 sqlQueryObject.addSelectField("nome_porta");
  464.                 sqlQueryObject.addWhereCondition("id_soggetto = "+CostantiDB.SOGGETTI+".id");
  465.                 if(this.driver.useSuperUser && superuser!=null && (!"".equals(superuser)))
  466.                     sqlQueryObject.addWhereCondition(CostantiDB.SOGGETTI+".superuser = ?");
  467.                 sqlQueryObject.addWhereLikeCondition("nome_porta",search,true, true);
  468.                 if(tipoSoggettiProtocollo!=null && tipoSoggettiProtocollo.size()>0) {
  469.                     sqlQueryObject.addWhereINCondition("tipo_soggetto", true, tipoSoggettiProtocollo.toArray(new String[1]));
  470.                 }
  471.                 sqlQueryObject.setANDLogicOperator(true);
  472.                 sqlQueryObject.addOrderBy("nome_porta");
  473.                 sqlQueryObject.setSortType(true);
  474.                 sqlQueryObject.setLimit(limit);
  475.                 sqlQueryObject.setOffset(offset);
  476.                 queryString = sqlQueryObject.createSQLQuery();
  477.             } else {
  478.                 // senza search
  479.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  480.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  481.                 sqlQueryObject.addFromTable(CostantiDB.SOGGETTI);
  482.                 sqlQueryObject.addSelectField(CostantiDB.PORTE_APPLICATIVE+".id");
  483.                 sqlQueryObject.addSelectField("nome_porta");
  484.                 sqlQueryObject.addWhereCondition("id_soggetto = "+CostantiDB.SOGGETTI+".id");
  485.                 if(this.driver.useSuperUser && superuser!=null && (!"".equals(superuser)))
  486.                     sqlQueryObject.addWhereCondition(CostantiDB.SOGGETTI+".superuser = ?");
  487.                 if(tipoSoggettiProtocollo!=null && tipoSoggettiProtocollo.size()>0) {
  488.                     sqlQueryObject.addWhereINCondition("tipo_soggetto", true, tipoSoggettiProtocollo.toArray(new String[1]));
  489.                 }
  490.                 sqlQueryObject.setANDLogicOperator(true);
  491.                 sqlQueryObject.addOrderBy("nome_porta");
  492.                 sqlQueryObject.setSortType(true);
  493.                 sqlQueryObject.setLimit(limit);
  494.                 sqlQueryObject.setOffset(offset);
  495.                 queryString = sqlQueryObject.createSQLQuery();
  496.             }

  497.             stm = con.prepareStatement(queryString);
  498.             if(this.driver.useSuperUser && superuser!=null && (!"".equals(superuser)))
  499.                 stm.setString(1, superuser);
  500.             rs = stm.executeQuery();

  501.             PortaApplicativa pa = null;
  502.             while (rs.next()) {

  503.                 pa = this.porteApplicativeDriver.getPortaApplicativa(rs.getLong("id"),con);

  504.                 lista.add(pa);

  505.             }

  506.             return lista;

  507.         } catch (Exception qe) {
  508.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppList] Errore : " + qe.getMessage(),qe);
  509.         } finally {
  510.             //Chiudo statement and resultset
  511.             JDBCUtilities.closeResources(rs, stm);

  512.             this.driver.closeConnection(con);
  513.         }

  514.     }

  515.     /**
  516.      * Ritorna la lista di proprieta di una Porta Applicativa
  517.      */
  518.     protected List<Proprieta> porteAppPropList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  519.         int offset;
  520.         int limit;
  521.         int idLista = Liste.PORTE_APPLICATIVE_PROP;
  522.         String search;
  523.         String queryString;

  524.         limit = ricerca.getPageSize(idLista);
  525.         offset = ricerca.getIndexIniziale(idLista);
  526.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));      


  527.         Connection con = null;
  528.         PreparedStatement stmt=null;
  529.         ResultSet risultato=null;
  530.         ArrayList<Proprieta> lista = new ArrayList<>();

  531.         if (this.driver.atomica) {
  532.             try {
  533.                 con = this.driver.getConnectionFromDatasource("porteAppPropList");
  534.             } catch (Exception e) {
  535.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Exception accedendo al datasource :" + e.getMessage(),e);

  536.             }

  537.         } else
  538.             con = this.driver.globalConnection;

  539.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  540.         try {

  541.             if (!search.equals("")) {
  542.                 //query con search
  543.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  544.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_PROP);
  545.                 sqlQueryObject.addSelectCountField("*", "cont");
  546.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  547.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  548.                 sqlQueryObject.setANDLogicOperator(true);
  549.                 queryString = sqlQueryObject.createSQLQuery();
  550.             } else {
  551.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  552.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_PROP);
  553.                 sqlQueryObject.addSelectCountField("*", "cont");
  554.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  555.                 queryString = sqlQueryObject.createSQLQuery();
  556.             }
  557.             stmt = con.prepareStatement(queryString);
  558.             stmt.setLong(1, idPortaApplicativa);
  559.             risultato = stmt.executeQuery();
  560.             if (risultato.next())
  561.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  562.             risultato.close();
  563.             stmt.close();

  564.             // ricavo le entries
  565.             if (limit == 0) // con limit
  566.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  567.             if (!search.equals("")) { // con search
  568.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  569.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_PROP);
  570.                 sqlQueryObject.addSelectField("id_porta");
  571.                 sqlQueryObject.addSelectField("nome");
  572.                 sqlQueryObject.addSelectField("valore");
  573.                 sqlQueryObject.addSelectField("enc_value");
  574.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  575.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  576.                 sqlQueryObject.setANDLogicOperator(true);
  577.                 sqlQueryObject.addOrderBy("nome");
  578.                 sqlQueryObject.setSortType(true);
  579.                 sqlQueryObject.setLimit(limit);
  580.                 sqlQueryObject.setOffset(offset);
  581.                 queryString = sqlQueryObject.createSQLQuery();
  582.             } else {
  583.                 // senza search
  584.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  585.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_PROP);
  586.                 sqlQueryObject.addSelectField("id_porta");
  587.                 sqlQueryObject.addSelectField("nome");
  588.                 sqlQueryObject.addSelectField("valore");
  589.                 sqlQueryObject.addSelectField("enc_value");
  590.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  591.                 sqlQueryObject.addOrderBy("nome");
  592.                 sqlQueryObject.setSortType(true);
  593.                 sqlQueryObject.setLimit(limit);
  594.                 sqlQueryObject.setOffset(offset);
  595.                 queryString = sqlQueryObject.createSQLQuery();
  596.             }
  597.             stmt = con.prepareStatement(queryString);
  598.             stmt.setLong(1, idPortaApplicativa);
  599.             risultato = stmt.executeQuery();

  600.             Proprieta prop = null;
  601.             while (risultato.next()) {

  602.                 prop = new Proprieta();

  603.                 prop.setId(risultato.getLong("id_porta"));
  604.                 prop.setNome(risultato.getString("nome"));
  605.                
  606.                 String plainValue = risultato.getString("valore");
  607.                 String encValue = risultato.getString("enc_value");
  608.                 if(encValue!=null && StringUtils.isNotEmpty(encValue)) {
  609.                     prop.setValore(encValue);
  610.                 }
  611.                 else {
  612.                     prop.setValore(plainValue);
  613.                 }

  614.                 lista.add(prop);
  615.             }

  616.             return lista;

  617.         } catch (Exception qe) {
  618.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Errore : " + qe.getMessage(),qe);
  619.         } finally {
  620.             //Chiudo statement and resultset
  621.             JDBCUtilities.closeResources(risultato, stmt);
  622.             this.driver.closeConnection(con);
  623.         }
  624.     }
  625.    
  626.     protected List<Proprieta> porteApplicativeAutenticazioneCustomPropList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  627.         int offset;
  628.         int limit;
  629.         int idLista = Liste.PORTE_APPLICATIVE_PROPRIETA_AUTENTICAZIONE;
  630.         String search;
  631.         String queryString;

  632.         limit = ricerca.getPageSize(idLista);
  633.         offset = ricerca.getIndexIniziale(idLista);
  634.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));      


  635.         Connection con = null;
  636.         PreparedStatement stmt=null;
  637.         ResultSet risultato=null;
  638.         ArrayList<Proprieta> lista = new ArrayList<>();

  639.         if (this.driver.atomica) {
  640.             try {
  641.                 con = this.driver.getConnectionFromDatasource("porteApplicativeAutorizzazioneCustomPropList");
  642.             } catch (Exception e) {
  643.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Exception accedendo al datasource :" + e.getMessage(),e);

  644.             }

  645.         } else
  646.             con = this.driver.globalConnection;

  647.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  648.         try {

  649.             if (!search.equals("")) {
  650.                 //query con search
  651.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  652.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTENTICAZIONE_PROP);
  653.                 sqlQueryObject.addSelectCountField("*", "cont");
  654.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  655.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  656.                 sqlQueryObject.setANDLogicOperator(true);
  657.                 queryString = sqlQueryObject.createSQLQuery();
  658.             } else {
  659.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  660.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTENTICAZIONE_PROP);
  661.                 sqlQueryObject.addSelectCountField("*", "cont");
  662.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  663.                 queryString = sqlQueryObject.createSQLQuery();
  664.             }
  665.             stmt = con.prepareStatement(queryString);
  666.             stmt.setLong(1, idPortaApplicativa);
  667.             risultato = stmt.executeQuery();
  668.             if (risultato.next())
  669.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  670.             risultato.close();
  671.             stmt.close();

  672.             // ricavo le entries
  673.             if (limit == 0) // con limit
  674.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  675.             if (!search.equals("")) { // con search
  676.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  677.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTENTICAZIONE_PROP);
  678.                 sqlQueryObject.addSelectField("id");
  679.                 sqlQueryObject.addSelectField("id_porta");
  680.                 sqlQueryObject.addSelectField("nome");
  681.                 sqlQueryObject.addSelectField("valore");
  682.                 sqlQueryObject.addSelectField("enc_value");
  683.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  684.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  685.                 sqlQueryObject.setANDLogicOperator(true);
  686.                 sqlQueryObject.addOrderBy("nome");
  687.                 sqlQueryObject.setSortType(true);
  688.                 sqlQueryObject.setLimit(limit);
  689.                 sqlQueryObject.setOffset(offset);
  690.                 queryString = sqlQueryObject.createSQLQuery();
  691.             } else {
  692.                 // senza search
  693.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  694.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTENTICAZIONE_PROP);
  695.                 sqlQueryObject.addSelectField("id");
  696.                 sqlQueryObject.addSelectField("id_porta");
  697.                 sqlQueryObject.addSelectField("nome");
  698.                 sqlQueryObject.addSelectField("valore");
  699.                 sqlQueryObject.addSelectField("enc_value");
  700.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  701.                 sqlQueryObject.addOrderBy("nome");
  702.                 sqlQueryObject.setSortType(true);
  703.                 sqlQueryObject.setLimit(limit);
  704.                 sqlQueryObject.setOffset(offset);
  705.                 queryString = sqlQueryObject.createSQLQuery();
  706.             }
  707.             stmt = con.prepareStatement(queryString);
  708.             stmt.setLong(1, idPortaApplicativa);
  709.             risultato = stmt.executeQuery();

  710.             Proprieta prop = null;
  711.             while (risultato.next()) {

  712.                 prop = new Proprieta();

  713.                 prop.setId(risultato.getLong("id"));
  714.                 prop.setNome(risultato.getString("nome"));
  715.                
  716.                 String plainValue = risultato.getString("valore");
  717.                 String encValue = risultato.getString("enc_value");
  718.                 if(encValue!=null && StringUtils.isNotEmpty(encValue)) {
  719.                     prop.setValore(encValue);
  720.                 }
  721.                 else {
  722.                     prop.setValore(plainValue);
  723.                 }

  724.                 lista.add(prop);
  725.             }

  726.             return lista;

  727.         } catch (Exception qe) {
  728.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Errore : " + qe.getMessage(),qe);
  729.         } finally {
  730.             //Chiudo statement and resultset
  731.             JDBCUtilities.closeResources(risultato, stmt);
  732.             this.driver.closeConnection(con);
  733.         }
  734.     }
  735.    
  736.     /**
  737.      * Ritorna la lista di proprieta per l'autorizzazione custom di una Porta Applicativa
  738.      */
  739.     protected List<Proprieta> porteApplicativeAutorizzazioneCustomPropList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  740.         int offset;
  741.         int limit;
  742.         int idLista = Liste.PORTE_APPLICATIVE_PROPRIETA_AUTORIZZAZIONE;
  743.         String search;
  744.         String queryString;

  745.         limit = ricerca.getPageSize(idLista);
  746.         offset = ricerca.getIndexIniziale(idLista);
  747.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));      


  748.         Connection con = null;
  749.         PreparedStatement stmt=null;
  750.         ResultSet risultato=null;
  751.         ArrayList<Proprieta> lista = new ArrayList<>();

  752.         if (this.driver.atomica) {
  753.             try {
  754.                 con = this.driver.getConnectionFromDatasource("porteApplicativeAutorizzazioneCustomPropList");
  755.             } catch (Exception e) {
  756.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Exception accedendo al datasource :" + e.getMessage(),e);

  757.             }

  758.         } else
  759.             con = this.driver.globalConnection;

  760.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  761.         try {

  762.             if (!search.equals("")) {
  763.                 //query con search
  764.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  765.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTORIZZAZIONE_PROP);
  766.                 sqlQueryObject.addSelectCountField("*", "cont");
  767.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  768.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  769.                 sqlQueryObject.setANDLogicOperator(true);
  770.                 queryString = sqlQueryObject.createSQLQuery();
  771.             } else {
  772.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  773.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTORIZZAZIONE_PROP);
  774.                 sqlQueryObject.addSelectCountField("*", "cont");
  775.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  776.                 queryString = sqlQueryObject.createSQLQuery();
  777.             }
  778.             stmt = con.prepareStatement(queryString);
  779.             stmt.setLong(1, idPortaApplicativa);
  780.             risultato = stmt.executeQuery();
  781.             if (risultato.next())
  782.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  783.             risultato.close();
  784.             stmt.close();

  785.             // ricavo le entries
  786.             if (limit == 0) // con limit
  787.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  788.             if (!search.equals("")) { // con search
  789.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  790.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTORIZZAZIONE_PROP);
  791.                 sqlQueryObject.addSelectField("id");
  792.                 sqlQueryObject.addSelectField("id_porta");
  793.                 sqlQueryObject.addSelectField("nome");
  794.                 sqlQueryObject.addSelectField("valore");
  795.                 sqlQueryObject.addSelectField("enc_value");
  796.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  797.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  798.                 sqlQueryObject.setANDLogicOperator(true);
  799.                 sqlQueryObject.addOrderBy("nome");
  800.                 sqlQueryObject.setSortType(true);
  801.                 sqlQueryObject.setLimit(limit);
  802.                 sqlQueryObject.setOffset(offset);
  803.                 queryString = sqlQueryObject.createSQLQuery();
  804.             } else {
  805.                 // senza search
  806.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  807.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTORIZZAZIONE_PROP);
  808.                 sqlQueryObject.addSelectField("id");
  809.                 sqlQueryObject.addSelectField("id_porta");
  810.                 sqlQueryObject.addSelectField("nome");
  811.                 sqlQueryObject.addSelectField("valore");
  812.                 sqlQueryObject.addSelectField("enc_value");
  813.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  814.                 sqlQueryObject.addOrderBy("nome");
  815.                 sqlQueryObject.setSortType(true);
  816.                 sqlQueryObject.setLimit(limit);
  817.                 sqlQueryObject.setOffset(offset);
  818.                 queryString = sqlQueryObject.createSQLQuery();
  819.             }
  820.             stmt = con.prepareStatement(queryString);
  821.             stmt.setLong(1, idPortaApplicativa);
  822.             risultato = stmt.executeQuery();

  823.             Proprieta prop = null;
  824.             while (risultato.next()) {

  825.                 prop = new Proprieta();

  826.                 prop.setId(risultato.getLong("id"));
  827.                 prop.setNome(risultato.getString("nome"));
  828.                
  829.                 String plainValue = risultato.getString("valore");
  830.                 String encValue = risultato.getString("enc_value");
  831.                 if(encValue!=null && StringUtils.isNotEmpty(encValue)) {
  832.                     prop.setValore(encValue);
  833.                 }
  834.                 else {
  835.                     prop.setValore(plainValue);
  836.                 }

  837.                 lista.add(prop);
  838.             }

  839.             return lista;

  840.         } catch (Exception qe) {
  841.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Errore : " + qe.getMessage(),qe);
  842.         } finally {
  843.             //Chiudo statement and resultset
  844.             JDBCUtilities.closeResources(risultato, stmt);
  845.             this.driver.closeConnection(con);
  846.         }
  847.     }
  848.    
  849.     protected List<Proprieta> porteApplicativeAutorizzazioneContenutoCustomPropList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  850.         int offset;
  851.         int limit;
  852.         int idLista = Liste.PORTE_APPLICATIVE_PROPRIETA_AUTORIZZAZIONE_CONTENUTO;
  853.         String search;
  854.         String queryString;

  855.         limit = ricerca.getPageSize(idLista);
  856.         offset = ricerca.getIndexIniziale(idLista);
  857.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));      


  858.         Connection con = null;
  859.         PreparedStatement stmt=null;
  860.         ResultSet risultato=null;
  861.         ArrayList<Proprieta> lista = new ArrayList<>();

  862.         if (this.driver.atomica) {
  863.             try {
  864.                 con = this.driver.getConnectionFromDatasource("porteApplicativeAutorizzazioneCustomPropList");
  865.             } catch (Exception e) {
  866.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Exception accedendo al datasource :" + e.getMessage(),e);

  867.             }

  868.         } else
  869.             con = this.driver.globalConnection;

  870.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  871.         try {

  872.             if (!search.equals("")) {
  873.                 //query con search
  874.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  875.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTORIZZAZIONE_CONTENUTI_PROP);
  876.                 sqlQueryObject.addSelectCountField("*", "cont");
  877.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  878.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  879.                 sqlQueryObject.setANDLogicOperator(true);
  880.                 queryString = sqlQueryObject.createSQLQuery();
  881.             } else {
  882.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  883.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTORIZZAZIONE_CONTENUTI_PROP);
  884.                 sqlQueryObject.addSelectCountField("*", "cont");
  885.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  886.                 queryString = sqlQueryObject.createSQLQuery();
  887.             }
  888.             stmt = con.prepareStatement(queryString);
  889.             stmt.setLong(1, idPortaApplicativa);
  890.             risultato = stmt.executeQuery();
  891.             if (risultato.next())
  892.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  893.             risultato.close();
  894.             stmt.close();

  895.             // ricavo le entries
  896.             if (limit == 0) // con limit
  897.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  898.             if (!search.equals("")) { // con search
  899.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  900.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTORIZZAZIONE_CONTENUTI_PROP);
  901.                 sqlQueryObject.addSelectField("id");
  902.                 sqlQueryObject.addSelectField("id_porta");
  903.                 sqlQueryObject.addSelectField("nome");
  904.                 sqlQueryObject.addSelectField("valore");
  905.                 sqlQueryObject.addSelectField("enc_value");
  906.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  907.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  908.                 sqlQueryObject.setANDLogicOperator(true);
  909.                 sqlQueryObject.addOrderBy("nome");
  910.                 sqlQueryObject.setSortType(true);
  911.                 sqlQueryObject.setLimit(limit);
  912.                 sqlQueryObject.setOffset(offset);
  913.                 queryString = sqlQueryObject.createSQLQuery();
  914.             } else {
  915.                 // senza search
  916.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  917.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AUTORIZZAZIONE_CONTENUTI_PROP);
  918.                 sqlQueryObject.addSelectField("id");
  919.                 sqlQueryObject.addSelectField("id_porta");
  920.                 sqlQueryObject.addSelectField("nome");
  921.                 sqlQueryObject.addSelectField("valore");
  922.                 sqlQueryObject.addSelectField("enc_value");
  923.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  924.                 sqlQueryObject.addOrderBy("nome");
  925.                 sqlQueryObject.setSortType(true);
  926.                 sqlQueryObject.setLimit(limit);
  927.                 sqlQueryObject.setOffset(offset);
  928.                 queryString = sqlQueryObject.createSQLQuery();
  929.             }
  930.             stmt = con.prepareStatement(queryString);
  931.             stmt.setLong(1, idPortaApplicativa);
  932.             risultato = stmt.executeQuery();

  933.             Proprieta prop = null;
  934.             while (risultato.next()) {

  935.                 prop = new Proprieta();

  936.                 prop.setId(risultato.getLong("id"));
  937.                 prop.setNome(risultato.getString("nome"));
  938.                
  939.                 String plainValue = risultato.getString("valore");
  940.                 String encValue = risultato.getString("enc_value");
  941.                 if(encValue!=null && StringUtils.isNotEmpty(encValue)) {
  942.                     prop.setValore(encValue);
  943.                 }
  944.                 else {
  945.                     prop.setValore(plainValue);
  946.                 }

  947.                 lista.add(prop);
  948.             }

  949.             return lista;

  950.         } catch (Exception qe) {
  951.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Errore : " + qe.getMessage(),qe);
  952.         } finally {
  953.             //Chiudo statement and resultset
  954.             JDBCUtilities.closeResources(risultato, stmt);
  955.             this.driver.closeConnection(con);
  956.         }
  957.     }
  958.    
  959.     /**
  960.      * Ritorna la lista di Azioni di una  Porta Applicativa
  961.      */
  962.     protected List<PortaApplicativaAzione> porteAppAzioneList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  963.         int offset;
  964.         int limit;
  965.         int idLista = Liste.PORTE_APPLICATIVE_AZIONI;
  966.         String search;
  967.         String queryString;

  968.         limit = ricerca.getPageSize(idLista);
  969.         offset = ricerca.getIndexIniziale(idLista);
  970.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));      


  971.         Connection con = null;
  972.         PreparedStatement stmt=null;
  973.         ResultSet risultato=null;
  974.         ArrayList<PortaApplicativaAzione> lista = new ArrayList<>();

  975.         if (this.driver.atomica) {
  976.             try {
  977.                 con = this.driver.getConnectionFromDatasource("porteAppPropList");
  978.             } catch (Exception e) {
  979.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Exception accedendo al datasource :" + e.getMessage(),e);

  980.             }

  981.         } else
  982.             con = this.driver.globalConnection;

  983.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  984.         try {

  985.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  986.             sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AZIONI);
  987.             sqlQueryObject.addSelectCountField("*", "cont");
  988.             sqlQueryObject.addWhereCondition("id_porta = ?");
  989.             if (!search.equals("")) {
  990.                 //query con search
  991.                 sqlQueryObject.addWhereLikeCondition("azione", search, true, true);
  992.             }
  993.             sqlQueryObject.setANDLogicOperator(true);
  994.             queryString = sqlQueryObject.createSQLQuery();
  995.            
  996.             stmt = con.prepareStatement(queryString);
  997.             stmt.setLong(1, idPortaApplicativa);
  998.             risultato = stmt.executeQuery();
  999.             if (risultato.next())
  1000.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  1001.             risultato.close();
  1002.             stmt.close();

  1003.             // ricavo le entries
  1004.             if (limit == 0) // con limit
  1005.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  1006.            
  1007.             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1008.             sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_AZIONI);
  1009.             sqlQueryObject.addSelectField("id_porta");
  1010.             sqlQueryObject.addSelectField("azione");
  1011.             sqlQueryObject.addSelectField("id");
  1012.             sqlQueryObject.addWhereCondition("id_porta = ?");
  1013.            
  1014.             if (!search.equals("")) { // con search
  1015.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  1016.             }
  1017.            
  1018.             sqlQueryObject.setANDLogicOperator(true);
  1019.             sqlQueryObject.addOrderBy("azione");
  1020.             sqlQueryObject.setSortType(true);
  1021.             sqlQueryObject.setLimit(limit);
  1022.             sqlQueryObject.setOffset(offset);
  1023.             queryString = sqlQueryObject.createSQLQuery();
  1024.            
  1025.             stmt = con.prepareStatement(queryString);
  1026.             stmt.setLong(1, idPortaApplicativa);
  1027.             risultato = stmt.executeQuery();

  1028.             PortaApplicativaAzione azione = null;
  1029.             while (risultato.next()) {

  1030.                 azione = new PortaApplicativaAzione();
  1031.                
  1032.                 azione.setId(risultato.getLong("id"));
  1033.                 azione.setNome(risultato.getString("azione")) ;
  1034.                
  1035.                 String nomePortaDelegante = null;
  1036.                 azione.setNomePortaDelegante(nomePortaDelegante);
  1037.                 PortaApplicativaAzioneIdentificazione identificazione = null;
  1038.                 azione.setIdentificazione(identificazione);
  1039.                 StatoFunzionalita forceInterfaceBased = StatoFunzionalita.ABILITATO;
  1040.                 azione.setForceInterfaceBased(forceInterfaceBased);

  1041.                 lista.add(azione);
  1042.             }

  1043.             return lista;

  1044.         } catch (Exception qe) {
  1045.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Errore : " + qe.getMessage(),qe);
  1046.         } finally {
  1047.             //Chiudo statement and resultset
  1048.             JDBCUtilities.closeResources(risultato, stmt);
  1049.             this.driver.closeConnection(con);
  1050.         }
  1051.     }

  1052.     protected List<ServizioApplicativo> porteAppServizioApplicativoList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  1053.         String nomeMetodo = "porteAppServizioApplicativoList";
  1054.         int idLista = Liste.PORTE_APPLICATIVE_SERVIZIO_APPLICATIVO;
  1055.         int offset;
  1056.         int limit;
  1057.         String search;
  1058.         String queryString;

  1059.         limit = ricerca.getPageSize(idLista);
  1060.         offset = ricerca.getIndexIniziale(idLista);
  1061.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));

  1062.         Connection con = null;
  1063.         PreparedStatement stmt=null;
  1064.         PreparedStatement stmt1=null;
  1065.         ResultSet risultato=null;
  1066.         ArrayList<ServizioApplicativo> lista = new ArrayList<>();

  1067.         if (this.driver.atomica) {
  1068.             try {
  1069.                 con = this.driver.getConnectionFromDatasource("porteAppServizioApplicativoList");
  1070.             } catch (Exception e) {
  1071.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  1072.             }

  1073.         } else
  1074.             con = this.driver.globalConnection;

  1075.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1076.         try {

  1077.             if (!search.equals("")) {
  1078.                 //query con search
  1079.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1080.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SA);
  1081.                 sqlQueryObject.addFromTable(CostantiDB.SERVIZI_APPLICATIVI);
  1082.                 sqlQueryObject.addSelectCountField("*", "cont");
  1083.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1084.                 sqlQueryObject.addWhereCondition(CostantiDB.PORTE_APPLICATIVE_SA+".id_servizio_applicativo="+CostantiDB.SERVIZI_APPLICATIVI+".id");
  1085.                 sqlQueryObject.addWhereLikeCondition(CostantiDB.SERVIZI_APPLICATIVI+".nome", search, true, true);
  1086.                 sqlQueryObject.setANDLogicOperator(true);
  1087.                 queryString = sqlQueryObject.createSQLQuery();
  1088.             } else {
  1089.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1090.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SA);
  1091.                 sqlQueryObject.addSelectCountField("*", "cont");
  1092.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1093.                 queryString = sqlQueryObject.createSQLQuery();
  1094.             }
  1095.             stmt = con.prepareStatement(queryString);
  1096.             stmt.setLong(1, idPortaApplicativa);
  1097.             risultato = stmt.executeQuery();
  1098.             if (risultato.next())
  1099.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  1100.             risultato.close();
  1101.             stmt.close();

  1102.             // ricavo le entries
  1103.             if (limit == 0) // con limit
  1104.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  1105.             if (!search.equals("")) { // con search
  1106.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1107.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SA);
  1108.                 sqlQueryObject.addFromTable(CostantiDB.SERVIZI_APPLICATIVI);
  1109.                 sqlQueryObject.addSelectField("id_servizio_applicativo");
  1110.                 sqlQueryObject.addSelectField("id_porta");
  1111.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1112.                 sqlQueryObject.addWhereCondition(CostantiDB.PORTE_APPLICATIVE_SA+".id_servizio_applicativo="+CostantiDB.SERVIZI_APPLICATIVI+".id");
  1113.                 sqlQueryObject.addWhereLikeCondition(CostantiDB.SERVIZI_APPLICATIVI+".nome", search, true, true);
  1114.                 sqlQueryObject.setANDLogicOperator(true);
  1115.                 sqlQueryObject.addOrderBy("id_servizio_applicativo");
  1116.                 sqlQueryObject.setSortType(true);
  1117.                 sqlQueryObject.setLimit(limit);
  1118.                 sqlQueryObject.setOffset(offset);
  1119.                 queryString = sqlQueryObject.createSQLQuery();
  1120.             } else {
  1121.                 // senza search
  1122.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1123.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SA);
  1124.                 sqlQueryObject.addSelectField("id_servizio_applicativo");
  1125.                 sqlQueryObject.addSelectField("id_porta");
  1126.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1127.                 sqlQueryObject.addOrderBy("id_servizio_applicativo");
  1128.                 sqlQueryObject.setSortType(true);
  1129.                 sqlQueryObject.setLimit(limit);
  1130.                 sqlQueryObject.setOffset(offset);
  1131.                 queryString = sqlQueryObject.createSQLQuery();
  1132.             }
  1133.             stmt = con.prepareStatement(queryString);
  1134.             stmt.setLong(1, idPortaApplicativa);
  1135.             risultato = stmt.executeQuery();

  1136.             ServizioApplicativo sa = null;
  1137.             ResultSet rs1;
  1138.             long idServizioApplicativo = 0;
  1139.             while (risultato.next()) {
  1140.                 idServizioApplicativo = risultato.getLong("id_servizio_applicativo");

  1141.                 sa = new ServizioApplicativo();

  1142.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1143.                 sqlQueryObject.addFromTable(CostantiDB.SERVIZI_APPLICATIVI);
  1144.                 sqlQueryObject.addSelectField("*");
  1145.                 sqlQueryObject.addWhereCondition("id = ?");
  1146.                 queryString = sqlQueryObject.createSQLQuery();

  1147.                 stmt1 = con.prepareStatement(queryString);
  1148.                 stmt1.setLong(1, idServizioApplicativo);

  1149.                 rs1 = stmt1.executeQuery();

  1150.                 // recupero i dati del servizio applicativo
  1151.                 if (rs1.next()) {
  1152.                     sa.setId(idServizioApplicativo);
  1153.                     sa.setNome(rs1.getString("nome"));
  1154.                     sa.setDescrizione(rs1.getString("descrizione"));
  1155.                     sa.setIdSoggetto(rs1.getLong("id_soggetto"));
  1156.                 } else
  1157.                     throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore recuperando i dati del Servizio Applicativo.");

  1158.                 rs1.close();
  1159.                 stmt1.close();
  1160.                 lista.add(sa);

  1161.             }
  1162.             risultato.close();
  1163.             stmt.close();
  1164.             return lista;

  1165.         } catch (Exception qe) {
  1166.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  1167.         } finally {

  1168.             //Chiudo statement and resultset
  1169.             JDBCUtilities.closeResources(risultato, stmt);
  1170.             JDBCUtilities.closeResources(stmt1);
  1171.            
  1172.             this.driver.closeConnection(con);
  1173.         }
  1174.     }
  1175.    
  1176.     protected List<PortaApplicativaAutorizzazioneSoggetto> porteAppSoggettoList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  1177.         String nomeMetodo = "porteAppSoggettoList";
  1178.         int idLista = Liste.PORTE_APPLICATIVE_SOGGETTO;
  1179.         int offset;
  1180.         int limit;
  1181.         String search;
  1182.         String queryString;

  1183.         limit = ricerca.getPageSize(idLista);
  1184.         offset = ricerca.getIndexIniziale(idLista);
  1185.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));

  1186.         Connection con = null;
  1187.         PreparedStatement stmt=null;
  1188.         PreparedStatement stmt1=null;
  1189.         ResultSet risultato=null;
  1190.         ArrayList<PortaApplicativaAutorizzazioneSoggetto> lista = new ArrayList<>();

  1191.         if (this.driver.atomica) {
  1192.             try {
  1193.                 con = this.driver.getConnectionFromDatasource("porteAppSoggettoList");
  1194.             } catch (Exception e) {
  1195.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  1196.             }

  1197.         } else
  1198.             con = this.driver.globalConnection;

  1199.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1200.         try {

  1201.             //query con search
  1202.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1203.             sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SOGGETTI);
  1204.             sqlQueryObject.addSelectCountField("*", "cont");
  1205.             sqlQueryObject.addWhereCondition("id_porta = ?");
  1206.             if (!search.equals("")) {
  1207.                 sqlQueryObject.addWhereLikeCondition(CostantiDB.PORTE_APPLICATIVE_SOGGETTI+".nome_soggetto", search, true, true);
  1208.                 sqlQueryObject.setANDLogicOperator(true);
  1209.             }
  1210.             queryString = sqlQueryObject.createSQLQuery();
  1211.             stmt = con.prepareStatement(queryString);
  1212.             stmt.setLong(1, idPortaApplicativa);
  1213.             risultato = stmt.executeQuery();
  1214.             if (risultato.next())
  1215.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  1216.             risultato.close();
  1217.             stmt.close();

  1218.             // ricavo le entries
  1219.             if (limit == 0) // con limit
  1220.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  1221.            
  1222.             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1223.             sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SOGGETTI);
  1224.             sqlQueryObject.addSelectField("id_porta");
  1225.             sqlQueryObject.addSelectField("tipo_soggetto");
  1226.             sqlQueryObject.addSelectField("nome_soggetto");
  1227.             sqlQueryObject.addWhereCondition("id_porta = ?");
  1228.             if (!search.equals("")) {
  1229.                 sqlQueryObject.addWhereLikeCondition(CostantiDB.PORTE_APPLICATIVE_SOGGETTI+".nome_soggetto", search, true, true);
  1230.                 sqlQueryObject.setANDLogicOperator(true);
  1231.             }
  1232.             sqlQueryObject.addOrderBy("tipo_soggetto");
  1233.             sqlQueryObject.addOrderBy("nome_soggetto");
  1234.             sqlQueryObject.setSortType(true);
  1235.             sqlQueryObject.setLimit(limit);
  1236.             sqlQueryObject.setOffset(offset);
  1237.             queryString = sqlQueryObject.createSQLQuery();
  1238.            
  1239.             stmt = con.prepareStatement(queryString);
  1240.             stmt.setLong(1, idPortaApplicativa);
  1241.             risultato = stmt.executeQuery();

  1242.             PortaApplicativaAutorizzazioneSoggetto paAuthSoggetto = null;
  1243.             while (risultato.next()) {
  1244.                 paAuthSoggetto = new PortaApplicativaAutorizzazioneSoggetto();
  1245.                 paAuthSoggetto.setNome(risultato.getString("nome_soggetto"));
  1246.                 paAuthSoggetto.setTipo(risultato.getString("tipo_soggetto"));
  1247.                
  1248.                 lista.add(paAuthSoggetto);
  1249.             }
  1250.             risultato.close();
  1251.             stmt.close();
  1252.             return lista;

  1253.         } catch (Exception qe) {
  1254.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  1255.         } finally {

  1256.             //Chiudo statement and resultset
  1257.             JDBCUtilities.closeResources(risultato, stmt);
  1258.             JDBCUtilities.closeResources(stmt1);
  1259.             this.driver.closeConnection(con);
  1260.         }
  1261.     }
  1262.    
  1263.     protected List<PortaApplicativaAutorizzazioneServizioApplicativo> porteAppServiziApplicativiAutorizzatiList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  1264.         String nomeMetodo = "porteAppServiziApplicativiAutorizzatiList";
  1265.         int idLista = Liste.PORTE_APPLICATIVE_SERVIZIO_APPLICATIVO_AUTORIZZATO;
  1266.         String nomeTabella = CostantiDB.PORTE_APPLICATIVE_SA_AUTORIZZATI;
  1267.         return _porteAppServiziApplicativiAutorizzatiTokenList(idPortaApplicativa, ricerca,
  1268.                 nomeMetodo, nomeTabella, idLista);
  1269.     }
  1270.    
  1271.     protected List<PortaApplicativaAutorizzazioneServizioApplicativo> porteAppServiziApplicativiAutorizzatiTokenList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  1272.         String nomeMetodo = "porteAppServiziApplicativiAutorizzatiTokenList";
  1273.         int idLista = Liste.PORTE_APPLICATIVE_TOKEN_SERVIZIO_APPLICATIVO;
  1274.         String nomeTabella = CostantiDB.PORTE_APPLICATIVE_TOKEN_SA;
  1275.         return _porteAppServiziApplicativiAutorizzatiTokenList(idPortaApplicativa, ricerca,
  1276.                 nomeMetodo, nomeTabella, idLista);
  1277.     }
  1278.     private List<PortaApplicativaAutorizzazioneServizioApplicativo> _porteAppServiziApplicativiAutorizzatiTokenList(long idPortaApplicativa, ISearch ricerca,
  1279.             String nomeMetodo, String nomeTabella, int idLista) throws DriverConfigurazioneException {
  1280.         int offset;
  1281.         int limit;
  1282.         String search;
  1283.         String queryString;

  1284.         limit = ricerca.getPageSize(idLista);
  1285.         offset = ricerca.getIndexIniziale(idLista);
  1286.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));

  1287.         Connection con = null;
  1288.         PreparedStatement stmt=null;
  1289.         PreparedStatement stmt1=null;
  1290.         ResultSet risultato=null;
  1291.         ArrayList<PortaApplicativaAutorizzazioneServizioApplicativo> lista = new ArrayList<>();

  1292.         if (this.driver.atomica) {
  1293.             try {
  1294.                 con = this.driver.getConnectionFromDatasource("porteAppServiziApplicativiAutorizzatiTokenList");
  1295.             } catch (Exception e) {
  1296.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  1297.             }

  1298.         } else
  1299.             con = this.driver.globalConnection;

  1300.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1301.         try {

  1302.             //query con search
  1303.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1304.             sqlQueryObject.addFromTable(nomeTabella);
  1305.             sqlQueryObject.addSelectCountField("*", "cont");
  1306.             sqlQueryObject.addWhereCondition("id_porta = ?");
  1307.             if (!search.equals("")) {
  1308.                 sqlQueryObject.addFromTable(CostantiDB.SERVIZI_APPLICATIVI);
  1309.                 sqlQueryObject.addWhereCondition(CostantiDB.SERVIZI_APPLICATIVI+".id="+nomeTabella+".id_servizio_applicativo");
  1310.                 sqlQueryObject.addWhereLikeCondition(CostantiDB.SERVIZI_APPLICATIVI+".nome", search, true, true);
  1311.             }
  1312.             sqlQueryObject.setANDLogicOperator(true);
  1313.             queryString = sqlQueryObject.createSQLQuery();
  1314.             stmt = con.prepareStatement(queryString);
  1315.             stmt.setLong(1, idPortaApplicativa);
  1316.             risultato = stmt.executeQuery();
  1317.             if (risultato.next())
  1318.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  1319.             risultato.close();
  1320.             stmt.close();

  1321.             // ricavo le entries
  1322.             if (limit == 0) // con limit
  1323.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  1324.            
  1325.             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1326.             sqlQueryObject.addFromTable(nomeTabella);
  1327.             sqlQueryObject.addFromTable(CostantiDB.SERVIZI_APPLICATIVI);
  1328.             sqlQueryObject.addFromTable(CostantiDB.SOGGETTI);
  1329.             sqlQueryObject.addSelectField("id_porta");
  1330.             sqlQueryObject.addSelectField("id_servizio_applicativo");
  1331.             sqlQueryObject.addSelectField("nome");
  1332.             sqlQueryObject.addSelectAliasField(CostantiDB.SERVIZI_APPLICATIVI, "id_soggetto", "idSoggettoProprietarioSA");
  1333.             sqlQueryObject.addSelectAliasField(CostantiDB.SOGGETTI, "tipo_soggetto", "tipoSoggettoProprietarioSA");
  1334.             sqlQueryObject.addSelectAliasField(CostantiDB.SOGGETTI, "nome_soggetto", "nomeSoggettoProprietarioSA");
  1335.             sqlQueryObject.addWhereCondition("id_porta = ?");
  1336.             sqlQueryObject.addWhereCondition(CostantiDB.SERVIZI_APPLICATIVI+".id="+nomeTabella+".id_servizio_applicativo");
  1337.             sqlQueryObject.addWhereCondition(CostantiDB.SERVIZI_APPLICATIVI+".id_soggetto="+CostantiDB.SOGGETTI+".id");
  1338.             sqlQueryObject.setANDLogicOperator(true);
  1339.             if (!search.equals("")) {
  1340.                 sqlQueryObject.addWhereLikeCondition(CostantiDB.SERVIZI_APPLICATIVI+".nome", search, true, true);
  1341.             }
  1342.             sqlQueryObject.addOrderBy(CostantiDB.SERVIZI_APPLICATIVI+".nome");
  1343.             sqlQueryObject.setSortType(true);
  1344.             sqlQueryObject.setLimit(limit);
  1345.             sqlQueryObject.setOffset(offset);
  1346.             queryString = sqlQueryObject.createSQLQuery();
  1347.            
  1348.             stmt = con.prepareStatement(queryString);
  1349.             stmt.setLong(1, idPortaApplicativa);
  1350.             risultato = stmt.executeQuery();

  1351.             PortaApplicativaAutorizzazioneServizioApplicativo paAuthSa = null;
  1352.             while (risultato.next()) {
  1353.                 paAuthSa = new PortaApplicativaAutorizzazioneServizioApplicativo();
  1354.                 paAuthSa.setNome(risultato.getString("nome"));
  1355.                 paAuthSa.setTipoSoggettoProprietario(risultato.getString("tipoSoggettoProprietarioSA"));
  1356.                 paAuthSa.setNomeSoggettoProprietario(risultato.getString("nomeSoggettoProprietarioSA"));
  1357.                 lista.add(paAuthSa);
  1358.             }
  1359.             risultato.close();
  1360.             stmt.close();
  1361.             return lista;

  1362.         } catch (Exception qe) {
  1363.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  1364.         } finally {

  1365.             //Chiudo statement and resultset
  1366.             JDBCUtilities.closeResources(risultato, stmt);
  1367.             JDBCUtilities.closeResources(stmt1);
  1368.             this.driver.closeConnection(con);
  1369.         }
  1370.     }

  1371.     protected List<MessageSecurityFlowParameter> porteAppMessageSecurityRequestList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  1372.         String nomeMetodo = "porteAppMessageSecurityRequestList";
  1373.         int idLista = Liste.PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST;

  1374.         int offset;
  1375.         int limit;
  1376.         String search;
  1377.         String queryString;
  1378.         limit = ricerca.getPageSize(idLista);
  1379.         offset = ricerca.getIndexIniziale(idLista);
  1380.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));


  1381.         Connection con = null;
  1382.         PreparedStatement stmt=null;
  1383.         ResultSet risultato=null;
  1384.         ArrayList<MessageSecurityFlowParameter> lista = new ArrayList<>();

  1385.         if (this.driver.atomica) {
  1386.             try {
  1387.                 con = this.driver.getConnectionFromDatasource("porteAppMessageSecurityRequestList");
  1388.             } catch (Exception e) {
  1389.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  1390.             }

  1391.         } else
  1392.             con = this.driver.globalConnection;

  1393.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1394.         try {

  1395.             if (!search.equals("")) {
  1396.                 //query con search
  1397.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1398.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST);
  1399.                 sqlQueryObject.addSelectCountField("*", "cont");
  1400.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1401.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  1402.                 sqlQueryObject.setANDLogicOperator(true);
  1403.                 queryString = sqlQueryObject.createSQLQuery();
  1404.             } else {
  1405.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1406.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST);
  1407.                 sqlQueryObject.addSelectCountField("*", "cont");
  1408.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1409.                 queryString = sqlQueryObject.createSQLQuery();
  1410.             }
  1411.             stmt = con.prepareStatement(queryString);
  1412.             stmt.setLong(1, idPortaApplicativa);
  1413.             risultato = stmt.executeQuery();
  1414.             if (risultato.next())
  1415.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  1416.             risultato.close();
  1417.             stmt.close();

  1418.             // ricavo le entries
  1419.             if (limit == 0) // con limit
  1420.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  1421.             if (!search.equals("")) { // con search
  1422.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1423.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST);
  1424.                 sqlQueryObject.addSelectField("id_porta");
  1425.                 sqlQueryObject.addSelectField("nome");
  1426.                 sqlQueryObject.addSelectField("valore");
  1427.                 sqlQueryObject.addSelectField("enc_value");
  1428.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1429.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  1430.                 sqlQueryObject.setANDLogicOperator(true);
  1431.                 sqlQueryObject.addOrderBy("nome");
  1432.                 sqlQueryObject.setSortType(true);
  1433.                 sqlQueryObject.setLimit(limit);
  1434.                 sqlQueryObject.setOffset(offset);
  1435.                 queryString = sqlQueryObject.createSQLQuery();
  1436.             } else {
  1437.                 // senza search
  1438.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1439.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MESSAGE_SECURITY_REQUEST);
  1440.                 sqlQueryObject.addSelectField("id_porta");
  1441.                 sqlQueryObject.addSelectField("nome");
  1442.                 sqlQueryObject.addSelectField("valore");
  1443.                 sqlQueryObject.addSelectField("enc_value");
  1444.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1445.                 sqlQueryObject.addOrderBy("nome");
  1446.                 sqlQueryObject.setSortType(true);
  1447.                 sqlQueryObject.setLimit(limit);
  1448.                 sqlQueryObject.setOffset(offset);
  1449.                 queryString = sqlQueryObject.createSQLQuery();
  1450.             }
  1451.             stmt = con.prepareStatement(queryString);
  1452.             stmt.setLong(1, idPortaApplicativa);
  1453.             risultato = stmt.executeQuery();

  1454.             MessageSecurityFlowParameter wsreq;
  1455.             while (risultato.next()) {

  1456.                 wsreq = new MessageSecurityFlowParameter();

  1457.                 wsreq.setId(risultato.getLong("id_porta"));
  1458.                 wsreq.setNome(risultato.getString("nome"));
  1459.                
  1460.                 String plainValue = risultato.getString("valore");
  1461.                 String encValue = risultato.getString("enc_value");
  1462.                 if(encValue!=null && StringUtils.isNotEmpty(encValue)) {
  1463.                     wsreq.setValore(encValue);
  1464.                 }
  1465.                 else {
  1466.                     wsreq.setValore(plainValue);
  1467.                 }

  1468.                 lista.add(wsreq);
  1469.             }

  1470.             return lista;

  1471.         } catch (Exception qe) {
  1472.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  1473.         } finally {

  1474.             //Chiudo statement and resultset
  1475.             JDBCUtilities.closeResources(risultato, stmt);

  1476.             this.driver.closeConnection(con);
  1477.         }
  1478.     }

  1479.     protected List<MessageSecurityFlowParameter> porteAppMessageSecurityResponseList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  1480.         String nomeMetodo = "porteAppMessageSecurityResponseList";
  1481.         int idLista = Liste.PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE;
  1482.         int offset;
  1483.         int limit;
  1484.         String search;
  1485.         String queryString;

  1486.         limit = ricerca.getPageSize(idLista);
  1487.         offset = ricerca.getIndexIniziale(idLista);
  1488.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));


  1489.         Connection con = null;
  1490.         PreparedStatement stmt=null;
  1491.         ResultSet risultato=null;
  1492.         ArrayList<MessageSecurityFlowParameter> lista = new ArrayList<>();

  1493.         if (this.driver.atomica) {
  1494.             try {
  1495.                 con = this.driver.getConnectionFromDatasource("porteAppMessageSecurityResponseList");
  1496.             } catch (Exception e) {
  1497.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  1498.             }

  1499.         } else
  1500.             con = this.driver.globalConnection;

  1501.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1502.         try {

  1503.             if (!search.equals("")) {
  1504.                 //query con search
  1505.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1506.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE);
  1507.                 sqlQueryObject.addSelectCountField("*", "cont");
  1508.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1509.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  1510.                 sqlQueryObject.setANDLogicOperator(true);
  1511.                 queryString = sqlQueryObject.createSQLQuery();
  1512.             } else {
  1513.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1514.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE);
  1515.                 sqlQueryObject.addSelectCountField("*", "cont");
  1516.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1517.                 queryString = sqlQueryObject.createSQLQuery();
  1518.             }
  1519.             stmt = con.prepareStatement(queryString);
  1520.             stmt.setLong(1, idPortaApplicativa);
  1521.             risultato = stmt.executeQuery();
  1522.             if (risultato.next())
  1523.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  1524.             risultato.close();
  1525.             stmt.close();

  1526.             // ricavo le entries
  1527.             if (limit == 0) // con limit
  1528.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;

  1529.             if (!search.equals("")) { // con search
  1530.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1531.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE);
  1532.                 sqlQueryObject.addSelectField("id_porta");
  1533.                 sqlQueryObject.addSelectField("nome");
  1534.                 sqlQueryObject.addSelectField("valore");
  1535.                 sqlQueryObject.addSelectField("enc_value");
  1536.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1537.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  1538.                 sqlQueryObject.setANDLogicOperator(true);
  1539.                 sqlQueryObject.addOrderBy("nome");
  1540.                 sqlQueryObject.setSortType(true);
  1541.                 sqlQueryObject.setLimit(limit);
  1542.                 sqlQueryObject.setOffset(offset);
  1543.                 queryString = sqlQueryObject.createSQLQuery();
  1544.             } else {
  1545.                 // senza search
  1546.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1547.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MESSAGE_SECURITY_RESPONSE);
  1548.                 sqlQueryObject.addSelectField("id_porta");
  1549.                 sqlQueryObject.addSelectField("nome");
  1550.                 sqlQueryObject.addSelectField("valore");
  1551.                 sqlQueryObject.addSelectField("enc_value");
  1552.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1553.                 sqlQueryObject.addOrderBy("nome");
  1554.                 sqlQueryObject.setSortType(true);
  1555.                 sqlQueryObject.setLimit(limit);
  1556.                 sqlQueryObject.setOffset(offset);
  1557.                 queryString = sqlQueryObject.createSQLQuery();
  1558.             }
  1559.             stmt = con.prepareStatement(queryString);
  1560.             stmt.setLong(1, idPortaApplicativa);
  1561.             risultato = stmt.executeQuery();

  1562.             MessageSecurityFlowParameter wsresp;
  1563.             while (risultato.next()) {

  1564.                 wsresp = new MessageSecurityFlowParameter();

  1565.                 wsresp.setId(risultato.getLong("id_porta"));
  1566.                 wsresp.setNome(risultato.getString("nome"));
  1567.                
  1568.                 String plainValue = risultato.getString("valore");
  1569.                 String encValue = risultato.getString("enc_value");
  1570.                 if(encValue!=null && StringUtils.isNotEmpty(encValue)) {
  1571.                     wsresp.setValore(encValue);
  1572.                 }
  1573.                 else {
  1574.                     wsresp.setValore(plainValue);
  1575.                 }

  1576.                 lista.add(wsresp);
  1577.             }

  1578.             return lista;

  1579.         } catch (Exception qe) {
  1580.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  1581.         } finally {

  1582.             //Chiudo statement and resultset
  1583.             JDBCUtilities.closeResources(risultato, stmt);
  1584.             this.driver.closeConnection(con);
  1585.         }

  1586.     }
  1587.    
  1588.     protected List<CorrelazioneApplicativaElemento> porteApplicativeCorrelazioneApplicativaList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  1589.         String nomeMetodo = "porteApplicativeCorrelazioneApplicativaList";
  1590.         int idLista = Liste.PORTE_APPLICATIVE_CORRELAZIONE_APPLICATIVA;
  1591.         int offset;
  1592.         int limit;
  1593.         String search;
  1594.         String queryString;

  1595.         limit = ricerca.getPageSize(idLista);
  1596.         offset = ricerca.getIndexIniziale(idLista);
  1597.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));


  1598.         Connection con = null;
  1599.         PreparedStatement stmt=null;
  1600.         ResultSet risultato=null;
  1601.         ArrayList<CorrelazioneApplicativaElemento> lista = new ArrayList<>();

  1602.         if (this.driver.atomica) {
  1603.             try {
  1604.                 con = this.driver.getConnectionFromDatasource("porteApplicativeCorrelazioneApplicativaList");
  1605.             } catch (Exception e) {
  1606.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  1607.             }

  1608.         } else
  1609.             con = this.driver.globalConnection;

  1610.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1611.         try {

  1612.             if (!search.equals("")) {
  1613.                 //query con search
  1614.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1615.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_CORRELAZIONE);
  1616.                 sqlQueryObject.addSelectCountField("*", "cont");
  1617.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1618.                 sqlQueryObject.addWhereLikeCondition("nome_elemento", search, true, true);
  1619.                 sqlQueryObject.setANDLogicOperator(true);
  1620.                 queryString = sqlQueryObject.createSQLQuery();
  1621.             } else {
  1622.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1623.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_CORRELAZIONE);
  1624.                 sqlQueryObject.addSelectCountField("*", "cont");
  1625.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1626.                 queryString = sqlQueryObject.createSQLQuery();
  1627.             }
  1628.             stmt = con.prepareStatement(queryString);
  1629.             stmt.setLong(1, idPortaApplicativa);
  1630.             risultato = stmt.executeQuery();
  1631.             if (risultato.next())
  1632.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  1633.             risultato.close();
  1634.             stmt.close();

  1635.             // ricavo le entries
  1636.             if (limit == 0) // con limit
  1637.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  1638.             if (!search.equals("")) { // con search
  1639.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1640.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_CORRELAZIONE);
  1641.                 sqlQueryObject.addSelectField("id");
  1642.                 sqlQueryObject.addSelectField("nome_elemento");
  1643.                 sqlQueryObject.addSelectField("mode_correlazione");
  1644.                 sqlQueryObject.addSelectField("id_porta");
  1645.                 sqlQueryObject.addSelectField("identificazione_fallita");
  1646.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1647.                 sqlQueryObject.addWhereLikeCondition("nome_elemento", search, true, true);
  1648.                 sqlQueryObject.setANDLogicOperator(true);
  1649.                 sqlQueryObject.addOrderBy("id");
  1650.                 sqlQueryObject.setSortType(true);
  1651.                 sqlQueryObject.setLimit(limit);
  1652.                 sqlQueryObject.setOffset(offset);
  1653.                 queryString = sqlQueryObject.createSQLQuery();
  1654.             } else {
  1655.                 // senza search
  1656.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1657.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_CORRELAZIONE);
  1658.                 sqlQueryObject.addSelectField("id");
  1659.                 sqlQueryObject.addSelectField("nome_elemento");
  1660.                 sqlQueryObject.addSelectField("mode_correlazione");
  1661.                 sqlQueryObject.addSelectField("id_porta");
  1662.                 sqlQueryObject.addSelectField("identificazione_fallita");
  1663.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1664.                 sqlQueryObject.addOrderBy("id");
  1665.                 sqlQueryObject.setSortType(true);
  1666.                 sqlQueryObject.setLimit(limit);
  1667.                 sqlQueryObject.setOffset(offset);
  1668.                 queryString = sqlQueryObject.createSQLQuery();
  1669.             }
  1670.             stmt = con.prepareStatement(queryString);
  1671.             stmt.setLong(1, idPortaApplicativa);
  1672.             risultato = stmt.executeQuery();

  1673.             CorrelazioneApplicativaElemento cae = null;

  1674.             //long idServizioApplicativo = 0;
  1675.             while (risultato.next()) {
  1676.                 cae = new CorrelazioneApplicativaElemento();
  1677.                 cae.setId(risultato.getLong("id"));
  1678.                 cae.setNome(risultato.getString("nome_elemento"));
  1679.                 cae.setIdentificazione(DriverConfigurazioneDBLib.getEnumCorrelazioneApplicativaRichiestaIdentificazione(risultato.getString("mode_correlazione")));
  1680.                 cae.setIdentificazioneFallita(DriverConfigurazioneDBLib.getEnumCorrelazioneApplicativaGestioneIdentificazioneFallita(risultato.getString("identificazione_fallita")));
  1681.                 lista.add(cae);
  1682.             }

  1683.             return lista;

  1684.         } catch (Exception qe) {
  1685.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  1686.         } finally {

  1687.             //Chiudo statement and resultset
  1688.             JDBCUtilities.closeResources(risultato, stmt);

  1689.             this.driver.closeConnection(con);
  1690.         }
  1691.     }



  1692.     protected List<CorrelazioneApplicativaRispostaElemento> porteApplicativeCorrelazioneApplicativaRispostaList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  1693.         String nomeMetodo = "porteApplicativeCorrelazioneApplicativaRispostaList";
  1694.         int idLista = Liste.PORTE_APPLICATIVE_CORRELAZIONE_APPLICATIVA_RISPOSTA;
  1695.         int offset;
  1696.         int limit;
  1697.         String search;
  1698.         String queryString;

  1699.         limit = ricerca.getPageSize(idLista);
  1700.         offset = ricerca.getIndexIniziale(idLista);
  1701.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));


  1702.         Connection con = null;
  1703.         PreparedStatement stmt=null;
  1704.         ResultSet risultato=null;
  1705.         ArrayList<CorrelazioneApplicativaRispostaElemento> lista = new ArrayList<>();

  1706.         if (this.driver.atomica) {
  1707.             try {
  1708.                 con = this.driver.getConnectionFromDatasource("porteApplicativeCorrelazioneApplicativaRispostaList");
  1709.             } catch (Exception e) {
  1710.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  1711.             }

  1712.         } else
  1713.             con = this.driver.globalConnection;

  1714.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1715.         try {

  1716.             if (!search.equals("")) {
  1717.                 //query con search
  1718.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1719.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_CORRELAZIONE_RISPOSTA);
  1720.                 sqlQueryObject.addSelectCountField("*", "cont");
  1721.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1722.                 sqlQueryObject.addWhereLikeCondition("nome_elemento", search, true, true);
  1723.                 sqlQueryObject.setANDLogicOperator(true);
  1724.                 queryString = sqlQueryObject.createSQLQuery();
  1725.             } else {
  1726.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1727.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_CORRELAZIONE_RISPOSTA);
  1728.                 sqlQueryObject.addSelectCountField("*", "cont");
  1729.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1730.                 queryString = sqlQueryObject.createSQLQuery();
  1731.             }
  1732.             stmt = con.prepareStatement(queryString);
  1733.             stmt.setLong(1, idPortaApplicativa);
  1734.             risultato = stmt.executeQuery();
  1735.             if (risultato.next())
  1736.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  1737.             risultato.close();
  1738.             stmt.close();

  1739.             // ricavo le entries
  1740.             if (limit == 0) // con limit
  1741.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  1742.             if (!search.equals("")) { // con search
  1743.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1744.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_CORRELAZIONE_RISPOSTA);
  1745.                 sqlQueryObject.addSelectField("id");
  1746.                 sqlQueryObject.addSelectField("nome_elemento");
  1747.                 sqlQueryObject.addSelectField("mode_correlazione");
  1748.                 sqlQueryObject.addSelectField("id_porta");
  1749.                 sqlQueryObject.addSelectField("identificazione_fallita");
  1750.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1751.                 sqlQueryObject.addWhereLikeCondition("nome_elemento", search, true, true);
  1752.                 sqlQueryObject.setANDLogicOperator(true);
  1753.                 sqlQueryObject.addOrderBy("id");
  1754.                 sqlQueryObject.setSortType(true);
  1755.                 sqlQueryObject.setLimit(limit);
  1756.                 sqlQueryObject.setOffset(offset);
  1757.                 queryString = sqlQueryObject.createSQLQuery();
  1758.             } else {
  1759.                 // senza search
  1760.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1761.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_CORRELAZIONE_RISPOSTA);
  1762.                 sqlQueryObject.addSelectField("id");
  1763.                 sqlQueryObject.addSelectField("nome_elemento");
  1764.                 sqlQueryObject.addSelectField("mode_correlazione");
  1765.                 sqlQueryObject.addSelectField("id_porta");
  1766.                 sqlQueryObject.addSelectField("identificazione_fallita");
  1767.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1768.                 sqlQueryObject.addOrderBy("id");
  1769.                 sqlQueryObject.setSortType(true);
  1770.                 sqlQueryObject.setLimit(limit);
  1771.                 sqlQueryObject.setOffset(offset);
  1772.                 queryString = sqlQueryObject.createSQLQuery();
  1773.             }
  1774.             stmt = con.prepareStatement(queryString);
  1775.             stmt.setLong(1, idPortaApplicativa);
  1776.             risultato = stmt.executeQuery();

  1777.             CorrelazioneApplicativaRispostaElemento cae = null;

  1778.             //long idServizioApplicativo = 0;
  1779.             while (risultato.next()) {
  1780.                 cae = new CorrelazioneApplicativaRispostaElemento();
  1781.                 cae.setId(risultato.getLong("id"));
  1782.                 cae.setNome(risultato.getString("nome_elemento"));
  1783.                 cae.setIdentificazione(DriverConfigurazioneDBLib.getEnumCorrelazioneApplicativaRispostaIdentificazione(risultato.getString("mode_correlazione")));
  1784.                 cae.setIdentificazioneFallita(DriverConfigurazioneDBLib.getEnumCorrelazioneApplicativaGestioneIdentificazioneFallita(risultato.getString("identificazione_fallita")));
  1785.                 lista.add(cae);
  1786.             }

  1787.             return lista;

  1788.         } catch (Exception qe) {
  1789.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  1790.         } finally {

  1791.             //Chiudo statement and resultset
  1792.             JDBCUtilities.closeResources(risultato, stmt);

  1793.             this.driver.closeConnection(con);
  1794.         }
  1795.     }
  1796.    
  1797.     protected List<PortaApplicativa> serviziPorteAppList(String tipoServizio,String nomeServizio, Integer versioneServizio,
  1798.             long idServizio, long idSoggettoErogatore, ISearch ricerca) throws DriverConfigurazioneException {
  1799.         String nomeMetodo = "serviziPorteAppList";
  1800.         int idLista = Liste.CONFIGURAZIONE_EROGAZIONE;
  1801.         int offset;
  1802.         int limit;
  1803.         String search;
  1804.         String queryString;

  1805.         limit = ricerca.getPageSize(idLista);
  1806.         offset = ricerca.getIndexIniziale(idLista);
  1807.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));
  1808.         ricerca.getSearchString(idLista);

  1809.         Connection con = null;
  1810.         PreparedStatement stmt = null;
  1811.         ResultSet risultato = null;

  1812.         ArrayList<PortaApplicativa> lista = new ArrayList<PortaApplicativa>();

  1813.         try {

  1814.             if (this.driver.atomica) {
  1815.                 try {
  1816.                     con = this.driver.getConnectionFromDatasource(nomeMetodo);

  1817.                 } catch (Exception e) {
  1818.                     throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  1819.                 }

  1820.             } else
  1821.                 con = this.driver.globalConnection;

  1822.             this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);
  1823.            
  1824.             if (!search.equals("")) {
  1825.                 //query con search
  1826.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1827.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  1828.                 sqlQueryObject.addSelectCountField("*", "cont");
  1829.                 sqlQueryObject.addWhereCondition(false, "id_soggetto = ? AND tipo_servizio = ? AND servizio=? AND versione_servizio=? AND id_soggetto_virtuale <= ?",
  1830.                         "id_soggetto = ? AND id_servizio = ? AND id_soggetto_virtuale <= ?",
  1831.                         "id_soggetto_virtuale = ? AND tipo_servizio = ? AND servizio=?  AND versione_servizio=?",
  1832.                         "id_soggetto_virtuale = ? AND id_servizio = ?");
  1833.                 sqlQueryObject.addWhereLikeCondition("nome_porta", search, true, true);
  1834.                 sqlQueryObject.setANDLogicOperator(true);
  1835.                 queryString = sqlQueryObject.createSQLQuery();
  1836.             } else {
  1837.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1838.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  1839.                 sqlQueryObject.addSelectCountField("*", "cont");
  1840.                 sqlQueryObject.addWhereCondition(false, "id_soggetto = ? AND tipo_servizio = ? AND servizio=? AND versione_servizio=? AND id_soggetto_virtuale <= ?",
  1841.                         "id_soggetto = ? AND id_servizio = ? AND id_soggetto_virtuale <= ?",
  1842.                         "id_soggetto_virtuale = ? AND tipo_servizio = ? AND servizio=? AND versione_servizio=?",
  1843.                         "id_soggetto_virtuale = ? AND id_servizio = ?");
  1844.                 sqlQueryObject.setANDLogicOperator(true);
  1845.                 queryString = sqlQueryObject.createSQLQuery();
  1846.             }
  1847.             stmt = con.prepareStatement(queryString);

  1848.             int index = 1;
  1849.            
  1850.             stmt.setLong(index++, idSoggettoErogatore);
  1851.             stmt.setString(index++, tipoServizio);
  1852.             stmt.setString(index++, nomeServizio);
  1853.             stmt.setInt(index++, versioneServizio);
  1854.             stmt.setLong(index++, 0);

  1855.             stmt.setLong(index++, idSoggettoErogatore);
  1856.             stmt.setLong(index++, idServizio);
  1857.             stmt.setLong(index++, 0);

  1858.             stmt.setLong(index++, idSoggettoErogatore);
  1859.             stmt.setString(index++, tipoServizio);
  1860.             stmt.setString(index++, nomeServizio);
  1861.             stmt.setInt(index++, versioneServizio);

  1862.             stmt.setLong(index++, idSoggettoErogatore);
  1863.             stmt.setLong(index++, idServizio);

  1864.             risultato = stmt.executeQuery();
  1865.             if (risultato.next())
  1866.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  1867.             risultato.close();
  1868.             stmt.close();

  1869.             // ricavo le entries
  1870.             if (limit == 0) // con limit
  1871.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  1872.             if (!search.equals("")) { // con search
  1873.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1874.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  1875.                 sqlQueryObject.addSelectField("id_soggetto");
  1876.                 sqlQueryObject.addSelectField("id_servizio");
  1877.                 sqlQueryObject.addSelectField("id_soggetto_virtuale");
  1878.                 sqlQueryObject.addSelectField("nome_porta");
  1879.                 sqlQueryObject.addSelectField("id");
  1880.                 sqlQueryObject.addWhereCondition(false, "id_soggetto = ? AND tipo_servizio = ? AND servizio=? AND versione_servizio=? AND id_soggetto_virtuale <= ?",
  1881.                         "id_soggetto = ? AND id_servizio = ? AND id_soggetto_virtuale <= ?",
  1882.                         "id_soggetto_virtuale = ? AND tipo_servizio = ? AND servizio=? AND versione_servizio=?",
  1883.                         "id_soggetto_virtuale = ? AND id_servizio = ?");
  1884.                 sqlQueryObject.addWhereLikeCondition("nome_porta", search, true, true);
  1885.                 sqlQueryObject.setANDLogicOperator(true);
  1886.                 sqlQueryObject.addOrderBy("nome_porta");
  1887.                 sqlQueryObject.setSortType(true);
  1888.                 sqlQueryObject.setLimit(limit);
  1889.                 sqlQueryObject.setOffset(offset);
  1890.                 queryString = sqlQueryObject.createSQLQuery();
  1891.             } else {
  1892.                 // senza search
  1893.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1894.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE);
  1895.                 sqlQueryObject.addSelectField("id_soggetto");
  1896.                 sqlQueryObject.addSelectField("id_servizio");
  1897.                 sqlQueryObject.addSelectField("id_soggetto_virtuale");
  1898.                 sqlQueryObject.addSelectField("nome_porta");
  1899.                 sqlQueryObject.addSelectField("id");
  1900.                 sqlQueryObject.addWhereCondition(false, "id_soggetto = ? AND tipo_servizio = ? AND servizio=? AND versione_servizio=? AND id_soggetto_virtuale <= ?",
  1901.                         "id_soggetto = ? AND id_servizio = ? AND id_soggetto_virtuale <= ?",
  1902.                         "id_soggetto_virtuale = ? AND tipo_servizio = ? AND servizio=? AND versione_servizio=?",
  1903.                         "id_soggetto_virtuale = ? AND id_servizio = ?");
  1904.                 sqlQueryObject.setANDLogicOperator(true);
  1905.                 sqlQueryObject.addOrderBy("nome_porta");
  1906.                 sqlQueryObject.setSortType(true);
  1907.                 sqlQueryObject.setLimit(limit);
  1908.                 sqlQueryObject.setOffset(offset);
  1909.                 queryString = sqlQueryObject.createSQLQuery();
  1910.             }
  1911.             stmt = con.prepareStatement(queryString);

  1912.             index = 1;
  1913.            
  1914.             stmt.setLong(index++, idSoggettoErogatore);
  1915.             stmt.setString(index++, tipoServizio);
  1916.             stmt.setString(index++, nomeServizio);
  1917.             stmt.setInt(index++, versioneServizio);
  1918.             stmt.setLong(index++, 0);

  1919.             stmt.setLong(index++, idSoggettoErogatore);
  1920.             stmt.setLong(index++, idServizio);
  1921.             stmt.setLong(index++, 0);

  1922.             stmt.setLong(index++, idSoggettoErogatore);
  1923.             stmt.setString(index++, tipoServizio);
  1924.             stmt.setString(index++, nomeServizio);
  1925.             stmt.setInt(index++, versioneServizio);

  1926.             stmt.setLong(index++, idSoggettoErogatore);
  1927.             stmt.setLong(index++, idServizio);

  1928.             risultato = stmt.executeQuery();

  1929.             PortaApplicativa pa = null;

  1930.             while (risultato.next()) {

  1931.                 pa = this.porteApplicativeDriver.getPortaApplicativa(risultato.getLong("id"));

  1932.                 lista.add(pa);

  1933.             }

  1934.             return lista;

  1935.         } catch (Exception se) {

  1936.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception: " + se.getMessage(),se);
  1937.         } finally {
  1938.             //Chiudo statement and resultset
  1939.             JDBCUtilities.closeResources(risultato, stmt);
  1940.             this.driver.closeConnection(con);
  1941.         }
  1942.     }
  1943.    
  1944.     protected List<MtomProcessorFlowParameter> porteApplicativeMTOMRequestList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  1945.         String nomeMetodo = "porteApplicativeMTOMRequestList";
  1946.         int idLista = Liste.PORTE_APPLICATIVE_MTOM_REQUEST;
  1947.         int offset;
  1948.         int limit;
  1949.         String search;
  1950.         String queryString;

  1951.         limit = ricerca.getPageSize(idLista);
  1952.         offset = ricerca.getIndexIniziale(idLista);
  1953.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));


  1954.         Connection con = null;
  1955.         PreparedStatement stmt=null;
  1956.         ResultSet risultato=null;
  1957.         ArrayList<MtomProcessorFlowParameter> lista = new ArrayList<>();

  1958.         if (this.driver.atomica) {
  1959.             try {
  1960.                 con = this.driver.getConnectionFromDatasource(nomeMetodo);
  1961.             } catch (Exception e) {
  1962.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  1963.             }

  1964.         } else
  1965.             con = this.driver.globalConnection;

  1966.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  1967.         try {

  1968.             if (!search.equals("")) {
  1969.                 //query con search
  1970.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1971.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MTOM_REQUEST);
  1972.                 sqlQueryObject.addSelectCountField("*", "cont");
  1973.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1974.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  1975.                 sqlQueryObject.setANDLogicOperator(true);
  1976.                 queryString = sqlQueryObject.createSQLQuery();
  1977.             } else {
  1978.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1979.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MTOM_REQUEST);
  1980.                 sqlQueryObject.addSelectCountField("*", "cont");
  1981.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  1982.                 queryString = sqlQueryObject.createSQLQuery();
  1983.             }
  1984.             stmt = con.prepareStatement(queryString);
  1985.             stmt.setLong(1, idPortaApplicativa);
  1986.             risultato = stmt.executeQuery();
  1987.             if (risultato.next())
  1988.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  1989.             risultato.close();
  1990.             stmt.close();

  1991.             // ricavo le entries
  1992.             if (limit == 0) // con limit
  1993.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;

  1994.             if (!search.equals("")) { // con search
  1995.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  1996.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MTOM_REQUEST);
  1997.                 sqlQueryObject.addSelectField("id_porta");
  1998.                 sqlQueryObject.addSelectField("nome");
  1999.                 sqlQueryObject.addSelectField("pattern");
  2000.                 sqlQueryObject.addSelectField("content_type");
  2001.                 sqlQueryObject.addSelectField("required");
  2002.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  2003.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  2004.                 sqlQueryObject.setANDLogicOperator(true);
  2005.                 sqlQueryObject.addOrderBy("nome");
  2006.                 sqlQueryObject.setSortType(true);
  2007.                 sqlQueryObject.setLimit(limit);
  2008.                 sqlQueryObject.setOffset(offset);
  2009.                 queryString = sqlQueryObject.createSQLQuery();
  2010.             } else {
  2011.                 // senza search
  2012.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2013.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MTOM_REQUEST);
  2014.                 sqlQueryObject.addSelectField("id_porta");
  2015.                 sqlQueryObject.addSelectField("nome");
  2016.                 sqlQueryObject.addSelectField("pattern");
  2017.                 sqlQueryObject.addSelectField("content_type");
  2018.                 sqlQueryObject.addSelectField("required");
  2019.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  2020.                 sqlQueryObject.addOrderBy("nome");
  2021.                 sqlQueryObject.setSortType(true);
  2022.                 sqlQueryObject.setLimit(limit);
  2023.                 sqlQueryObject.setOffset(offset);
  2024.                 queryString = sqlQueryObject.createSQLQuery();
  2025.             }
  2026.             stmt = con.prepareStatement(queryString);
  2027.             stmt.setLong(1, idPortaApplicativa);
  2028.             risultato = stmt.executeQuery();

  2029.             MtomProcessorFlowParameter reqPar;
  2030.             while (risultato.next()) {

  2031.                 reqPar = new MtomProcessorFlowParameter();
  2032.                
  2033.                 reqPar.setId(risultato.getLong("id_porta"));
  2034.                 reqPar.setNome(risultato.getString("nome"));
  2035.                 reqPar.setPattern(risultato.getString("pattern"));
  2036.                 reqPar.setContentType(risultato.getString("content_type"));
  2037.                 int required = risultato.getInt("required");
  2038.                 boolean isrequired = false;
  2039.                 if (required == CostantiDB.TRUE)
  2040.                     isrequired = true;
  2041.                 reqPar.setRequired(isrequired);

  2042.                

  2043.                 lista.add(reqPar);
  2044.             }

  2045.             return lista;

  2046.         } catch (Exception qe) {
  2047.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2048.         } finally {

  2049.             //Chiudo statement and resultset
  2050.             JDBCUtilities.closeResources(risultato, stmt);

  2051.             this.driver.closeConnection(con);
  2052.         }
  2053.     }

  2054.     protected List<MtomProcessorFlowParameter> porteApplicativeMTOMResponseList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  2055.         String nomeMetodo = "porteApplicativeMTOMResponseList";
  2056.         int idLista = Liste.PORTE_APPLICATIVE_MTOM_RESPONSE;
  2057.         int offset;
  2058.         int limit;
  2059.         String search;
  2060.         String queryString;

  2061.         limit = ricerca.getPageSize(idLista);
  2062.         offset = ricerca.getIndexIniziale(idLista);
  2063.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));


  2064.         Connection con = null;
  2065.         PreparedStatement stmt=null;
  2066.         ResultSet risultato=null;
  2067.         ArrayList<MtomProcessorFlowParameter> lista = new ArrayList<>();

  2068.         if (this.driver.atomica) {
  2069.             try {
  2070.                 con = this.driver.getConnectionFromDatasource(nomeMetodo);
  2071.             } catch (Exception e) {
  2072.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Exception accedendo al datasource :" + e.getMessage(),e);

  2073.             }

  2074.         } else
  2075.             con = this.driver.globalConnection;

  2076.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2077.         try {

  2078.             if (!search.equals("")) {
  2079.                 //query con search
  2080.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2081.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MTOM_RESPONSE);
  2082.                 sqlQueryObject.addSelectCountField("*", "cont");
  2083.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  2084.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  2085.                 sqlQueryObject.setANDLogicOperator(true);
  2086.                 queryString = sqlQueryObject.createSQLQuery();
  2087.             } else {
  2088.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2089.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MTOM_RESPONSE);
  2090.                 sqlQueryObject.addSelectCountField("*", "cont");
  2091.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  2092.                 queryString = sqlQueryObject.createSQLQuery();
  2093.             }
  2094.             stmt = con.prepareStatement(queryString);
  2095.             stmt.setLong(1, idPortaApplicativa);
  2096.             risultato = stmt.executeQuery();
  2097.             if (risultato.next())
  2098.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  2099.             risultato.close();
  2100.             stmt.close();

  2101.             // ricavo le entries
  2102.             if (limit == 0) // con limit
  2103.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;

  2104.             if (!search.equals("")) { // con search
  2105.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2106.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MTOM_RESPONSE);
  2107.                 sqlQueryObject.addSelectField("id_porta");
  2108.                 sqlQueryObject.addSelectField("nome");
  2109.                 sqlQueryObject.addSelectField("pattern");
  2110.                 sqlQueryObject.addSelectField("content_type");
  2111.                 sqlQueryObject.addSelectField("required");
  2112.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  2113.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  2114.                 sqlQueryObject.setANDLogicOperator(true);
  2115.                 sqlQueryObject.addOrderBy("nome");
  2116.                 sqlQueryObject.setSortType(true);
  2117.                 sqlQueryObject.setLimit(limit);
  2118.                 sqlQueryObject.setOffset(offset);
  2119.                 queryString = sqlQueryObject.createSQLQuery();
  2120.             } else {
  2121.                 // senza search
  2122.                 ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2123.                 sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_MTOM_RESPONSE);
  2124.                 sqlQueryObject.addSelectField("id_porta");
  2125.                 sqlQueryObject.addSelectField("nome");
  2126.                 sqlQueryObject.addSelectField("pattern");
  2127.                 sqlQueryObject.addSelectField("content_type");
  2128.                 sqlQueryObject.addSelectField("required");
  2129.                 sqlQueryObject.addWhereCondition("id_porta = ?");
  2130.                 sqlQueryObject.addOrderBy("nome");
  2131.                 sqlQueryObject.setSortType(true);
  2132.                 sqlQueryObject.setLimit(limit);
  2133.                 sqlQueryObject.setOffset(offset);
  2134.                 queryString = sqlQueryObject.createSQLQuery();
  2135.             }
  2136.             stmt = con.prepareStatement(queryString);
  2137.             stmt.setLong(1, idPortaApplicativa);
  2138.             risultato = stmt.executeQuery();

  2139.             MtomProcessorFlowParameter resPar;
  2140.             while (risultato.next()) {
  2141.                
  2142.                 resPar = new MtomProcessorFlowParameter();
  2143.                
  2144.                 resPar.setId(risultato.getLong("id_porta"));
  2145.                 resPar.setNome(risultato.getString("nome"));
  2146.                 resPar.setPattern(risultato.getString("pattern"));
  2147.                 resPar.setContentType(risultato.getString("content_type"));
  2148.                 int required = risultato.getInt("required");
  2149.                 boolean isrequired = false;
  2150.                 if (required == CostantiDB.TRUE)
  2151.                     isrequired = true;
  2152.                 resPar.setRequired(isrequired);

  2153.                

  2154.                 lista.add(resPar);
  2155.             }

  2156.             return lista;

  2157.         } catch (Exception qe) {
  2158.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::" + nomeMetodo + "] Errore : " + qe.getMessage(),qe);
  2159.         } finally {

  2160.             //Chiudo statement and resultset
  2161.             JDBCUtilities.closeResources(risultato, stmt);

  2162.             this.driver.closeConnection(con);
  2163.         }
  2164.     }
  2165.    
  2166.     /**
  2167.      * Ritorna la lista di proprieta per la configurazione custom dei connettori multipli di una Porta Applicativa
  2168.      */
  2169.     protected List<Proprieta> porteApplicativeConnettoriMultipliConfigPropList(long idPortaApplicativa, ISearch ricerca) throws DriverConfigurazioneException {
  2170.         int offset;
  2171.         int limit;
  2172.         int idLista = Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_CONFIG_PROPRIETA;
  2173.         String search;
  2174.         String queryString;

  2175.         limit = ricerca.getPageSize(idLista);
  2176.         offset = ricerca.getIndexIniziale(idLista);
  2177.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));      


  2178.         Connection con = null;
  2179.         PreparedStatement stmt=null;
  2180.         ResultSet risultato=null;
  2181.         ArrayList<Proprieta> lista = new ArrayList<>();

  2182.         if (this.driver.atomica) {
  2183.             try {
  2184.                 con = this.driver.getConnectionFromDatasource("porteApplicativeConnettoriMultipliConfigPropList");
  2185.             } catch (Exception e) {
  2186.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteApplicativeConnettoriMultipliConfigPropList] Exception accedendo al datasource :" + e.getMessage(),e);

  2187.             }

  2188.         } else
  2189.             con = this.driver.globalConnection;

  2190.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2191.         try {

  2192.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2193.             sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_BEHAVIOUR_PROPS);
  2194.             sqlQueryObject.addSelectCountField("*", "cont");
  2195.             sqlQueryObject.addWhereCondition("id_porta = ?");
  2196.            
  2197.             if (!search.equals("")) {
  2198.                 //query con search
  2199.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  2200.                 sqlQueryObject.setANDLogicOperator(true);
  2201.             }
  2202.            
  2203.             queryString = sqlQueryObject.createSQLQuery();
  2204.            
  2205.             stmt = con.prepareStatement(queryString);
  2206.             stmt.setLong(1, idPortaApplicativa);
  2207.             risultato = stmt.executeQuery();
  2208.             if (risultato.next())
  2209.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  2210.             risultato.close();
  2211.             stmt.close();

  2212.             // ricavo le entries
  2213.             if (limit == 0) // con limit
  2214.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  2215.            
  2216.             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2217.             sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_BEHAVIOUR_PROPS);
  2218.             sqlQueryObject.addSelectField("id");
  2219.             sqlQueryObject.addSelectField("id_porta");
  2220.             sqlQueryObject.addSelectField("nome");
  2221.             sqlQueryObject.addSelectField("valore");
  2222.             sqlQueryObject.addWhereCondition("id_porta = ?");
  2223.            
  2224.             if (!search.equals("")) { // con search
  2225.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  2226.                 sqlQueryObject.setANDLogicOperator(true);
  2227.             }
  2228.            
  2229.             sqlQueryObject.addOrderBy("nome");
  2230.             sqlQueryObject.setSortType(true);
  2231.             sqlQueryObject.setLimit(limit);
  2232.             sqlQueryObject.setOffset(offset);
  2233.             queryString = sqlQueryObject.createSQLQuery();
  2234.            
  2235.             stmt = con.prepareStatement(queryString);
  2236.             stmt.setLong(1, idPortaApplicativa);
  2237.             risultato = stmt.executeQuery();

  2238.             Proprieta prop = null;
  2239.             while (risultato.next()) {

  2240.                 prop = new Proprieta();

  2241.                 prop.setId(risultato.getLong("id"));
  2242.                 prop.setNome(risultato.getString("nome"));
  2243.                 prop.setValore(risultato.getString("valore"));

  2244.                 lista.add(prop);
  2245.             }

  2246.             return lista;

  2247.         } catch (Exception qe) {
  2248.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteApplicativeConnettoriMultipliConfigPropList] Errore : " + qe.getMessage(),qe);
  2249.         } finally {
  2250.             //Chiudo statement and resultset
  2251.             JDBCUtilities.closeResources(risultato, stmt);
  2252.             this.driver.closeConnection(con);
  2253.         }
  2254.     }
  2255.    
  2256.     /**
  2257.      * Ritorna la lista di proprieta di un connettore multiplo di una Porta Applicativa
  2258.      */
  2259.     protected List<Proprieta> porteApplicativeConnettoriMultipliPropList(long idPaSa, ISearch ricerca) throws DriverConfigurazioneException {
  2260.         int offset;
  2261.         int limit;
  2262.         int idLista = Liste.PORTE_APPLICATIVE_CONNETTORI_MULTIPLI_PROPRIETA;
  2263.         String search;
  2264.         String queryString;

  2265.         limit = ricerca.getPageSize(idLista);
  2266.         offset = ricerca.getIndexIniziale(idLista);
  2267.         search = (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" : ricerca.getSearchString(idLista));      


  2268.         Connection con = null;
  2269.         PreparedStatement stmt=null;
  2270.         ResultSet risultato=null;
  2271.         ArrayList<Proprieta> lista = new ArrayList<>();

  2272.         if (this.driver.atomica) {
  2273.             try {
  2274.                 con = this.driver.getConnectionFromDatasource("porteApplicativeAutorizzazioneCustomPropList");
  2275.             } catch (Exception e) {
  2276.                 throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Exception accedendo al datasource :" + e.getMessage(),e);

  2277.             }

  2278.         } else
  2279.             con = this.driver.globalConnection;

  2280.         this.driver.logDebug("operazione this.driver.atomica = " + this.driver.atomica);

  2281.         try {

  2282.             ISQLQueryObject sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2283.             sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SA_PROPS);
  2284.             sqlQueryObject.addSelectCountField("*", "cont");
  2285.             sqlQueryObject.addWhereCondition("id_porta = ?");
  2286.            
  2287.             if (!search.equals("")) {
  2288.                 //query con search
  2289.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  2290.                 sqlQueryObject.setANDLogicOperator(true);
  2291.             }
  2292.            
  2293.             queryString = sqlQueryObject.createSQLQuery();
  2294.            
  2295.             stmt = con.prepareStatement(queryString);
  2296.             stmt.setLong(1, idPaSa);
  2297.             risultato = stmt.executeQuery();
  2298.             if (risultato.next())
  2299.                 ricerca.setNumEntries(idLista,risultato.getInt(1));
  2300.             risultato.close();
  2301.             stmt.close();

  2302.             // ricavo le entries
  2303.             if (limit == 0) // con limit
  2304.                 limit = ISQLQueryObject.LIMIT_DEFAULT_VALUE;
  2305.            
  2306.             sqlQueryObject = SQLObjectFactory.createSQLQueryObject(this.driver.tipoDB);
  2307.             sqlQueryObject.addFromTable(CostantiDB.PORTE_APPLICATIVE_SA_PROPS);
  2308.             sqlQueryObject.addSelectField("id");
  2309.             sqlQueryObject.addSelectField("id_porta");
  2310.             sqlQueryObject.addSelectField("nome");
  2311.             sqlQueryObject.addSelectField("valore");
  2312.             sqlQueryObject.addWhereCondition("id_porta = ?");
  2313.            
  2314.             if (!search.equals("")) { // con search
  2315.                 sqlQueryObject.addWhereLikeCondition("nome", search, true, true);
  2316.                 sqlQueryObject.setANDLogicOperator(true);
  2317.             }
  2318.            
  2319.             sqlQueryObject.addOrderBy("nome");
  2320.             sqlQueryObject.setSortType(true);
  2321.             sqlQueryObject.setLimit(limit);
  2322.             sqlQueryObject.setOffset(offset);
  2323.             queryString = sqlQueryObject.createSQLQuery();
  2324.            
  2325.             stmt = con.prepareStatement(queryString);
  2326.             stmt.setLong(1, idPaSa);
  2327.             risultato = stmt.executeQuery();

  2328.             Proprieta prop = null;
  2329.             while (risultato.next()) {

  2330.                 prop = new Proprieta();

  2331.                 prop.setId(risultato.getLong("id"));
  2332.                 prop.setNome(risultato.getString("nome"));
  2333.                 prop.setValore(risultato.getString("valore"));

  2334.                 lista.add(prop);
  2335.             }

  2336.             return lista;

  2337.         } catch (Exception qe) {
  2338.             throw new DriverConfigurazioneException("[DriverConfigurazioneDB::porteAppPropList] Errore : " + qe.getMessage(),qe);
  2339.         } finally {
  2340.             //Chiudo statement and resultset
  2341.             JDBCUtilities.closeResources(risultato, stmt);
  2342.             this.driver.closeConnection(con);
  2343.         }
  2344.     }
  2345. }