[Swift-commit] r8329 - branches/release-0.95/src/org/griphyn/vdl/karajan/lib

hategan at ci.uchicago.edu hategan at ci.uchicago.edu
Thu Dec 11 13:23:27 CST 2014


Author: hategan
Date: 2014-12-11 13:23:26 -0600 (Thu, 11 Dec 2014)
New Revision: 8329

Modified:
   branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java
Log:
allow environment variables in sites.xml and check if environment variables or system properties exist when doing substitution

Modified: branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java
===================================================================
--- branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java	2014-12-11 19:21:36 UTC (rev 8328)
+++ branches/release-0.95/src/org/griphyn/vdl/karajan/lib/SiteCatalog.java	2014-12-11 19:23:26 UTC (rev 8329)
@@ -336,7 +336,13 @@
                     break;
                 case '}':
                     if (li != -1) {
-                        sb.append(System.getProperty(v.substring(li + 1, i)));
+                        String propName = v.substring(li + 1, i);
+                        if (propName.startsWith("env.")) {
+                            sb.append(getEnv(propName.substring(4)));
+                        }
+                        else {
+                            sb.append(getSystemProperty(propName));
+                        }
                         li = -1;
                     }
                     else {
@@ -351,4 +357,24 @@
         }
         return sb.toString();
     }
+
+    private String getEnv(String name) {
+        String value = System.getenv(name);
+        if (value == null) {
+            throw new IllegalArgumentException("No such environment variable: '" + name + "'");
+        }
+        else {
+            return value;
+        }
+    }
+
+    private String getSystemProperty(String propName) {
+        String value = System.getProperty(propName);
+        if (value == null) {
+            throw new IllegalArgumentException("No such system property: '" + propName + "'");
+        }
+        else {
+            return value;
+        }
+    }
 }




More information about the Swift-commit mailing list