InitRuntimeConfigReader.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.web.ctrlstat.core;

  21. import org.openspcoop2.pdd.config.ConfigurazioneNodiRuntimeInit;
  22. import org.openspcoop2.pdd.config.InvokerNodiRuntime;
  23. import org.openspcoop2.pdd.logger.filetrace.FileTraceGovWayState;
  24. import org.openspcoop2.utils.UtilsException;
  25. import org.openspcoop2.web.ctrlstat.config.ConsoleProperties;

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

  36.     private ConsoleProperties consoleProperties;
  37.        
  38.     public InitRuntimeConfigReader(ConsoleProperties consoleProperties, boolean reInitSecretMaps) throws UtilsException {
  39.         super(InitListener.getLog(), consoleProperties.getConfigurazioneNodiRuntime(),
  40.                 reInitSecretMaps,
  41.                 consoleProperties.getBYOKEnvSecretsConfig(), consoleProperties.isBYOKEnvSecretsConfigRequired());
  42.         this.consoleProperties = consoleProperties;
  43.     }
  44.    
  45.     @Override
  46.     protected boolean isCompleted(String alias) {
  47.        
  48.         boolean finished = false;
  49.        
  50.         InvokerNodiRuntime invoker = new InvokerNodiRuntime(InitListener.log, this.configurazioneNodiRuntime);
  51.         analizeFileTraceGovWayState(invoker, alias, this.consoleProperties);
  52.         if(InitListener.getFileTraceGovWayState()!=null) {
  53.             finished = true;
  54.         }
  55.        
  56.         return finished;
  57.     }

  58.     private void analizeFileTraceGovWayState(InvokerNodiRuntime invoker, String alias, ConsoleProperties consoleProperties) {
  59.         try{
  60.             String tmp = invoker.invokeJMXMethod(alias, consoleProperties.getJmxPdDConfigurazioneSistemaType(alias),
  61.                     consoleProperties.getJmxPdDConfigurazioneSistemaNomeRisorsa(alias),
  62.                     consoleProperties.getJmxPdDConfigurazioneSistemaNomeMetodoGetFileTrace(alias));
  63.             InitListener.setFileTraceGovWayState(FileTraceGovWayState.toConfig(tmp,true));  
  64.         } catch (Exception e) {
  65.             InitListener.logDebug(e.getMessage(),e);
  66.             // provo su tutti i nodi, non voglio mettere un vincolo che serve per forza un nodo acceso
  67.         }
  68.     }
  69.    
  70.     @Override
  71.     protected String getDescrizione() {
  72.         return "secrets,filetrace";
  73.     }
  74. }