PorteApplicativeResponseCaching.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.pa;

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

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

  26. import org.apache.commons.lang.StringUtils;
  27. import org.apache.struts.action.Action;
  28. import org.apache.struts.action.ActionForm;
  29. import org.apache.struts.action.ActionForward;
  30. import org.apache.struts.action.ActionMapping;
  31. import org.openspcoop2.core.config.Configurazione;
  32. import org.openspcoop2.core.config.PortaApplicativa;
  33. import org.openspcoop2.core.config.ResponseCachingConfigurazione;
  34. import org.openspcoop2.core.config.ResponseCachingConfigurazioneControl;
  35. import org.openspcoop2.core.config.ResponseCachingConfigurazioneGenerale;
  36. import org.openspcoop2.core.config.ResponseCachingConfigurazioneHashGenerator;
  37. import org.openspcoop2.core.config.ResponseCachingConfigurazioneRegola;
  38. import org.openspcoop2.core.config.constants.StatoFunzionalita;
  39. import org.openspcoop2.core.config.constants.StatoFunzionalitaCacheDigestQueryParameter;
  40. import org.openspcoop2.web.ctrlstat.core.ControlStationCore;
  41. import org.openspcoop2.web.ctrlstat.costanti.CostantiControlStation;
  42. import org.openspcoop2.web.ctrlstat.servlet.GeneralHelper;
  43. import org.openspcoop2.web.ctrlstat.servlet.config.ConfigurazioneCore;
  44. import org.openspcoop2.web.lib.mvc.Costanti;
  45. import org.openspcoop2.web.lib.mvc.DataElement;
  46. import org.openspcoop2.web.lib.mvc.ForwardParams;
  47. import org.openspcoop2.web.lib.mvc.GeneralData;
  48. import org.openspcoop2.web.lib.mvc.PageData;
  49. import org.openspcoop2.web.lib.mvc.Parameter;
  50. import org.openspcoop2.web.lib.mvc.ServletUtils;
  51. import org.openspcoop2.web.lib.mvc.TipoOperazione;

  52. /***
  53.  *
  54.  * PorteApplicativeResponseCaching
  55.  *
  56.  * @author Giuliano Pintori (pintori@link.it)
  57.  * @author $Author$
  58.  * @version $Rev$, $Date$
  59.  */
  60. public class PorteApplicativeResponseCaching extends Action {

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

  63.         TipoOperazione tipoOperazione = TipoOperazione.OTHER;

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

  65.         // Inizializzo PageData
  66.         PageData pd = new PageData();

  67.         GeneralHelper generalHelper = new GeneralHelper(session);

  68.         // Inizializzo GeneralData
  69.         GeneralData gd = generalHelper.initGeneralData(request);

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

  71.         try {

  72.             PorteApplicativeHelper porteApplicativeHelper = new PorteApplicativeHelper(request, pd, session);
  73.             // prelevo il flag che mi dice da quale pagina ho acceduto la sezione delle porte applicative
  74.             Integer parentPA = ServletUtils.getIntegerAttributeFromSession(PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT, session, request);
  75.             if(parentPA == null) parentPA = PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_NONE;
  76.            
  77.             String id = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID);
  78.             int idInt = Integer.parseInt(id);
  79.             String idsogg = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO);
  80.             String idAsps = porteApplicativeHelper.getParameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS);
  81.             if(idAsps == null)
  82.                 idAsps = "";

  83.             // Preparo il menu
  84.             porteApplicativeHelper.makeMenu();

  85.             PorteApplicativeCore porteApplicativeCore = new PorteApplicativeCore();
  86.             ConfigurazioneCore confCore = new ConfigurazioneCore(porteApplicativeCore);

  87.             boolean showStato = true;
  88.             String statoResponseCachingPorta = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_STATO_PORTA);
  89.             String responseCachingEnabledTmp = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_STATO);
  90.             boolean responseCachingEnabled = ServletUtils.isCheckBoxEnabled(responseCachingEnabledTmp);
  91.            
  92.             String responseCachingSecondsTmp = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_TIMEOUT);
  93.             int responseCachingSeconds = 1;
  94.             if(responseCachingSecondsTmp != null) {
  95.                 try {
  96.                     responseCachingSeconds = Integer.parseInt(responseCachingSecondsTmp);
  97.                 }catch(Exception e) {
  98.                     // ignore
  99.                 }
  100.             }
  101.            
  102.            
  103.             String responseCachingMaxResponseSizeTmp = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_MAX_RESPONSE_SIZE);
  104.             boolean responseCachingMaxResponseSize = ServletUtils.isCheckBoxEnabled(responseCachingMaxResponseSizeTmp);
  105.            
  106.             String responseCachingMaxResponseSizeBytesTmp = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_MAX_RESPONSE_SIZE_BYTES);
  107.             long responseCachingMaxResponseSizeBytes = 1;
  108.             if(responseCachingMaxResponseSizeBytesTmp != null) {
  109.                 try {
  110.                     responseCachingMaxResponseSizeBytes = Integer.parseInt(responseCachingMaxResponseSizeBytesTmp);
  111.                 }catch(Exception e) {
  112.                     // ignore
  113.                 }
  114.             }
  115.             String responseCachingDigestUrlInvocazioneTmp = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_URI_INVOCAZIONE);
  116.             boolean responseCachingDigestUrlInvocazione = ServletUtils.isCheckBoxEnabled(responseCachingDigestUrlInvocazioneTmp);
  117.             String responseCachingDigestHeadersTmp = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_HEADERS);
  118.             boolean responseCachingDigestHeaders = ServletUtils.isCheckBoxEnabled(responseCachingDigestHeadersTmp);
  119.             String responseCachingDigestPayloadTmp = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_PAYLOAD);
  120.             boolean responseCachingDigestPayload = ServletUtils.isCheckBoxEnabled(responseCachingDigestPayloadTmp);
  121.             String responseCachingDigestHeadersNomiHeaders = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_HEADERS_NOMI_HEADERS);
  122.             StatoFunzionalitaCacheDigestQueryParameter responseCachingDigestQueryParameter = null;
  123.             String responseCachingDigestQueryParameterTmp = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_QUERY_PARAMETERS);
  124.             if(responseCachingDigestQueryParameterTmp!=null && !"".equals(responseCachingDigestQueryParameterTmp)) {
  125.                 responseCachingDigestQueryParameter = StatoFunzionalitaCacheDigestQueryParameter.toEnumConstant(responseCachingDigestQueryParameterTmp, true);
  126.             }
  127.             String responseCachingDigestNomiParametriQuery = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_RESPONSE_DIGEST_QUERY_PARAMETERS_NOMI);
  128.                        
  129.             String responseCachingCacheControlNoCacheTmp = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CACHE_CONTROL_NO_CACHE);
  130.             boolean responseCachingCacheControlNoCache = ServletUtils.isCheckBoxEnabled(responseCachingCacheControlNoCacheTmp);
  131.             String responseCachingCacheControlMaxAgeTmp = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CACHE_CONTROL_MAX_AGE);
  132.             boolean responseCachingCacheControlMaxAge = ServletUtils.isCheckBoxEnabled(responseCachingCacheControlMaxAgeTmp);
  133.             String responseCachingCacheControlNoStoreTmp = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_CACHE_CONTROL_NO_STORE);
  134.             boolean responseCachingCacheControlNoStore = ServletUtils.isCheckBoxEnabled(responseCachingCacheControlNoStoreTmp);

  135.             String idTab = porteApplicativeHelper.getParameter(CostantiControlStation.PARAMETRO_ID_TAB);
  136.             if(!porteApplicativeHelper.isModalitaCompleta() && StringUtils.isNotEmpty(idTab)) {
  137.                 ServletUtils.setObjectIntoSession(request, session, idTab, CostantiControlStation.PARAMETRO_ID_TAB);
  138.             }
  139.            
  140.             String servletResponseCachingConfigurazioneRegolaList = PorteApplicativeCostanti.SERVLET_NAME_PORTE_APPLICATIVE_RESPONSE_CACHING_CONFIGURAZIONE_REGOLA_LIST;
  141.             List<Parameter> paramsResponseCachingConfigurazioneRegolaList = new ArrayList<>();
  142.             paramsResponseCachingConfigurazioneRegolaList.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID, id));
  143.             paramsResponseCachingConfigurazioneRegolaList.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_SOGGETTO, idsogg));
  144.             paramsResponseCachingConfigurazioneRegolaList.add(new Parameter(PorteApplicativeCostanti.PARAMETRO_PORTE_APPLICATIVE_ID_ASPS, idAsps));
  145.            
  146.             PortaApplicativa pa = porteApplicativeCore.getPortaApplicativa(idInt);
  147.             String idporta = pa.getNome();

  148.             ResponseCachingConfigurazione oldConfigurazione = pa.getResponseCaching();
  149.             boolean visualizzaLinkConfigurazioneRegola = porteApplicativeHelper.isResponseCachingAbilitato(oldConfigurazione) && responseCachingEnabled;
  150.             List<ResponseCachingConfigurazioneRegola> listaRegoleCachingConfigurazione = oldConfigurazione != null ?  oldConfigurazione.getRegolaList() : null;
  151.             int numeroResponseCachingConfigurazioneRegola = porteApplicativeHelper.numeroRegoleResponseCaching(oldConfigurazione);

  152.             boolean initConfigurazione = false;
  153.             String postBackElementName = porteApplicativeHelper.getPostBackElementName();
  154.             if(postBackElementName != null ){
  155.                 if(postBackElementName.equalsIgnoreCase(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_STATO_PORTA)){
  156.                     initConfigurazione = true;
  157.                 }
  158.                
  159.                 if(postBackElementName.equalsIgnoreCase(CostantiControlStation.PARAMETRO_CONFIGURAZIONE_RESPONSE_CACHING_STATO)){
  160.                     if(!porteApplicativeHelper.isResponseCachingAbilitato(oldConfigurazione) && responseCachingEnabled) {
  161.                         ResponseCachingConfigurazione configurazioneTmp = new ResponseCachingConfigurazione();
  162.                        
  163.                         responseCachingSeconds = configurazioneTmp.getCacheTimeoutSeconds() != null ? configurazioneTmp.getCacheTimeoutSeconds().intValue() : 1;
  164.                        
  165.                         responseCachingMaxResponseSize = false;
  166.                         if(configurazioneTmp.getMaxMessageSize() != null) {
  167.                             responseCachingMaxResponseSize = true;
  168.                             responseCachingMaxResponseSizeBytes = configurazioneTmp.getMaxMessageSize().longValue();
  169.                         }
  170.                        
  171.                         responseCachingDigestUrlInvocazione = true;
  172.                         responseCachingDigestQueryParameter = StatoFunzionalitaCacheDigestQueryParameter.ABILITATO;
  173.                         responseCachingDigestHeaders = false;
  174.                         responseCachingDigestPayload = true;
  175.                         configurazioneTmp.setHashGenerator(new ResponseCachingConfigurazioneHashGenerator());
  176.                         if(configurazioneTmp.getHashGenerator() != null) {
  177.                            
  178.                             if(configurazioneTmp.getHashGenerator().getQueryParameters() != null)
  179.                                 responseCachingDigestQueryParameter = configurazioneTmp.getHashGenerator().getQueryParameters();
  180.                            
  181.                             if(configurazioneTmp.getHashGenerator().getQueryParameterList() != null)  
  182.                                 responseCachingDigestNomiParametriQuery = StringUtils.join(configurazioneTmp.getHashGenerator().getQueryParameterList(), ",");
  183.                            
  184.                             if(configurazioneTmp.getHashGenerator().getHeaders() != null && configurazioneTmp.getHashGenerator().getHeaders().equals(StatoFunzionalita.ABILITATO))
  185.                                 responseCachingDigestHeaders = true;
  186.                            
  187.                             if(configurazioneTmp.getHashGenerator().getRequestUri() != null && configurazioneTmp.getHashGenerator().getRequestUri().equals(StatoFunzionalita.ABILITATO))
  188.                                 responseCachingDigestUrlInvocazione = true;
  189.                            
  190.                             if(configurazioneTmp.getHashGenerator().getPayload() != null && configurazioneTmp.getHashGenerator().getPayload().equals(StatoFunzionalita.ABILITATO))
  191.                                 responseCachingDigestPayload = true;
  192.                         }
  193.                        
  194.                         responseCachingCacheControlNoCache = true;
  195.                         responseCachingCacheControlMaxAge = true;
  196.                         responseCachingCacheControlNoStore = true;
  197.                         configurazioneTmp.setControl(new ResponseCachingConfigurazioneControl());
  198.                         if(configurazioneTmp.getControl() != null) {
  199.                             responseCachingCacheControlNoCache = configurazioneTmp.getControl().isNoCache();
  200.                             responseCachingCacheControlMaxAge = configurazioneTmp.getControl().isMaxAge();
  201.                             responseCachingCacheControlNoStore = configurazioneTmp.getControl().isNoStore();
  202.                         }
  203.                         numeroResponseCachingConfigurazioneRegola = configurazioneTmp.sizeRegolaList();
  204.                     }
  205.                 }
  206.             }

  207.             List<Parameter> lstParam = porteApplicativeHelper.getTitoloPA(parentPA, idsogg, idAsps);

  208.             String labelPerPorta = null;
  209.             if(parentPA!=null && (parentPA.intValue() == PorteApplicativeCostanti.ATTRIBUTO_PORTE_APPLICATIVE_PARENT_CONFIGURAZIONE)) {
  210.                 labelPerPorta = porteApplicativeCore.getLabelRegolaMappingErogazionePortaApplicativa(
  211.                         PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_RESPONSE_CACHING_CONFIGURAZIONE_CONFIG_DI,
  212.                         PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_RESPONSE_CACHING_CONFIGURAZIONE,
  213.                         pa);
  214.             }
  215.             else {
  216.                 labelPerPorta = PorteApplicativeCostanti.LABEL_PARAMETRO_PORTE_APPLICATIVE_RESPONSE_CACHING_CONFIGURAZIONE_CONFIG_DI+idporta;
  217.             }

  218.             lstParam.add(new Parameter(labelPerPorta,  null));
  219.            
  220.             // imposta menu' contestuale
  221.             porteApplicativeHelper.impostaComandiMenuContestualePA(idsogg, idAsps);

  222.             // edit in progress
  223.             if (porteApplicativeHelper.isEditModeInProgress()) {
  224.                 ServletUtils.setPageDataTitle(pd, lstParam);

  225.                 if(statoResponseCachingPorta == null) {
  226.                     if(oldConfigurazione == null) {
  227.                         statoResponseCachingPorta = CostantiControlStation.VALUE_PARAMETRO_RESPONSE_CACHING_STATO_DEFAULT;  
  228.                     } else {
  229.                         statoResponseCachingPorta = CostantiControlStation.VALUE_PARAMETRO_RESPONSE_CACHING_STATO_RIDEFINITO;
  230.                         responseCachingEnabled = false;
  231.                         if(oldConfigurazione != null && oldConfigurazione.getStato().equals(StatoFunzionalita.ABILITATO)) {
  232.                             responseCachingEnabled = true;
  233.                            
  234.                             responseCachingSeconds = oldConfigurazione.getCacheTimeoutSeconds() != null ? oldConfigurazione.getCacheTimeoutSeconds().intValue() : 1;
  235.                            
  236.                             responseCachingMaxResponseSize = false;
  237.                             if(oldConfigurazione.getMaxMessageSize() != null) {
  238.                                 responseCachingMaxResponseSize = true;
  239.                                 responseCachingMaxResponseSizeBytes = oldConfigurazione.getMaxMessageSize().longValue();
  240.                             }
  241.                            
  242.                             responseCachingDigestUrlInvocazione = true;
  243.                             responseCachingDigestQueryParameter = StatoFunzionalitaCacheDigestQueryParameter.ABILITATO;
  244.                             responseCachingDigestHeaders = false;
  245.                             responseCachingDigestPayload = true;
  246.                             responseCachingDigestHeadersNomiHeaders = "";
  247.                             if(oldConfigurazione.getHashGenerator() != null) {
  248.                                
  249.                                 if(oldConfigurazione.getHashGenerator().getQueryParameters() != null)
  250.                                     responseCachingDigestQueryParameter = oldConfigurazione.getHashGenerator().getQueryParameters();
  251.                                
  252.                                 if(oldConfigurazione.getHashGenerator().getQueryParameterList() != null)  
  253.                                     responseCachingDigestNomiParametriQuery = StringUtils.join(oldConfigurazione.getHashGenerator().getQueryParameterList(), ",");
  254.                                
  255.                                 if(oldConfigurazione.getHashGenerator().getHeaders() != null)  
  256.                                     responseCachingDigestHeaders = oldConfigurazione.getHashGenerator().getHeaders().equals(StatoFunzionalita.ABILITATO);
  257.                                
  258.                                 if(oldConfigurazione.getHashGenerator().getHeaderList() != null)  
  259.                                     responseCachingDigestHeadersNomiHeaders = StringUtils.join(oldConfigurazione.getHashGenerator().getHeaderList(), ",");
  260.                                
  261.                                 if(oldConfigurazione.getHashGenerator().getRequestUri() != null)
  262.                                     responseCachingDigestUrlInvocazione = oldConfigurazione.getHashGenerator().getRequestUri().equals(StatoFunzionalita.ABILITATO);
  263.                                
  264.                                 if(oldConfigurazione.getHashGenerator().getPayload() != null)
  265.                                     responseCachingDigestPayload = oldConfigurazione.getHashGenerator().getPayload().equals(StatoFunzionalita.ABILITATO);
  266.                                
  267.                             }
  268.                            
  269.                             responseCachingCacheControlNoCache = true;
  270.                             responseCachingCacheControlMaxAge = true;
  271.                             responseCachingCacheControlNoStore = true;
  272.                             if(oldConfigurazione.getControl() != null) {
  273.                                 responseCachingCacheControlNoCache = oldConfigurazione.getControl().isNoCache();
  274.                                 responseCachingCacheControlMaxAge = oldConfigurazione.getControl().isMaxAge();
  275.                                 responseCachingCacheControlNoStore = oldConfigurazione.getControl().isNoStore();
  276.                             }
  277.                            
  278.                             visualizzaLinkConfigurazioneRegola = porteApplicativeHelper.isResponseCachingAbilitato(oldConfigurazione) && responseCachingEnabled;
  279.                             listaRegoleCachingConfigurazione = oldConfigurazione.getRegolaList();
  280.                             numeroResponseCachingConfigurazioneRegola = porteApplicativeHelper.numeroRegoleResponseCaching(oldConfigurazione);
  281.                         }
  282.                     }
  283.                 }

  284.                 if(initConfigurazione) {
  285.                     if(statoResponseCachingPorta.equals(CostantiControlStation.VALUE_PARAMETRO_RESPONSE_CACHING_STATO_RIDEFINITO)) {
  286.                         Configurazione configurazione = confCore.getConfigurazioneGenerale();
  287.                         ResponseCachingConfigurazioneGenerale responseCachingGenerale = configurazione.getResponseCaching();
  288.                         responseCachingEnabled = false;
  289.                         if(responseCachingGenerale != null) {
  290.                             oldConfigurazione = responseCachingGenerale.getConfigurazione();
  291.                             if(oldConfigurazione != null && oldConfigurazione.getStato().equals(StatoFunzionalita.ABILITATO)) {
  292.                                 responseCachingEnabled = true;
  293.                                
  294.                                 responseCachingSeconds = oldConfigurazione.getCacheTimeoutSeconds() != null ? oldConfigurazione.getCacheTimeoutSeconds().intValue() : 1;
  295.                                
  296.                                 responseCachingMaxResponseSize = false;
  297.                                 if(oldConfigurazione.getMaxMessageSize() != null) {
  298.                                     responseCachingMaxResponseSize = true;
  299.                                     responseCachingMaxResponseSizeBytes = oldConfigurazione.getMaxMessageSize().longValue();
  300.                                 }
  301.                                
  302.                                 responseCachingDigestUrlInvocazione = true;
  303.                                 responseCachingDigestQueryParameter = StatoFunzionalitaCacheDigestQueryParameter.ABILITATO;
  304.                                 responseCachingDigestHeaders = false;
  305.                                 responseCachingDigestPayload = true;
  306.                                 if(oldConfigurazione.getHashGenerator() != null) {
  307.                                    
  308.                                     if(oldConfigurazione.getHashGenerator().getQueryParameters() != null)
  309.                                         responseCachingDigestQueryParameter = oldConfigurazione.getHashGenerator().getQueryParameters();
  310.                                    
  311.                                     if(oldConfigurazione.getHashGenerator().getQueryParameterList() != null)  
  312.                                         responseCachingDigestNomiParametriQuery = StringUtils.join(oldConfigurazione.getHashGenerator().getQueryParameterList(), ",");
  313.                                    
  314.                                     if(oldConfigurazione.getHashGenerator().getHeaders() != null)  
  315.                                         responseCachingDigestHeaders = oldConfigurazione.getHashGenerator().getHeaders().equals(StatoFunzionalita.ABILITATO);
  316.                                    
  317.                                     if(oldConfigurazione.getHashGenerator().getHeaderList() != null)  
  318.                                         responseCachingDigestHeadersNomiHeaders = StringUtils.join(oldConfigurazione.getHashGenerator().getHeaderList(), ",");
  319.                                    
  320.                                     if(oldConfigurazione.getHashGenerator().getRequestUri() != null)
  321.                                         responseCachingDigestUrlInvocazione = oldConfigurazione.getHashGenerator().getRequestUri().equals(StatoFunzionalita.ABILITATO);
  322.                                    
  323.                                     if(oldConfigurazione.getHashGenerator().getPayload() != null)
  324.                                         responseCachingDigestPayload = oldConfigurazione.getHashGenerator().getPayload().equals(StatoFunzionalita.ABILITATO);
  325.                                 }
  326.                                
  327.                                 responseCachingCacheControlNoCache = true;
  328.                                 responseCachingCacheControlMaxAge = true;
  329.                                 responseCachingCacheControlNoStore = true;
  330.                                 if(oldConfigurazione.getControl() != null) {
  331.                                     responseCachingCacheControlNoCache = oldConfigurazione.getControl().isNoCache();
  332.                                     responseCachingCacheControlMaxAge = oldConfigurazione.getControl().isMaxAge();
  333.                                     responseCachingCacheControlNoStore = oldConfigurazione.getControl().isNoStore();
  334.                                 }
  335.                                
  336.                             }
  337.                             else {
  338.                                
  339.                                 responseCachingEnabled = true;
  340.                                
  341.                                 ResponseCachingConfigurazione configurazioneTmp = new ResponseCachingConfigurazione();
  342.                                
  343.                                 responseCachingSeconds = configurazioneTmp.getCacheTimeoutSeconds() != null ? configurazioneTmp.getCacheTimeoutSeconds().intValue() : 1;
  344.                                
  345.                                 responseCachingMaxResponseSize = false;
  346.                                 if(configurazioneTmp.getMaxMessageSize() != null) {
  347.                                     responseCachingMaxResponseSize = true;
  348.                                     responseCachingMaxResponseSizeBytes = configurazioneTmp.getMaxMessageSize().longValue();
  349.                                 }
  350.                                
  351.                                 responseCachingDigestUrlInvocazione = true;
  352.                                 responseCachingDigestQueryParameter = StatoFunzionalitaCacheDigestQueryParameter.ABILITATO;
  353.                                 responseCachingDigestHeaders = false;
  354.                                 responseCachingDigestPayload = true;
  355.                                 configurazioneTmp.setHashGenerator(new ResponseCachingConfigurazioneHashGenerator());
  356.                                 if(configurazioneTmp.getHashGenerator() != null) {
  357.                                    
  358.                                     if(configurazioneTmp.getHashGenerator().getQueryParameters() != null)
  359.                                         responseCachingDigestQueryParameter = configurazioneTmp.getHashGenerator().getQueryParameters();
  360.                                    
  361.                                     if(configurazioneTmp.getHashGenerator().getQueryParameterList() != null)  
  362.                                         responseCachingDigestNomiParametriQuery = StringUtils.join(configurazioneTmp.getHashGenerator().getQueryParameterList(), ",");
  363.                                    
  364.                                     if(configurazioneTmp.getHashGenerator().getHeaders() != null)  
  365.                                         responseCachingDigestHeaders = configurazioneTmp.getHashGenerator().getHeaders().equals(StatoFunzionalita.ABILITATO);
  366.                                    
  367.                                     if(configurazioneTmp.getHashGenerator().getHeaderList() != null)  
  368.                                         responseCachingDigestHeadersNomiHeaders = StringUtils.join(configurazioneTmp.getHashGenerator().getHeaderList(), ",");
  369.                                    
  370.                                     if(configurazioneTmp.getHashGenerator().getRequestUri() != null)
  371.                                         responseCachingDigestUrlInvocazione = configurazioneTmp.getHashGenerator().getRequestUri().equals(StatoFunzionalita.ABILITATO);
  372.                                    
  373.                                     if(configurazioneTmp.getHashGenerator().getPayload() != null)
  374.                                         responseCachingDigestPayload = configurazioneTmp.getHashGenerator().getPayload().equals(StatoFunzionalita.ABILITATO);
  375.                                 }
  376.                                
  377.                                 responseCachingCacheControlNoCache = true;
  378.                                 responseCachingCacheControlMaxAge = true;
  379.                                 responseCachingCacheControlNoStore = true;
  380.                                 configurazioneTmp.setControl(new ResponseCachingConfigurazioneControl());
  381.                                 if(configurazioneTmp.getControl() != null) {
  382.                                     responseCachingCacheControlNoCache = configurazioneTmp.getControl().isNoCache();
  383.                                     responseCachingCacheControlMaxAge = configurazioneTmp.getControl().isMaxAge();
  384.                                     responseCachingCacheControlNoStore = configurazioneTmp.getControl().isNoStore();
  385.                                 }
  386.                                
  387.                                 visualizzaLinkConfigurazioneRegola = false;
  388.                                 listaRegoleCachingConfigurazione = configurazioneTmp.getRegolaList();
  389.                                 numeroResponseCachingConfigurazioneRegola = porteApplicativeHelper.numeroRegoleResponseCaching(configurazioneTmp);
  390.                             }
  391.                         }
  392.                     }
  393.                 }

  394.                 // preparo i campi
  395.                 List<DataElement> dati = new ArrayList<>();
  396.                 dati.add(ServletUtils.getDataElementForEditModeFinished());

  397.                 porteApplicativeHelper.addConfigurazioneResponseCachingPorteToDati(tipoOperazione, dati, showStato, statoResponseCachingPorta,
  398.                         responseCachingEnabled, responseCachingSeconds, responseCachingMaxResponseSize, responseCachingMaxResponseSizeBytes,
  399.                         responseCachingDigestUrlInvocazione, responseCachingDigestHeaders, responseCachingDigestPayload, responseCachingDigestHeadersNomiHeaders, responseCachingDigestQueryParameter, responseCachingDigestNomiParametriQuery,
  400.                         responseCachingCacheControlNoCache, responseCachingCacheControlMaxAge, responseCachingCacheControlNoStore, visualizzaLinkConfigurazioneRegola,
  401.                         servletResponseCachingConfigurazioneRegolaList, paramsResponseCachingConfigurazioneRegolaList, numeroResponseCachingConfigurazioneRegola );

  402.                 dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.OTHER,id, idsogg, null, idAsps, dati);

  403.                 pd.setDati(dati);

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

  405.                 return ServletUtils.getStrutsForwardEditModeInProgress(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_RESPONSE_CACHING,    ForwardParams.OTHER(""));
  406.             }

  407.             // Controlli sui campi immessi
  408.             boolean isOk = porteApplicativeHelper.checkDataConfigurazioneResponseCachingPorta(tipoOperazione, showStato, statoResponseCachingPorta);
  409.             if (!isOk) {

  410.                 ServletUtils.setPageDataTitle(pd, lstParam);

  411.                 // preparo i campi
  412.                 List<DataElement> dati = new ArrayList<>();
  413.                 dati.add(ServletUtils.getDataElementForEditModeFinished());

  414.                 porteApplicativeHelper.addConfigurazioneResponseCachingPorteToDati(tipoOperazione, dati, showStato, statoResponseCachingPorta,
  415.                         responseCachingEnabled, responseCachingSeconds, responseCachingMaxResponseSize, responseCachingMaxResponseSizeBytes,
  416.                         responseCachingDigestUrlInvocazione, responseCachingDigestHeaders, responseCachingDigestPayload, responseCachingDigestHeadersNomiHeaders, responseCachingDigestQueryParameter, responseCachingDigestNomiParametriQuery,
  417.                         responseCachingCacheControlNoCache, responseCachingCacheControlMaxAge, responseCachingCacheControlNoStore, visualizzaLinkConfigurazioneRegola,
  418.                         servletResponseCachingConfigurazioneRegolaList, paramsResponseCachingConfigurazioneRegolaList, numeroResponseCachingConfigurazioneRegola );

  419.                 dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.OTHER,id, idsogg, null, idAsps, dati);

  420.                 pd.setDati(dati);

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

  422.                 return ServletUtils.getStrutsForwardEditModeCheckError(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_RESPONSE_CACHING,    ForwardParams.OTHER(""));
  423.             }

  424.             ResponseCachingConfigurazione newConfigurazione = null;
  425.             if(statoResponseCachingPorta.equals(CostantiControlStation.VALUE_PARAMETRO_RESPONSE_CACHING_STATO_RIDEFINITO)) {
  426.                 newConfigurazione = porteApplicativeHelper.getResponseCaching(responseCachingEnabled, responseCachingSeconds,
  427.                         responseCachingMaxResponseSize, responseCachingMaxResponseSizeBytes, responseCachingDigestUrlInvocazione,
  428.                         responseCachingDigestHeaders, responseCachingDigestPayload, responseCachingDigestHeadersNomiHeaders, responseCachingDigestQueryParameter, responseCachingDigestNomiParametriQuery,
  429.                         responseCachingCacheControlNoCache, responseCachingCacheControlMaxAge, responseCachingCacheControlNoStore,listaRegoleCachingConfigurazione);
  430.             }
  431.            
  432.             pa.setResponseCaching(newConfigurazione);
  433.             porteApplicativeCore.performUpdateOperation(userLogin, porteApplicativeHelper.smista(), pa);
  434.             // Preparo la lista
  435.             pd.setMessage(PorteApplicativeCostanti.LABEL_PORTE_APPLICATIVE_RESPONSE_CACHING_CON_SUCCESSO, Costanti.MESSAGE_TYPE_INFO);

  436.             pa = porteApplicativeCore.getPortaApplicativa(idInt);
  437.             idporta = pa.getNome();

  438.             ServletUtils.setPageDataTitle(pd, lstParam);

  439.             // preparo i campi
  440.             List<DataElement> dati = new ArrayList<>();
  441.             dati.add(ServletUtils.getDataElementForEditModeFinished());

  442.             // ricarico la configurazione

  443.             ResponseCachingConfigurazione configurazioneAggiornata = pa.getResponseCaching();
  444.            
  445.             if(configurazioneAggiornata == null) {
  446.                 statoResponseCachingPorta = CostantiControlStation.VALUE_PARAMETRO_RESPONSE_CACHING_STATO_DEFAULT;
  447.             } else {
  448.                 statoResponseCachingPorta = CostantiControlStation.VALUE_PARAMETRO_RESPONSE_CACHING_STATO_RIDEFINITO;
  449.                 if(configurazioneAggiornata.getStato() != null && configurazioneAggiornata.getStato().equals(StatoFunzionalita.ABILITATO)) {
  450.                     responseCachingEnabled = false;
  451.                     if(configurazioneAggiornata != null && configurazioneAggiornata.getStato().equals(StatoFunzionalita.ABILITATO)) {
  452.                         responseCachingEnabled = true;
  453.                        
  454.                         responseCachingSeconds = configurazioneAggiornata.getCacheTimeoutSeconds() != null ? configurazioneAggiornata.getCacheTimeoutSeconds().intValue() : 1;
  455.                        
  456.                         responseCachingMaxResponseSize = false;
  457.                         if(configurazioneAggiornata.getMaxMessageSize() != null) {
  458.                             responseCachingMaxResponseSize = true;
  459.                             responseCachingMaxResponseSizeBytes = configurazioneAggiornata.getMaxMessageSize().longValue();
  460.                         }
  461.                        
  462.                         responseCachingDigestUrlInvocazione = true;
  463.                         responseCachingDigestQueryParameter = StatoFunzionalitaCacheDigestQueryParameter.ABILITATO;
  464.                         responseCachingDigestHeaders = false;
  465.                         responseCachingDigestPayload = true;
  466.                         if(configurazioneAggiornata.getHashGenerator() != null) {
  467.                            
  468.                             if(configurazioneAggiornata.getHashGenerator().getQueryParameters() != null)
  469.                                 responseCachingDigestQueryParameter = configurazioneAggiornata.getHashGenerator().getQueryParameters();
  470.                            
  471.                             if(configurazioneAggiornata.getHashGenerator().getQueryParameterList() != null)  
  472.                                 responseCachingDigestNomiParametriQuery = StringUtils.join(configurazioneAggiornata.getHashGenerator().getQueryParameterList(), ",");
  473.                            
  474.                             if(configurazioneAggiornata.getHashGenerator().getHeaders() != null)  
  475.                                 responseCachingDigestHeaders = configurazioneAggiornata.getHashGenerator().getHeaders().equals(StatoFunzionalita.ABILITATO);
  476.                            
  477.                             if(configurazioneAggiornata.getHashGenerator().getHeaderList() != null)  
  478.                                 responseCachingDigestHeadersNomiHeaders = StringUtils.join(configurazioneAggiornata.getHashGenerator().getHeaderList(), ",");
  479.                            
  480.                             if(configurazioneAggiornata.getHashGenerator().getRequestUri() != null)
  481.                                 responseCachingDigestUrlInvocazione = configurazioneAggiornata.getHashGenerator().getRequestUri().equals(StatoFunzionalita.ABILITATO);
  482.                            
  483.                             if(configurazioneAggiornata.getHashGenerator().getPayload() != null)
  484.                                 responseCachingDigestPayload = configurazioneAggiornata.getHashGenerator().getPayload().equals(StatoFunzionalita.ABILITATO);
  485.                         }
  486.                        
  487.                         responseCachingCacheControlNoCache = true;
  488.                         responseCachingCacheControlMaxAge = true;
  489.                         responseCachingCacheControlNoStore = true;
  490.                         if(configurazioneAggiornata.getControl() != null) {
  491.                             responseCachingCacheControlNoCache = configurazioneAggiornata.getControl().isNoCache();
  492.                             responseCachingCacheControlMaxAge = configurazioneAggiornata.getControl().isMaxAge();
  493.                             responseCachingCacheControlNoStore = configurazioneAggiornata.getControl().isNoStore();
  494.                         }
  495.                        
  496.                         numeroResponseCachingConfigurazioneRegola = configurazioneAggiornata.sizeRegolaList();
  497.                         visualizzaLinkConfigurazioneRegola = true;
  498.                     }
  499.                 }
  500.             }

  501.             porteApplicativeHelper.addConfigurazioneResponseCachingPorteToDati(tipoOperazione, dati, showStato, statoResponseCachingPorta,
  502.                     responseCachingEnabled, responseCachingSeconds, responseCachingMaxResponseSize, responseCachingMaxResponseSizeBytes,
  503.                     responseCachingDigestUrlInvocazione, responseCachingDigestHeaders, responseCachingDigestPayload, responseCachingDigestHeadersNomiHeaders, responseCachingDigestQueryParameter, responseCachingDigestNomiParametriQuery,
  504.                     responseCachingCacheControlNoCache, responseCachingCacheControlMaxAge, responseCachingCacheControlNoStore, visualizzaLinkConfigurazioneRegola,
  505.                     servletResponseCachingConfigurazioneRegolaList, paramsResponseCachingConfigurazioneRegolaList, numeroResponseCachingConfigurazioneRegola );

  506.             dati = porteApplicativeHelper.addHiddenFieldsToDati(TipoOperazione.OTHER,id, idsogg, null, idAsps, dati);

  507.             pd.setDati(dati);

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

  509.             return ServletUtils.getStrutsForwardEditModeFinished(mapping, PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_RESPONSE_CACHING, ForwardParams.OTHER(""));
  510.         } catch (Exception e) {
  511.             return ServletUtils.getStrutsForwardError(ControlStationCore.getLog(), e, pd, request, session, gd, mapping,
  512.                     PorteApplicativeCostanti.OBJECT_NAME_PORTE_APPLICATIVE_RESPONSE_CACHING, ForwardParams.OTHER(""));
  513.         }
  514.     }

  515. }