Monitor.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.monitor;

  21. import java.text.SimpleDateFormat;
  22. import java.util.ArrayList;
  23. import java.util.Date;
  24. import java.util.HashMap;
  25. import java.util.Iterator;
  26. import java.util.List;
  27. import java.util.Map;
  28. import java.util.Properties;
  29. import java.util.StringTokenizer;

  30. import javax.servlet.http.HttpServletRequest;
  31. import javax.servlet.http.HttpServletResponse;
  32. import javax.servlet.http.HttpSession;

  33. import org.apache.commons.lang.StringUtils;
  34. import org.apache.struts.action.Action;
  35. import org.apache.struts.action.ActionForm;
  36. import org.apache.struts.action.ActionForward;
  37. import org.apache.struts.action.ActionMapping;
  38. import org.openspcoop2.core.commons.Liste;
  39. import org.openspcoop2.core.config.PortaApplicativa;
  40. import org.openspcoop2.core.config.PortaApplicativaServizioApplicativo;
  41. import org.openspcoop2.core.config.ServizioApplicativo;
  42. import org.openspcoop2.core.config.constants.CostantiConfigurazione;
  43. import org.openspcoop2.core.config.driver.DriverConfigurazioneNotFound;
  44. import org.openspcoop2.core.id.IDPortaApplicativa;
  45. import org.openspcoop2.core.id.IDServizio;
  46. import org.openspcoop2.core.id.IDServizioApplicativo;
  47. import org.openspcoop2.core.id.IDSoggetto;
  48. import org.openspcoop2.core.registry.constants.PddTipologia;
  49. import org.openspcoop2.core.registry.driver.IDServizioFactory;
  50. import org.openspcoop2.message.constants.ServiceBinding;
  51. import org.openspcoop2.pdd.core.GestoreMessaggi;
  52. import org.openspcoop2.pdd.monitor.Busta;
  53. import org.openspcoop2.pdd.monitor.BustaServizio;
  54. import org.openspcoop2.pdd.monitor.BustaSoggetto;
  55. import org.openspcoop2.pdd.monitor.Dettaglio;
  56. import org.openspcoop2.pdd.monitor.Messaggio;
  57. import org.openspcoop2.pdd.monitor.ServizioApplicativoConsegna;
  58. import org.openspcoop2.pdd.monitor.StatoPdd;
  59. import org.openspcoop2.pdd.monitor.constants.StatoMessaggio;
  60. import org.openspcoop2.pdd.monitor.driver.DriverMonitoraggio;
  61. import org.openspcoop2.pdd.monitor.driver.FilterSearch;
  62. import org.openspcoop2.pdd.monitor.driver.FiltroStatoConsegnaAsincrona;
  63. import org.openspcoop2.pdd.monitor.driver.StatoConsegnaAsincrona;
  64. import org.openspcoop2.pdd.monitor.driver.StatoConsegneAsincrone;
  65. import org.openspcoop2.pdd.timers.TimerConsegnaContenutiApplicativiThread;
  66. import org.openspcoop2.utils.Utilities;
  67. import org.openspcoop2.utils.date.DateUtils;
  68. import org.openspcoop2.web.ctrlstat.config.ConsoleProperties;
  69. import org.openspcoop2.web.ctrlstat.config.DatasourceProperties;
  70. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  71. import org.openspcoop2.web.ctrlstat.core.ControlStationLogger;
  72. import org.openspcoop2.web.ctrlstat.core.ConsoleSearch;
  73. import org.openspcoop2.web.ctrlstat.dao.PdDControlStation;
  74. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  75. import org.openspcoop2.web.ctrlstat.servlet.aps.AccordiServizioParteSpecificaCore;
  76. import org.openspcoop2.web.ctrlstat.servlet.pa.PorteApplicativeCore;
  77. import org.openspcoop2.web.ctrlstat.servlet.pdd.PddCore;
  78. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCore;
  79. import org.openspcoop2.web.ctrlstat.servlet.sa.ServiziApplicativiCostanti;
  80. import org.openspcoop2.web.ctrlstat.servlet.soggetti.SoggettiCore;
  81. import org.openspcoop2.web.lib.audit.appender.AuditDisabilitatoException;
  82. import org.openspcoop2.web.lib.audit.appender.IDOperazione;
  83. import org.openspcoop2.web.lib.audit.log.constants.Tipologia;
  84. import org.openspcoop2.web.lib.mvc.AreaBottoni;
  85. import org.openspcoop2.web.lib.mvc.Costanti;
  86. import org.openspcoop2.web.lib.mvc.DataElement;
  87. import org.openspcoop2.web.lib.mvc.DataElementType;
  88. import org.openspcoop2.web.lib.mvc.GeneralData;
  89. import org.openspcoop2.web.lib.mvc.GeneralLink;
  90. import org.openspcoop2.web.lib.mvc.PageData;
  91. import org.openspcoop2.web.lib.mvc.Parameter;
  92. import org.openspcoop2.web.lib.mvc.ServletUtils;

  93. /**
  94.  *
  95.  * Servlet per la gestione del monitoraggio applicativo
  96.  *
  97.  *
  98.  * @author Andrea Poli (apoli@link.it)
  99.  * @author Stefano Corallo (corallo@link.it)
  100.  * @author Sandra Giangrandi (sandra@link.it)
  101.  * @author $Author$
  102.  * @version $Rev$, $Date$
  103.  *
  104.  */
  105. public final class Monitor extends Action {

  106.     // Driver Monitoraggio
  107.     private static Boolean initialized = null;
  108.     protected static MonitorCore monitorCore = null;
  109.     protected static PddCore pddCore = null;
  110.     protected static Boolean singlePdD = false;
  111.     protected static ConsoleProperties consoleProperties = null;
  112.    
  113.     /** Locale */
  114.     protected static Map<String, DriverMonitoraggio> driverMonitoraggioLocale = null;
  115.     protected static List<String> sorgentiDriverMonitoraggioLocale = null;
  116.     protected static List<String> labelSorgentiDriverMonitoraggioLocale = null;
  117.    
  118.     /**
  119.      * Inizializza il driver di monitoraggio.
  120.      *
  121.      * @throws Exception
  122.      */
  123.     private static synchronized void initMonitoraggio() throws Exception {

  124.         if (Monitor.initialized == null) {

  125.             // core
  126.             monitorCore = new MonitorCore();
  127.             pddCore = new PddCore(monitorCore);
  128.            
  129.             if(monitorCore.isSinglePdD()){
  130.            
  131.                 // Inizializzazione locale
  132.                
  133.                 DatasourceProperties datasourceProperties = null;
  134.                 try {
  135.                     datasourceProperties = DatasourceProperties.getInstance();
  136.                     sorgentiDriverMonitoraggioLocale = datasourceProperties.getSinglePddMonitorSorgentiDati();
  137.                     if(sorgentiDriverMonitoraggioLocale==null || sorgentiDriverMonitoraggioLocale.isEmpty()) {
  138.                         throw new Exception("Nessuna sorgente dati definita");
  139.                     }
  140.                 } catch (java.lang.Exception e) {
  141.                     ControlStationLogger.getPddConsoleCoreLogger().error("[govwayConsole] Lettura proprieta' non riuscita : " + e.getMessage());
  142.                     throw new Exception("[govwayConsole] Lettura proprieta' non riuscita : " + e.getMessage());
  143.                 }
  144.                
  145.                 labelSorgentiDriverMonitoraggioLocale = new ArrayList<>();
  146.                 driverMonitoraggioLocale = new HashMap<>();
  147.                 for (String sorgente : sorgentiDriverMonitoraggioLocale) {
  148.                    
  149.                     String label = null;
  150.                     String jndiName = "";
  151.                     Properties jndiProp = null;
  152.                     String tipoDatabase = null;
  153.                     try {
  154.                         label = datasourceProperties.getSinglePddMonitorLabel(sorgente);
  155.                         jndiName = datasourceProperties.getSinglePddMonitorDataSource(sorgente);
  156.                         jndiProp = datasourceProperties.getSinglePddMonitorDataSourceContext(sorgente);
  157.                         tipoDatabase = datasourceProperties.getSinglePddMonitorTipoDatabase(sorgente);
  158.                        
  159.                     } catch (java.lang.Exception e) {
  160.                         ControlStationLogger.getPddConsoleCoreLogger().error("[govwayConsole] Lettura proprieta' non riuscita per la sorgente dati '"+sorgente+"' : " + e.getMessage());
  161.                         throw new Exception("[govwayConsole] Lettura proprieta' non riuscita  per la sorgente dati '"+sorgente+"' : " + e.getMessage());
  162.                     }
  163.        
  164.                     try {
  165.                         labelSorgentiDriverMonitoraggioLocale.add(label);
  166.                         Monitor.driverMonitoraggioLocale.put(sorgente, new DriverMonitoraggio(jndiName, tipoDatabase, jndiProp));
  167.                     } catch (java.lang.Exception e) {
  168.                         ControlStationLogger.getPddConsoleCoreLogger().error("[govwayConsole] Inizializzazione DriverMonitoraggio non riuscita  per la sorgente dati '"+sorgente+"' : " + e.getMessage());
  169.                         throw new Exception("[govwayConsole] Inizializzazione DriverMonitoraggio non riuscita  per la sorgente dati '"+sorgente+"' : " + e.getMessage());
  170.                     }  
  171.                 }
  172.                                
  173.             }

  174.             singlePdD = monitorCore.isSinglePdD();
  175.             consoleProperties = ConsoleProperties.getInstance();
  176.            
  177.             // inizializzato
  178.             initialized = true;
  179.         }

  180.     }

  181.    
  182.    
  183.    
  184.    
  185.    
  186.     @Override
  187.     public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {

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

  189.         // Salvo il vecchio PageData
  190.         PageData pdold = ServletUtils.getPageDataFromSession(request, session);

  191.         // Inizializzo PageData
  192.         PageData pd = new PageData();

  193.         GeneralHelper generalHelper = new GeneralHelper(session);

  194.         // Inizializzo GeneralData
  195.         GeneralData gd = generalHelper.initGeneralData(request);

  196.         String userLogin = ServletUtils.getUserLoginFromSession(session);  

  197.         // Inizializzo driver
  198.         if (Monitor.initialized == null) {
  199.             Monitor.initMonitoraggio();
  200.         }

  201.         MonitorHelper monitorHelper = null;
  202.         try {

  203.             MonitorCore monitorCore = new MonitorCore();
  204.            
  205.             monitorHelper = new MonitorHelper(request, pd, session);

  206.             ArrayList<String> errors = new ArrayList<>();

  207.             String metodo = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_METHOD);
  208.             String ns = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_NEW_SEARCH);
  209.             String[] tipoProfcoll = MonitorCostanti.getDefaultValuesParametroTipoProfiloCollaborazione();
  210.             String actionConfirm = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_ACTION_CONFIRM);

  211.             if (monitorHelper.isEditModeInProgress() && (metodo == null || !metodo.equals(MonitorCostanti.DEFAULT_VALUE_FORM_BEAN_METHOD_DETAILS))&&
  212.                     actionConfirm == null && (ns == null || !ns.equals(MonitorCostanti.DEFAULT_VALUE_FALSE) )) {
  213.                 // prima volta che accedo quindi show form

  214.                 // recupero eventuali parametri nella request
  215.                 MonitorFormBean mb = this.getBeanForm(errors, monitorHelper);

  216.                 this.showForm(request, session, monitorHelper, pd, tipoProfcoll, MonitorMethods.getMethodsNames(), "", "", mb, monitorCore);

  217.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  218.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping,
  219.                         MonitorCostanti.OBJECT_NAME_MONITOR,
  220.                         MonitorCostanti.TIPO_OPERAZIONE_MONITOR
  221.                         );
  222.             }

  223.             String pageSize = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_PAGE_SIZE);
  224.             // se pageSize settato allora vuol dire che sono in una richiesta di
  225.             // nextPage
  226.             // altrimenti prima richiesta

  227.            
  228.             // se actionConfirm settato, significa che ho chiesto e
  229.             // confermato l'eliminazione delle richieste pendenti

  230.             // recupero i dati inseriti dall'utente nel form
  231.             MonitorFormBean formBean = null;
  232.             if (((pageSize == null) || pageSize.equals("")) &&
  233.                     actionConfirm == null) {
  234.                 formBean = this.getBeanForm(errors, monitorHelper);
  235.             } else {
  236.                 // prendo il form dalla sessione xe' salvato precedentemente
  237.                 formBean = ServletUtils.getObjectFromSession(request, session, MonitorFormBean.class, MonitorCostanti.SESSION_ATTRIBUTE_FORM_BEAN);
  238.                 errors.add("Dati form non validi. I dati non sono presenti in sessione.");
  239.             }

  240.             // se form non valido rimando all'inserimento dati
  241.             if (formBean == null) {
  242.                 // eventuali messaggi di errore nel pd
  243.                 String errMsg = "";
  244.                 Iterator<String> it = errors.listIterator();
  245.                 while (it.hasNext()) {
  246.                     String err = it.next();
  247.                     errMsg += err + "<br>";
  248.                 }
  249.                 pd.setMessage(errMsg);

  250.                 //              return mapping.findForward("MonitorForm");

  251.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  252.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping,
  253.                         MonitorCostanti.OBJECT_NAME_MONITOR,
  254.                         MonitorCostanti.TIPO_OPERAZIONE_MONITOR);
  255.             }

  256.             // controllo se visualizzazione dettaglio messaggio
  257.             if (formBean.getMethod().equals(MonitorCostanti.DEFAULT_VALUE_FORM_BEAN_METHOD_DETAILS)) {

  258.                 MonitorFormBean oldFormBeanRicerca = ServletUtils.getObjectFromSession(request, session, MonitorFormBean.class, MonitorCostanti.SESSION_ATTRIBUTE_FORM_BEAN);

  259.                 String idMessaggio = formBean.getIdMessaggio();
  260.                 FilterSearch filter = new FilterSearch();
  261.                 filter.setIdMessaggio(idMessaggio);
  262.                 filter.setBusta(new Busta());
  263.                 filter.setTipo(formBean.getTipo());

  264.                 ControlStationCore core = new ControlStationCore();
  265.                 SoggettiCore soggettiCore = new SoggettiCore(core);

  266.                 List<BustaSoggetto> filtroSoggetti = null;
  267.                 if(core.isVisioneOggettiGlobale(userLogin)==false){
  268.                     List<IDSoggetto> filtroIds = soggettiCore.getSoggettiWithSuperuser(userLogin);
  269.                     filtroSoggetti = new ArrayList<BustaSoggetto>();
  270.                     for (IDSoggetto idSoggetto : filtroIds) {
  271.                         BustaSoggetto sog = new BustaSoggetto();
  272.                         sog.setTipo(idSoggetto.getTipo());
  273.                         sog.setNome(idSoggetto.getNome());
  274.                         filtroSoggetti.add(sog);
  275.                     }
  276.                 }
  277.                 filter.setSoggettoList(filtroSoggetti);

  278.                 // prima richiesta con protocollo
  279.                 long countMessaggi = MonitorUtilities.countListaRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());
  280.                 List<Messaggio> listaMessaggi = MonitorUtilities.getListaRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());
  281.                 if (countMessaggi > 0) {
  282.                     Messaggio messaggio = listaMessaggi.get(0);
  283.                     // visualizzo dettagli messaggio
  284.                     this.showDettagliMessaggio(pd, monitorHelper, messaggio, oldFormBeanRicerca);

  285.                     ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  286.                     return ServletUtils.getStrutsForwardEditModeFinished(mapping, MonitorCostanti.OBJECT_NAME_MONITOR,
  287.                             MonitorCostanti.TIPO_OPERAZIONE_MONITOR_DETTAGLI);

  288.                     //                  return mapping.findForward("DettagliOk");
  289.                 } else {
  290.                     // seconda richiesta senza protocollo (NOTA: se l'utente ha visibilita locale, questi msg non li vedra' mai)
  291.                     // Solo l'amministratore con visibilita' globale li puo' vedere.
  292.                     filter.setBusta(null);
  293.                     countMessaggi = MonitorUtilities.countListaRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());
  294.                     listaMessaggi = MonitorUtilities.getListaRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());
  295.                     if (countMessaggi > 0) {
  296.                         Messaggio messaggio = listaMessaggi.get(0);
  297.                         // visualizzo dettagli messaggio
  298.                         this.showDettagliMessaggio(pd, monitorHelper, messaggio, oldFormBeanRicerca);

  299.                         //                      return mapping.findForward("DettagliOk");

  300.                         ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  301.                         return ServletUtils.getStrutsForwardEditModeFinished(mapping, MonitorCostanti.OBJECT_NAME_MONITOR,
  302.                                 MonitorCostanti.TIPO_OPERAZIONE_MONITOR_DETTAGLI);
  303.                     } else {
  304.                         // non ho trovato messaggi
  305.                         pd.setMessage("Il messaggio [" + formBean.getIdMessaggio() + "] non e' piu presente. Impossibile visualizzare il dettaglio.");
  306.                         // rinvio alla visulizzazione del form in quanto il
  307.                         // messaggio non e' piu presente
  308.                         this.showForm(request, session, monitorHelper, pd, tipoProfcoll, MonitorMethods.getMethodsNames(), "", "", formBean, monitorCore);

  309.                         ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  310.                         return ServletUtils.getStrutsForwardEditModeInProgress(mapping, MonitorCostanti.OBJECT_NAME_MONITOR,
  311.                                 MonitorCostanti.TIPO_OPERAZIONE_MONITOR_DETTAGLI);
  312.                         //                      return mapping.findForward("MonitorForm");
  313.                     }
  314.                 }
  315.             }

  316.             // controllo se cancellazione messaggio
  317.             String objToRemove = monitorHelper.getParameter(Costanti.PARAMETER_NAME_OBJECTS_FOR_REMOVE);
  318.             String objToRemoveType = monitorHelper.getParameter(Costanti.PARAMETER_NAME_OBJECTS_FOR_REMOVE_TYPE);
  319.             //String action = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_ACTION);
  320.             if (objToRemove != null) {
  321. //              if ((action != null) && action.equals(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_MONITOR_ACTION_DELETE)) {
  322.                 FilterSearch filter = new FilterSearch();

  323.                 ControlStationCore core = new ControlStationCore();
  324.                 SoggettiCore soggettiCore = new SoggettiCore(core);
  325.                 List<BustaSoggetto> filtroSoggetti = null;
  326.                 if(core.isVisioneOggettiGlobale(userLogin)==false){
  327.                     List<IDSoggetto> filtroIds = soggettiCore.getSoggettiWithSuperuser(userLogin);
  328.                     filtroSoggetti = new ArrayList<BustaSoggetto>();
  329.                     for (IDSoggetto idSoggetto : filtroIds) {
  330.                         BustaSoggetto sog = new BustaSoggetto();
  331.                         sog.setTipo(idSoggetto.getTipo());
  332.                         sog.setNome(idSoggetto.getNome());
  333.                         filtroSoggetti.add(sog);
  334.                     }
  335.                 }
  336.                 filter.setSoggettoList(filtroSoggetti);

  337.            

  338.                 // Elimino i soggetti dal db
  339.                 StringTokenizer objTok = new StringTokenizer(objToRemove, ",");
  340.                 int[] idToRemove = new int[objTok.countTokens()];

  341.                 Tipologia tipoOperazione = Tipologia.DEL;
  342.                 //System.out.println("tIPOOO '"+objToRemoveType+"'");
  343.                 if(objToRemoveType!=null && MonitorCostanti.ACTION_RICONSEGNA_IMMEDIATA.equals(objToRemoveType)) {
  344.                     tipoOperazione = Tipologia.CHANGE;
  345.                 }
  346.                
  347.                 long n = 0;
  348.                 long nError = 0;
  349.                
  350.                 int k = 0;
  351.                 while (objTok.hasMoreElements()) {
  352.                     idToRemove[k++] = Integer.parseInt(objTok.nextToken());
  353.                 }
  354.                 @SuppressWarnings("unused")
  355.                 String msgKO = "Impossibile cancellare Messaggio: <br>";
  356.                 @SuppressWarnings("unused")
  357.                 String msgOK = "Cancellato Messaggio : <br>";
  358.                 for (int i = 0; i < idToRemove.length; i++) {

  359.                     List<?> dataElements = (List<?>) pdold.getDati().get(idToRemove[i]);
  360.                    
  361.                     // ID PARAMETRO_MONITOR_ID_MESSAGGIO alla posizione 2
  362.                     DataElement de = (DataElement) dataElements.get(1);
  363.                     String idMessaggio = de.getValue();
  364.                     filter.setIdMessaggio(idMessaggio);
  365.                    
  366.                     // TIPO (inbox/outbox) PARAMETRO_MONITOR_TIPO alla posizione 3
  367.                     de = (DataElement) dataElements.get(2);
  368.                     String tipo = de.getValue();
  369.                     filter.setTipo(tipo);
  370.                    
  371.                     IDOperazione [] idOperazione = null;
  372.                     boolean auditDisabiltato = false;
  373.                     try{
  374.                         idOperazione = core.performAuditRequest(new Tipologia []{tipoOperazione}, userLogin, new Object[] {filter});
  375.                     }catch(AuditDisabilitatoException disabilitato){
  376.                         auditDisabiltato = true;
  377.                     }
  378.                     try{
  379.                         if(Tipologia.CHANGE.equals(tipoOperazione)) {
  380.                             long changeReali = MonitorUtilities.aggiornaDataRispedizioneRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());
  381.                             if(changeReali>0) {
  382.                                 n = n + changeReali;
  383.                             }
  384.                         }
  385.                         else {
  386.                             long deleteReali =MonitorUtilities.deleteRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());
  387.                             if(deleteReali>0) {
  388.                                 n = n + deleteReali;
  389.                             }
  390.                         }
  391.                        
  392.                         if (n > 0) {
  393.                             msgOK += " -" + idMessaggio + "<br>";
  394.                         } else {
  395.                             msgKO += " - " + idMessaggio + "<br>";
  396.                         }
  397.                         if(!auditDisabiltato){
  398.                             core.performAuditComplete(idOperazione, new Tipologia []{tipoOperazione}, userLogin, new Object[] {filter});
  399.                         }
  400.                     }catch(Exception e){
  401.                        
  402.                         nError++;
  403.                        
  404.                         if(!auditDisabiltato){
  405.                             core.performAuditError(idOperazione, e.getMessage(), new Tipologia []{tipoOperazione}, userLogin, new Object[] {filter});
  406.                         }
  407.                         msgKO += " - " + idMessaggio + "<br>";
  408.                         continue;
  409.                     }
  410.                    

  411.                 }
  412.                
  413.                 if(Tipologia.CHANGE.equals(tipoOperazione)) {
  414.                     pd.setMessage("Aggiornata la data di rispedizione di " + n + " messaggi"+(n==1?"o":"") +
  415.                             (nError>0 ? "<br>L'aggiornamento è fallito per "+nError+" messaggi"+(nError==1?"o":"") : ""),
  416.                             nError>0 ? Costanti.MESSAGE_TYPE_ERROR : Costanti.MESSAGE_TYPE_INFO);
  417.                 }
  418.                 else {
  419.                     pd.setMessage("Eliminat"+(n==1?"o":"i")+" " + n + " messaggi"+(n==1?"o":"") +
  420.                             (nError>0 ? "<br>L'eliminazione è fallita per "+nError+" messaggi"+(nError==1?"o":"") : ""),
  421.                             nError>0 ? Costanti.MESSAGE_TYPE_ERROR : Costanti.MESSAGE_TYPE_INFO);
  422.                 }

  423.             }

  424.             // richiedo l'azione al ws
  425.             FilterSearch filter = new FilterSearch();
  426.             FiltroStatoConsegnaAsincrona filterConsegnaAsincrona = new FiltroStatoConsegnaAsincrona();

  427.             if(formBean.getOrderByConsegnaAsincrona()!=null) {
  428.                 if(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_CODA.equals(formBean.getOrderByConsegnaAsincrona())) {
  429.                     filterConsegnaAsincrona.setOrderByInCoda(true);
  430.                 }
  431.                 else if(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_RICONSEGNA.equals(formBean.getOrderByConsegnaAsincrona())) {
  432.                     filterConsegnaAsincrona.setOrderByInRiconsegna(true);
  433.                 }
  434.                 else if(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_MESSAGE_BOX.equals(formBean.getOrderByConsegnaAsincrona())) {
  435.                     filterConsegnaAsincrona.setOrderByInMessageBox(true);
  436.                 }
  437.             }
  438.            
  439.             BustaSoggetto mittente = formBean.getMittente();
  440.             BustaSoggetto destinatario = formBean.getDestinatario();
  441.             BustaServizio servizio = formBean.getServizio();
  442.             String azione = formBean.getAzione();
  443.             String profilo = formBean.getProfiloCollaborazione();
  444.             boolean riscontro = formBean.isRiscontro();

  445.             Busta busta = null;
  446.             if ((mittente != null) || (destinatario != null) || (servizio != null) || (azione != null) || (profilo != null) || riscontro) {
  447.                 busta = new Busta();
  448.                 busta.setMittente(mittente);
  449.                 busta.setDestinatario(destinatario);
  450.                 busta.setAzione(azione);
  451.                 busta.setProfiloCollaborazione(profilo);
  452.                 busta.setServizio(servizio);
  453.                 busta.setAttesaRiscontro(riscontro);
  454.                 filter.setBusta(busta);
  455.             }

  456.             // setto gli altri filtri
  457.             filter.setMessagePattern(formBean.getMessagePattern());
  458.             filter.setIdMessaggio(formBean.getIdMessaggio());
  459.             if(formBean.getSoglia()>0)
  460.                 filter.setSoglia(formBean.getSoglia());
  461.             if(formBean.getStato()!=null)
  462.                 filter.setStato(org.openspcoop2.pdd.monitor.constants.StatoMessaggio.toEnumConstant(formBean.getStato()));
  463.             filter.setCorrelazioneApplicativa(formBean.getCorrelazioneApplicativa());


  464.             ControlStationCore core = new ControlStationCore();
  465.             SoggettiCore soggettiCore = new SoggettiCore(core);
  466.             List<BustaSoggetto> filtroSoggetti = null;
  467.             if(core.isVisioneOggettiGlobale(userLogin)==false){
  468.                 List<IDSoggetto> filtroIds = soggettiCore.getSoggettiWithSuperuser(userLogin);
  469.                 filtroSoggetti = new ArrayList<BustaSoggetto>();
  470.                 for (IDSoggetto idSoggetto : filtroIds) {
  471.                     BustaSoggetto sog = new BustaSoggetto();
  472.                     sog.setTipo(idSoggetto.getTipo());
  473.                     sog.setNome(idSoggetto.getNome());
  474.                     filtroSoggetti.add(sog);
  475.                 }
  476.             }
  477.             filter.setSoggettoList(filtroSoggetti);

  478.             // mostro risultati azione in base al tipo di metodo
  479.             if (formBean.getMethod().equals(MonitorMethods.STATO_RICHIESTE.getNome())) {

  480.                 StatoPdd statoPdD = MonitorUtilities.getStatoRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());
  481.                 this.showStatoPdD(pd, monitorHelper,  statoPdD, MonitorMethods.STATO_RICHIESTE.getNome(), formBean);

  482.                 //              return mapping.findForward("StatoNalOk");


  483.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  484.                 return ServletUtils.getStrutsForwardEditModeFinished(mapping, MonitorCostanti.OBJECT_NAME_MONITOR,
  485.                         MonitorCostanti.TIPO_OPERAZIONE_MONITOR_STATO_PDD);

  486.             } else if (formBean.getMethod().equals(MonitorMethods.STATO_CONSEGNE_ASINCRONE.getNome())) {

  487.                 // Criteri di visualizzazione/ricerca
  488.                 ConsoleSearch ricerca = new ConsoleSearch();

  489.                 String newSearch = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_NEW_SEARCH);
  490.                 if ((newSearch != null) && newSearch.equals(MonitorCostanti.DEFAULT_VALUE_FALSE)) {
  491.                     Object oldfilter = ServletUtils.getObjectFromSession(request, session, MonitorCostanti.SESSION_ATTRIBUTE_FILTER_SEARCH);
  492.                     if (oldfilter != null && oldfilter instanceof FiltroStatoConsegnaAsincrona) {
  493.                         filterConsegnaAsincrona = (FiltroStatoConsegnaAsincrona) oldfilter;
  494.                     }

  495.                     ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);
  496.                 }

  497.                 int idLista = Liste.MONITOR_MSG;
  498.                 ricerca = monitorHelper.checkSearchParameters(idLista, ricerca);
  499.                 ServletUtils.addListElementIntoSession(request, session, MonitorCostanti.OBJECT_NAME_MONITOR);
  500.                 // per i criteri di
  501.                 // ricerca dalla jsp
  502.                 filter.setLimit(ricerca.getPageSize(idLista));
  503.                 filter.setOffset(ricerca.getIndexIniziale(idLista));
  504.                
  505.                 StatoConsegneAsincrone statoConsegneAsincrone = MonitorUtilities.getStatoConsegneAsincrone(filterConsegnaAsincrona, formBean.getSorgenteDati());

  506.                 this.showStatoConsegneAsincrone(pd, monitorHelper, statoConsegneAsincrone, MonitorMethods.STATO_CONSEGNE_ASINCRONE.getNome(), formBean);

  507.                 // imposto i parametri per l'eventuale richiesta di nextPage
  508.                 Parameter pMethod = new Parameter(MonitorCostanti.PARAMETRO_MONITOR_METHOD, MonitorMethods.STATO_CONSEGNE_ASINCRONE.getNome());
  509.                 Parameter pNewSearch = new Parameter(MonitorCostanti.PARAMETRO_MONITOR_NEW_SEARCH, MonitorCostanti.DEFAULT_VALUE_FALSE);
  510.                 Parameter pSorgente = new Parameter(MonitorCostanti.PARAMETRO_MONITOR_SORGENTE, formBean.getSorgenteDati());
  511.                
  512.                 // salvo l'oggetto ricerca nella sessione
  513.                 ServletUtils.setSearchObjectIntoSession(request, session, ricerca);
  514.                 // conservo il form bean nella session per eventuali richieste
  515.                 // successive (nextPage)
  516.                 ServletUtils.setObjectIntoSession(request, session, formBean, MonitorCostanti.SESSION_ATTRIBUTE_FORM_BEAN);
  517.                 ServletUtils.setObjectIntoSession(request, session, filterConsegnaAsincrona, MonitorCostanti.SESSION_ATTRIBUTE_FILTER_SEARCH);
  518.                
  519.                 // refresh ricerca
  520.                 List<Parameter> listRefresh = new ArrayList<>();
  521.                 listRefresh.add(pMethod);
  522.                 listRefresh.add(pNewSearch);
  523.                 listRefresh.add(pSorgente);
  524.                 pd.addComandoAggiornaRicercaButton(MonitorCostanti.SERVLET_NAME_MONITOR, listRefresh);
  525.                
  526.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  527.                 return ServletUtils.getStrutsForwardEditModeFinished(mapping, MonitorCostanti.OBJECT_NAME_MONITOR,
  528.                         MonitorCostanti.TIPO_OPERAZIONE_MONITOR);

  529.                 //              return mapping.findForward("MessaggiOk");

  530.             } else if (formBean.getMethod().equals(MonitorMethods.LISTA_RICHIESTE_PENDENTI.getNome())) {

  531.                 // Criteri di visualizzazione/ricerca
  532.                 ConsoleSearch ricerca = new ConsoleSearch();

  533.                 String newSearch = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_NEW_SEARCH);
  534.                 if ((newSearch != null) && newSearch.equals(MonitorCostanti.DEFAULT_VALUE_FALSE)) {
  535.                     Object oldfilter = ServletUtils.getObjectFromSession(request, session, MonitorCostanti.SESSION_ATTRIBUTE_FILTER_SEARCH);
  536.                     if (oldfilter != null && oldfilter instanceof FilterSearch) {
  537.                         filter = (FilterSearch) oldfilter;
  538.                     }

  539.                     ricerca = (ConsoleSearch) ServletUtils.getSearchObjectFromSession(request, session, ConsoleSearch.class);
  540.                 }

  541.                 int idLista = Liste.MONITOR_MSG;
  542.                 ricerca = monitorHelper.checkSearchParameters(idLista, ricerca);
  543.                 ServletUtils.addListElementIntoSession(request, session, MonitorCostanti.OBJECT_NAME_MONITOR);
  544.                 // per i criteri di
  545.                 // ricerca dalla jsp
  546.                 filter.setLimit(ricerca.getPageSize(idLista));
  547.                 filter.setOffset(ricerca.getIndexIniziale(idLista));

  548.                 long countMessaggi = MonitorUtilities.countListaRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());
  549.                 List<Messaggio> listaMessaggi = MonitorUtilities.getListaRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());

  550.                 this.showMessaggi(pd, monitorHelper, countMessaggi, listaMessaggi, MonitorMethods.LISTA_RICHIESTE_PENDENTI.getNome(), ricerca, filter, formBean);

  551.                 // imposto i parametri per l'eventuale richiesta di nextPage
  552.                 Parameter pMethod = new Parameter(MonitorCostanti.PARAMETRO_MONITOR_METHOD, MonitorMethods.LISTA_RICHIESTE_PENDENTI.getNome());
  553.                 Parameter pNewSearch = new Parameter(MonitorCostanti.PARAMETRO_MONITOR_NEW_SEARCH, MonitorCostanti.DEFAULT_VALUE_FALSE);
  554.                 Parameter pPdd = new Parameter(MonitorCostanti.PARAMETRO_MONITOR_PDD, formBean.getPdd());
  555.                 Parameter pSorgente = new Parameter(MonitorCostanti.PARAMETRO_MONITOR_SORGENTE, formBean.getSorgenteDati());


  556.                 // salvo l'oggetto ricerca nella sessione
  557.                 ServletUtils.setSearchObjectIntoSession(request, session, ricerca);
  558.                 // conservo il form bean nella session per eventuali richieste
  559.                 // successive (nextPage)
  560.                 ServletUtils.setObjectIntoSession(request, session, formBean, MonitorCostanti.SESSION_ATTRIBUTE_FORM_BEAN);
  561.                 ServletUtils.setObjectIntoSession(request, session, filter, MonitorCostanti.SESSION_ATTRIBUTE_FILTER_SEARCH);

  562.                 if(singlePdD){
  563.                     request.setAttribute(Costanti.REQUEST_ATTIBUTE_PARAMS, ServletUtils.getParametersAsString(false, pMethod, pNewSearch, pSorgente));
  564.                 }
  565.                 else{
  566.                     request.setAttribute(Costanti.REQUEST_ATTIBUTE_PARAMS, ServletUtils.getParametersAsString(false, pMethod, pNewSearch, pPdd));
  567.                 }

  568.                 // refresh ricerca
  569.                 List<Parameter> listRefresh = new ArrayList<>();
  570.                 listRefresh.add(pMethod);
  571.                 listRefresh.add(pNewSearch);
  572.                 listRefresh.add(pSorgente);
  573.                 pd.addComandoAggiornaRicercaButton(MonitorCostanti.SERVLET_NAME_MONITOR, listRefresh);

  574.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  575.                 return ServletUtils.getStrutsForwardEditModeFinished(mapping, MonitorCostanti.OBJECT_NAME_MONITOR,
  576.                         MonitorCostanti.TIPO_OPERAZIONE_MONITOR);

  577.                 //              return mapping.findForward("MessaggiOk");

  578.             } else if (formBean.getMethod().equals(MonitorMethods.ELIMINAZIONE_RICHIESTE_PENDENTI.getNome()) ||
  579.                     formBean.getMethod().equals(MonitorMethods.RICONSEGNA_IMMEDIATA_RICHIESTE_PENDENTI.getNome())) {

  580.                 boolean updateDataRispedizione = formBean.getMethod().equals(MonitorMethods.RICONSEGNA_IMMEDIATA_RICHIESTE_PENDENTI.getNome());
  581.                
  582.                 if (actionConfirm == null) {
  583.                     monitorHelper.makeMenu();

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

  586.                     lstParam.add(new Parameter(MonitorCostanti.LABEL_MONITOR, null));

  587.                     ServletUtils.setPageDataTitle(pd, lstParam);

  588.                     String msg = "";
  589.                     if (filter != null) {
  590.                         if (filter.getCorrelazioneApplicativa() != null && !"".equals(filter.getCorrelazioneApplicativa()))
  591.                             msg += "<br>ID Applicativo: "+filter.getCorrelazioneApplicativa();
  592.                         if (filter.getMessagePattern() != null && !"".equals(filter.getMessagePattern()))
  593.                             msg += "<br>Contenuto Messaggio: "+filter.getMessagePattern();
  594.                         if (filter.getSoglia() > 0)
  595.                             msg += "<br>Messaggi piu' vecchi di (minuti): "+filter.getSoglia();
  596.                         if (filter.getStato() != null && !"".equals(filter.getStato().getValue()))
  597.                             msg += "<br>Stato: "+filter.getStato();
  598.                         if (filter.getIdMessaggio() != null && !"".equals(filter.getIdMessaggio()))
  599.                             msg += "<br>ID: "+filter.getIdMessaggio();
  600.                         if (filter.getBusta() != null) {
  601.                             if (filter.getBusta().getProfiloCollaborazione() != null && !"".equals(filter.getBusta().getProfiloCollaborazione()))
  602.                                 msg += "<br>Profilo di collaborazione: "+filter.getBusta().getProfiloCollaborazione();
  603.                             if (filter.getBusta().isAttesaRiscontro())
  604.                                 msg += "<br>In Attesa di Riscontro: "+filter.getBusta().isAttesaRiscontro();
  605.                             if (filter.getBusta().getMittente() != null) {
  606.                                 if (filter.getBusta().getMittente().getTipo() != null && !"".equals(filter.getBusta().getMittente().getTipo()))
  607.                                     msg += "<br>Tipo Mittente: "+filter.getBusta().getMittente().getTipo();
  608.                                 if (filter.getBusta().getMittente().getNome() != null && !"".equals(filter.getBusta().getMittente().getNome()))
  609.                                     msg += "<br>Nome Mittente: "+filter.getBusta().getMittente().getNome();
  610.                             }
  611.                             if (filter.getBusta().getDestinatario() != null) {
  612.                                 if (filter.getBusta().getDestinatario().getTipo() != null && !"".equals(filter.getBusta().getDestinatario().getTipo()))
  613.                                     msg += "<br>Tipo Destinatario: "+filter.getBusta().getDestinatario().getTipo();
  614.                                 if (filter.getBusta().getDestinatario().getNome() != null && !"".equals(filter.getBusta().getDestinatario().getNome()))
  615.                                     msg += "<br>Nome Destinatario: "+filter.getBusta().getDestinatario().getNome();
  616.                             }
  617.                             if (filter.getBusta().getServizio() != null) {
  618.                                 if (filter.getBusta().getServizio().getTipo() != null && !"".equals(filter.getBusta().getServizio().getTipo()))
  619.                                     msg += "<br>Tipo Servizio: "+filter.getBusta().getServizio().getTipo();
  620.                                 if (filter.getBusta().getServizio().getNome() != null && !"".equals(filter.getBusta().getServizio().getNome()))
  621.                                     msg += "<br>Nome Servizio: "+filter.getBusta().getServizio().getNome();
  622.                                 if (filter.getBusta().getServizio().getVersione() != null && filter.getBusta().getServizio().getVersione().intValue()>0)
  623.                                     msg += "<br>Versione Servizio: "+filter.getBusta().getServizio().getVersione();
  624.                             }
  625.                             if (filter.getBusta().getAzione() != null && !"".equals(filter.getBusta().getAzione()))
  626.                                 msg += "<br>Azione: "+filter.getBusta().getAzione();
  627.                         }
  628.                     }
  629.                     StatoPdd stato =  MonitorUtilities.getStatoRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());
  630.                     String prefixMsg = "Eliminare i";
  631.                     if(updateDataRispedizione) {
  632.                         prefixMsg = "Aggiornare la data di riconsegna dei";
  633.                     }
  634.                     if(stato.getTotMessaggi()>0){
  635.                         if (msg.equals(""))
  636.                             msg = prefixMsg+" "+stato.getTotMessaggi()+" messaggi?";
  637.                         else
  638.                             msg = prefixMsg+" "+stato.getTotMessaggi()+" messaggi corrispondenti ai filtri selezionati?<br>"+msg;
  639.                     }else{
  640.                         if (msg.equals(""))
  641.                             msg = "Non esistono messaggi";
  642.                         else
  643.                             msg = "Non esistono messaggi corrispondenti ai filtri selezionati:<br>"+msg;
  644.                         pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);
  645.                     }
  646.                     pd.setMessage(msg, Costanti.MESSAGE_TYPE_INFO);

  647.                     // imposto i parametri per l'eventuale richiesta di nextPage
  648.                     //                  String params = "method=" + MonitorMethods.ELIMINAZIONE_RICHIESTE_PENDENTI.getNome();
  649.                     //                  params += "&monhid=yes";
  650.                     //                  params += "&actionConfirm=yes";

  651.                     Parameter pMethod = new Parameter(MonitorCostanti.PARAMETRO_MONITOR_METHOD, formBean.getMethod());
  652.                     Parameter pActionconfirm = new Parameter(MonitorCostanti.PARAMETRO_MONITOR_ACTION_CONFIRM, Costanti.CHECK_BOX_ENABLED);

  653.                     ServletUtils.setObjectIntoSession(request, session, formBean, MonitorCostanti.SESSION_ATTRIBUTE_FORM_BEAN);
  654.                     ServletUtils.setObjectIntoSession(request, session, filter, MonitorCostanti.SESSION_ATTRIBUTE_FILTER_SEARCH);

  655.                     request.setAttribute(Costanti.REQUEST_ATTIBUTE_PARAMS, ServletUtils.getParametersAsString(false, pMethod, pActionconfirm));

  656.                     ServletUtils.addListElementIntoSession(request, session, MonitorCostanti.OBJECT_NAME_MONITOR);
  657.                    
  658.                     if(stato.getTotMessaggi()>0){
  659.                        
  660.                         String pre = Costanti.HTML_MODAL_SPAN_PREFIX;
  661.                         String post = Costanti.HTML_MODAL_SPAN_SUFFIX;
  662.                         pd.setMessage(pre + msg + post, Costanti.MESSAGE_TYPE_CONFIRM);

  663.                         String[][] bottoni = {
  664.                                 { Costanti.LABEL_MONITOR_BUTTON_ANNULLA,
  665.                                     Costanti.LABEL_MONITOR_BUTTON_ANNULLA_CONFERMA_PREFIX +
  666.                                     Costanti.LABEL_MONITOR_BUTTON_ANNULLA_CONFERMA_SUFFIX

  667.                                 },
  668.                                 { Costanti.LABEL_MONITOR_BUTTON_CONFERMA,
  669.                                     Costanti.LABEL_MONITOR_BUTTON_ESEGUI_OPERAZIONE_CONFERMA_PREFIX +
  670.                                     Costanti.LABEL_MONITOR_BUTTON_ESEGUI_OPERAZIONE_CONFERMA_SUFFIX }};
  671.                         pd.setBottoni(bottoni);
  672.                        
  673.                         List<DataElement>dati = new ArrayList<>();
  674.                         dati.add(ServletUtils.getDataElementForEditModeFinished());
  675.                         pd.setDati(dati);
  676.                        
  677.                         this.showForm(request, session, monitorHelper, pd, tipoProfcoll, MonitorMethods.getMethodsNames(), "", "", formBean, monitorCore);
  678.                     }  
  679.                         ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  680.                         return ServletUtils.getStrutsForwardEditModeInProgress(mapping, MonitorCostanti.OBJECT_NAME_MONITOR,
  681.                                 MonitorCostanti.TIPO_OPERAZIONE_MONITOR);

  682.                 } else {
  683.                     if(actionConfirm.equals(Costanti.PARAMETRO_ACTION_CONFIRM_VALUE_OK)) {
  684.                        
  685.                         Tipologia tipoOperazione = Tipologia.DEL;
  686.                         if(updateDataRispedizione) {
  687.                             tipoOperazione = Tipologia.CHANGE;
  688.                         }
  689.                        
  690.                         IDOperazione [] idOperazione = null;
  691.                         boolean auditDisabiltato = false;
  692.                         try{
  693.                             idOperazione = core.performAuditRequest(new Tipologia []{tipoOperazione}, userLogin, new Object[] {filter});
  694.                         }catch(AuditDisabilitatoException disabilitato){
  695.                             auditDisabiltato = true;
  696.                         }
  697.                         try{
  698.                             long n = -1;
  699.                             if(Tipologia.CHANGE.equals(tipoOperazione)) {
  700.                                 n = MonitorUtilities.aggiornaDataRispedizioneRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());
  701.                                 pd.setMessage("Aggiornata la data di rispedizione di " + n + " messaggi"+(n==1?"o":""), Costanti.MESSAGE_TYPE_INFO);
  702.                             }
  703.                             else {
  704.                                 n = MonitorUtilities.deleteRichiestePendenti(filter,formBean.getPdd(),formBean.getSorgenteDati());
  705.                                 pd.setMessage("Eliminat"+(n==1?"o":"i")+" " + n + " messaggi"+(n==1?"o":""), Costanti.MESSAGE_TYPE_INFO);
  706.                             }
  707.                             if(!auditDisabiltato){
  708.                                 core.performAuditComplete(idOperazione, new Tipologia []{tipoOperazione}, userLogin, new Object[] {filter});
  709.                             }
  710.                         }catch(Exception e){
  711.                             if(!auditDisabiltato){
  712.                                 core.performAuditError(idOperazione, e.getMessage(), new Tipologia []{tipoOperazione}, userLogin, new Object[] {filter});
  713.                             }
  714.                             throw e;
  715.                         }  
  716.                    
  717.                     }

  718.                     this.showForm(request, session, monitorHelper, pd, tipoProfcoll, MonitorMethods.getMethodsNames(), "", "", formBean, monitorCore);

  719.                     ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  720.                     return ServletUtils.getStrutsForwardEditModeInProgress(mapping, MonitorCostanti.OBJECT_NAME_MONITOR,
  721.                             MonitorCostanti.TIPO_OPERAZIONE_MONITOR);

  722.                     //                  return mapping.findForward("MonitorForm");

  723.                     // return mapping.findForward("DeleteOk");
  724.                 }
  725.             } else {
  726.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);

  727.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping,
  728.                         MonitorCostanti.OBJECT_NAME_MONITOR,
  729.                         MonitorCostanti.TIPO_OPERAZIONE_MONITOR);
  730.             }

  731.         }
  732.         catch(javax.xml.ws.WebServiceException exception){
  733.            
  734.             try{
  735.            
  736.                 if(monitorHelper!=null)
  737.                     monitorHelper.makeMenu();
  738.                
  739.                 ControlStationCore.getLog().error(exception.getMessage(), exception);
  740.                
  741.                 Throwable e = exception;
  742.                 if(Utilities.existsInnerException(e,  org.apache.cxf.transport.http.HTTPException.class)){
  743.                     e = Utilities.getInnerException(e, org.apache.cxf.transport.http.HTTPException.class);
  744.                 }
  745.                 pd.setMessage(e.getMessage());
  746.                
  747.                 pd.disableEditMode();
  748.                
  749.                 ServletUtils.setGeneralAndPageDataIntoSession(request, session, gd, pd);
  750.                
  751.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping,
  752.                         MonitorCostanti.OBJECT_NAME_MONITOR,
  753.                         MonitorCostanti.TIPO_OPERAZIONE_MONITOR);
  754.             }
  755.             catch (Throwable e) {
  756.                 return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  757.                         MonitorCostanti.OBJECT_NAME_MONITOR,
  758.                         MonitorCostanti.TIPO_OPERAZIONE_MONITOR);
  759.             }  
  760.            
  761.         }
  762.         catch (Throwable e) {
  763.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  764.                     MonitorCostanti.OBJECT_NAME_MONITOR,
  765.                     MonitorCostanti.TIPO_OPERAZIONE_MONITOR);
  766.         }  

  767.     }

  768.     /**
  769.      * Recupera i dati dalla request e riempe il form
  770.      *
  771.      * @param request
  772.      * @return MonitorFormBean
  773.      * @throws Exception
  774.      */
  775.     private MonitorFormBean getBeanForm(ArrayList<String> errors, MonitorHelper monitorHelper) throws Exception {
  776.         try {
  777.             MonitorFormBean form = null;

  778.             String method = null;
  779.             // controllo se richiesta corretta
  780.             boolean trovato = false;
  781.             method = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_METHOD);
  782.             if ((method == null) || method.equals("")) {
  783.                 return null;
  784.             }

  785.             MonitorMethods[] methods = MonitorMethods.values();

  786.             for (int i = 0; (i < methods.length) && (trovato == false); i++) {
  787.                 if (method.equals(methods[i].getNome()) || method.equals(MonitorCostanti.DEFAULT_VALUE_FORM_BEAN_METHOD_DETAILS)) {
  788.                     trovato = true;
  789.                     continue;
  790.                 }
  791.             }

  792.             if (trovato == false) {
  793.                 errors.add("Metodo selezionato sconosciuto. Selezionare un metodo tra:" + MonitorMethods.getMethodNames().toString());
  794.                 throw new Exception("Metodo selezionato SCONOSCIUTO.");
  795.             }

  796.             form = new MonitorFormBean();

  797.             form.setMethod(method);

  798.             String orderByConsegnaAsincrona = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_ORDER_BY_CONSEGNA_ASINCRONA);
  799.             if ((orderByConsegnaAsincrona != null) && !orderByConsegnaAsincrona.equals("")) {
  800.                 form.setOrderByConsegnaAsincrona(orderByConsegnaAsincrona);
  801.             }
  802.            
  803.             String idMessaggio = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_ID_MESSAGGIO);
  804.             if ((idMessaggio != null) && !idMessaggio.equals("")) {
  805.                 form.setIdMessaggio(idMessaggio);
  806.             }

  807.             // tipo messaggio outbox/inbox
  808.             String tipo = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO);
  809.             if ((tipo != null) && !tipo.equals("")) {
  810.                 form.setTipo(tipo);
  811.             }

  812.             // Profilo Collaborazione
  813.             String profcoll = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_PROFILO_COLLABORAZIONE);

  814.             if ((profcoll == null) || profcoll.equals("") || profcoll.equals(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ANY)) {
  815.                 form.setProfiloCollaborazione(null);
  816.             } else if (profcoll.equals(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ASINCRONO_ASIMMETRICO)) {
  817.                 form.setProfiloCollaborazione(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_ASINCRONO_ASIMMETRICO);
  818.             } else if (profcoll.equals(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ASINCRONO_SIMMETRICO)) {
  819.                 form.setProfiloCollaborazione(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_ASINCRONO_SIMMETRICO);
  820.             } else if (profcoll.equals(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_SINCRONO)) {
  821.                 form.setProfiloCollaborazione(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_SINCRONO);
  822.             } else if (profcoll.equals(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ONEWAY)) {
  823.                 form.setProfiloCollaborazione(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_SINGOLO_ONEWAY);
  824.             }

  825.             // Mittente
  826.             String tipoSogg = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_MITTENTE);
  827.             String nomeSogg = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_NOME_MITTENTE);
  828.             BustaSoggetto mittente = null;
  829.             if (((tipoSogg != null) && !tipoSogg.equals("")) || ((nomeSogg != null) && !nomeSogg.equals(""))) {
  830.                 mittente = new BustaSoggetto();
  831.                 mittente.setNome(nomeSogg);
  832.                 mittente.setTipo(tipoSogg);
  833.             }
  834.             form.setMittente(mittente);

  835.             // Destinatario
  836.             BustaSoggetto destinatario = null;
  837.             tipoSogg = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_DESTINATARIO);
  838.             nomeSogg = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_NOME_DESTINATARIO);
  839.             if (((tipoSogg != null) && !tipoSogg.equals("")) || ((nomeSogg != null) && !nomeSogg.equals(""))) {
  840.                 destinatario = new BustaSoggetto();
  841.                 destinatario.setNome(nomeSogg);
  842.                 destinatario.setTipo(tipoSogg);
  843.             }
  844.             form.setDestinatario(destinatario);

  845.             // Servizio
  846.             BustaServizio servizio = null;
  847.             String tipoServizio = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_SERVIZIO);
  848.             String nomeServizio = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_NOME_SERVIZIO);
  849.             if (((tipoServizio != null) && !tipoServizio.equals("")) || ((nomeServizio != null) && !nomeServizio.equals(""))) {
  850.                 servizio = new BustaServizio();
  851.                 servizio.setNome(nomeServizio);
  852.                 servizio.setTipo(tipoServizio);
  853.             }
  854.             String versioneServizio = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_VERSIONE_SERVIZIO);
  855.             if(versioneServizio!=null && !"".equals(versioneServizio)) {
  856.                 if(servizio==null) {
  857.                     servizio = new BustaServizio();
  858.                 }
  859.                 servizio.setVersione(Integer.valueOf(versioneServizio));
  860.             }
  861.             form.setServizio(servizio);

  862.             // Azione
  863.             String azione = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_AZIONE);
  864.             if ((azione != null) && !azione.equals("")) {
  865.                 form.setAzione(azione);
  866.             }

  867.             // Soglia
  868.             String soglia = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_SOGLIA);
  869.             long sogliaLong = 0;
  870.             try {
  871.                 sogliaLong = Long.parseLong(soglia);
  872.             } catch (Exception e) {
  873.                 // ignore
  874.             }
  875.             form.setSoglia(sogliaLong);

  876.             // Riscontro
  877.             String riscontro = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_RISCONTRO);
  878.             if ((riscontro != null) && !riscontro.equals("")) {
  879.                 form.setRiscontro(true);
  880.             }

  881.             // pdd/sorgente
  882.             if(singlePdD){
  883.                 String sorgente = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_SORGENTE);
  884.                 if ((sorgente != null) && !sorgente.equals("")) {
  885.                     form.setSorgenteDati(sorgente);
  886.                 }
  887.             }
  888.             else {
  889.                 String pdd = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_PDD);
  890.                 if ((pdd != null) && !pdd.equals("")) {
  891.                     form.setPdd(pdd);
  892.                 }
  893.             }

  894.             // stato
  895.             String stato = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_STATO);
  896.             if ((stato != null) && (stato.equals(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_STATO_NONE) || stato.equals(""))) {
  897.                 stato = null;
  898.             }
  899.             form.setStato(stato);

  900.             // messagePattern
  901. //          String mp = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_PATTERN);
  902. //          if ((mp != null) && !mp.equals("")) {
  903. //              form.setMessagePattern(mp);
  904. //          }

  905.             // CorrelazioneApplicativa
  906.             String correlazioneApplicativa = monitorHelper.getParameter(MonitorCostanti.PARAMETRO_MONITOR_CORRELAZIONE_APPLICATIVA);
  907.             if ((correlazioneApplicativa != null) && !correlazioneApplicativa.equals("")) {
  908.                 form.setCorrelazioneApplicativa(correlazioneApplicativa);
  909.             }
  910.            
  911.             return form;
  912.         } catch (Exception e) {
  913.             throw new Exception(e);
  914.         }
  915.     }

  916.     private List<Parameter> createSearchString(MonitorFormBean monitorFormBean )
  917.             throws Exception {
  918.         try {
  919.             List<Parameter> lstParam = new ArrayList<>();

  920.             // metodo
  921.             if (monitorFormBean.getMethod() != null) {
  922.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_METHOD, monitorFormBean.getMethod()));
  923.             }
  924.             // pdd
  925.             if (monitorFormBean.getPdd() != null) {
  926.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_PDD,  monitorFormBean.getPdd()));
  927.             }
  928.             // sorgenteDati
  929.             if (monitorFormBean.getSorgenteDati() != null) {
  930.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_SORGENTE,  monitorFormBean.getSorgenteDati()));
  931.             }

  932.             // destinatario
  933.             if (monitorFormBean.getDestinatario() != null) {
  934.                 BustaSoggetto destinatario = monitorFormBean.getDestinatario();
  935.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_DESTINATARIO, destinatario.getTipo()));
  936.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_NOME_DESTINATARIO,  destinatario.getNome()));
  937.             }
  938.             // mittente
  939.             if (monitorFormBean.getMittente() != null) {
  940.                 BustaSoggetto mitt = monitorFormBean.getMittente();
  941.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_MITTENTE, mitt.getTipo()));
  942.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_NOME_MITTENTE, mitt.getNome()));
  943.             }
  944.             // servizio
  945.             if (monitorFormBean.getServizio() != null) {
  946.                 BustaServizio serv = monitorFormBean.getServizio();
  947.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_SERVIZIO, serv.getTipo()));
  948.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_NOME_SERVIZIO, serv.getNome()));
  949.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_VERSIONE_SERVIZIO, serv.getVersione()!=null ? (serv.getVersione().intValue()+"") : null));
  950.             }

  951.             // idmessaggio
  952.             if (monitorFormBean.getIdMessaggio() != null) {
  953.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_ID_MESSAGGIO, monitorFormBean.getIdMessaggio()));
  954.             }
  955.             // pattern
  956. //          if (monitorFormBean.getMessagePattern() != null) {
  957. //              lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_PATTERN, monitorFormBean.getMessagePattern()));
  958. //          }
  959.            
  960.             // azione
  961.             if (monitorFormBean.getAzione() != null) {
  962.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_AZIONE, monitorFormBean.getAzione()));
  963.             }
  964.             // stato
  965.             if (monitorFormBean.getStato() != null) {
  966.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_STATO, monitorFormBean.getStato()));
  967.             }
  968.             // soglia
  969.             if (monitorFormBean.getSoglia() > 0) {
  970.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_SOGLIA,""+ monitorFormBean.getSoglia()));
  971.             }
  972.             // riscontro
  973.             if (monitorFormBean.isRiscontro()) {
  974.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_RISCONTRO, ""+monitorFormBean.isRiscontro()));
  975.             }

  976.             // profilo collaborazione
  977.             String profcoll = monitorFormBean.getProfiloCollaborazione();
  978.             if (profcoll == null) {
  979.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_PROFILO_COLLABORAZIONE,
  980.                         MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ANY));
  981.             } else if (profcoll.equals(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_ASINCRONO_ASIMMETRICO)) {
  982.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_PROFILO_COLLABORAZIONE,
  983.                         MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ASINCRONO_ASIMMETRICO));
  984.             } else if (profcoll.equals(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_ASINCRONO_SIMMETRICO)) {
  985.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_PROFILO_COLLABORAZIONE,
  986.                         MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ASINCRONO_SIMMETRICO));
  987.             } else if (profcoll.equals(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_SINCRONO)) {
  988.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_PROFILO_COLLABORAZIONE,
  989.                         MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_SINCRONO));
  990.             } else if (profcoll.equals(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_SINGOLO_ONEWAY)) {
  991.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_PROFILO_COLLABORAZIONE,
  992.                         MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ONEWAY));
  993.             } else {
  994.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO_PROFILO_COLLABORAZIONE,
  995.                         MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ANY ));
  996.             }

  997.             // correlazioneApplicative
  998.             if (monitorFormBean.getCorrelazioneApplicativa()!=null) {
  999.                 lstParam.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_CORRELAZIONE_APPLICATIVA, monitorFormBean.getCorrelazioneApplicativa()));
  1000.             }

  1001.             return lstParam;

  1002.             //          return ServletUtils.getParametersAsString(inserisciPrimoParametro, lstParam.toArray(new Parameter[lstParam.size()])).replaceAll(" ", "%20");
  1003.         } catch (Exception e) {
  1004.             throw new Exception(e);
  1005.         }
  1006.     }

  1007.     private void showForm(HttpServletRequest request, HttpSession session, MonitorHelper monitorHelper, PageData pd, String[] profiliCollaborazione,
  1008.             String[] metodiMonitor, String azione, String soglia, MonitorFormBean mb, MonitorCore monitorCore) throws Exception {
  1009.         try {
  1010.             monitorHelper.makeMenu();

  1011.             //User user = ServletUtils.getUserFromSession(session);

  1012.             // setto la barra del titolo
  1013.             List<GeneralLink> titlelist = new ArrayList<>();
  1014.             GeneralLink tl1 = new GeneralLink();
  1015.             tl1.setLabel(MonitorCostanti.LABEL_MONITOR);
  1016.             titlelist.add(tl1);
  1017.             pd.setTitleList(titlelist);

  1018.             // preparo i campi
  1019.             List<DataElement> dati = new ArrayList<>();
  1020.             dati.add(ServletUtils.getDataElementForEditModeFinished());

  1021.             DataElement de = new DataElement();
  1022.             de.setType(DataElementType.TITLE);
  1023.             de.setLabel(MonitorCostanti.LABEL_MONITOR);
  1024.             dati.add(de);
  1025.            
  1026.             // select method
  1027.             de = new DataElement();
  1028.             de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_METHOD);
  1029.             de.setType(DataElementType.SELECT);
  1030.             de.setName(MonitorCostanti.PARAMETRO_MONITOR_METHOD);
  1031.             de.setSelected(mb != null ? mb.getMethod() : "");
  1032.             de.setValues(metodiMonitor);
  1033.             de.setPostBack(true);
  1034.             dati.add(de);
  1035.            
  1036.             if(singlePdD){
  1037.                 de = new DataElement();
  1038.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_SORGENTE);
  1039.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_SORGENTE);
  1040.                 String sorgenteSelezionata = mb != null ? mb.getSorgenteDati() : sorgentiDriverMonitoraggioLocale.get(0);
  1041.                 if(sorgentiDriverMonitoraggioLocale.size()>1) {
  1042.                     de.setType(DataElementType.SELECT);
  1043.                     de.setValues(sorgentiDriverMonitoraggioLocale);
  1044.                     de.setLabels(labelSorgentiDriverMonitoraggioLocale);
  1045.                     de.setSelected(sorgenteSelezionata);
  1046.                 }
  1047.                 else {
  1048.                     de.setType(DataElementType.HIDDEN);
  1049.                     de.setValue(sorgenteSelezionata);
  1050.                 }
  1051.                 dati.add(de);
  1052.             }
  1053.             else {
  1054.                 String user = ServletUtils.getUserLoginFromSession(session);
  1055.                 List<PdDControlStation> pdds = pddCore.pddList(user, new ConsoleSearch(true));
  1056.                 // String[] nomiPdD = new String[];
  1057.                 List<String> nomiPdD = new ArrayList<>();
  1058.                 for (PdDControlStation pdd : pdds) {
  1059.                         // visualizzo tutte le pdd che non sono esterne
  1060.                         if (!pdd.getTipo().equals(PddTipologia.ESTERNO.toString())) {
  1061.                                 nomiPdD.add(pdd.getNome());
  1062.                         }
  1063.                 }
  1064.                 de = new DataElement();
  1065.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_PORTA_DOMINIO);
  1066.                 de.setType(DataElementType.SELECT);
  1067.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_PDD);
  1068.                 de.setValues(nomiPdD.toArray(new String[nomiPdD.size()]));
  1069.                 de.setSelected(mb != null ? mb.getPdd() : consoleProperties.getGestioneCentralizzataWSMonitorPddDefault());
  1070.                 dati.add(de);
  1071.             }
  1072.            
  1073.             boolean showFilterConsegnaAsincrona = (mb==null || mb.getMethod()==null || mb.getMethod().equals(MonitorMethods.STATO_CONSEGNE_ASINCRONE.getNome()));
  1074.                    
  1075.             if(showFilterConsegnaAsincrona) {
  1076.                
  1077.                 List<String> values = new ArrayList<>();
  1078.                 values.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_CODA);
  1079.                 values.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_RICONSEGNA);
  1080.                 values.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_MESSAGE_BOX);
  1081.                
  1082.                 de = new DataElement();
  1083.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_PARAMETRO_MONITOR_ORDER_BY_CONSEGNA_ASINCRONA);
  1084.                 de.setType(DataElementType.SELECT);
  1085.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_ORDER_BY_CONSEGNA_ASINCRONA);
  1086.                 de.setValues(values);
  1087.                 de.setSelected(mb != null && mb.getOrderByConsegnaAsincrona()!=null ? mb.getOrderByConsegnaAsincrona() : MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_CODA);
  1088.                 dati.add(de);
  1089.                
  1090.             }
  1091.            
  1092.            
  1093.             boolean showFilter = (mb!=null && mb.getMethod()!=null && !mb.getMethod().equals(MonitorMethods.STATO_CONSEGNE_ASINCRONE.getNome()));
  1094.            
  1095.             if(showFilter) {
  1096.                
  1097.                 // Titolo Filter
  1098.                 de = new DataElement();
  1099.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_FILTRO_RICERCA);
  1100.                 de.setType(DataElementType.TITLE);
  1101.                 dati.add(de);
  1102.    
  1103.                 // CorrelazioneApplicativa
  1104.                 de = new DataElement();
  1105.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_CORRELAZIONE_APPLICATIVA);
  1106.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_CORRELAZIONE_APPLICATIVA);
  1107.                 de.setType(DataElementType.TEXT_EDIT);
  1108.                 de.setValue(mb != null ? mb.getCorrelazioneApplicativa() : "");
  1109.                 de.setSize(monitorHelper.getSize());
  1110.                 dati.add(de);
  1111.    
  1112.                 // Message Pattern
  1113.     //          de = new DataElement();
  1114.     //          de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_PATTERN);
  1115.     //          de.setName(MonitorCostanti.PARAMETRO_MONITOR_PATTERN);
  1116.     //          de.setType(DataElementType.TEXT_EDIT);
  1117.     //          de.setValue(mb != null ? mb.getMessagePattern() : "");
  1118.     //          de.setSize(monitorHelper.getSize());
  1119.     //          dati.add(de);
  1120.    
  1121.                 // Soglia
  1122.                 de = new DataElement();
  1123.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_SOGLIA_LABEL);
  1124.                 de.setNote(MonitorCostanti.LABEL_PARAMETRO_MONITOR_SOGLIA_NOTE);
  1125.                 de.setType(DataElementType.TEXT_EDIT);
  1126.                 de.setSize(monitorHelper.getSize());
  1127.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_SOGLIA);
  1128.                 de.setValue(mb != null ? "" + mb.getSoglia() : soglia);
  1129.                 dati.add(de);
  1130.    
  1131.                 // Stato
  1132.                 if(monitorCore.isShowJ2eeOptions()) {
  1133.                     String [] stati = MonitorCostanti.getDefaultValuesParametroStato();
  1134.                     de = new DataElement();
  1135.                     de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_STATO);
  1136.                     de.setType(DataElementType.SELECT);
  1137.                     de.setValues(stati);
  1138.                     de.setSelected(mb != null ? mb.getStato() : MonitorCostanti.DEFAULT_VALUE_PARAMETRO_STATO_NONE);
  1139.                     de.setName(MonitorCostanti.PARAMETRO_MONITOR_STATO);
  1140.                     dati.add(de);
  1141.                 }
  1142.                    
  1143.                 de = new DataElement();
  1144.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_INFORMAZIONI_PROTOCOLLO);
  1145.                 de.setType(DataElementType.TITLE);
  1146.                 dati.add(de);
  1147.    
  1148.                 // ID Messaggio
  1149.                 de = new DataElement();
  1150.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_ID_MESSAGGIO);
  1151.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_ID_MESSAGGIO);
  1152.                 de.setType(DataElementType.TEXT_EDIT);
  1153.                 de.setValue(mb != null ? mb.getIdMessaggio() : "");
  1154.                 de.setSize(monitorHelper.getSize());
  1155.                 dati.add(de);
  1156.    
  1157.                 // Profilo Collaborazione
  1158.                 de = new DataElement();
  1159.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO_PROFILO_COLLABORAZIONE);
  1160.                 de.setType(DataElementType.SELECT);
  1161.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO_PROFILO_COLLABORAZIONE);
  1162.                 de.setValues(profiliCollaborazione);
  1163.                 String profcoll = mb != null ? mb.getProfiloCollaborazione() : "";
  1164.                 if ((profcoll == null) || profcoll.equals("") || profcoll.equals(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ANY)) {
  1165.                     de.setSelected(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_NONE);
  1166.                 } else if (profcoll.equals(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_ASINCRONO_ASIMMETRICO)) {
  1167.                     de.setSelected(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ASINCRONO_ASIMMETRICO);
  1168.                 } else if (profcoll.equals(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_ASINCRONO_SIMMETRICO)) {
  1169.                     de.setSelected(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ASINCRONO_SIMMETRICO);
  1170.                 } else if (profcoll.equals(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_SINCRONO)) {
  1171.                     de.setSelected(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_SINCRONO);
  1172.                 } else if (profcoll.equals(MonitorCostanti.LABEL_MONITOR_PROFILO_COLLABORAZIONE_SINGOLO_ONEWAY)) {
  1173.                     de.setSelected(MonitorCostanti.DEFAULT_VALUE_PARAMETRO_TIPO_PROFILO_COLLABORAZIONE_ONEWAY);
  1174.                 }
  1175.    
  1176.                 dati.add(de);
  1177.    
  1178.                 // riscontro
  1179.                 de = new DataElement();
  1180.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_RISCONTRO);
  1181.                 de.setType(DataElementType.CHECKBOX);
  1182.                 de.setValue(mb != null ? "" + mb.isRiscontro() : "");
  1183.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_RISCONTRO);
  1184.                 dati.add(de);
  1185.    
  1186.                 // Mittente
  1187.                 de = new DataElement();
  1188.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_SOGGETTO_MITTENTE);
  1189.                 de.setType(DataElementType.TITLE);
  1190.                 dati.add(de);
  1191.    
  1192.                 // Tipo Mittente
  1193.     //          if (InterfaceType.STANDARD.equals(user.getInterfaceType())) {
  1194.     //              de = new DataElement();
  1195.     //              de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO_MITTENTE);
  1196.     //              de.setType(DataElementType.HIDDEN);
  1197.     //              de.setSize(monitorHelper.getSize());
  1198.     //              de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO_MITTENTE);
  1199.     //              de.setValue("");
  1200.     //              dati.add(de);
  1201.     //          } else {
  1202.                
  1203.                 SoggettiCore soggettiCore = new SoggettiCore(monitorCore);
  1204.                 List<String> tipiSoggetti = new ArrayList<>();
  1205.                 List<String> tipiSoggetti_label = new ArrayList<>();
  1206.                 tipiSoggetti.add("");
  1207.                 tipiSoggetti_label.add("-");
  1208.                 tipiSoggetti.addAll(soggettiCore.getTipiSoggettiGestiti());
  1209.                 tipiSoggetti_label.addAll(soggettiCore.getTipiSoggettiGestiti());
  1210.                
  1211.                 de = new DataElement();
  1212.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO_MITTENTE);
  1213.                 de.setType(DataElementType.SELECT);
  1214.                 de.setSize(monitorHelper.getSize());
  1215.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO_MITTENTE);
  1216.                 de.setSelected(mb != null ? (mb.getMittente() != null ? mb.getMittente().getTipo() : "") : "");
  1217.                 de.setValues(tipiSoggetti);
  1218.                 de.setLabels(tipiSoggetti_label);
  1219.                 dati.add(de);
  1220.                
  1221.     //          de = new DataElement();
  1222.     //          de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO_MITTENTE);
  1223.     //          de.setType(DataElementType.TEXT_EDIT);
  1224.     //          de.setSize(monitorHelper.getSize());
  1225.     //          de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO_MITTENTE);
  1226.     //          de.setValue(mb != null ? (mb.getMittente() != null ? mb.getMittente().getTipoSoggetto() : "") : "");
  1227.     //          dati.add(de);
  1228.                 //}
  1229.    
  1230.                 de = new DataElement();
  1231.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_NOME_MITTENTE );
  1232.                 de.setType(DataElementType.TEXT_EDIT);
  1233.                 de.setSize(monitorHelper.getSize());
  1234.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_NOME_MITTENTE);
  1235.                 de.setValue(mb != null ? (mb.getMittente() != null ? mb.getMittente().getNome() : "") : "");
  1236.                 dati.add(de);
  1237.    
  1238.                 // Destinatario
  1239.                 de = new DataElement();
  1240.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_SOGGETTO_DESTINATARIO);
  1241.                 de.setType(DataElementType.TITLE);
  1242.                 dati.add(de);
  1243.                
  1244.                 // Destinatario
  1245.     //          if (InterfaceType.STANDARD.equals(user.getInterfaceType())) {
  1246.     //              de = new DataElement();
  1247.     //              de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO_DESTINATARIO );
  1248.     //              de.setType(DataElementType.HIDDEN);
  1249.     //              de.setSize(monitorHelper.getSize());
  1250.     //              de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO_DESTINATARIO);
  1251.     //              de.setValue("");
  1252.     //              dati.add(de);
  1253.     //          } else {
  1254.     //          de = new DataElement();
  1255.     //          de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO_DESTINATARIO);
  1256.     //          de.setType(DataElementType.TEXT_EDIT);
  1257.     //          de.setSize(monitorHelper.getSize());
  1258.     //          de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO_DESTINATARIO);
  1259.     //          de.setValue(mb != null ? (mb.getDestinatario() != null ? mb.getDestinatario().getTipoSoggetto() : "") : "");
  1260.     //          dati.add(de);
  1261.                 //}
  1262.    
  1263.                 de = new DataElement();
  1264.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO_DESTINATARIO);
  1265.                 de.setType(DataElementType.SELECT);
  1266.                 de.setSize(monitorHelper.getSize());
  1267.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO_DESTINATARIO);
  1268.                 de.setSelected(mb != null ? (mb.getDestinatario() != null ? mb.getDestinatario().getTipo() : "") : "");
  1269.                 de.setValues(tipiSoggetti);
  1270.                 de.setLabels(tipiSoggetti_label);
  1271.                 dati.add(de);
  1272.                
  1273.                 de = new DataElement();
  1274.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_NOME_DESTINATARIO );
  1275.                 de.setType(DataElementType.TEXT_EDIT);
  1276.                 de.setSize(monitorHelper.getSize());
  1277.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_NOME_DESTINATARIO);
  1278.                 de.setValue(mb != null ? (mb.getDestinatario() != null ? mb.getDestinatario().getNome() : "") : "");
  1279.                 dati.add(de);
  1280.    
  1281.                 // Servizio
  1282.                 de = new DataElement();
  1283.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_SERVIZIO);
  1284.                 de.setType(DataElementType.TITLE);
  1285.                 dati.add(de);
  1286.                
  1287.                 // Servizio
  1288.     //          if (InterfaceType.STANDARD.equals(user.getInterfaceType())) {
  1289.     //              de = new DataElement();
  1290.     //              de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO_SERVIZIO );
  1291.     //              de.setType(DataElementType.HIDDEN);
  1292.     //              de.setSize(monitorHelper.getSize());
  1293.     //              de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO_SERVIZIO);
  1294.     //              de.setValue("");
  1295.     //              dati.add(de);
  1296.     //          } else {
  1297.     //          de = new DataElement();
  1298.     //          de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO_SERVIZIO);
  1299.     //          de.setType(DataElementType.TEXT_EDIT);
  1300.     //          de.setSize(monitorHelper.getSize());
  1301.     //          de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO_SERVIZIO);
  1302.     //          de.setValue(mb != null ? (mb.getServizio() != null ? mb.getServizio().getTipo() : "") : "");
  1303.     //          dati.add(de);
  1304.                
  1305.                 AccordiServizioParteSpecificaCore aspsCore = new AccordiServizioParteSpecificaCore(monitorCore);
  1306.                 List<String> tipiServizi = new ArrayList<>();
  1307.                 List<String> tipiServizi_label = new ArrayList<>();
  1308.                 tipiServizi.add("");
  1309.                 tipiServizi_label.add("-");
  1310.                 List<String> list = monitorCore.getProtocolli(request, session);
  1311.                 for (String protocolloL : list) {
  1312.                     tipiServizi.addAll(aspsCore.getTipiServiziGestitiProtocollo(protocolloL,ServiceBinding.SOAP));
  1313.                     tipiServizi_label.addAll(aspsCore.getTipiServiziGestitiProtocollo(protocolloL,ServiceBinding.SOAP));
  1314.                     List<String> l = aspsCore.getTipiServiziGestitiProtocollo(protocolloL,ServiceBinding.REST);
  1315.                     if(l!=null && !l.isEmpty()) {
  1316.                         for (String tipo : list) {
  1317.                             if(!tipiServizi.contains(tipo)) {
  1318.                                 tipiServizi.add(tipo);
  1319.                                 tipiServizi_label.add(tipo);
  1320.                             }
  1321.                         }
  1322.                     }  
  1323.                 }
  1324.                
  1325.                 de = new DataElement();
  1326.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO_SERVIZIO);
  1327.                 de.setType(DataElementType.SELECT);
  1328.                 de.setSize(monitorHelper.getSize());
  1329.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO_SERVIZIO);
  1330.                 de.setSelected(mb != null ? (mb.getServizio() != null ? mb.getServizio().getTipo() : "") : "");
  1331.                 de.setValues(tipiServizi);
  1332.                 de.setLabels(tipiServizi_label);
  1333.                 dati.add(de);
  1334.                 //}
  1335.    
  1336.                 de = new DataElement();
  1337.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_NOME_SERVIZIO);
  1338.                 de.setType(DataElementType.TEXT_EDIT);
  1339.                 de.setSize(monitorHelper.getSize());
  1340.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_NOME_SERVIZIO);
  1341.                 de.setValue(mb != null ? (mb.getServizio() != null ? mb.getServizio().getNome() : "") : "");
  1342.                 dati.add(de);
  1343.    
  1344.                 String versione = null;
  1345.                 if(mb!=null && mb.getServizio()!=null && mb.getServizio().getVersione()!=null) {
  1346.                     versione = mb.getServizio().getVersione().intValue()+"";
  1347.                 }
  1348.                 //String versioneSelezionata = ((versione==null || "".equals(versione)) ? "1" : versione);
  1349.                 de = monitorHelper.getVersionDataElement(MonitorCostanti.LABEL_PARAMETRO_MONITOR_VERSIONE_SERVIZIO,
  1350.                         MonitorCostanti.PARAMETRO_MONITOR_VERSIONE_SERVIZIO,
  1351.                         versione, false);
  1352.                 dati.add(de);
  1353.    
  1354.                
  1355.                 // Azione
  1356.                
  1357.                 de = new DataElement();
  1358.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_AZIONE);
  1359.                 de.setType(DataElementType.TITLE);
  1360.                 dati.add(de);
  1361.                
  1362.                 de = new DataElement();
  1363.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_AZIONE);
  1364.                 de.setType(DataElementType.TEXT_EDIT);
  1365.                 de.setSize(monitorHelper.getSize());
  1366.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_AZIONE);
  1367.                 de.setValue(mb != null ? mb.getAzione() : azione);
  1368.                 dati.add(de);
  1369.                
  1370.             }

  1371.             pd.setDati(dati);
  1372.            
  1373.             pd.setLabelBottoneInvia(MonitorCostanti.LABEL_ACCEDI);
  1374.            
  1375.         } catch (Exception e) {
  1376.             throw new Exception(e);
  1377.         }
  1378.     }

  1379.     private void showStatoPdD(PageData pd, MonitorHelper monitorHelper,   StatoPdd statoPdD, String methodName, MonitorFormBean monitorFormBean)
  1380.             throws Exception{
  1381.         try {
  1382.             // index e pagesize non sono utilizzate
  1383.             // ma bisogna settarla comunque
  1384.             pd.setIndex(0);
  1385.             pd.setPageSize(20);

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

  1388.             lstParam.add(new Parameter(MonitorCostanti.LABEL_MONITOR, MonitorCostanti.SERVLET_NAME_MONITOR,
  1389.                     this.createSearchString(monitorFormBean).toArray(new Parameter[lstParam.size()])));
  1390.             lstParam.add(new Parameter(methodName, null));

  1391.             ServletUtils.setPageDataTitle(pd, lstParam);

  1392.             monitorHelper.makeMenu();

  1393.             // totale
  1394.             DataElement de = new DataElement();
  1395.             List<DataElement> dati = new ArrayList<>();

  1396.             // Se statoNal e' null allora nessuna informazione presente
  1397.             if (statoPdD == null) {
  1398.                 de = new DataElement();
  1399.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_NESSUNA_INFORMAZIONE_PRESENTE);
  1400.                 de.setType(DataElementType.TEXT);
  1401.                 de.setSize(monitorHelper.getSize());
  1402.                 dati.add(de);
  1403.             } else {

  1404.                 // Stampo informazioni relative al numero di messaggi

  1405.                 de = new DataElement();
  1406.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_STATO_PORTA_DOMINIO);
  1407.                 de.setType(DataElementType.TITLE);
  1408.                 de.setSize(monitorHelper.getSize());
  1409.                 dati.add(de);

  1410.                 /* Totali */
  1411.                 de = new DataElement();
  1412.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_TOTALE_MESSAGGI);
  1413.                 de.setType(DataElementType.TEXT);
  1414.                 long totMsg = statoPdD.getTotMessaggi();
  1415.                 de.setValue(totMsg > 0 ? "" + totMsg : MonitorCostanti.LABEL_MONITOR_NESSUN_MESSAGGIO);
  1416.                 de.setSize(monitorHelper.getSize());
  1417.                 dati.add(de);

  1418.                 if (totMsg > 0) {
  1419.                     // Max
  1420.                     de = new DataElement();
  1421.                     de.setLabel(MonitorCostanti.LABEL_MONITOR_TEMPO_MASSIMO_ATTESA);
  1422.                     de.setType(DataElementType.TEXT);
  1423.                     de.setValue(Utilities.convertSystemTimeIntoStringMillisecondi(statoPdD.getTempoMaxAttesa() * 1000, false));
  1424.                     de.setSize(monitorHelper.getSize());
  1425.                     dati.add(de);
  1426.                     // Medio
  1427.                     de = new DataElement();
  1428.                     de.setLabel(MonitorCostanti.LABEL_MONITOR_TEMPO_MEDIO_ATTESA);
  1429.                     de.setType(DataElementType.TEXT);
  1430.                     de.setValue(Utilities.convertSystemTimeIntoStringMillisecondi(statoPdD.getTempoMedioAttesa() * 1000, false));
  1431.                     de.setSize(monitorHelper.getSize());
  1432.                     dati.add(de);

  1433.                 }

  1434.                 /* Consegna */
  1435.                 de = new DataElement();
  1436.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_MESSAGGI_CONSEGNA);
  1437.                 de.setType(DataElementType.TITLE);
  1438.                 de.setSize(monitorHelper.getSize());
  1439.                 dati.add(de);

  1440.                 de = new DataElement();
  1441.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_TOTALE_MESSAGGI);
  1442.                 de.setType(DataElementType.TEXT);
  1443.                 long inConsegna = statoPdD.getNumMsgInConsegna();
  1444.                 de.setValue(inConsegna > 0 ? "" + inConsegna : MonitorCostanti.LABEL_MONITOR_NESSUN_MESSAGGIO_CONSEGNA);
  1445.                 de.setSize(monitorHelper.getSize());
  1446.                 dati.add(de);
  1447.                 if (inConsegna > 0) {
  1448.                     // Max
  1449.                     de = new DataElement();
  1450.                     de.setLabel(MonitorCostanti.LABEL_MONITOR_TEMPO_MASSIMO_ATTESA);
  1451.                     de.setType(DataElementType.TEXT);
  1452.                     de.setValue(Utilities.convertSystemTimeIntoStringMillisecondi(statoPdD.getTempoMaxAttesaInConsegna() * 1000, false));
  1453.                     de.setSize(monitorHelper.getSize());
  1454.                     dati.add(de);
  1455.                     // Medio
  1456.                     de = new DataElement();
  1457.                     de.setLabel(MonitorCostanti.LABEL_MONITOR_TEMPO_MEDIO_ATTESA);
  1458.                     de.setType(DataElementType.TEXT);
  1459.                     de.setValue(Utilities.convertSystemTimeIntoStringMillisecondi(statoPdD.getTempoMedioAttesaInConsegna() * 1000, false));
  1460.                     de.setSize(monitorHelper.getSize());
  1461.                     dati.add(de);
  1462.                 }

  1463.                 /* Spedizione */
  1464.                 de = new DataElement();
  1465.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_MESSAGGI_SPEDIZIONE);
  1466.                 de.setType(DataElementType.TITLE);
  1467.                 de.setSize(monitorHelper.getSize());
  1468.                 dati.add(de);

  1469.                 de = new DataElement();
  1470.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_TOTALE_MESSAGGI);
  1471.                 de.setType(DataElementType.TEXT);
  1472.                 long inSpedizione = statoPdD.getNumMsgInSpedizione();
  1473.                 de.setValue(inSpedizione > 0 ? "" + inSpedizione : MonitorCostanti.LABEL_MONITOR_NESSUN_MESSAGGIO_SPEDIZIONE);
  1474.                 de.setSize(monitorHelper.getSize());
  1475.                 dati.add(de);
  1476.                 if (inSpedizione > 0) {
  1477.                     // Max
  1478.                     de = new DataElement();
  1479.                     de.setLabel(MonitorCostanti.LABEL_MONITOR_TEMPO_MASSIMO_ATTESA);
  1480.                     de.setType(DataElementType.TEXT);
  1481.                     de.setValue(Utilities.convertSystemTimeIntoStringMillisecondi(statoPdD.getTempoMaxAttesaInSpedizione() * 1000, false));
  1482.                     de.setSize(monitorHelper.getSize());
  1483.                     dati.add(de);
  1484.                     // Medio
  1485.                     de = new DataElement();
  1486.                     de.setLabel(MonitorCostanti.LABEL_MONITOR_TEMPO_MEDIO_ATTESA);
  1487.                     de.setType(DataElementType.TEXT);
  1488.                     de.setValue(Utilities.convertSystemTimeIntoStringMillisecondi(statoPdD.getTempoMedioAttesaInSpedizione() * 1000, false));
  1489.                     de.setSize(monitorHelper.getSize());
  1490.                     dati.add(de);
  1491.                 }

  1492.                 /* Processamento */
  1493.                 de = new DataElement();
  1494.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_MESSAGGI_PROCESSAMENTO);
  1495.                 de.setType(DataElementType.TITLE);
  1496.                 de.setSize(monitorHelper.getSize());
  1497.                 dati.add(de);

  1498.                 de = new DataElement();
  1499.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_TOTALE_MESSAGGI_PROCESSAMENTO);
  1500.                 de.setType(DataElementType.TEXT);
  1501.                 long inProcess = statoPdD.getNumMsgInProcessamento();
  1502.                 de.setValue(inProcess > 0 ? "" + inProcess : MonitorCostanti.LABEL_MONITOR_NESSUN_MESSAGGIO_PROCESSAMENTO);
  1503.                 de.setSize(monitorHelper.getSize());
  1504.                 dati.add(de);
  1505.                 if (inProcess > 0) {
  1506.                     // Max
  1507.                     de = new DataElement();
  1508.                     de.setLabel(MonitorCostanti.LABEL_MONITOR_TEMPO_MASSIMO_ATTESA);
  1509.                     de.setType(DataElementType.TEXT);
  1510.                     de.setValue(Utilities.convertSystemTimeIntoStringMillisecondi(statoPdD.getTempoMaxAttesaInProcessamento() * 1000, false));
  1511.                     de.setSize(monitorHelper.getSize());
  1512.                     dati.add(de);
  1513.                     // Medio
  1514.                     de = new DataElement();
  1515.                     de.setLabel(MonitorCostanti.LABEL_MONITOR_TEMPO_MEDIO_ATTESA);
  1516.                     de.setType(DataElementType.TEXT);
  1517.                     de.setValue(Utilities.convertSystemTimeIntoStringMillisecondi(statoPdD.getTempoMedioAttesaInProcessamento() * 1000, false));
  1518.                     de.setSize(monitorHelper.getSize());
  1519.                     dati.add(de);
  1520.                 }

  1521.                 /* Messaggi Duplicati */
  1522.                 de = new DataElement();
  1523.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_MESSAGGI_DUPLICATI);
  1524.                 de.setType(DataElementType.TITLE);
  1525.                 de.setSize(monitorHelper.getSize());
  1526.                 dati.add(de);
  1527.                 de = new DataElement();
  1528.                 de.setLabel(MonitorCostanti.LABEL_MONITOR_TOTALE_MESSAGGI);
  1529.                 de.setType(DataElementType.TEXT);
  1530.                 long duplicati = statoPdD.getTotMessaggiDuplicati();
  1531.                 de.setValue(duplicati > 0 ? "" + duplicati : MonitorCostanti.LABEL_MONITOR_NESSUN_MESSAGGIO_DUPLICATO);
  1532.                 de.setSize(monitorHelper.getSize());
  1533.                 dati.add(de);

  1534.             }
  1535.             pd.setInserisciBottoni(false);
  1536.             pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);
  1537.             pd.setDati(dati);
  1538.         } catch (Exception e) {
  1539.             throw new Exception(e);
  1540.         }
  1541.     }

  1542.     private void showDettagliMessaggio(PageData pd, MonitorHelper monitorHelper, Messaggio messaggio, MonitorFormBean monitorFormBean)
  1543.             throws Exception {
  1544.         try {

  1545.             PorteApplicativeCore paCore = new PorteApplicativeCore(monitorCore);
  1546.             ServiziApplicativiCore saCore = new ServiziApplicativiCore(monitorCore);
  1547.             SoggettiCore soggettiCore = new SoggettiCore(monitorCore);
  1548.                
  1549.             SimpleDateFormat formatterRispedizione = DateUtils.getDefaultDateTimeFormatter("yyyy-MM-dd HH:mm:ss.SSS");
  1550.            
  1551.             List<Parameter> newSearchFalse = this.createSearchString(monitorFormBean);
  1552.             newSearchFalse.add(new Parameter(MonitorCostanti.PARAMETRO_MONITOR_NEW_SEARCH, MonitorCostanti.DEFAULT_VALUE_FALSE));

  1553.             // setto la barra del titolo
  1554.             List<Parameter> lstParam = new ArrayList<>();
  1555.             lstParam.add(new Parameter(MonitorCostanti.LABEL_MONITOR, MonitorCostanti.SERVLET_NAME_MONITOR,
  1556.                     this.createSearchString(monitorFormBean).toArray(new Parameter[lstParam.size()])));
  1557.             lstParam.add(new Parameter(MonitorMethods.LISTA_RICHIESTE_PENDENTI.getNome(), MonitorCostanti.SERVLET_NAME_MONITOR,
  1558.                     newSearchFalse.toArray(new Parameter[lstParam.size()])));
  1559.             lstParam.add(new Parameter(MonitorCostanti.LABEL_MONITOR_DETTAGLIO_MESSAGGIO, null));

  1560.             ServletUtils.setPageDataTitle(pd, lstParam);

  1561.             monitorHelper.makeMenu();
  1562.            
  1563.             List<DataElement> dati = new ArrayList<>();
  1564.            
  1565.             DataElement de = new DataElement();
  1566.             de.setLabel(MonitorCostanti.LABEL_MONITOR_INFORMAZIONI_PROTOCOLLO);
  1567.             de.setType(DataElementType.TITLE);
  1568.             dati.add(de);
  1569.            
  1570.             de = new DataElement();
  1571.             de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_ID_MESSAGGIO);
  1572.             de.setValue(messaggio.getIdMessaggio());
  1573.             de.setName(MonitorCostanti.PARAMETRO_MONITOR_ID_MESSAGGIO);
  1574.             dati.add(de);

  1575.             /* BUSTA */
  1576.             Busta busta = messaggio.getBustaInfo();
  1577.             BustaSoggetto mittente = (busta != null ? busta.getMittente() : null);
  1578.             BustaSoggetto destinatario = (busta != null ? busta.getDestinatario() : null);
  1579.             BustaServizio servizio = (busta != null ? busta.getServizio() : null);
  1580.             String azione = (busta != null ? busta.getAzione() : null);
  1581.             String profilo = (busta != null ? busta.getProfiloCollaborazione() : null);
  1582.             String riferimento = (busta != null ? busta.getRiferimentoMessaggio() : null);
  1583.             boolean riscontro = (busta != null ? busta.isAttesaRiscontro() : false);

  1584.             if (mittente != null && mittente.getTipo()!=null && mittente.getNome()!=null) {
  1585.                 /* Mittente */
  1586.                 de = new DataElement();
  1587.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_MITTENTE);
  1588.                 de.setType(DataElementType.TEXT);
  1589.                 de.setValue(mittente.getTipo() + "/" + mittente.getNome());
  1590.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_MITTENTE);
  1591.                 dati.add(de);
  1592.             }

  1593.             if (destinatario != null) {
  1594.                 /* Destinatario */
  1595.                 de = new DataElement();
  1596.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_DESTINATARIO);
  1597.                 de.setType(DataElementType.TEXT);
  1598.                 de.setValue(destinatario.getTipo() + "/" + destinatario.getNome());
  1599.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_DESTINATARIO);
  1600.                 dati.add(de);
  1601.             }

  1602.             if (servizio != null) {
  1603.                 /* Servizio */
  1604.                 de = new DataElement();
  1605.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_SERVIZIO);
  1606.                 de.setType(DataElementType.TEXT);
  1607.                 de.setValue(servizio.getTipo() + "/" + servizio.getNome()+
  1608.                         (servizio.getVersione()!=null ? (" v"+servizio.getVersione().intValue()) : "")
  1609.                         );
  1610.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_SERVIZIO);
  1611.                 dati.add(de);
  1612.             }
  1613.             if (azione != null) {
  1614.                 /* Azione */
  1615.                 de = new DataElement();
  1616.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_AZIONE);
  1617.                 de.setType(DataElementType.TEXT);
  1618.                 de.setValue(busta.getAzione());
  1619.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_AZIONE);
  1620.                 dati.add(de);
  1621.             }
  1622.             if (riferimento != null) {
  1623.                 /* Riferimento */
  1624.                 de = new DataElement();
  1625.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_RIFERIMENTO);
  1626.                 de.setType(DataElementType.TEXT);
  1627.                 de.setValue(riferimento);
  1628.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_RIFERIMENTO);
  1629.                 dati.add(de);
  1630.             }
  1631.             if (profilo != null) {
  1632.                 /* Profilo Collaborazione */
  1633.                 de = new DataElement();
  1634.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_PROFILO);
  1635.                 de.setType(DataElementType.TEXT);
  1636.                 de.setValue(profilo);
  1637.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_PROFILO);
  1638.                 dati.add(de);
  1639.             }

  1640.             /* Riscontro */
  1641.             de = new DataElement();
  1642.             de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_RISCONTRO);
  1643.             de.setType(DataElementType.TEXT);
  1644.             de.setValue("" + riscontro);
  1645.             de.setName(MonitorCostanti.PARAMETRO_MONITOR_RISCONTRO);
  1646.             dati.add(de);

  1647.             /* Dettaglio */
  1648.             de = new DataElement();
  1649.             de.setLabel(MonitorCostanti.LABEL_MONITOR_DETTAGLIO);
  1650.             de.setType(DataElementType.TITLE);
  1651.             dati.add(de);

  1652.             Dettaglio dettaglio = messaggio.getDettaglio();
  1653.             // tipo
  1654.             de = new DataElement();
  1655.             de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO);
  1656.             de.setType(DataElementType.TEXT);
  1657.             de.setValue(dettaglio.getTipo());
  1658.             de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO);
  1659.             dati.add(de);

  1660.             // idmodulo
  1661.             de = new DataElement();
  1662.             de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_MODULO );
  1663.             de.setType(DataElementType.TEXT);
  1664.             de.setValue(dettaglio.getIdModulo());
  1665.             de.setName(MonitorCostanti.PARAMETRO_MONITOR_MODULO);
  1666.             dati.add(de);
  1667.             // stato
  1668.             de = new DataElement();
  1669.             de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_STATO);
  1670.             de.setType(DataElementType.TEXT);
  1671.             if(messaggio.getStato()!=null)
  1672.                 de.setValue(messaggio.getStato().getValue());  
  1673.             de.setName(MonitorCostanti.PARAMETRO_MONITOR_STATO);
  1674.             dati.add(de);
  1675.             if(dettaglio.getProprietaList()!=null && dettaglio.getProprietaList().size()>0){
  1676.                 for (int i = 0; i < dettaglio.getProprietaList().size(); i++) {
  1677.                     de = new DataElement();
  1678.                     de.setLabel(dettaglio.getProprietaList().get(i).getNome());
  1679.                     de.setType(DataElementType.TEXT);
  1680.                     de.setValue(dettaglio.getProprietaList().get(i).getValore());
  1681.                     de.setName(dettaglio.getProprietaList().get(i).getNome());
  1682.                     dati.add(de);
  1683.                 }
  1684.             }
  1685.             if(dettaglio.getIdCorrelazioneApplicativa()!=null){
  1686.                 // CorrelazioneApplicativa
  1687.                 de = new DataElement();
  1688.                 de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_CORRELAZIONE_APPLICATIVA);
  1689.                 de.setType(DataElementType.TEXT);
  1690.                 de.setValue(dettaglio.getIdCorrelazioneApplicativa());
  1691.                 de.setName(MonitorCostanti.PARAMETRO_MONITOR_CORRELAZIONE_APPLICATIVA);
  1692.                 dati.add(de);
  1693.             }

  1694.             SimpleDateFormat formatter = DateUtils.getDefaultDateTimeFormatter("yyyy-MM-dd HH:mm:ss.SSS");
  1695.             // ora registrazione
  1696.             de = new DataElement();
  1697.             de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_ORA_REGISTRAZIONE);
  1698.             de.setType(DataElementType.TEXT);
  1699.             de.setValue(formatter.format(messaggio.getOraRegistrazione().getTime()));
  1700.             de.setName(MonitorCostanti.PARAMETRO_MONITOR_ORA_REGISTRAZIONE);
  1701.             dati.add(de);

  1702.             // ora attuale
  1703.             de = new DataElement();
  1704.             de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_ORA_ATTUALE);
  1705.             de.setType(DataElementType.TEXT);
  1706.             de.setValue(formatter.format(messaggio.getOraAttuale().getTime()));
  1707.             de.setName(MonitorCostanti.PARAMETRO_MONITOR_ORA_ATTUALE);
  1708.             dati.add(de);

  1709.             String erroreProcessamento = dettaglio.getErroreProcessamento();
  1710.             // servizi applicativi consegna
  1711.             if (messaggio.getDettaglio().getServizioApplicativoConsegnaList().size()>0) {
  1712.                 // visualizzo i dettagli consegna
  1713.                 for (int i = 0; i < messaggio.getDettaglio().getServizioApplicativoConsegnaList().size(); i++) {
  1714.                     ServizioApplicativoConsegna sac1 = messaggio.getDettaglio().getServizioApplicativoConsegnaList().get(i);
  1715.                     erroreProcessamento = sac1.getErroreProcessamento();

  1716.                     String labelSA = null;
  1717.                     String nomeConnettore = null;
  1718.                     String labelErogazione = null;
  1719.                     if(sac1.getNomePorta()!=null) {
  1720.                         if(sac1.getNome()!=null) {
  1721.                             IDPortaApplicativa idPA = new IDPortaApplicativa();
  1722.                             idPA.setNome(sac1.getNomePorta());
  1723.                             if(paCore.existsPortaApplicativa(idPA)) {
  1724.                                 PortaApplicativa pa = null;
  1725.                                 try {
  1726.                                     pa = paCore.getPortaApplicativa(idPA);
  1727.                                 }catch(DriverConfigurazioneNotFound notF) {
  1728.                                     // ignore
  1729.                                 }
  1730.                                 if(pa!=null) {
  1731.                                     if(pa.getBehaviour()!=null) {
  1732.                                         if(pa.sizeServizioApplicativoList()>0) {
  1733.                                             for (int j = 0; j < pa.sizeServizioApplicativoList(); j++) {
  1734.                                                 PortaApplicativaServizioApplicativo pasa = pa.getServizioApplicativo(j);
  1735.                                                 if(pasa.getNome().equals(sac1.getNome())) {
  1736.                                                     if(pasa.getDatiConnettore()!=null) {
  1737.                                                         labelSA = pasa.getDatiConnettore().getNome();
  1738.                                                     }
  1739.                                                     else {
  1740.                                                         labelSA = CostantiConfigurazione.NOME_CONNETTORE_DEFAULT;
  1741.                                                     }
  1742.                                                     nomeConnettore = labelSA;
  1743.                                                     break;
  1744.                                                 }
  1745.                                             }
  1746.                                         }
  1747.                                     }
  1748.                                     else {
  1749.                                         IDServizioApplicativo idSA = new IDServizioApplicativo();
  1750.                                         idSA.setNome(sac1.getNome());
  1751.                                         idSA.setIdSoggettoProprietario(new IDSoggetto(pa.getTipoSoggettoProprietario(), pa.getNomeSoggettoProprietario()));
  1752.                                         ServizioApplicativo sa = null;
  1753.                                         try {
  1754.                                             sa = saCore.getServizioApplicativo(idSA);
  1755.                                         } catch (Exception notFound) {
  1756.                                             // ignore
  1757.                                         }
  1758.                                         if(sa!=null) {
  1759.                                             if(ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER.equals(sa.getTipo())) {
  1760.                                                 labelSA = sac1.getNome();
  1761.                                             }
  1762.                                         }
  1763.                                     }
  1764.                                    
  1765.                                     if(labelErogazione==null) {
  1766.                                         IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(pa.getServizio().getTipo(), pa.getServizio().getNome(),
  1767.                                                 pa.getTipoSoggettoProprietario(), pa.getNomeSoggettoProprietario(),
  1768.                                                 pa.getServizio().getVersione());
  1769.                                         String protocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(pa.getTipoSoggettoProprietario());
  1770.                                         labelErogazione = monitorHelper.getLabelServizioErogazione(protocollo, idServizio);
  1771.                                     }
  1772.                                 }
  1773.                             }
  1774.                         }
  1775.                     }
  1776.                    
  1777.                     de = new DataElement();
  1778.                     if(labelSA!=null) {
  1779.                         de.setLabel(MonitorCostanti.LABEL_MONITOR_DETTAGLI_CONSEGNA+" [" + labelSA + "]");
  1780.                     }
  1781.                     else {
  1782.                         de.setLabel(MonitorCostanti.LABEL_MONITOR_DETTAGLI_CONSEGNA);
  1783.                     }
  1784.                     de.setType(DataElementType.TITLE);
  1785.                     dati.add(de);

  1786.                     // erogazione
  1787.                     if(labelErogazione!=null || sac1.getNomePorta()!=null) {
  1788.                         de = new DataElement();
  1789.                         de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_NOME_CONSEGNA_PORTA);
  1790.                         de.setType(DataElementType.TEXT);
  1791.                         if(labelErogazione!=null) {
  1792.                             de.setValue(labelErogazione);
  1793.                         }
  1794.                         else {
  1795.                             de.setValue(sac1.getNomePorta());
  1796.                         }
  1797.                         de.setName(MonitorCostanti.PARAMETRO_MONITOR_NOME_CONSEGNA_PORTA);
  1798.                         dati.add(de);
  1799.                     }
  1800.                     if(nomeConnettore!=null) {
  1801.                         de = new DataElement();
  1802.                         de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_NOME_CONSEGNA_CONNETTORE);
  1803.                         de.setType(DataElementType.TEXT);
  1804.                         de.setValue(nomeConnettore);
  1805.                         de.setName(MonitorCostanti.PARAMETRO_MONITOR_NOME_CONSEGNA_CONNETTORE);
  1806.                         dati.add(de);
  1807.                     }
  1808.                                        
  1809.                     // nome
  1810.                     de = new DataElement();
  1811.                     de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_NOME_CONSEGNA_APPLICATIVO_INTERNO);
  1812.                     de.setType(DataElementType.TEXT);
  1813.                     de.setValue(sac1.getNome());
  1814.                     de.setName(MonitorCostanti.PARAMETRO_MONITOR_NOME_CONSEGNA_APPLICATIVO_INTERNO);
  1815.                     dati.add(de);
  1816.                    
  1817.                     // tipo consegna
  1818.                     de = new DataElement();
  1819.                     de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_TIPO_CONSEGNA);
  1820.                     de.setType(DataElementType.TEXT);
  1821.                     de.setValue(sac1.getTipoConsegna());
  1822.                     de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO_CONSEGNA);
  1823.                     dati.add(de);
  1824.                    
  1825.                     // errore processamento
  1826.                     if (erroreProcessamento != null) {
  1827.                         de = new DataElement();
  1828.                         de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_ERRORE);
  1829.                         de.setValue(erroreProcessamento);
  1830.                         de.setName(MonitorCostanti.PARAMETRO_MONITOR_ERRORE);
  1831.                         if(erroreProcessamento!=null && !"".equals(erroreProcessamento)){
  1832.                             de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  1833.                             de.setRows(6);
  1834.                             de.setCols(80);
  1835.                         }else{
  1836.                             de.setType(DataElementType.TEXT);
  1837.                         }
  1838.                         dati.add(de);
  1839.                     }

  1840.                     // data rispedizione
  1841.                     if(GestoreMessaggi.CONSEGNA_TRAMITE_CONNETTORE.equals(sac1.getTipoConsegna())){
  1842.                         if(sac1.getDataRispedizione()!=null) {
  1843.                             de = new DataElement();
  1844.                             de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_CONSEGNA_DA);
  1845.                             de.setType(DataElementType.TEXT);
  1846.                             de.setValue(formatterRispedizione.format(sac1.getDataRispedizione()));
  1847.                             de.setName(MonitorCostanti.PARAMETRO_MONITOR_IN_CONSEGNA_DA);
  1848.                             dati.add(de);
  1849.                         }
  1850.                        
  1851.                         // Priorita
  1852.                         de = new DataElement();
  1853.                         de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_PRIORITA);
  1854.                         de.setType(DataElementType.TEXT);
  1855.                         de.setValue(sac1.getPriorita());
  1856.                         de.setName(MonitorCostanti.PARAMETRO_MONITOR_PRIORITA);
  1857.                         dati.add(de);
  1858.                        
  1859.                         // Coda
  1860.                         de = new DataElement();
  1861.                         de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_CODA);
  1862.                         de.setType(DataElementType.TEXT);
  1863.                         de.setValue(sac1.getCoda());
  1864.                         de.setName(MonitorCostanti.PARAMETRO_MONITOR_CODA);
  1865.                         dati.add(de);
  1866.                        
  1867.                         // In attesa esito sincrono
  1868.                         if(sac1.isAttesaEsito()) { // lo visualizzo solo se true
  1869.                             de = new DataElement();
  1870.                             de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_ATTESA_ESITO);
  1871.                             de.setType(DataElementType.TEXT);
  1872.                             de.setValue(sac1.isAttesaEsito()+"");
  1873.                             de.setName(MonitorCostanti.PARAMETRO_MONITOR_ATTESA_ESITO);
  1874.                             dati.add(de);
  1875.                         }
  1876.                     }
  1877.                    
  1878.                     // integration manager
  1879.                     de = new DataElement();
  1880.                     de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_AUTORIZZAZIONE);
  1881.                     de.setType(DataElementType.TEXT);
  1882.                     de.setValue("" + sac1.isAutorizzazioneIntegrationManager());
  1883.                     de.setName(MonitorCostanti.PARAMETRO_MONITOR_AUTORIZZAZIONE);
  1884.                     dati.add(de);
  1885.                    
  1886.                     // sbustamento soap
  1887.                     de = new DataElement();
  1888.                     de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_SBUSTAMENTO);
  1889.                     de.setType(DataElementType.TEXT);
  1890.                     de.setValue("" + sac1.isSbustamentoSoap());
  1891.                     de.setName(MonitorCostanti.PARAMETRO_MONITOR_SBUSTAMENTO);
  1892.                     dati.add(de);
  1893.                    
  1894.                     // sbustamento informazioni protocollo
  1895.                     de = new DataElement();
  1896.                     de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_SBUSTAMENTO_INFORMAZIONI_PROTOCOLLO);
  1897.                     de.setType(DataElementType.TEXT);
  1898.                     de.setValue("" + sac1.isSbustamentoInformazioniProtocollo());
  1899.                     de.setName(MonitorCostanti.PARAMETRO_MONITOR_SBUSTAMENTO_INFORMAZIONI_PROTOCOLLO);
  1900.                     dati.add(de);
  1901.                    
  1902.                 }

  1903.             } else {
  1904.                 // Errore processamento
  1905.                 if(erroreProcessamento!=null && !"".equals(erroreProcessamento)){
  1906.                     de = new DataElement();
  1907.                     de.setLabel(MonitorCostanti.LABEL_PARAMETRO_MONITOR_ERRORE );
  1908.                     de.setValue(erroreProcessamento);
  1909.                     de.setName(MonitorCostanti.PARAMETRO_MONITOR_ERRORE);          
  1910.                     de.setType(DataElementType.TEXT_AREA_NO_EDIT);
  1911.                     de.setRows(6);
  1912.                     de.setCols(80);
  1913.                     dati.add(de);
  1914.                 }
  1915.             }

  1916.             pd.setDati(dati);

  1917.             pd.setMode(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME);
  1918.         } catch (Exception e) {
  1919.             throw new Exception(e);
  1920.         }
  1921.     }

  1922.     private void showStatoConsegneAsincrone(PageData pd, MonitorHelper monitorHelper, StatoConsegneAsincrone statoConsegneAsincrone,
  1923.             String methodName, MonitorFormBean monitorFormBean)
  1924.             throws Exception {
  1925.         try {
  1926.            
  1927.             pd.setPaginazione(false);
  1928.             pd.setSearch("off");

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

  1931.             lstParam.add(new Parameter(MonitorCostanti.LABEL_MONITOR, MonitorCostanti.SERVLET_NAME_MONITOR,
  1932.                     this.createSearchString(monitorFormBean).toArray(new Parameter[lstParam.size()])));
  1933.             lstParam.add(new Parameter(methodName, null));

  1934.             ServletUtils.setPageDataTitle(pd, lstParam);

  1935.             monitorHelper.makeMenu();

  1936.            
  1937.             List<String> labels = new ArrayList<>();
  1938. //          labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_NOW);
  1939.             labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_SERVIZIO_APPLICATIVO);
  1940.             labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_CODA);
  1941.             labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_RICONSEGNA);
  1942.             labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_MESSAGE_BOX);
  1943. //          labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_CODA_VECCHIO);
  1944. //          labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_CODA_RECENTE);
  1945. //          labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_RICONSEGNA_VECCHIO);
  1946. //          labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_RICONSEGNA_RECENTE);
  1947. //          labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_MESSAGE_BOX_VECCHIO);
  1948. //          labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_MESSAGE_BOX_RECENTE);
  1949.             pd.setLabels(labels.toArray(new String[1]));
  1950.            
  1951.             List<List<DataElement>> dati = new ArrayList<>();

  1952.             if (statoConsegneAsincrone != null && statoConsegneAsincrone.size()>0) {
  1953.                 // aggiungo i messaggi
  1954.                 DataElement de = null;
  1955.                 // Dichiaro il formatter per la data
  1956.                 SimpleDateFormat formatter = DateUtils.getDefaultDateTimeFormatter("yyyy-MM-dd HH:mm");
  1957.                
  1958.                 SoggettiCore soggettiCore = new SoggettiCore(monitorCore);
  1959.                
  1960.                 List<String> servizi = statoConsegneAsincrone.getServiziApplicativi();
  1961.                 for (String servizioApplicativo : servizi) {
  1962.                    
  1963.                     List<DataElement> e = new ArrayList<>();
  1964.                    
  1965.                     StatoConsegnaAsincrona stato = statoConsegneAsincrone.getStato(servizioApplicativo);
  1966.                    
  1967. //                  de = new DataElement();
  1968. //                  de.setValue(formatter.format(stato.getNow()));
  1969. //                  e.add(de);
  1970.                    
  1971.                     de = new DataElement();
  1972.                     IDServizio idServizio = monitorCore.getLabelNomeServizioApplicativo(stato.getServizioApplicativo());
  1973.                     if(idServizio==null) {
  1974.                         de.setValue(stato.getServizioApplicativo());
  1975.                     }
  1976.                     else {
  1977.                         String protocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(idServizio.getSoggettoErogatore().getTipo());
  1978.                         String nomeErogazione = monitorHelper.getLabelServizioErogazione(protocollo, idServizio);
  1979.                         if(idServizio.getAzione()!=null) {
  1980.                             de.setValue(idServizio.getAzione()+" di "+nomeErogazione);
  1981.                         }
  1982.                         else {
  1983.                             de.setValue(nomeErogazione);
  1984.                         }
  1985.                     }
  1986.                     de.setToolTip(MonitorCostanti.LABEL_PARAMETRO_MONITOR_NOW+": "+formatter.format(stato.getNow()));
  1987.                     e.add(de);
  1988.                    
  1989.                     de = new DataElement();
  1990.                     if(stato.getInCoda()>0) {
  1991.                         StringBuilder sb = new StringBuilder();
  1992.                         sb.append("<b>").append(stato.getInCoda()).append("</b> ");
  1993.                         if(stato.getVecchioInCoda()!=null) {
  1994.                             sb.append(" ("). //append("<BR/>").
  1995.                                 //append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_VECCHIO).
  1996.                                 append(formatter.format(stato.getVecchioInCoda()));
  1997.                         }
  1998.                         if(stato.getRecenteInCoda()!=null) {
  1999.                             if(stato.getVecchioInCoda()!=null) {
  2000.                                 sb.append(" -");
  2001.                             }
  2002.                             sb.append(" "). //.append("<BR/>").
  2003.                                 //append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_RECENTE).
  2004.                                 append(formatter.format(stato.getRecenteInCoda())).
  2005.                                 append(")");
  2006.                         }
  2007.                         de.setValue(sb.toString());
  2008.                     }
  2009.                     else {
  2010.                         de.setValue(stato.getInCoda()+"");
  2011.                     }
  2012.                     e.add(de);
  2013.                    
  2014.                     de = new DataElement();
  2015.                     if(stato.getInRiconsegna()>0) {
  2016.                         StringBuilder sb = new StringBuilder();
  2017.                         sb.append("<b>").append(stato.getInRiconsegna()).append("</b> ");
  2018.                         if(stato.getVecchioInRiconsegna()!=null) {
  2019.                             sb.append(" ("). //append("<BR/>").
  2020.                                 //append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_VECCHIO).
  2021.                                 append(formatter.format(stato.getVecchioInRiconsegna()));
  2022.                         }
  2023.                         if(stato.getRecenteInRiconsegna()!=null) {
  2024.                             if(stato.getVecchioInRiconsegna()!=null) {
  2025.                                 sb.append(" -");
  2026.                             }
  2027.                             sb.append(" "). //.append("<BR/>").
  2028.                                 //append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_RECENTE).
  2029.                                 append(formatter.format(stato.getRecenteInRiconsegna())).
  2030.                                 append(")");
  2031.                         }
  2032.                         de.setValue(sb.toString());
  2033.                     }
  2034.                     else {
  2035.                         de.setValue(stato.getInRiconsegna()+"");
  2036.                     }
  2037.                     e.add(de);
  2038.                    
  2039.                     de = new DataElement();
  2040.                     if(stato.getInMessageBox()>0) {
  2041.                         StringBuilder sb = new StringBuilder();
  2042.                         sb.append("<b>").append(stato.getInMessageBox()).append("</b> ");
  2043.                         if(stato.getVecchioInMessageBox()!=null) {
  2044.                             sb.append(" ("). //append("<BR/>").
  2045.                                 //append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_VECCHIO).
  2046.                                 append(formatter.format(stato.getVecchioInMessageBox()));
  2047.                         }
  2048.                         if(stato.getRecenteInMessageBox()!=null) {
  2049.                             if(stato.getVecchioInMessageBox()!=null) {
  2050.                                 sb.append(" -");
  2051.                             }
  2052.                             sb.append(" "). //.append("<BR/>").
  2053.                                 //append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_RECENTE).
  2054.                                 append(formatter.format(stato.getRecenteInMessageBox())).
  2055.                                 append(")");
  2056.                         }
  2057.                         de.setValue(sb.toString());
  2058.                     }
  2059.                     else {
  2060.                         de.setValue(stato.getInMessageBox()+"");
  2061.                     }
  2062.                     e.add(de);
  2063.                    
  2064.                    
  2065.                     dati.add(e);
  2066.                 }
  2067.             }

  2068.             pd.setSelect(false);
  2069.             pd.setRemoveButton(false);
  2070.             pd.setAddButton(false);
  2071.            
  2072.             pd.setDati(dati);
  2073.         } catch (Exception e) {
  2074.             throw new Exception(e);
  2075.         }
  2076.     }
  2077.    
  2078.     private void showMessaggi(PageData pd, MonitorHelper monitorHelper, long countMessaggi,  List<Messaggio> listaMessaggi,
  2079.             String methodName, ConsoleSearch ricerca, FilterSearch filterSearch, MonitorFormBean monitorFormBean)
  2080.             throws Exception {
  2081.         try {
  2082.             // index e pagesize non sono utilizzate
  2083.             // ma bisogna settarla comunque
  2084.             int idLista = Liste.MONITOR_MSG;
  2085.             int limit = ricerca.getPageSize(idLista);
  2086.             int offset = ricerca.getIndexIniziale(idLista);
  2087.             // String search =
  2088.             // (org.openspcoop2.core.constants.Costanti.SESSION_ATTRIBUTE_VALUE_RICERCA_UNDEFINED.equals(ricerca.getSearchString(idLista)) ? "" :
  2089.             // ricerca.getSearchString(idLista));

  2090.             pd.setIndex(offset);
  2091.             pd.setPageSize(limit);
  2092.             pd.setSearch("off");

  2093.             int totMsg = (int) countMessaggi;

  2094.             pd.setNumEntries(totMsg);

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

  2097.             lstParam.add(new Parameter(MonitorCostanti.LABEL_MONITOR, MonitorCostanti.SERVLET_NAME_MONITOR,
  2098.                     this.createSearchString(monitorFormBean).toArray(new Parameter[lstParam.size()])));
  2099.             lstParam.add(new Parameter(methodName, null));

  2100.             ServletUtils.setPageDataTitle(pd, lstParam);

  2101.             monitorHelper.makeMenu();

  2102.             // preparo string filtro ricerca
  2103.             Busta busta = filterSearch.getBusta();
  2104.             BustaServizio servizio = (busta != null ? busta.getServizio() : null);
  2105.             BustaSoggetto mittente = (busta != null ? busta.getMittente() : null);
  2106.             BustaSoggetto destinatario = (busta != null ? busta.getDestinatario() : null);
  2107.             String profilo = (busta != null ? busta.getProfiloCollaborazione() : null);
  2108.             String azione = (busta != null ? busta.getAzione() : null);
  2109.             String idMessaggio = filterSearch.getIdMessaggio();
  2110.             //String msgPattern = filterSearch.getMessagePattern();
  2111.             String correlazioneApplicativa = filterSearch.getCorrelazioneApplicativa();
  2112.             long soglia = filterSearch.getSoglia();
  2113.             boolean riscontro = (busta != null ? busta.isAttesaRiscontro() : false);

  2114.             String _mittente = null;
  2115.             if(mittente!=null) {
  2116.                 _mittente = this.getIntestazioneFiltroRicerca(mittente.getTipo(), mittente.getNome());
  2117.             }
  2118.             String _destinatario = null;
  2119.             if(destinatario!=null) {
  2120.                 _destinatario = this.getIntestazioneFiltroRicerca(destinatario.getTipo(), destinatario.getNome());
  2121.             }
  2122.             String _servizio = null;
  2123.             if(servizio!=null) {
  2124.                 _servizio = this.getIntestazioneFiltroRicerca(servizio.getTipo(), servizio.getNome());
  2125.             }
  2126.             if(servizio!=null && servizio.getVersione()!=null) {
  2127.                 if(_servizio!=null) {
  2128.                     _servizio = _servizio + " v"+servizio.getVersione().intValue();
  2129.                 }
  2130.                 else {
  2131.                     _servizio = "v"+servizio.getVersione().intValue();
  2132.                 }
  2133.             }

  2134.             StringBuilder parametriFiltro = new StringBuilder();

  2135.             if (correlazioneApplicativa != null) {
  2136.                 if(parametriFiltro.length()>0) {
  2137.                     parametriFiltro.append(" and ");
  2138.                 }
  2139.                 parametriFiltro.append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_CORRELAZIONE_APPLICATIVA).append("=").append(correlazioneApplicativa);
  2140.             }
  2141. //          if ((msgPattern != null) && !msgPattern.equals("")) {
  2142. //              if(parametriFiltro.length()>0) {
  2143. //                  parametriFiltro.append(" and ");
  2144. //              }
  2145. //              parametriFiltro.append(MonitorCostanti.PARAMETRO_MONITOR_PATTERN, msgPattern ));
  2146. //          }
  2147.             if (soglia > 0) {
  2148.                 if(parametriFiltro.length()>0) {
  2149.                     parametriFiltro.append(" and ");
  2150.                 }
  2151.                 parametriFiltro.append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_SOGLIA_LABEL).append("=").append(soglia + "");
  2152.             }
  2153.             if(monitorCore.isShowJ2eeOptions()) {
  2154.                 if (filterSearch.getStato()!=null && !"".equals(filterSearch.getStato().getValue()) && !MonitorCostanti.DEFAULT_VALUE_PARAMETRO_STATO_NONE.equals(filterSearch.getStato().getValue())) {
  2155.                     if(parametriFiltro.length()>0) {
  2156.                         parametriFiltro.append(" and ");
  2157.                     }
  2158.                     parametriFiltro.append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_STATO).append("=").append(filterSearch.getStato() + "");
  2159.                 }
  2160.             }
  2161.             if (idMessaggio!=null) {
  2162.                 if(parametriFiltro.length()>0) {
  2163.                     parametriFiltro.append(" and ");
  2164.                 }
  2165.                 parametriFiltro.append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_ID_MESSAGGIO).append("=").append(idMessaggio);
  2166.             }
  2167.             if(busta!=null){
  2168.                 if (profilo != null) {
  2169.                     if(parametriFiltro.length()>0) {
  2170.                         parametriFiltro.append(" and ");
  2171.                     }
  2172.                     parametriFiltro.append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_PROFILO).append("=").append(profilo);
  2173.                 }
  2174.                 if (riscontro) {
  2175.                     if(parametriFiltro.length()>0) {
  2176.                         parametriFiltro.append(" and ");
  2177.                     }
  2178.                     parametriFiltro.append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_RISCONTRO).append("=").append(riscontro + "");
  2179.                 }
  2180.                 if (_mittente != null) {
  2181.                     if(parametriFiltro.length()>0) {
  2182.                         parametriFiltro.append(" and ");
  2183.                     }
  2184.                     parametriFiltro.append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_MITTENTE).append("=").append(_mittente);
  2185.                 }
  2186.                 if (_destinatario != null) {
  2187.                     if(parametriFiltro.length()>0) {
  2188.                         parametriFiltro.append(" and ");
  2189.                     }
  2190.                     parametriFiltro.append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_DESTINATARIO).append("=").append(_destinatario);
  2191.                 }
  2192.                 if (_servizio != null) {
  2193.                     if(parametriFiltro.length()>0) {
  2194.                         parametriFiltro.append(" and ");
  2195.                     }
  2196.                     parametriFiltro.append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_SERVIZIO).append("=").append(_servizio);
  2197.                 }
  2198.                 if ((azione != null) && !azione.equals("")) {
  2199.                     if(parametriFiltro.length()>0) {
  2200.                         parametriFiltro.append(" and ");
  2201.                     }
  2202.                     parametriFiltro.append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_AZIONE).append("=").append(azione );
  2203.                 }
  2204.             }
  2205.            
  2206.             // se ci sono opzioni di filtraggio impostate allora visualizzo il
  2207.             // filtro
  2208.             if (parametriFiltro.length() > 0) {
  2209.                 StringBuilder sb = new StringBuilder("Filtro: ");
  2210.                 sb.append(parametriFiltro.toString());
  2211.                 pd.setMessage(sb.toString(), Costanti.MESSAGE_TYPE_INFO);
  2212.             }

  2213.             List<String> labels = new ArrayList<>();
  2214.             //labels.add(MonitorCostanti.LABEL_MONITOR_IDMESSAGGIO);
  2215.             labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_ORA_REGISTRAZIONE);
  2216.             if(monitorCore.isShowJ2eeOptions()) {
  2217.                 labels.add(MonitorCostanti.LABEL_PARAMETRO_MONITOR_STATO);
  2218.             }
  2219.             labels.add(MonitorCostanti.LABEL_MONITOR_EROGAZIONE);
  2220.             labels.add(MonitorCostanti.LABEL_MONITOR_DETTAGLIO);
  2221.             pd.setLabels(labels.toArray(new String[1]));

  2222.             List<List<DataElement>> dati = new ArrayList<>();

  2223.             boolean existsMessaggioInConsegna = false;

  2224.             if (listaMessaggi != null) {
  2225.                 // aggiungo i messaggi
  2226.                 DataElement de = null;
  2227.                 // Dichiaro il formatter per la data
  2228.                 SimpleDateFormat formatter = DateUtils.getDefaultDateTimeFormatter("yyyy-MM-dd HH:mm");
  2229.                 SimpleDateFormat formatterRispedizione = DateUtils.getDefaultDateTimeFormatter("yyyy-MM-dd HH:mm:ss");

  2230.                 Map<String,PortaApplicativa> mapPA = new HashMap<>();
  2231.                 Map<String,Boolean> mapConsegnaMultipla = new HashMap<>();
  2232.                 Map<String,Boolean> mapServer = new HashMap<>();
  2233.                 Map<String,String> mapConnettori = new HashMap<>();
  2234.                 Map<String,String> mapEndpointConnettori = new HashMap<>();
  2235.                 Map<String,String> mapErogazione = new HashMap<>();
  2236.                
  2237.                 PorteApplicativeCore paCore = new PorteApplicativeCore(monitorCore);
  2238.                 ServiziApplicativiCore saCore = new ServiziApplicativiCore(monitorCore);
  2239.                 SoggettiCore soggettiCore = new SoggettiCore(monitorCore);
  2240.                
  2241.                 for (int i = 0; i < listaMessaggi.size(); i++) {

  2242.                     List<DataElement> e = new ArrayList<>();
  2243.                    
  2244.                     Messaggio messaggio = listaMessaggi.get(i);

  2245.                     String tipo = messaggio.getDettaglio() != null ? messaggio.getDettaglio().getTipo() : "";

  2246.                     de = new DataElement();
  2247.                     String pdd = "";
  2248.                     if(monitorFormBean.getPdd()!=null && !"".equals(monitorFormBean.getPdd())){
  2249.                         pdd = monitorFormBean.getPdd();
  2250.                     }
  2251.                     String sorgente = "";
  2252.                     if(monitorFormBean.getSorgenteDati()!=null && !"".equals(monitorFormBean.getSorgenteDati())){
  2253.                         sorgente = monitorFormBean.getSorgenteDati();
  2254.                     }
  2255.                     de.setUrl(
  2256.                             MonitorCostanti.SERVLET_NAME_MONITOR,
  2257.                             new Parameter(MonitorCostanti.PARAMETRO_MONITOR_ID_MESSAGGIO, messaggio.getIdMessaggio()),
  2258.                             new Parameter(MonitorCostanti.PARAMETRO_MONITOR_METHOD, MonitorCostanti.DEFAULT_VALUE_FORM_BEAN_METHOD_DETAILS),
  2259.                             new Parameter(MonitorCostanti.PARAMETRO_MONITOR_TIPO, tipo),
  2260.                             new Parameter(MonitorCostanti.PARAMETRO_MONITOR_PDD, pdd),
  2261.                             new Parameter(MonitorCostanti.PARAMETRO_MONITOR_SORGENTE, sorgente)
  2262.                             );
  2263.                     //de.setValue(messaggio.getIdMessaggio());
  2264.                     //NON SERVE SALVO IL PAGE DATA //de.setIdToRemove(messaggio.getIdMessaggio());
  2265.                     de.setToolTip(messaggio.getIdMessaggio());
  2266.                     //e.add(de);

  2267.                     // Ora Registrazione come label
  2268.                     Date oraRegistrazione = messaggio.getOraRegistrazione();
  2269.                     //de = new DataElement();
  2270.                     de.setValue(formatter.format(oraRegistrazione));
  2271.                     e.add(de);
  2272.                
  2273.                     // serve per l'eliminazione (posizione 2 e 3)
  2274.                     de = new DataElement();
  2275.                     de.setType(DataElementType.HIDDEN);
  2276.                     de.setName(MonitorCostanti.PARAMETRO_MONITOR_ID_MESSAGGIO);
  2277.                     de.setValue(messaggio.getIdMessaggio());
  2278.                     e.add(de);
  2279.                    
  2280.                     de = new DataElement();
  2281.                     de.setType(DataElementType.HIDDEN);
  2282.                     de.setName(MonitorCostanti.PARAMETRO_MONITOR_TIPO);
  2283.                     de.setValue(tipo);
  2284.                     e.add(de);
  2285.                    
  2286.                     // Stato
  2287.                     if(monitorCore.isShowJ2eeOptions()) {
  2288.                         de = new DataElement();
  2289.                         StatoMessaggio stato = messaggio.getStato();
  2290.                         String statoS = "";
  2291.                         if(stato!=null)
  2292.                             statoS = stato.getValue();
  2293.                         de.setValue(statoS);
  2294.                         e.add(de);
  2295.                     }

  2296.                     // Erogazione
  2297.                     Dettaglio dettaglio = messaggio.getDettaglio();
  2298.                     String nomeErogazione = null;
  2299.                     Boolean consegnaMultipla = null;
  2300.                     String nomePortaSac0 = null;
  2301.                     if (dettaglio != null) {
  2302.                         if (dettaglio.getServizioApplicativoConsegnaList().size()>0) {
  2303.                             ServizioApplicativoConsegna sac0 = messaggio.getDettaglio().getServizioApplicativoConsegnaList().get(0); // prendo il prima, la porta e' uguale per tutti
  2304.                             nomePortaSac0 = sac0.getNomePorta();
  2305.                             nomeErogazione = mapErogazione.get(sac0.getNomePorta());
  2306.                             consegnaMultipla = mapConsegnaMultipla.get(sac0.getNomePorta());
  2307.                             if(nomeErogazione==null || consegnaMultipla==null) {
  2308.                                 PortaApplicativa pa = mapPA.get(sac0.getNomePorta());
  2309.                                 if(pa==null) {
  2310.                                     IDPortaApplicativa idPA = new IDPortaApplicativa();
  2311.                                     idPA.setNome(sac0.getNomePorta());
  2312.                                     try {
  2313.                                         pa = paCore.getPortaApplicativa(idPA);
  2314.                                         mapPA.put(sac0.getNomePorta(),pa);
  2315.                                     } catch (DriverConfigurazioneNotFound notFound) {
  2316.                                         // ignore
  2317.                                     }
  2318.                                 }
  2319.                                 if(pa!=null) {
  2320.                                     if(nomeErogazione==null) {
  2321.                                         IDServizio idServizio = IDServizioFactory.getInstance().getIDServizioFromValues(pa.getServizio().getTipo(), pa.getServizio().getNome(),
  2322.                                                 pa.getTipoSoggettoProprietario(), pa.getNomeSoggettoProprietario(),
  2323.                                                 pa.getServizio().getVersione());
  2324.                                         String protocollo = soggettiCore.getProtocolloAssociatoTipoSoggetto(pa.getTipoSoggettoProprietario());
  2325.                                         nomeErogazione = monitorHelper.getLabelServizioErogazione(protocollo, idServizio);
  2326.                                         if(nomeErogazione!=null) {
  2327.                                             mapErogazione.put(sac0.getNomePorta(), nomeErogazione);
  2328.                                         }
  2329.                                     }
  2330.                                     if(consegnaMultipla==null) {
  2331.                                         consegnaMultipla = pa.getBehaviour()!=null;
  2332.                                         mapConsegnaMultipla.put(sac0.getNomePorta(), consegnaMultipla);
  2333.                                     }
  2334.                                 }
  2335.                             }
  2336.                         }
  2337.                     }
  2338.                     de = new DataElement();
  2339.                     if(nomeErogazione!=null) {
  2340.                         de.setValue(nomeErogazione);
  2341.                     }
  2342.                     else if(nomePortaSac0!=null) {
  2343.                         de.setValue(nomePortaSac0);
  2344.                     }
  2345.                     else {
  2346.                         de.setValue("-");
  2347.                     }
  2348.                     e.add(de);
  2349.                    
  2350.                     // Dettaglio
  2351.                     StringBuilder sbDestinatari = new StringBuilder();
  2352.                     if (dettaglio != null) {
  2353.                         if (dettaglio.getServizioApplicativoConsegnaList().size()>0) {
  2354.                             // visualizzo i dettagli consegna
  2355.                             for (int j = 0; j < messaggio.getDettaglio().getServizioApplicativoConsegnaList().size(); j++) {
  2356.                                 ServizioApplicativoConsegna sac = messaggio.getDettaglio().getServizioApplicativoConsegnaList().get(j);
  2357.                                 String nome = sac.getNome();
  2358.                                 Boolean isServer = null;
  2359.                                 String nomeConnettore = null;
  2360.                                 String endpointConnettore = null;
  2361.                                 if(sac.getNomePorta()!=null) {
  2362.                                    
  2363.                                     String keyPorta = sac.getNomePorta()+"#"+nome;
  2364.                                     isServer = mapServer.get(keyPorta);
  2365.                                     nomeConnettore = mapConnettori.get(keyPorta);
  2366.                                     endpointConnettore = mapEndpointConnettori.get(keyPorta);
  2367.                                                                        
  2368.                                     if(nomeConnettore==null) {
  2369.                                         PortaApplicativa pa = mapPA.get(sac.getNomePorta());
  2370.                                         if(pa==null) {
  2371.                                             IDPortaApplicativa idPA = new IDPortaApplicativa();
  2372.                                             idPA.setNome(sac.getNomePorta());
  2373.                                             try {
  2374.                                                 pa = paCore.getPortaApplicativa(idPA);
  2375.                                                 mapPA.put(sac.getNomePorta(),pa);
  2376.                                             } catch (DriverConfigurazioneNotFound notFound) {
  2377.                                                 // ignore
  2378.                                             }
  2379.                                         }
  2380.                                         if(pa!=null && pa.getBehaviour() != null) {
  2381.                                             if(pa.sizeServizioApplicativoList()>0) {
  2382.                                                 for (int k = 0; k < pa.sizeServizioApplicativoList(); k++) {
  2383.                                                     PortaApplicativaServizioApplicativo pasa = pa.getServizioApplicativo(k);
  2384.                                                     if(pasa.getNome().equals(nome)) {
  2385.                                                         if(pasa.getDatiConnettore()!=null) {
  2386.                                                             nomeConnettore = pasa.getDatiConnettore().getNome();
  2387.                                                         }
  2388.                                                         break;
  2389.                                                     }
  2390.                                                 }
  2391.                                             }
  2392.                                         }
  2393.                                         if(nomeConnettore!=null) {
  2394.                                             mapConnettori.put(keyPorta,nomeConnettore);
  2395.                                         }
  2396.                                     }
  2397.                                     if(nomeConnettore==null) {
  2398.                                         if(isServer==null) {
  2399.                                             PortaApplicativa pa = mapPA.get(sac.getNomePorta());
  2400.                                             if(pa==null) {
  2401.                                                 IDPortaApplicativa idPA = new IDPortaApplicativa();
  2402.                                                 idPA.setNome(sac.getNomePorta());
  2403.                                                 try {
  2404.                                                     pa = paCore.getPortaApplicativa(idPA);
  2405.                                                     mapPA.put(sac.getNomePorta(),pa);
  2406.                                                 } catch (DriverConfigurazioneNotFound notFound) {
  2407.                                                     // ignore
  2408.                                                 }
  2409.                                             }
  2410.                                             if(pa!=null) {
  2411.                                                 IDServizioApplicativo idSA = new IDServizioApplicativo();
  2412.                                                 idSA.setNome(nome);
  2413.                                                 idSA.setIdSoggettoProprietario(new IDSoggetto(pa.getTipoSoggettoProprietario(), pa.getNomeSoggettoProprietario()));
  2414.                                                 ServizioApplicativo sa = null;
  2415.                                                 try {
  2416.                                                     sa = saCore.getServizioApplicativo(idSA);
  2417.                                                 } catch (Exception notFound) {
  2418.                                                     // ignore
  2419.                                                 }
  2420.                                                 if(sa!=null) {
  2421.                                                     isServer = ServiziApplicativiCostanti.VALUE_SERVIZI_APPLICATIVI_TIPO_SERVER.equals(sa.getTipo());
  2422.                                                     mapServer.put(keyPorta, isServer);
  2423.                                                 }
  2424.                                             }
  2425.                                         }
  2426.                                     }
  2427.                                     if(endpointConnettore==null && GestoreMessaggi.CONSEGNA_TRAMITE_CONNETTORE.equals(sac.getTipoConsegna())) {
  2428.                                         PortaApplicativa pa = mapPA.get(sac.getNomePorta());
  2429.                                         if(pa==null) {
  2430.                                             IDPortaApplicativa idPA = new IDPortaApplicativa();
  2431.                                             idPA.setNome(sac.getNomePorta());
  2432.                                             try {
  2433.                                                 pa = paCore.getPortaApplicativa(idPA);
  2434.                                                 mapPA.put(sac.getNomePorta(),pa);
  2435.                                             } catch (DriverConfigurazioneNotFound notFound) {
  2436.                                                 // ignore
  2437.                                             }
  2438.                                         }
  2439.                                         if(pa!=null) {
  2440.                                             IDServizioApplicativo idSA = new IDServizioApplicativo();
  2441.                                             idSA.setNome(nome);
  2442.                                             idSA.setIdSoggettoProprietario(new IDSoggetto(pa.getTipoSoggettoProprietario(), pa.getNomeSoggettoProprietario()));
  2443.                                             ServizioApplicativo sa = null;
  2444.                                             try {
  2445.                                                 sa = saCore.getServizioApplicativo(idSA);
  2446.                                             } catch (Exception notFound) {
  2447.                                                 // ignore
  2448.                                             }
  2449.                                             if(sa!=null) {
  2450.                                                 endpointConnettore = monitorHelper.getLabelConnettore(sa.getInvocazioneServizio(),false,false);
  2451.                                                 mapEndpointConnettori.put(keyPorta, endpointConnettore);
  2452.                                             }
  2453.                                         }
  2454.                                     }
  2455.                                 }
  2456.                                
  2457.                                 if(consegnaMultipla!=null && consegnaMultipla) {
  2458.                                    
  2459.                                     if(j>0) {
  2460.                                         sbDestinatari.append(org.openspcoop2.core.constants.Costanti.WEB_NEW_LINE);
  2461.                                     }
  2462.                                    
  2463.                                     sbDestinatari.append("<b>");
  2464.                                     if(isServer!=null && isServer) {
  2465.                                         sbDestinatari.append(nome);
  2466.                                     }
  2467.                                     else if(nomeConnettore!=null) {
  2468.                                         sbDestinatari.append(nomeConnettore);
  2469.                                     }
  2470.                                     else {
  2471.                                         sbDestinatari.append(nome);
  2472.                                     }
  2473.                                     sbDestinatari.append("</b>");
  2474.                                     sbDestinatari.append(". ");
  2475.                                 }
  2476.                                                            
  2477.                                 boolean appenaPresoInCarico = false;
  2478.                                 if(GestoreMessaggi.CONSEGNA_TRAMITE_CONNETTORE.equals(sac.getTipoConsegna())){
  2479.                                    
  2480.                                     existsMessaggioInConsegna=true;
  2481.                                    
  2482.                                     if(TimerConsegnaContenutiApplicativiThread.ID_MODULO.equals(sac.getErroreProcessamento())) {
  2483.                                         appenaPresoInCarico = true;
  2484.                                         sbDestinatari.append("In coda in attesa di essere gestito");
  2485.                                     }
  2486.                                     else {
  2487.                                         if(sac.getDataRispedizione()!=null) {
  2488.                                             sbDestinatari.append(MonitorCostanti.LABEL_PARAMETRO_MONITOR_IN_CONSEGNA_DA).append(": ").
  2489.                                                 append(formatterRispedizione.format(sac.getDataRispedizione()));
  2490.                                         }  
  2491.                                     }
  2492.                                     if(endpointConnettore!=null) {
  2493.                                         int maxLengthConnettore = 200;
  2494.                                         sbDestinatari.append("<BR/>- endpoint: ");
  2495.                                         if(endpointConnettore.length()>maxLengthConnettore) {
  2496.                                             sbDestinatari.append(endpointConnettore.substring(0, maxLengthConnettore-2)+"...");
  2497.                                         }
  2498.                                         else {
  2499.                                             sbDestinatari.append(endpointConnettore);
  2500.                                         }
  2501.                                     }
  2502.                                 }
  2503.                                 else if(GestoreMessaggi.CONSEGNA_TRAMITE_INTEGRATION_MANAGER.equals(sac.getTipoConsegna())){
  2504.                                     sbDestinatari.append("Disponibile tramite "+ServiziApplicativiCostanti.LABEL_SERVIZIO_MESSAGE_BOX);
  2505.                                 }
  2506.                                 else if(GestoreMessaggi.CONSEGNA_TRAMITE_CONNECTION_REPLY.equals(sac.getTipoConsegna())){
  2507.                                     sbDestinatari.append(GestoreMessaggi.CONSEGNA_TRAMITE_CONNECTION_REPLY.toLowerCase());
  2508.                                 }
  2509.                                
  2510.                                 if(!appenaPresoInCarico && sac.getErroreProcessamento()!=null){
  2511.                                     String erroreProcessamento = sac.getErroreProcessamento();
  2512.                                     sbDestinatari.append("<BR/>- errore: ");
  2513.                                     int maxLengthErroreProcessamento = 200;
  2514.                                     if(erroreProcessamento.length()>maxLengthErroreProcessamento) {
  2515.                                         sbDestinatari.append(erroreProcessamento.substring(0, maxLengthErroreProcessamento-2)+"...");
  2516.                                     }
  2517.                                     else {
  2518.                                         sbDestinatari.append(erroreProcessamento);
  2519.                                     }
  2520.                                 }
  2521.                             }
  2522.                         }
  2523.                     }
  2524.                     de = new DataElement();
  2525.                     de.setValue(sbDestinatari.toString());
  2526.                     e.add(de);

  2527.                     dati.add(e);
  2528.                 }
  2529.             }

  2530.             // aggiungo la matrice delle informazioni
  2531.             // pd.setSelect(false);
  2532.             // pd.setRemoveButton(true);

  2533.             pd.setAddButton(false);
  2534.            
  2535.             if (listaMessaggi != null && !listaMessaggi.isEmpty() && existsMessaggioInConsegna) {
  2536.                 List<AreaBottoni> bottoni = new ArrayList<>();
  2537.                 AreaBottoni ab = new AreaBottoni();
  2538.                 List<DataElement> otherbott = new ArrayList<>();
  2539.                 DataElement de = new DataElement();
  2540.                 de.setValue(MonitorCostanti.LABEL_ACTION_RICONSEGNA_IMMEDIATA);
  2541.                 de.setOnClick(MonitorCostanti.ACTION_RICONSEGNA_IMMEDIATA_ONCLICK);
  2542.                 de.setDisabilitaAjaxStatus();
  2543.                 otherbott.add(de);
  2544.                 ab.setBottoni(otherbott);
  2545.                 bottoni.add(ab);
  2546.                 pd.setAreaBottoni(bottoni);
  2547.             }
  2548.            
  2549.             pd.setDati(dati);
  2550.         } catch (Exception e) {
  2551.             throw new Exception(e);
  2552.         }
  2553.     }
  2554.    
  2555.     private String getIntestazioneFiltroRicerca(String tipo, String nome) {
  2556.         if(tipo!=null && StringUtils.isNotEmpty(tipo) && nome!=null && StringUtils.isNotEmpty(nome)) {
  2557.             return tipo + "/" + nome;
  2558.         }
  2559.         else if(nome!=null && StringUtils.isNotEmpty(nome)) {
  2560.             return nome;
  2561.         }
  2562.         else if(tipo!=null && StringUtils.isNotEmpty(tipo)) {
  2563.             return "tipo "+tipo;
  2564.         }
  2565.         return null;
  2566.     }
  2567. }