BaseConsoleItem.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.protocol.sdk.properties;

  21. import org.openspcoop2.core.mapping.DBProtocolPropertiesUtils;
  22. import org.openspcoop2.protocol.sdk.ProtocolException;
  23. import org.openspcoop2.protocol.sdk.constants.ConsoleItemType;

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

  32.     private String id; // non modificabile
  33.     private String label;
  34.     private ConsoleItemType type;
  35.        
  36.     protected BaseConsoleItem(String id, String label, ConsoleItemType type) throws ProtocolException{
  37.         if(id==null){
  38.             throw new ProtocolException("Id undefined");
  39.         }
  40.         this.id = id;
  41.         this.setLabel(label);
  42.         this.setType(type);
  43.     }

  44.     public String getId() {
  45.         return this.id;
  46.     }
  47.    
  48.     public String getLabel() {
  49.         return this.label;
  50.     }
  51.     public void setLabel(String label) throws ProtocolException {
  52.         if(label==null){
  53.             throw new ProtocolException("Label undefined");
  54.         }
  55.         this.label = label;
  56.     }
  57.    
  58.     public boolean isHidden() {
  59.         return this.type!=null && (ConsoleItemType.HIDDEN.equals(this.type) || ConsoleItemType.LOCK_HIDDEN.equals(this.type));
  60.     }
  61.    
  62.     public boolean isLockedType() {
  63.         return this.type!=null && (ConsoleItemType.LOCK.equals(this.type) || ConsoleItemType.LOCK_HIDDEN.equals(this.type));
  64.     }
  65.     public ConsoleItemType getType() {
  66.         return this.type;
  67.     }
  68.     public void setType(ConsoleItemType type) throws ProtocolException {
  69.         if(type==null){
  70.             throw new ProtocolException("Type undefined");
  71.         }
  72.         this.type = type;
  73.         if(this.isLockedType()) {
  74.             DBProtocolPropertiesUtils.addConfidentialProtocolProperty(this.id);
  75.         }
  76.     }
  77.    
  78. }