AccordiCooperazioneAllegatiView.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.ac;

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

  23. import javax.servlet.http.HttpServletRequest;
  24. import javax.servlet.http.HttpServletResponse;
  25. import javax.servlet.http.HttpSession;

  26. import org.apache.struts.action.Action;
  27. import org.apache.struts.action.ActionForm;
  28. import org.apache.struts.action.ActionForward;
  29. import org.apache.struts.action.ActionMapping;
  30. import org.openspcoop2.core.registry.AccordoCooperazione;
  31. import org.openspcoop2.core.registry.Documento;
  32. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  33. import org.openspcoop2.web.ctrlstat.core.Utilities;
  34. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  35. import org.openspcoop2.web.ctrlstat.servlet.archivi.ArchiviCore;
  36. import org.openspcoop2.web.lib.mvc.Costanti;
  37. import org.openspcoop2.web.lib.mvc.DataElement;
  38. import org.openspcoop2.web.lib.mvc.GeneralData;
  39. import org.openspcoop2.web.lib.mvc.PageData;
  40. import org.openspcoop2.web.lib.mvc.Parameter;
  41. import org.openspcoop2.web.lib.mvc.ServletUtils;
  42. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  43. /**
  44.  * accordiCoopAllegatiView
  45.  *
  46.  * @author Andrea Poli (apoli@link.it)
  47.  * @author Stefano Corallo (corallo@link.it)
  48.  * @author Sandra Giangrandi (sandra@link.it)
  49.  * @author $Author$
  50.  * @version $Rev$, $Date$
  51.  *
  52.  */
  53. public final class AccordiCooperazioneAllegatiView extends Action {

  54.     @Override
  55.     public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

  56.         HttpSession session = request.getSession(true);

  57.         // Inizializzo PageData
  58.         PageData pd = new PageData();

  59.         GeneralHelper generalHelper = new GeneralHelper(session);

  60.         // Inizializzo GeneralData
  61.         GeneralData gd = generalHelper.initGeneralData(request);

  62.         try {

  63.             AccordiCooperazioneHelper acHelper = new AccordiCooperazioneHelper(request, pd, session);

  64.             String idAllegato = acHelper.getParameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ALLEGATO);
  65.             String idAccordo = acHelper.getParameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID_ACCORDO);
  66.             String nomeDocumento = acHelper.getParameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME_DOCUMENTO);
  67.             long idAllegatoLong = Long.parseLong(idAllegato);
  68.             long idAccordoLong = Long.parseLong(idAccordo);

  69.             /**String tipoSICA = acHelper.getParameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_TIPO_SICA);
  70.             if("".equals(tipoSICA))
  71.                 tipoSICA = null;*/

  72.             AccordiCooperazioneCore acCore = new AccordiCooperazioneCore();
  73.             ArchiviCore archiviCore = new ArchiviCore(acCore);

  74.             // Preparo il menu
  75.             acHelper.makeMenu();

  76.             // Prendo il nome
  77.             AccordoCooperazione ac = acCore.getAccordoCooperazione(idAccordoLong);
  78.             String titleAS = acHelper.getLabelIdAccordoCooperazione(ac);

  79.             Documento doc = archiviCore.getDocumento(idAllegatoLong,true);

  80.             StringBuilder contenutoAllegato = new StringBuilder();
  81.             String errore = Utilities.getTestoVisualizzabile(doc.getByteContenuto(),contenutoAllegato);

  82.             // setto la barra del titolo
  83.             List<Parameter> lstParam = new ArrayList<>();
  84.             lstParam.add(new Parameter(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE, AccordiCooperazioneCostanti.SERVLET_NAME_ACCORDI_COOPERAZIONE_LIST));
  85.             lstParam.add(new Parameter(AccordiCooperazioneCostanti.LABEL_ACCORDI_COOPERAZIONE_ALLEGATI_DI+ titleAS,
  86.                     AccordiCooperazioneCostanti.SERVLET_NAME_AC_ALLEGATI_LIST,
  87.                     new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_ID, idAccordo),
  88.                     new Parameter(AccordiCooperazioneCostanti.PARAMETRO_ACCORDI_COOPERAZIONE_NOME, ac.getNome())));
  89.             lstParam.add(new Parameter(nomeDocumento, null));
  90.            
  91.             ServletUtils.setPageDataTitle(pd, lstParam);

  92.             // preparo i campi
  93.             List<DataElement> dati = new ArrayList<>();

  94.             dati=   acHelper.addAllegatiToDati(TipoOperazione.OTHER,
  95.                     idAllegato, idAccordo, doc, contenutoAllegato, errore, dati,null,false);

  96.             pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);
  97.             pd.setDati(dati);

  98.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  99.             return ServletUtils.getStrutsForwardEditModeInProgress(mapping, AccordiCooperazioneCostanti.OBJECT_NAME_AC_ALLEGATI,
  100.                     AccordiCooperazioneCostanti.TIPO_OPERAZIONE_VIEW);
  101.         } catch (Exception e) {
  102.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  103.                     AccordiCooperazioneCostanti.OBJECT_NAME_AC_ALLEGATI,
  104.                     AccordiCooperazioneCostanti.TIPO_OPERAZIONE_VIEW);
  105.         }  
  106.     }


  107. }