FileTraceConfig.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.logger.filetrace;

  21. import java.io.File;
  22. import java.io.FileInputStream;
  23. import java.io.FileNotFoundException;
  24. import java.io.FileOutputStream;
  25. import java.io.InputStream;
  26. import java.util.ArrayList;
  27. import java.util.Collections;
  28. import java.util.HashMap;
  29. import java.util.List;
  30. import java.util.Map;
  31. import java.util.Properties;
  32. import java.util.Scanner;

  33. import org.apache.commons.lang.StringUtils;
  34. import org.openspcoop2.core.commons.CoreException;
  35. import org.openspcoop2.monitor.sdk.transaction.FaseTracciamento;
  36. import org.openspcoop2.pdd.config.OpenSPCoop2Properties;
  37. import org.openspcoop2.utils.LoggerWrapperFactory;
  38. import org.openspcoop2.utils.SemaphoreLock;
  39. import org.openspcoop2.utils.UtilsException;
  40. import org.openspcoop2.utils.properties.PropertiesReader;
  41. import org.openspcoop2.utils.resources.FileSystemUtilities;

  42. /**    
  43.  * FileTraceConfig
  44.  *
  45.  * @author Poli Andrea (poli@link.it)
  46.  * @author $Author$
  47.  * @version $Rev$, $Date$
  48.  */
  49. public class FileTraceConfig {
  50.    
  51.     private static HashMap<String, FileTraceConfig> staticInstanceMap = new HashMap<>();
  52.     private static final org.openspcoop2.utils.Semaphore semaphore = new org.openspcoop2.utils.Semaphore("FileTraceConfig");

  53.     public static void init(InputStream is, String fileNamePath, boolean globale) throws CoreException {
  54.         SemaphoreLock lock = semaphore.acquireThrowRuntime("init_InputStream");
  55.         try {
  56.             if(!staticInstanceMap.containsKey(fileNamePath)){
  57.                 FileTraceConfig instance = new FileTraceConfig(is, globale);
  58.                 staticInstanceMap.put(fileNamePath, instance);
  59.             }
  60.         }finally {
  61.             semaphore.release(lock, "init_InputStream");
  62.         }
  63.     }
  64.     public static void init(File file, boolean globale) throws CoreException {
  65.         SemaphoreLock lock = semaphore.acquireThrowRuntime("init_File");
  66.         try {
  67.             if(!staticInstanceMap.containsKey(file.getAbsolutePath())){
  68.                 FileTraceConfig instance = new FileTraceConfig(file, globale);
  69.                 staticInstanceMap.put(file.getAbsolutePath(), instance);
  70.             }
  71.         }finally {
  72.             semaphore.release(lock, "init_File");
  73.         }
  74.     }
  75.     public static void update(File file, boolean globale) throws CoreException {
  76.         SemaphoreLock lock = semaphore.acquireThrowRuntime("update");
  77.         try {
  78.             updateWithoutSynchronizedEngine(file, globale);
  79.         }finally {
  80.             semaphore.release(lock, "update_File");
  81.         }
  82.     }
  83.     public static void resetFileTraceAssociatePorte()  {
  84.         SemaphoreLock lock = semaphore.acquireThrowRuntime("resetFileTraceAssociatePorte");
  85.         try {
  86.             if(!staticInstanceMap.isEmpty()) {
  87.                 List<String> removeEntries = new ArrayList<>();
  88.                 for (Map.Entry<String,FileTraceConfig> entry : staticInstanceMap.entrySet()) {
  89.                     String path = entry.getKey();
  90.                     FileTraceConfig config = staticInstanceMap.get(path);
  91.                     if(config.isGlobale()) {
  92.                         continue;
  93.                     }
  94.                     /**updateWithoutSynchronizedEngine(new File(path), config.isGlobale());*/
  95.                     removeEntries.add(path); // verra poi ricreato
  96.                 }
  97.                 while(!removeEntries.isEmpty()) {
  98.                     String path = removeEntries.remove(0);
  99.                     staticInstanceMap.remove(path);
  100.                 }
  101.             }
  102.         }finally {
  103.             semaphore.release(lock, "resetFileTraceAssociatePorte");
  104.         }
  105.     }
  106.     private static void updateWithoutSynchronizedEngine(File file, boolean globale) throws CoreException {
  107.         FileTraceConfig newConfig = new FileTraceConfig(file, globale);
  108.         FileTraceConfig instance = newConfig;
  109.         staticInstanceMap.remove(file.getAbsolutePath());
  110.         staticInstanceMap.put(file.getAbsolutePath(), instance);
  111.     }
  112.     public static FileTraceConfig getConfig(File file, boolean globale) throws CoreException {
  113.         if(!staticInstanceMap.containsKey(file.getAbsolutePath())){
  114.             init(file, globale);
  115.         }
  116.         return staticInstanceMap.get(file.getAbsolutePath());
  117.     }
  118.    
  119.     private boolean globale = true;
  120.    
  121.     private LogSeverity logSeverity = LogSeverity.info;
  122.    
  123.     private Map<String, String> escape = new HashMap<>();
  124.        
  125.     private String headersSeparator = ",";
  126.     private String headerSeparator = "=";
  127.     private String headerPrefix = "";
  128.     private String headerSuffix = "";
  129.     private List<String> headerBlackList;
  130.     private List<String> headerWhiteList;
  131.    
  132.     private String headerMultiValueSeparator = ","; // per singolo header
  133.    
  134.     private List<String> propertiesSortKeys = new ArrayList<>();
  135.     private Map<String, String> propertiesNames = new HashMap<>();
  136.     private Map<String, String> propertiesValues = new HashMap<>();
  137.     private Map<String, String> propertiesEncryptionMode = new HashMap<>();
  138.    
  139.     private Map<String, FileTraceEncryptConfig> encryptionMode = new HashMap<>();
  140.    
  141.     private List<String> topicErogazioni = new ArrayList<>();
  142.     private Map<String, Topic> topicErogazioniMap = new HashMap<>();
  143.    
  144.     private List<String> topicFruizioni = new ArrayList<>();
  145.     private Map<String, Topic> topicFruizioneMap = new HashMap<>();
  146.    
  147.     public FileTraceConfig(File file, boolean globale) throws CoreException {
  148.         try(FileInputStream fin = new FileInputStream(file)){
  149.             initEngine(fin, globale);
  150.         }catch(Exception e) {
  151.             throw new CoreException(e.getMessage(),e);
  152.         }
  153.     }
  154.     public FileTraceConfig(InputStream is, boolean globale) throws CoreException {
  155.         initEngine(is, globale);
  156.     }
  157.    
  158.     private static boolean escapeInFile = true;
  159.     public static boolean isEscapeInFile() {
  160.         return escapeInFile;
  161.     }
  162.     public static void setEscapeInFile(boolean escapeInFile) {
  163.         FileTraceConfig.escapeInFile = escapeInFile;
  164.     }
  165.     private void initEngine(InputStream is, boolean globale) throws CoreException {
  166.         try {
  167.             this.globale = globale;
  168.            
  169.             Properties p = new Properties();
  170.            
  171.             if(escapeInFile) {
  172.                 p.load(is); // non tratta bene i caratteri speciali
  173.             }
  174.             else {
  175.                 fillProperties(p, is);
  176.                
  177.                 File fTmp = FileSystemUtilities.createTempFile("test", ".properties");
  178.                 try {
  179.                     try(FileOutputStream fout = new FileOutputStream(fTmp)){
  180.                         p.store(fout, "test");
  181.                     }
  182.                     try(FileInputStream finNewP = new FileInputStream(fTmp)){
  183.                          p = new Properties();
  184.                          p.load(finNewP);
  185.                     }
  186.                 }finally {
  187.                     FileSystemUtilities.deleteFile(fTmp);
  188.                 }
  189.             }
  190.            
  191.             PropertiesReader reader = new PropertiesReader(p,true);
  192.            
  193.             // ** Log **
  194.            
  195.             String tmp = getProperty(reader, "log.severity", false);
  196.             if(tmp!=null) {
  197.                 this.logSeverity = LogSeverity.valueOf(tmp);
  198.             }
  199.            
  200.             InputStream isLog = getInputStreamLogFile(reader);
  201.             Properties pLog = new Properties();
  202.             pLog.load(isLog);
  203.             LoggerWrapperFactory.setLogConfiguration(pLog, true);
  204.                
  205.            
  206.             // ** Topics **
  207.            
  208.             boolean erogazioni = true;
  209.             registerTopic(reader, erogazioni);
  210.             registerTopic(reader, !erogazioni);
  211.            
  212.             // ** Encryption mode
  213.            
  214.             this.encryptionMode = FileTraceEncryptConfig.parse(reader);
  215.            
  216.             // ** Format **
  217.            
  218.             readFormatProperties(reader);
  219.                
  220.         }catch(Exception t) {
  221.             throw new CoreException(t.getMessage(),t);
  222.         }
  223.     }
  224.     private void fillProperties(Properties p, InputStream is) {
  225.         Scanner scanner = new Scanner(is);
  226.         while (scanner.hasNextLine()) {
  227.             String line = scanner.nextLine();
  228.             if(line.startsWith("#") ||
  229.                     StringUtils.isEmpty(line) ||
  230.                     (line.endsWith("=") && line.length()==1) ||
  231.                     (line.indexOf("=")<=0)
  232.                 ) {
  233.                 continue;
  234.             }
  235.             /**System.out.println("LINE ["+line+"]");*/
  236.             String key = null;
  237.             String value = "";
  238.             if(line.endsWith("=")) {
  239.                 key = line.substring(0, line.length()-1);
  240.             }
  241.             else {
  242.                 int indexOf = line.indexOf("=");
  243.                 key = line.substring(0, indexOf);
  244.                 value = line.substring(indexOf+1, line.length());
  245.             }
  246.             p.put(key, value);
  247.         }
  248.         scanner.close();
  249.     }
  250.    
  251.     private InputStream getInputStreamLogFile(PropertiesReader reader) throws UtilsException, FileNotFoundException {
  252.         String tmp = getProperty(reader, "log.config.file", true);
  253.        
  254.         File fTmp = new File(tmp);
  255.         if(fTmp.exists()) {
  256.             return new FileInputStream(fTmp);
  257.         }
  258.        
  259.         InputStream isTmp = FileTraceConfig.class.getResourceAsStream(tmp);
  260.         if(isTmp!=null) {
  261.             return isTmp;
  262.         }
  263.        
  264.         if(!tmp.startsWith("/")) {
  265.             isTmp = FileTraceConfig.class.getResourceAsStream("/"+tmp);
  266.             if(isTmp!=null) {
  267.                 return isTmp;
  268.             }
  269.         }
  270.        
  271.         fTmp = new File(OpenSPCoop2Properties.getInstance().getRootDirectory(), tmp);
  272.         if(fTmp.exists()) {
  273.             return new FileInputStream(fTmp);
  274.         }
  275.    
  276.         throw new UtilsException("File '"+tmp+"' not found");
  277.        
  278.     }
  279.    
  280.     private void registerTopic(PropertiesReader reader, boolean erogazioni) throws UtilsException {
  281.        
  282.         String tipo = erogazioni ? "erogazioni" : "fruizioni";
  283.        
  284.         String propertyName = "topic."+tipo;
  285.         String tmp = getProperty(reader, propertyName, false);

  286.         if(tmp!=null && !StringUtils.isEmpty(tmp)) {
  287.            
  288.             List<String> list = erogazioni ? this.topicErogazioni : this.topicFruizioni;
  289.             Map<String, Topic> map = erogazioni ? this.topicErogazioniMap : this.topicFruizioneMap;
  290.        
  291.             String [] split = tmp.split(",");
  292.             if(split!=null && split.length>0) {
  293.                 for (int i = 0; i < split.length; i++) {
  294.                     String nome = split[i].trim();
  295.                    
  296.                     if(list.contains(nome)) {
  297.                         throw new UtilsException("Found duplicate topic '"+nome+"' ("+tipo+")");
  298.                     }
  299.                     list.add(nome);
  300.                    
  301.                     Topic topic = new Topic();
  302.                     topic.setErogazioni(erogazioni);
  303.                     topic.setNome(nome);
  304.                    
  305.                     String propertyNameOnlyRequestSent = propertyName+"."+nome+".requestSent";
  306.                     String tmpOnlyRequestSent = getProperty(reader, propertyNameOnlyRequestSent, false);
  307.                     if(tmpOnlyRequestSent!=null) {
  308.                         topic.setOnlyRequestSent(Boolean.valueOf(tmpOnlyRequestSent));
  309.                     }
  310.                     else {
  311.                         // backward
  312.                         propertyNameOnlyRequestSent = propertyName+"."+nome+".requestSended";
  313.                         tmpOnlyRequestSent = getProperty(reader, propertyNameOnlyRequestSent, false);
  314.                         if(tmpOnlyRequestSent!=null) {
  315.                             topic.setOnlyRequestSent(Boolean.valueOf(tmpOnlyRequestSent));
  316.                         }
  317.                     }
  318.                    
  319.                     String propertyNameInRequestContentDefined = propertyName+"."+nome+".inRequestContentDefined";
  320.                     String tmpInRequestContentDefined = getProperty(reader, propertyNameInRequestContentDefined, false);
  321.                     if(tmpInRequestContentDefined!=null)
  322.                         topic.setOnlyInRequestContentDefined(Boolean.valueOf(tmpInRequestContentDefined));
  323.                    
  324.                     String propertyNameOutRequestContentDefined = propertyName+"."+nome+".outRequestContentDefined";
  325.                     String tmpOutRequestContentDefined = getProperty(reader, propertyNameOutRequestContentDefined, false);
  326.                     if(tmpOutRequestContentDefined!=null)
  327.                         topic.setOnlyOutRequestContentDefined(Boolean.valueOf(tmpOutRequestContentDefined));
  328.                    
  329.                     String propertyNameInResponseContentDefined = propertyName+"."+nome+".inResponseContentDefined";
  330.                     String tmpInResponseContentDefined = getProperty(reader, propertyNameInResponseContentDefined, false);
  331.                     if(tmpInResponseContentDefined!=null)
  332.                         topic.setOnlyInResponseContentDefined(Boolean.valueOf(tmpInResponseContentDefined));
  333.                    
  334.                     String propertyNameOutResponseContentDefined = propertyName+"."+nome+".outResponseContentDefined";
  335.                     String tmpOutResponseContentDefined = getProperty(reader, propertyNameOutResponseContentDefined, false);
  336.                     if(tmpOutResponseContentDefined!=null)
  337.                         topic.setOnlyOutResponseContentDefined(Boolean.valueOf(tmpOutResponseContentDefined));
  338.                    
  339.                     String propertyNameTrackingPhases = propertyName+"."+nome+".trackingPhases";
  340.                     List<String> trackingPhases = getList(reader, propertyNameTrackingPhases);
  341.                     if(trackingPhases!=null && !trackingPhases.isEmpty()) {
  342.                         for (String phase : trackingPhases) {
  343.                             if("inRequest".equalsIgnoreCase(phase) || "in-request".equalsIgnoreCase(phase) || "requestIn".equalsIgnoreCase(phase) || "request-in".equalsIgnoreCase(phase)) {
  344.                                 topic.addFaseTracciamento(FaseTracciamento.IN_REQUEST);
  345.                             }
  346.                             else if("outRequest".equalsIgnoreCase(phase) || "out-request".equalsIgnoreCase(phase) || "requestOut".equalsIgnoreCase(phase) || "request-out".equalsIgnoreCase(phase)) {
  347.                                 topic.addFaseTracciamento(FaseTracciamento.OUT_REQUEST);
  348.                             }
  349.                             else if("outResponse".equalsIgnoreCase(phase) || "out-response".equalsIgnoreCase(phase) || "responseOut".equalsIgnoreCase(phase) || "response-out".equalsIgnoreCase(phase)) {
  350.                                 topic.addFaseTracciamento(FaseTracciamento.OUT_RESPONSE);
  351.                             }
  352.                             else if("postOutResponse".equalsIgnoreCase(phase) || "post-out-response".equalsIgnoreCase(phase) || "postResponseOut".equalsIgnoreCase(phase) || "post-response-out".equalsIgnoreCase(phase)) {                             topic.addFaseTracciamento(FaseTracciamento.POST_OUT_RESPONSE);
  353.                                 topic.addFaseTracciamento(FaseTracciamento.POST_OUT_RESPONSE);
  354.                             }
  355.                             else {
  356.                                 throw new UtilsException("Found unknown tracking phase '"+phase+"' in property '"+propertyNameTrackingPhases+"'");
  357.                             }
  358.                         }
  359.                     }
  360.                    
  361.                     String propertyNameCategory = "category.topic."+tipo+"."+nome;
  362.                     String category = getProperty(reader, propertyNameCategory, true);
  363.                     topic.setCategoryName(category);
  364.                     topic.setLog(LoggerWrapperFactory.getLogger(category));
  365.                    
  366.                     String propertyNameFormat = "format.topic."+tipo+"."+nome;
  367.                     String format = getProperty(reader, propertyNameFormat, true);
  368.                     topic.setFormat(format);
  369.                    
  370.                     map.put(nome, topic);
  371.                 }
  372.             }
  373.         }
  374.     }
  375.     private List<String> getList(PropertiesReader reader, String propertyName) throws UtilsException {
  376.         List<String> list = new ArrayList<>();      
  377.         String tmp = getProperty(reader, propertyName, false);
  378.         if(tmp!=null && !StringUtils.isEmpty(tmp)) {
  379.             String [] split = tmp.split(",");
  380.             if(split!=null && split.length>0) {
  381.                 for (int i = 0; i < split.length; i++) {
  382.                     String nome = split[i].trim();
  383.                     if(list.contains(nome)) {
  384.                         throw new UtilsException("Found duplicate topic '"+nome+"' in property '"+propertyName+"'");
  385.                     }
  386.                     list.add(nome);
  387.                 }
  388.             }
  389.         }
  390.         return list;
  391.     }
  392.    
  393.     private void readFormatProperties(PropertiesReader reader) throws UtilsException {
  394.         Properties escapeMap = reader.readProperties("format.escape.");
  395.         if(escapeMap!=null && !escapeMap.isEmpty()) {
  396.             for (Object s : escapeMap.keySet()) {
  397.                 String key = (String) s;
  398.                 this.escape.put(key, escapeMap.getProperty(key));
  399.             }
  400.         }
  401.        
  402.         List<String> listPosition = new ArrayList<>();
  403.         List<String> listPnames = new ArrayList<>();
  404.                
  405.         String prefixProperty = "format.property.";
  406.         Properties propertiesMap = reader.readProperties(prefixProperty);
  407.         parseProperties(propertiesMap, prefixProperty,
  408.                 listPosition, listPnames,
  409.                 false,
  410.                 reader);
  411.        
  412.         String prefixEncryptedProperty = "format.encryptedProperty.";
  413.         propertiesMap = reader.readProperties(prefixEncryptedProperty);
  414.         parseProperties(propertiesMap, prefixEncryptedProperty,
  415.                 listPosition, listPnames,
  416.                 true,
  417.                 reader);        
  418.        
  419.         Collections.sort(listPosition);
  420.         this.propertiesSortKeys = listPosition;
  421.        
  422.         String tmp = getProperty(reader, "format.headers.separator", false);
  423.         if(tmp!=null) {
  424.             this.headersSeparator = tmp;
  425.         }
  426.        
  427.         tmp = getProperty(reader, "format.headers.header.separator", false);
  428.         if(tmp!=null) {
  429.             this.headerSeparator = tmp;
  430.         }
  431.        
  432.         tmp = getProperty(reader, "format.headers.header.prefix", false);
  433.         if(tmp!=null) {
  434.             this.headerPrefix = tmp;
  435.         }
  436.        
  437.         tmp = getProperty(reader, "format.headers.header.suffix", false);
  438.         if(tmp!=null) {
  439.             this.headerSuffix = tmp;
  440.         }
  441.        
  442.         tmp = getProperty(reader, "format.header.multiValueSeparator", false);
  443.         if(tmp!=null) {
  444.             this.headerMultiValueSeparator = tmp;
  445.         }
  446.        
  447.         tmp = getProperty(reader, "format.header.whiteList", false);
  448.         if(tmp!=null && !"".equals(tmp.trim())) {
  449.             tmp = tmp.trim();
  450.             this.headerWhiteList = new ArrayList<>();
  451.             if(tmp.contains(",")) {
  452.                 String [] split = tmp.split(",");
  453.                 if(split!=null && split.length>0) {
  454.                     for (String s : split) {
  455.                         if(s!=null) {
  456.                             s = s.trim();
  457.                             if(!"".equals(s)) {
  458.                                 this.headerWhiteList.add(s);
  459.                             }
  460.                         }
  461.                     }
  462.                 }
  463.             }
  464.             else {
  465.                 this.headerWhiteList.add(tmp);
  466.             }
  467.         }
  468.        
  469.         tmp = getProperty(reader, "format.header.blackList", false);
  470.         if(tmp!=null && !"".equals(tmp.trim())) {
  471.             tmp = tmp.trim();
  472.             this.headerBlackList = new ArrayList<>();
  473.             if(tmp.contains(",")) {
  474.                 String [] split = tmp.split(",");
  475.                 if(split!=null && split.length>0) {
  476.                     for (String s : split) {
  477.                         if(s!=null) {
  478.                             s = s.trim();
  479.                             if(!"".equals(s)) {
  480.                                 this.headerBlackList.add(s);
  481.                             }
  482.                         }
  483.                     }
  484.                 }
  485.             }
  486.             else {
  487.                 this.headerBlackList.add(tmp);
  488.             }
  489.         }
  490.     }
  491.    
  492.     private void parseProperties(Properties propertiesMap, String prefix,
  493.             List<String> listPosition, List<String> listPnames,
  494.             boolean encrypted,
  495.             PropertiesReader reader) throws UtilsException {
  496.         if(propertiesMap!=null && !propertiesMap.isEmpty()) {
  497.             for (Object s : propertiesMap.keySet()) {
  498.                 String key = (String) s;
  499.                 parseProperty(key, propertiesMap, prefix,
  500.                         listPosition, listPnames,
  501.                         encrypted,
  502.                         reader);
  503.             }
  504.         }
  505.     }
  506.     private void parseProperty(String key, Properties propertiesMap, String prefix,
  507.             List<String> listPosition, List<String> listPnames,
  508.             boolean encrypted,
  509.             PropertiesReader reader) throws UtilsException {
  510.         if(!key.contains(".") || key.length()<3 || key.startsWith(".") || key.endsWith(".")) {
  511.             throw new UtilsException("Format property '"+prefix+""+key+"' wrong (expected: "+prefix+"<intPosition>.<nomeProperty>)");
  512.         }
  513.         String prefixBad = "Bad property '"+prefix+""+key+"'";
  514.        
  515.         int indexOf = key.indexOf(".");
  516.         String pos = key.substring(0, indexOf);
  517.         String nomeP = key.substring(indexOf+1,key.length());
  518.         String posPadded = StringUtils.leftPad(pos, 10, "0");
  519.         if(listPosition.contains(posPadded)) {
  520.             throw new UtilsException(prefixBad+": contains duplicate position '"+pos+"'");
  521.         }
  522.         if(listPnames.contains(nomeP)) {
  523.             throw new UtilsException(prefixBad+". contains duplicate name '"+nomeP+"'");
  524.         }
  525.         listPosition.add(posPadded);
  526.         this.propertiesNames.put(posPadded, nomeP);
  527.         this.propertiesValues.put(posPadded, propertiesMap.getProperty(key));
  528.        
  529.         if(encrypted) {
  530.             parseEncryptedProperty(reader,
  531.                     key, prefixBad, posPadded);
  532.         }
  533.     }
  534.     private void parseEncryptedProperty(PropertiesReader reader,
  535.             String key, String prefixBad, String posPadded) throws UtilsException {
  536.         String modeP = "format.encrypt."+key;
  537.         String mode = reader.getValue_convertEnvProperties(modeP);
  538.         if(this.encryptionMode==null || this.encryptionMode.isEmpty()) {
  539.             throw new UtilsException(prefixBad+": no encryption mode defined");
  540.         }
  541.         if(mode==null || StringUtils.isEmpty(mode.trim())) {
  542.             if(this.encryptionMode.size()==1) {
  543.                 // ce n'รจ solo una definita
  544.                 this.propertiesEncryptionMode.put(posPadded, this.encryptionMode.keySet().iterator().next());
  545.             }
  546.             else {
  547.                 throw new UtilsException(prefixBad+": undefined property '"+modeP+"'");
  548.             }
  549.         }
  550.         else {
  551.             mode = mode.trim();
  552.             if(!this.encryptionMode.containsKey(mode)) {
  553.                 throw new UtilsException(prefixBad+": unknown encryption mode '"+mode+"'");
  554.             }
  555.             this.propertiesEncryptionMode.put(posPadded, mode);
  556.         }
  557.     }
  558.    
  559.     private String getProperty(PropertiesReader reader, String key, boolean required) throws UtilsException {
  560.         String tmp = reader.getValue(key);
  561.         if(tmp==null) {
  562.             if(required) {
  563.                 throw new UtilsException("Property '"+key+"' not found");
  564.             }
  565.             return null;
  566.         }
  567.         else {
  568.             tmp = tmp.trim();
  569.             return tmp;
  570.         }
  571.     }
  572.    
  573.     public LogSeverity getLogSeverity() {
  574.         return this.logSeverity;
  575.     }
  576.    
  577.     public Map<String, String> getEscape() {
  578.         return this.escape;
  579.     }
  580.    
  581.     public String getHeadersSeparator() {
  582.         return this.headersSeparator;
  583.     }
  584.     public String getHeaderSeparator() {
  585.         return this.headerSeparator;
  586.     }
  587.     public String getHeaderPrefix() {
  588.         return this.headerPrefix;
  589.     }
  590.     public String getHeaderSuffix() {
  591.         return this.headerSuffix;
  592.     }
  593.     public List<String> getHeaderBlackList() {
  594.         return this.headerBlackList;
  595.     }
  596.     public List<String> getHeaderWhiteList() {
  597.         return this.headerWhiteList;
  598.     }
  599.    
  600.     public String getHeaderMultiValueSeparator() {
  601.         return this.headerMultiValueSeparator;
  602.     }
  603.    
  604.     public List<String> getPropertiesSortKeys() {
  605.         return this.propertiesSortKeys;
  606.     }
  607.     public Map<String, String> getPropertiesNames() {
  608.         return this.propertiesNames;
  609.     }
  610.     public Map<String, String> getPropertiesValues() {
  611.         return this.propertiesValues;
  612.     }
  613.     public Map<String, String> getPropertiesEncryptionMode() {
  614.         return this.propertiesEncryptionMode;
  615.     }
  616.    
  617.     public Map<String, FileTraceEncryptConfig> getEncryptionMode() {
  618.         return this.encryptionMode;
  619.     }
  620.    
  621.     public List<String> getTopicErogazioni() {
  622.         return this.topicErogazioni;
  623.     }
  624.     public Map<String, Topic> getTopicErogazioniMap() {
  625.         return this.topicErogazioniMap;
  626.     }
  627.     public List<String> getTopicFruizioni() {
  628.         return this.topicFruizioni;
  629.     }
  630.     public Map<String, Topic> getTopicFruizioneMap() {
  631.         return this.topicFruizioneMap;
  632.     }
  633.    
  634.     public boolean isGlobale() {
  635.         return this.globale;
  636.     }
  637. }