ConfigurazionePluginsUtils.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.servlet.config;

  21. import java.util.HashMap;
  22. import java.util.List;

  23. import org.openspcoop2.core.commons.ErrorsHandlerCostant;
  24. import org.openspcoop2.core.plugins.Plugin;
  25. import org.openspcoop2.protocol.engine.utils.DBOggettiInUsoUtils;

  26. /**
  27.  * ConfigurazionePluginsUtils
  28.  *
  29.  * @author Giuliano Pintori (pintori@link.it)
  30.  * @author $Author$
  31.  * @version $Rev$, $Date$
  32.  *
  33.  */
  34. public class ConfigurazionePluginsUtils {

  35.     public static boolean deletePlugin(Long idPlugin, String userLogin, ConfigurazioneCore confCore, ConfigurazioneHelper confHelper,
  36.             StringBuilder inUsoMessage, String newLine) throws Exception {
  37.         HashMap<ErrorsHandlerCostant, List<String>> whereIsInUso = new HashMap<ErrorsHandlerCostant, List<String>>();
  38.         boolean normalizeObjectIds = !confHelper.isModalitaCompleta();
  39.        
  40.         // rileggo il plugin
  41.         Plugin plugin = confCore.getPlugin(idPlugin);
  42.        
  43.         boolean pluginInUso = confCore.isPluginInUso(plugin.getClassName(),
  44.                 plugin.getLabel(), plugin.getTipoPlugin(), plugin.getTipo(),whereIsInUso,normalizeObjectIds);
  45.        
  46.         if (pluginInUso) {
  47.             inUsoMessage.append(DBOggettiInUsoUtils.toString(plugin.getClassName(),
  48.                     plugin.getLabel(), plugin.getTipoPlugin(), plugin.getTipo(), whereIsInUso, true, newLine));
  49.             inUsoMessage.append(newLine);
  50.             return true;

  51.         } else {
  52.             confCore.performDeleteOperation(userLogin, confHelper.smista(), plugin);
  53.         }
  54.        
  55.         return false;
  56.     }
  57. }