# HG changeset patch
# User Asier Lostalé <asier.lostale@openbravo.com>
# Date 1458631422 -3600
#      Tue Mar 22 08:23:42 2016 +0100
# Node ID a97e5a9808be6ffb91bf954e9d6b0172fce86797
# Parent  e58cbd8a7f8cf059d158caf25b586aafec8b42ff
fixed 32519: Openbravo.properties can be overriden from an absolute path

  It is now possible to override some properties by defining an abosolute path
  to a properties file through properties.path system property.

diff -r e58cbd8a7f8c -r a97e5a9808be src-core/src/org/openbravo/base/ConfigParameters.java
--- a/src-core/src/org/openbravo/base/ConfigParameters.java	Mon Mar 21 09:26:05 2016 +0100
+++ b/src-core/src/org/openbravo/base/ConfigParameters.java	Tue Mar 22 08:23:42 2016 +0100
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2001-2015 Openbravo S.L.U.
+ * Copyright (C) 2001-2016 Openbravo S.L.U.
  * Licensed under the Apache Software License version 2.0
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  * Unless required by applicable law or agreed to  in writing,  software  distributed
@@ -351,24 +351,33 @@
       return;
     }
 
-    String fileName = System.getProperty("machine.name");
-    if (fileName == null || fileName.isEmpty()) {
-      try {
-        fileName = InetAddress.getLocalHost().getHostName();
-        log4j.info("Checking override properties for " + fileName);
-      } catch (UnknownHostException e) {
-        log4j.error("Error when getting host name", e);
+    String absPath = System.getProperty("properties.path");
+    File propertiesFile = null;
+
+    if (absPath != null && !absPath.isEmpty()) {
+      propertiesFile = new File(absPath);
+      log4j.info("Looking for override properties file in " + absPath + ". Found: "
+          + propertiesFile.exists());
+    } else {
+      String fileName = System.getProperty("machine.name");
+      if (fileName == null || fileName.isEmpty()) {
+        try {
+          fileName = InetAddress.getLocalHost().getHostName();
+          log4j.info("Checking override properties for " + fileName);
+        } catch (UnknownHostException e) {
+          log4j.error("Error when getting host name", e);
+        }
       }
+
+      if (fileName == null || fileName.isEmpty()) {
+        log4j.debug("Override fileName env variable is not defined.");
+        return;
+      }
+
+      fileName += ".Openbravo.properties";
+      propertiesFile = new File(propFilePath, fileName);
     }
 
-    if (fileName == null || fileName.isEmpty()) {
-      log4j.debug("Override fileName env variable is not defined.");
-      return;
-    }
-
-    fileName += ".Openbravo.properties";
-    File propertiesFile = null;
-    propertiesFile = new File(propFilePath, fileName);
     if (!propertiesFile.exists()) {
       log4j.debug("No override file can be found at " + propertiesFile.getAbsolutePath());
       return;
