ConfigurazioneHandlerBean.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.plugins.utils.handlers;

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

  23. import org.openspcoop2.core.config.ConfigurazioneHandler;
  24. import org.openspcoop2.core.plugins.Plugin;
  25. import org.openspcoop2.utils.beans.BeanUtils;
  26. import org.openspcoop2.utils.beans.BlackListElement;

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

  35.     /**
  36.      *
  37.      */
  38.     private static final long serialVersionUID = 1L;
  39.    
  40.     private Plugin plugin;
  41.    
  42.     public void setPlugin(Plugin plugin) {
  43.         this.plugin = plugin;
  44.     }
  45.     public Plugin getPlugin() {
  46.         return this.plugin;
  47.     }

  48.     public ConfigurazioneHandlerBean() {
  49.         super();
  50.     }
  51.    
  52.     public ConfigurazioneHandlerBean(ConfigurazioneHandler handler, Plugin plugin){
  53.         List<BlackListElement> metodiEsclusi = new ArrayList<BlackListElement>(
  54.                 0);
  55.         metodiEsclusi.add(new BlackListElement("setPlugin",
  56.                 Plugin.class));
  57.        
  58.         BeanUtils.copy(this, handler, metodiEsclusi);
  59.        
  60.         this.plugin = plugin;
  61.     }
  62.    
  63.     private static final int LIMIT_NOME = 80;
  64.     private static final int LIMIT = 100;
  65.    
  66.     public String getNome(){
  67.         return this.plugin != null ? this.plugin.getLabel() : null;
  68.     }
  69.    
  70.     public String getNomeAbbr(){
  71.         String tmp = this.getNome();
  72.            
  73.         if(tmp != null){
  74.             if(tmp.length() >= LIMIT_NOME)
  75.                 return tmp.substring(0, (LIMIT_NOME-3))+"...";
  76.         }
  77.        
  78.         return tmp;
  79.     }
  80.    
  81.     public String getDescrizione(){
  82.         return this.plugin != null ? this.plugin.getDescrizione() : null;
  83.     }
  84.    
  85.     public String getDescrizioneAbbr(){
  86.         String tmp = this.getDescrizione();
  87.        
  88.         if(tmp != null){
  89.             if(tmp.length() >= LIMIT)
  90.                 return tmp.substring(0, (LIMIT-3))+"...";
  91.         }
  92.        
  93.         return tmp;
  94.     }
  95. }