]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6959: Added support for optional property variables. Property variables with...
authorremillet <remillet@yahoo.com>
Fri, 24 Jun 2016 15:40:12 +0000 (08:40 -0700)
committerremillet <remillet@yahoo.com>
Fri, 24 Jun 2016 15:40:12 +0000 (08:40 -0700)
services/common-api/src/main/java/org/collectionspace/services/common/api/Tools.java

index 7ab0ca009fde3820c3ed533d89370b25e6a2bdb7..52b5ebaebe491f0bc35673976ceb21edc45f26c3 100644 (file)
@@ -120,7 +120,7 @@ public class Tools {
     public static String searchAndReplaceWithQuoteReplacement(String source, String find, String replace){
         Pattern pattern = Pattern.compile(find);
         Matcher matcher = pattern.matcher(source);
-        String output = matcher.replaceAll(matcher.quoteReplacement(replace));
+        String output = matcher.replaceAll(Matcher.quoteReplacement(replace));
         return output;
     }
 
@@ -128,6 +128,7 @@ public class Tools {
     static boolean m_fileSystemIsMac = ":".equals(File.separator);
     
     public final static String FILE_EXTENSION_SEPARATOR = ".";
+       public final static String OPTIONAL_VALUE_SUFFIX = "_OPT";
 
     public static boolean fileSystemIsDOS(){return m_fileSystemIsDOS;}
     public static boolean fileSystemIsMac(){return m_fileSystemIsMac;}
@@ -327,6 +328,14 @@ public class Tools {
                
                return result;
        }
+               
+       static public boolean isOptional(String properyValue) {
+               boolean result = false;
+               
+               result = properyValue.endsWith(OPTIONAL_VALUE_SUFFIX);
+               
+               return result;
+       }
        
        /**
         * Try to find the value of a property variable in the system or JVM environment.  This code substitutes only property values formed
@@ -361,7 +370,11 @@ public class Tools {
 
                        if (result == null || result.isEmpty()) {
                                String errMsg = String.format("Could find neither an environment variable nor a systen variable named '%s'", key);
-                               throw new Exception(errMsg);
+                               if (isOptional(key) == true) {
+                                       System.err.println(errMsg);
+                               } else {
+                                       throw new Exception(errMsg);
+                               }
                        }
                }