AuditingDettaglioInfo.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.  * auditReportInfo
  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 AuditingDettaglioInfo 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 type = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_TYPE);
  63.             String idop = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_OPERATION_ID_OP);
  64.             long idlong = Long.parseLong(idop);
  65.             String datainizio = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_DATA_INIZIO);
  66.             String datafine = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_DATA_FINE);
  67.             String tipooperazione = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_TIPO_OPERAZIONE);
  68.             String tipooggetto = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_TIPO_OGGETTO);
  69.             String id = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_ID);
  70.             String oldid = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_OLD_ID);
  71.             String utente = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_UTENTE);
  72.             String statooperazione = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_STATO_OPERAZIONE);
  73.             String contoggetto = auditingHelper.getParameter(AuditCostanti.PARAMETRO_AUDIT_CONTENUTO_OGGETTO);

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

  85.             // Preparo il menu
  86.             auditingHelper.makeMenu();

  87.             AuditingCore auditingCore = new AuditingCore();
  88.            

  89.             // setto la barra del titolo
  90.             String label = "";
  91.             if (type.equals(AuditCostanti.DEFAULT_VALUE_PARAMETRO_AUDIT_TYPE_ERROR)){
  92.                 label = AuditCostanti.LABEL_AUDIT_MOTIVO_ERRORE;
  93.             }else{
  94.                 label = AuditCostanti.LABEL_AUDIT_DETTAGLIO_OGGETTO;
  95.             }
  96.             List<Parameter> lstParam = new ArrayList<>();

  97.             lstParam.add(new Parameter(AuditCostanti.LABEL_AUDIT, AuditCostanti.SERVLET_NAME_AUDITING));
  98.             lstParam.add(new Parameter(AuditCostanti.LABEL_AUDIT_OPERAZIONI, AuditCostanti.SERVLET_NAME_AUDITING,
  99.                     pDataInizio, pDataFine, pTipoOperazione, pTipoOggetto, pId, pOldId, pUtente, pStatoOperazione, pContoggetto, pEnd));
  100.             lstParam.add(new Parameter(AuditCostanti.LABEL_AUDIT_DETTAGLIO +" di " + idop,
  101.                     AuditCostanti.SERVLET_NAME_AUDITING_DETTAGLIO, pIdOp, pDataInizio, pDataFine, pTipoOperazione, pTipoOggetto,
  102.                     pId, pOldId, pUtente, pStatoOperazione, pContoggetto, pEnd
  103.                     ));
  104.             lstParam.add(new Parameter(label, null));

  105.             ServletUtils.setPageDataTitle(pd, lstParam);

  106.             // Prendo l'operazione
  107.             Operation singleOp = auditingCore.getAuditOperation(idlong);

  108.             // preparo i campi
  109.             List<DataElement> dati = null;
  110.             if (type.equals(AuditCostanti.DEFAULT_VALUE_PARAMETRO_AUDIT_TYPE_ERROR))
  111.                 dati = auditingHelper.getAuditHelper().addAuditReportInfoToDati(
  112.                         type, singleOp.getError());
  113.             else
  114.                 dati = auditingHelper.getAuditHelper().addAuditReportInfoToDati(
  115.                         type, singleOp.getObjectDetails());

  116.             pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);
  117.             pd.setDati(dati);

  118.             ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  119.             // Forward control to the specified success URI
  120.             return ServletUtils.getStrutsForward (mapping, AuditCostanti.OBJECT_NAME_AUDITING_DETTAGLIO, AuditCostanti.TIPO_OPERAZIONE_AUDITING_DETTAGLIO_INFO);

  121.         } catch (Exception e) {
  122.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  123.                     AuditCostanti.OBJECT_NAME_AUDITING_DETTAGLIO, AuditCostanti.TIPO_OPERAZIONE_AUDITING_DETTAGLIO_INFO);
  124.         }
  125.     }
  126. }