AuditingDettaglio.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.audit;

  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.web.ctrlstat.core.ControlStationCore;
  31. import org.openspcoop2.web.ctrlstat.servlet.ConsoleHelper;
  32. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  33. import org.openspcoop2.web.lib.audit.log.Operation;
  34. import org.openspcoop2.web.lib.audit.web.AuditCostanti;
  35. import org.openspcoop2.web.lib.mvc.Costanti;
  36. import org.openspcoop2.web.lib.mvc.DataElement;
  37. import org.openspcoop2.web.lib.mvc.GeneralData;
  38. import org.openspcoop2.web.lib.mvc.PageData;
  39. import org.openspcoop2.web.lib.mvc.Parameter;
  40. import org.openspcoop2.web.lib.mvc.ServletUtils;

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

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

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

  55.         // Inizializzo PageData
  56.         PageData pd = new PageData();

  57.         GeneralHelper generalHelper = new GeneralHelper(session);

  58.         // Inizializzo GeneralData
  59.         GeneralData gd = generalHelper.initGeneralData(request);

  60.         try {
  61.             ConsoleHelper auditingHelper = new ConsoleHelper(request, pd, session);

  62.             String idop = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_OPERATION_ID_OP);
  63.             long idlong = Long.parseLong(idop);
  64.             String datainizio = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_DATA_INIZIO);
  65.             String datafine = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_DATA_FINE);
  66.             String tipooperazione = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_TIPO_OPERAZIONE);
  67.             String tipooggetto = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_TIPO_OGGETTO);
  68.             String id = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_ID);
  69.             String oldid = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_OLD_ID);
  70.             String utente = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_UTENTE);
  71.             String statooperazione = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_STATO_OPERAZIONE);
  72.             String contoggetto = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_CONTENUTO_OGGETTO);

  73.             Parameter pDataInizio = new Parameter(AuditCostanti.PARAMETRO_AUDIT_DATA_INIZIO, datainizio);
  74.             Parameter pDataFine = new Parameter(AuditCostanti.PARAMETRO_AUDIT_DATA_FINE, datafine);
  75.             Parameter pTipoOperazione = new Parameter(AuditCostanti.PARAMETRO_AUDIT_TIPO_OPERAZIONE, tipooperazione);
  76.             Parameter pTipoOggetto = new Parameter(AuditCostanti.PARAMETRO_AUDIT_TIPO_OGGETTO, tipooggetto);
  77.             Parameter pId = new Parameter(AuditCostanti.PARAMETRO_AUDIT_ID, id);
  78.             Parameter pOldId = new Parameter(AuditCostanti.PARAMETRO_AUDIT_OLD_ID, oldid);
  79.             Parameter pUtente = new Parameter(AuditCostanti.PARAMETRO_AUDIT_UTENTE, utente);
  80.             Parameter pStatoOperazione = new Parameter(AuditCostanti.PARAMETRO_AUDIT_STATO_OPERAZIONE, statooperazione);
  81.             Parameter pContoggetto = new Parameter(AuditCostanti.PARAMETRO_AUDIT_CONTENUTO_OGGETTO, contoggetto);
  82.             Parameter pEnd = new Parameter(ServletUtils.getDataElementForEditModeFinished().getName(), ServletUtils.getDataElementForEditModeFinished().getValue());
  83.            
  84.             // Preparo il menu
  85.             auditingHelper.makeMenu();

  86.             AuditingCore auditingCore = new AuditingCore();

  87.             // setto la barra del titolo
  88.             List<Parameter> lstParam = new ArrayList<>();

  89.             lstParam.add(new Parameter(AuditCostanti.LABEL_AUDIT, AuditCostanti.SERVLET_NAME_AUDITING));
  90.             lstParam.add(new Parameter(AuditCostanti.LABEL_AUDIT_OPERAZIONI, AuditCostanti.SERVLET_NAME_AUDITING,
  91.                     pDataInizio, pDataFine, pTipoOperazione, pTipoOggetto, pId, pOldId, pUtente, pStatoOperazione, pContoggetto, pEnd));
  92.             lstParam.add(new Parameter(AuditCostanti.LABEL_AUDIT_DETTAGLIO +" di " + idop, null));

  93.             ServletUtils.setPageDataTitle(pd, lstParam);

  94.             // Prendo l'operazione
  95.             Operation singleOp = auditingCore.getAuditOperation(idlong);

  96.             // preparo i campi
  97.             boolean showLinkDocumentiBinari = !auditingCore.isAuditingRegistrazioneElementiBinari();
  98.             List<DataElement> dati = auditingHelper.getAuditHelper().addAuditReportDettaglioToDati(
  99.                     singleOp, showLinkDocumentiBinari,
  100.                     pDataInizio, pDataFine, pTipoOperazione, pTipoOggetto, pId, pOldId, pUtente, pStatoOperazione, pContoggetto);

  101.             pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);
  102.             pd.setDati(dati);

  103.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  104.             // Forward control to the specified success URI
  105.             return ServletUtils.getStrutsForward(mapping, AuditCostanti.OBJECT_NAME_AUDITING_DETTAGLIO, AuditCostanti.TIPO_OPERAZIONE_AUDITING_DETTAGLIO);

  106.         } catch (Exception e) {
  107.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  108.                     AuditCostanti.OBJECT_NAME_AUDITING_DETTAGLIO, AuditCostanti.TIPO_OPERAZIONE_AUDITING_DETTAGLIO);
  109.         }
  110.     }
  111. }