Author: bfoster
Date: Thu Mar 31 18:24:46 2011
New Revision: 1087398
URL: http://svn.apache.org/viewvc?rev=1087398&view=rev
Log:
fixed dirstruct xml file parser when replacing global variables in name
attribute for dir and file elements
------------------
OODT-169
Modified:
oodt/trunk/CHANGES.txt
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java
Modified: oodt/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1087398&r1=1087397&r2=1087398&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Thu Mar 31 18:24:46 2011
@@ -4,6 +4,9 @@ Apache OODT Change Log
Release 0.3-SNAPSHOT (in progress)
--------------------------------------------
+* OODT-169 Pushpull dirstruct xml files fail to replace global
+ variables in name attribute for dir and file elements (bfoster)
+
* OODT-166 Ability for puspull to dynamically generate ProductName for a given
mime-type (bfoster)
* OODT-167 ProcessedPageInfo isLastPage fails for case PageNum = 1 and
totalPages = 0 (bfoster)
Modified:
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java
URL:
http://svn.apache.org/viewvc/oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java?rev=1087398&r1=1087397&r2=1087398&view=diff
==============================================================================
---
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java
(original)
+++
oodt/trunk/pushpull/src/main/java/org/apache/oodt/cas/pushpull/filerestrictions/parsers/DirStructXmlParser.java
Thu Mar 31 18:24:46 2011
@@ -136,27 +136,31 @@ public class DirStructXmlParser implemen
private String replaceVariablesAndMethods(String input) {
for (int i = 0; i < input.length(); i++) {
- char c = input.substring(i, i + 1).charAt(0);
+ char c = input.charAt(i);
switch (c) {
case '$':
try {
- if (input.substring(i + 1, i + 2).charAt(0) == '{') {
+ if (input.charAt(i + 1) == '{') {
StringBuffer variable = new StringBuffer("");
- for (int j = i + 1; j < input.length(); j++) {
- char ch = input.substring(j, j + 1).charAt(0);
+ for (int j = i + 2; j < input.length(); j++) {
+ char ch = input.charAt(j);
if ((ch <= 'Z' && ch >= 'A')
- || (ch <= '9' && ch >= '0') || ch == '_')
+ || (ch <= 'z' && ch >= 'a')
+ || (ch <= '9' && ch >= '0')
+ || ch == '_')
variable.append(ch);
else
break;
}
Variable v = GlobalVariables.hashMap.get(variable
.toString());
- input = input.replaceFirst("${" + variable + "}", v
- .toString());
+ if (v == null)
+ throw new Exception("No variable defined with
name '" + variable.toString() + "'");
+ input = input.replaceFirst("\\$\\{" + variable +
"\\}", v.toString());
i = i + v.toString().length();
}
} catch (Exception e) {
+ LOG.log(Level.WARNING, "Failed to replace variable in
'" + input + " for i = '" + i + "' : " + e.getMessage(), e);
}
break;
case '%':