Author: challngr Date: Tue Feb 26 18:08:09 2013 New Revision: 1450316 URL: http://svn.apache.org/r1450316 Log: UIMA-2686 Fix thinkos parsing the resource string, sigh.
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccProperties.java uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/Utils.java Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccProperties.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccProperties.java?rev=1450316&r1=1450315&r2=1450316&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccProperties.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/DuccProperties.java Tue Feb 26 18:08:09 2013 @@ -186,11 +186,11 @@ public class DuccProperties extends Prop if ( val == null ) return null; if ( val.contains("${") ) { - val = Utils.resolvePlaceholderIfExists(val, this); + val = Utils.resolvePlaceholders(val, this); } if ( val.contains("${") ) { - val = Utils.resolvePlaceholderIfExists(val, System.getProperties()); + val = Utils.resolvePlaceholders(val, System.getProperties()); } return val; @@ -228,7 +228,7 @@ public class DuccProperties extends Prop String configDir = null; //System.out.println("Ducc Component Loading Configuration from Properties File:" // + agentPropertyFile); - agentPropertyFile = Utils.resolvePlaceholderIfExists(agentPropertyFile, System.getProperties()); + agentPropertyFile = Utils.resolvePlaceholders(agentPropertyFile, System.getProperties()); FileInputStream fis = new FileInputStream(agentPropertyFile); super.load(fis); fis.close(); Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/Utils.java URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/Utils.java?rev=1450316&r1=1450315&r2=1450316&view=diff ============================================================================== --- uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/Utils.java (original) +++ uima/sandbox/uima-ducc/trunk/uima-ducc-common/src/main/java/org/apache/uima/ducc/common/utils/Utils.java Tue Feb 26 18:08:09 2013 @@ -275,7 +275,7 @@ public class Utils { PropertyPlaceholderHelper pph = new PropertyPlaceholderHelper("${","}"); value = pph.replacePlaceholders(value, props); } - return value; + return value; } /** * Concatenates multiple arrays into one array of type <A> @@ -384,23 +384,28 @@ public class Utils { } String p = res.getFile(); - String[] parts = p.split("/"); + String[] parts = p.split("!"); + p = parts[0]; // The parent must be "lib", and "I" must be a jar, if this is to be valid - int last = parts.length - 1; - if ( !parts[last].endsWith(".jar") ) { + if ( !p.endsWith(".jar") ) { throw new IllegalArgumentException("Cannot find or infer DUCC_HOME, Utils is not in a jar."); } - - if ( !parts[last-1].equals(".lib") ) { - throw new IllegalArgumentException("Cannot find or infer DUCC_HOME, Utils is not found in a 'lib' directory."); - } + int ndx = p.lastIndexOf("/"); - ndx = p.lastIndexOf("/", ndx); + ndx = p.lastIndexOf("/", ndx-1); + p = p.substring(0, ndx); System.out.println("res " + res); System.out.println("p " + p); - DUCC_HOME = p.substring(0, ndx); + ndx = p.indexOf(':'); + DUCC_HOME = p.substring(ndx+1); + + File props = new File(DUCC_HOME + "/resources/ducc.properties"); + if ( ! props.exists() ) { + throw new IllegalArgumentException("Cannot find or infer DUCC_HOME, Utils is not in a jar."); + } + System.setProperty("DUCC_HOME", DUCC_HOME); return DUCC_HOME; }