PolicyConfiguration.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.pdd.core.controllo_traffico.policy.config;

  21. import java.io.Serializable;
  22. import java.util.List;

  23. import org.openspcoop2.core.config.Proprieta;
  24. import org.openspcoop2.core.controllo_traffico.beans.AbstractPolicyConfiguration;
  25. import org.openspcoop2.core.controllo_traffico.constants.Costanti;
  26. import org.openspcoop2.core.controllo_traffico.driver.PolicyGroupByActiveThreadsType;
  27. import org.openspcoop2.pdd.config.OpenSPCoop2Properties;

  28. /**
  29.  * Configuration
  30.  *
  31.  * @author Poli Andrea (apoli@link.it)
  32.  * @author $Author$
  33.  * @version $Rev$, $Date$
  34.  */
  35. public class PolicyConfiguration extends AbstractPolicyConfiguration implements Serializable {

  36.     private static final long serialVersionUID = 1L;

  37.     public PolicyConfiguration() {
  38.         super();
  39.     }

  40.     public PolicyConfiguration(boolean runtime) throws Exception {
  41.         super(runtime);
  42.     }

  43.     public PolicyConfiguration(List<Proprieta> p, List<PolicyGroupByActiveThreadsType> tipiSupportati, boolean runtime)
  44.             throws Exception {
  45.         super(p, tipiSupportati, runtime);
  46.     }

  47.     public PolicyConfiguration(List<Proprieta> p) throws Exception {
  48.         super(p);
  49.     }
  50.    
  51.     @Override
  52.     protected void initRuntimeInfoAll() throws Exception{
  53.            
  54.         OpenSPCoop2Properties op2Properties = OpenSPCoop2Properties.getInstance();
  55.        
  56.         // ** gestione policy **
  57.        
  58.         if(!Costanti.VALUE_MODALITA_SINCRONIZZAZIONE_DEFAULT.equals(this.syncMode)) {
  59.             this.gestionePolicyRidefinita = true;
  60.         }
  61.        
  62.         if(this.type==null) {
  63.             this.type = op2Properties.getControlloTrafficoGestorePolicyInMemoryType();
  64.         }
  65.        
  66.         switch (this.type) {
  67.         case LOCAL:
  68.             break;
  69.         case LOCAL_DIVIDED_BY_NODES:
  70.             if(this.getEngineLOCAL_DIVIDED_BY_NODES_remaining_zeroValue()==null) {
  71.                 this.setLOCAL_DIVIDED_BY_NODES_remaining_zeroValue(op2Properties.isControlloTrafficoGestorePolicyInMemoryLocalDividedByNodesRemainingZeroValue());
  72.             }
  73.             if(this.getEngineLOCAL_DIVIDED_BY_NODES_limit_roundingDown()==null) {
  74.                 this.setLOCAL_DIVIDED_BY_NODES_limit_roundingDown(op2Properties.isControlloTrafficoGestorePolicyInMemoryLocalDividedByNodesLimitRoundingDown());
  75.             }
  76.             if(this.getEngineLOCAL_DIVIDED_BY_NODES_limit_normalizedQuota()==null) {
  77.                 this.setLOCAL_DIVIDED_BY_NODES_limit_normalizedQuota(op2Properties.isControlloTrafficoGestorePolicyInMemoryLocalDividedByNodesLimitNormalizedQuota());
  78.             }
  79.             break;
  80.         case DATABASE:
  81.         case HAZELCAST_MAP:
  82.         case HAZELCAST_NEAR_CACHE:
  83.         case HAZELCAST_LOCAL_CACHE:
  84.         case HAZELCAST_NEAR_CACHE_UNSAFE_SYNC_MAP:
  85.         case HAZELCAST_NEAR_CACHE_UNSAFE_ASYNC_MAP:
  86.         case HAZELCAST_REPLICATED_MAP:
  87.         case HAZELCAST_PNCOUNTER:
  88.         case REDISSON_MAP:
  89.         case HAZELCAST_ATOMIC_LONG:
  90.         case HAZELCAST_ATOMIC_LONG_ASYNC:
  91.         case REDISSON_ATOMIC_LONG:
  92.         case REDISSON_LONGADDER:
  93.             break;
  94.         }
  95.        
  96.         // ** gestione http **
  97.        
  98.         if(!Costanti.VALUE_HTTP_HEADER_DEFAULT.equals(this.httpMode)) {
  99.             this.gestioneHttpHeadersRidefinita = true;
  100.         }
  101.        
  102.         if(Costanti.VALUE_HTTP_HEADER_RIDEFINITO.equals(this.httpMode)) {
  103.            
  104.             if(Costanti.VALUE_HTTP_HEADER_DISABILITATO.equals(this.httpMode_limit)) {
  105.                 this.disabledHttpHeaders_limit = true;
  106.             }
  107.             else if(Costanti.VALUE_HTTP_HEADER_ABILITATO_NO_WINDOWS.equals(this.httpMode_limit)) {
  108.                 this.forceHttpHeaders_limit_no_windows = true;
  109.             }
  110.             else if(Costanti.VALUE_HTTP_HEADER_ABILITATO_WINDOWS.equals(this.httpMode_limit)) {
  111.                 this.forceHttpHeaders_limit_windows = true;
  112.             }
  113.            
  114.             if(Costanti.VALUE_HTTP_HEADER_DISABILITATO.equals(this.httpMode_remaining)) {
  115.                 this.disabledHttpHeaders_remaining = true;
  116.             }
  117.            
  118.             if(Costanti.VALUE_HTTP_HEADER_DISABILITATO.equals(this.httpMode_reset)) {
  119.                 this.disabledHttpHeaders_reset = true;
  120.             }
  121.            
  122.             if(Costanti.VALUE_HTTP_HEADER_DISABILITATO.equals(this.httpMode_retry_after)) {
  123.                 this.disabledHttpHeaders_retryAfter = true;
  124.             }
  125.             else if(Costanti.VALUE_HTTP_HEADER_ABILITATO_NO_BACKOFF.equals(this.httpMode_retry_after)) {
  126.                 this.forceDisabledHttpHeaders_retryAfter_backoff = true;
  127.             }
  128.             else if(Costanti.VALUE_HTTP_HEADER_ABILITATO_BACKOFF.equals(this.httpMode_retry_after) && this.httpMode_retry_after_backoff!=null) {
  129.                 this.forceHttpHeaders_retryAfter_backoff = Integer.valueOf(this.httpMode_retry_after_backoff);
  130.             }
  131.         }
  132.         else if(Costanti.VALUE_HTTP_HEADER_DISABILITATO.equals(this.httpMode)) {
  133.             this.disabledHttpHeaders = true;
  134.         }

  135.     }

  136. }