[utilities COMMIT] in /spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config: DurationPropertyEditor...

noreply at shibboleth.net noreply at shibboleth.net
Mon Feb 17 11:11:26 EST 2014


Author: scantor
Date: Mon Feb 17 11:11:25 2014
New Revision: 532

URL: http://svn.shibboleth.net/view/utilities?rev=532&view=rev
Log:
Fall back to Long conversions for non-Duration strings.

Modified:
    spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationPropertyEditor.java
    spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationToLongConverter.java

Modified: spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationPropertyEditor.java
URL: http://svn.shibboleth.net/view/utilities/spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationPropertyEditor.java?rev=532&r1=531&r2=532&view=diff
==============================================================================
--- spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationPropertyEditor.java (original)
+++ spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationPropertyEditor.java Mon Feb 17 11:11:25 2014
@@ -32,10 +32,10 @@
 
         if (text.startsWith("P")) {
             setValue(DomTypeSupport.getDataTypeFactory().newDuration(text));
-        } else if (text.startsWith("-")) {
+        } else if (text.startsWith("-P")) {
             throw new IllegalArgumentException("Negative durations are not supported");
         } else {
-            throw new IllegalArgumentException("Durations must start with 'P'");
+            setValue(DomTypeSupport.getDataTypeFactory().newDuration(Long.valueOf(text)));
         }
     }    
 }

Modified: spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationToLongConverter.java
URL: http://svn.shibboleth.net/view/utilities/spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationToLongConverter.java?rev=532&r1=531&r2=532&view=diff
==============================================================================
--- spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationToLongConverter.java (original)
+++ spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationToLongConverter.java Mon Feb 17 11:11:25 2014
@@ -34,10 +34,11 @@
     public Long convert(String source) {
         if (source.startsWith("P")) {
             return DomTypeSupport.durationToLong(source);
-        } else if (source.startsWith("-")) {
+        } else if (source.startsWith("-P")) {
             throw new IllegalArgumentException("Negative durations are not supported");
         } else {
-            throw new IllegalArgumentException("Durations must start with 'P'");
+            // Treat as a Long.
+            return Long.valueOf(source);
         }
     }
 



More information about the commits mailing list