ConfigurazioneCanaliUtilities.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 java.util.Map;

  24. import org.openspcoop2.core.commons.ErrorsHandlerCostant;
  25. import org.openspcoop2.core.config.CanaleConfigurazione;
  26. import org.openspcoop2.protocol.engine.utils.DBOggettiInUsoUtils;

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

  36.     public static boolean deleteCanale(CanaleConfigurazione canale, String userLogin,
  37.             ConfigurazioneCore confCore, ConfigurazioneHelper confHelper, StringBuilder inUsoMessage, String newLine) throws Exception {

  38.         boolean deleteCanale = false;
  39.         // Controllo che il canale non sia in uso
  40.         Map<ErrorsHandlerCostant, List<String>> whereIsInUso = new HashMap<ErrorsHandlerCostant, List<String>>();
  41.         boolean normalizeObjectIds = !confHelper.isModalitaCompleta();
  42.         boolean canaleInUso  = confCore.isCanaleInUso(canale, whereIsInUso, normalizeObjectIds);

  43.         if (canaleInUso) {

  44.             inUsoMessage.append(DBOggettiInUsoUtils.toString(canale, whereIsInUso, true, newLine));
  45.             inUsoMessage.append(newLine);

  46.         } else {
  47.             // il canale si puo' eliminare
  48.             deleteCanale = true;
  49.         }

  50.         return deleteCanale;
  51.     }
  52.    
  53.     public static boolean isCanaleInUsoRegistro(CanaleConfigurazione canale,
  54.             ConfigurazioneCore confCore, ConfigurazioneHelper confHelper, StringBuilder inUsoMessage, String newLine) throws Exception {

  55.         // Controllo che il canale non sia in uso
  56.         Map<ErrorsHandlerCostant, List<String>> whereIsInUso = new HashMap<ErrorsHandlerCostant, List<String>>();
  57.         boolean normalizeObjectIds = !confHelper.isModalitaCompleta();
  58.         boolean canaleInUso  = confCore.isCanaleInUsoRegistro(canale, whereIsInUso, normalizeObjectIds);

  59.         if (canaleInUso) {

  60.             inUsoMessage.append(DBOggettiInUsoUtils.toString(canale, whereIsInUso, true, newLine));
  61.             inUsoMessage.append(newLine);

  62.         }  

  63.         return canaleInUso;
  64.     }
  65. }