AboutHelper.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.about;

  21. import java.util.List;

  22. import javax.servlet.http.HttpServletRequest;
  23. import javax.servlet.http.HttpSession;

  24. import org.apache.commons.lang.StringUtils;
  25. import org.openspcoop2.utils.IVersionInfo;
  26. import org.openspcoop2.utils.UtilsException;
  27. import org.openspcoop2.web.ctrlstat.core.ControlStationLogger;
  28. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  29. import org.openspcoop2.web.ctrlstat.servlet.ConsoleHelper;
  30. import org.openspcoop2.web.lib.mvc.BinaryParameter;
  31. import org.openspcoop2.web.lib.mvc.Costanti;
  32. import org.openspcoop2.web.lib.mvc.DataElement;
  33. import org.openspcoop2.web.lib.mvc.DataElementType;
  34. import org.openspcoop2.web.lib.mvc.MessageType;
  35. import org.openspcoop2.web.lib.mvc.PageData;
  36. import org.openspcoop2.web.lib.mvc.TargetType;
  37. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  38. /**
  39.  * AboutHelper
  40.  *
  41.  * @author Poli Andrea (apoli@link.it)
  42.  * @author Pintori Giuliano (pintori@link.it)
  43.  * @author $Author$
  44.  * @version $Rev$, $Date$
  45.  */
  46. public class AboutHelper extends ConsoleHelper {

  47.     public AboutHelper(HttpServletRequest request, PageData pd,
  48.             HttpSession session) throws Exception {
  49.         super(request, pd,  session);
  50.     }

  51.     public List<DataElement> addAboutToDati(List<DataElement> dati,TipoOperazione tipoOperazione, String userLogin,
  52.             BinaryParameter infoBP) throws UtilsException {
  53.          
  54.         IVersionInfo versionInfo = null;
  55.         try {
  56.             versionInfo = this.core.getInfoVersion(this.request, this.session);
  57.         }catch(Exception e) {
  58.             ControlStationLogger.getPddConsoleCoreLogger().error("Errore durante la lettura delle informazioni sulla versione: "+e.getMessage(),e);
  59.         }
  60.         if(versionInfo!=null) {
  61.             if(!StringUtils.isEmpty(versionInfo.getErrorMessage())) {
  62.                 this.pd.setMessage(versionInfo.getErrorMessage(), MessageType.ERROR);
  63.             }
  64.             else if(!StringUtils.isEmpty(versionInfo.getWarningMessage())) {
  65.                 this.pd.setMessage(versionInfo.getWarningMessage(), MessageType.INFO);
  66.             }
  67.         }

  68.         // titolo sezione
  69.         DataElement de = new DataElement();
  70.         de.setLabel(AboutCostanti.LABEL_PRODOTTO);
  71.         de.setType(DataElementType.TITLE);
  72.         dati.add(de);
  73.        
  74.         // versione
  75.         de = new DataElement();
  76.         de.setLabel(AboutCostanti.LABEL_VERSIONE);
  77.         de.setType(DataElementType.TEXT);
  78.         de.setValue(this.core.getProductVersion());
  79.         de.setStyleClass(Costanti.INPUT_TEXT_DEFAULT_CSS_CLASS_FONT_SIZE_16);
  80.         dati.add(de);
  81.        
  82.         // sito
  83.         de = new DataElement();
  84.         de.setLabelLink(AboutCostanti.LABEL_SITO);
  85.         de.setType(DataElementType.LINK);
  86.         de.setTarget(TargetType.BLANK);
  87.         if(versionInfo!=null && !StringUtils.isEmpty(versionInfo.getWebSite())) {
  88.             de.setValue(versionInfo.getWebSite());
  89.             de.setUrl(versionInfo.getWebSite());
  90.         }
  91.         else {
  92.             de.setValue(CostantiControlStation.LABEL_OPENSPCOOP2_WEB);
  93.             de.setUrl(CostantiControlStation.LABEL_OPENSPCOOP2_WEB);
  94.         }
  95.         de.setStyleClass(Costanti.INPUT_TEXT_DEFAULT_CSS_CLASS_FONT_SIZE_16);
  96.         dati.add(de);
  97.        
  98.         // copyright
  99.         de = new DataElement();
  100.         de.setLabel(AboutCostanti.LABEL_COPYRIGHT);
  101.         de.setType(DataElementType.TEXT);
  102.         if(versionInfo!=null && !StringUtils.isEmpty(versionInfo.getCopyright())) {
  103.             de.setValue(versionInfo.getCopyright());
  104.         }
  105.         else {
  106.             de.setValue(AboutCostanti.LABEL_COPYRIGHT_VALUE);
  107.         }
  108.         de.setStyleClass(Costanti.INPUT_TEXT_DEFAULT_CSS_CLASS_FONT_SIZE_16);
  109.         dati.add(de);
  110.        
  111.         // sito openspcoop
  112.         de = new DataElement();
  113.         de.setLabel(AboutCostanti.LABEL_LICENZA);
  114.         de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  115.         de.setCols(70);
  116.         if(versionInfo!=null) {
  117.             String info = versionInfo.getInfo();
  118.             String [] split = info.split("\n");
  119.             de.setValue(info);
  120.             if(split==null || split.length>11) {
  121.                 de.setRows(11);
  122.             }
  123.             else {
  124.                 de.setRows(split.length+1);
  125.             }
  126.         }
  127.         else {
  128.             de.setValue(AboutCostanti.LICENSE);
  129.             de.setRows(11);
  130.         }
  131.         dati.add(de);
  132.        
  133.         if(versionInfo!=null) {
  134.            
  135.             de = new DataElement();
  136.             de.setLabel(AboutCostanti.LABEL_PARAMETRO_ABOUT_INFO);
  137.             de.setType(DataElementType.TITLE);
  138.             dati.add(de);
  139.            
  140.             DataElement deFile = infoBP.getFileDataElement(AboutCostanti.LABEL_PARAMETRO_ABOUT_INFO, "", getSize());
  141.             deFile.setPostBack(false);
  142.             dati.add(deFile);
  143.             dati.addAll(infoBP.getFileNameDataElement());
  144.             dati.add(infoBP.getFileIdDataElement());
  145.            
  146.                
  147.             de = new DataElement();
  148.             de.setName(AboutCostanti.PARAMETRO_ABOUT_INFO_FINISH);
  149.             de.setType(DataElementType.HIDDEN);
  150.             de.setValue(Costanti.CHECK_BOX_ENABLED);
  151.             dati.add(de);
  152.                
  153.             this.pd.setLabelBottoneInvia(AboutCostanti.BUTTON);


  154.         }
  155.         else {
  156.             this.pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);
  157.         }
  158.        
  159.         return dati;
  160.     }

  161. }