OpenSPCoopAppenderUtilities.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.utils;

  21. import java.util.List;

  22. import org.slf4j.Logger;
  23. import org.openspcoop2.core.config.Property;

  24. /**    
  25.  * OpenSPCoopAppenderUtilities
  26.  *
  27.  * @author Poli Andrea (poli@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */
  31. public class OpenSPCoopAppenderUtilities {

  32.     public static void addParameters(Logger log,List<Property> appenderProperties,
  33.             String dsJndiName,
  34.             String connectionUrl, String connectionDriver, String connectionUsername, String connectionPassword,
  35.             String tipoDatabase,
  36.             boolean usePdDConnection, boolean debug
  37.             ) throws Exception{
  38.        
  39.        
  40.         if(dsJndiName!=null){
  41.             Property prop_ds = new Property();
  42.             prop_ds.setNome("datasource");
  43.             prop_ds.setValore(dsJndiName);
  44.             appenderProperties.add(prop_ds);
  45.         }
  46.         else if(connectionUrl!=null){
  47.             Property prop_connectionUrl = new Property();
  48.             prop_connectionUrl.setNome("connectionUrl");
  49.             prop_connectionUrl.setValore(connectionUrl);
  50.             appenderProperties.add(prop_connectionUrl);
  51.            
  52.             Property prop_driver = new Property();
  53.             prop_driver.setNome("connectionDriver");
  54.             prop_driver.setValore(connectionDriver);
  55.             appenderProperties.add(prop_driver);
  56.            
  57.             Property prop_username = new Property();
  58.             prop_username.setNome("connectionUsername");
  59.             prop_username.setValore(connectionUsername);
  60.             appenderProperties.add(prop_username);
  61.            
  62.             Property prop_password = new Property();
  63.             prop_password.setNome("connectionPassword");
  64.             prop_password.setValore(connectionPassword);
  65.             appenderProperties.add(prop_password);
  66.         }
  67.            
  68.         Property prop_tipoDatabase = new Property();
  69.         prop_tipoDatabase.setNome("tipoDatabase");
  70.         prop_tipoDatabase.setValore(tipoDatabase);
  71.         appenderProperties.add(prop_tipoDatabase);
  72.        
  73.         if(usePdDConnection) {
  74.             Property prop_usePdDConnection = new Property();
  75.             prop_usePdDConnection.setNome("usePdDConnection");
  76.             prop_usePdDConnection.setValore(usePdDConnection+"");
  77.             appenderProperties.add(prop_usePdDConnection);
  78.         }
  79.        
  80.         if(debug) {
  81.             Property prop_debug = new Property();
  82.             prop_debug.setNome("debug");
  83.             prop_debug.setValore(debug+"");
  84.             appenderProperties.add(prop_debug);
  85.         }

  86.     }
  87.    
  88.     public static void addCheckProperties(List<Property> appenderProperties, boolean checkProperties) {
  89.         Property prop_checkProperties = new Property();
  90.         prop_checkProperties.setNome("checkProperties");
  91.         prop_checkProperties.setValore(checkProperties+"");
  92.         appenderProperties.add(prop_checkProperties);
  93.     }
  94.    
  95. }