[utilities COMMIT] /spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationToLongConverter.java
noreply at shibboleth.net
noreply at shibboleth.net
Thu Mar 26 08:25:26 EDT 2015
Author: rdw
Date: Thu Mar 26 08:25:26 2015
New Revision: 787
URL: http://svn.shibboleth.net/view/utilities?rev=787&view=rev
Log:
IDP-637 Log an INFO level message if people ever specify an integer where they should have specified a duration. Fix the (system) configuration files where this happens and the comments in the properties files where the defaults have therefore changed from 0 to PT0S. Default configuration remains unchanged in function
Modified:
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/DurationToLongConverter.java
URL: http://svn.shibboleth.net/view/utilities/spring-extensions/trunk/src/main/java/net/shibboleth/ext/spring/config/DurationToLongConverter.java?rev=787&r1=786&r2=787&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 Thu Mar 26 08:25:26 2015
@@ -17,34 +17,41 @@
package net.shibboleth.ext.spring.config;
+import net.shibboleth.utilities.java.support.annotation.Duration;
+import net.shibboleth.utilities.java.support.xml.DOMTypeSupport;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.ConditionalConverter;
import org.springframework.core.convert.converter.Converter;
-import net.shibboleth.utilities.java.support.annotation.Duration;
-import net.shibboleth.utilities.java.support.xml.DOMTypeSupport;
-
-
/**
* Allows setting of Duration-valued properties using lexical string form.
*/
-public class DurationToLongConverter implements Converter<String,Long>, ConditionalConverter {
+public class DurationToLongConverter implements Converter<String, Long>, ConditionalConverter {
+
+ /** Logger. */
+ private Logger log = LoggerFactory.getLogger(DurationToLongConverter.class);
/** {@inheritDoc} */
- public Long convert(String source) {
+ @Override public Long convert(String source) {
if (source.startsWith("P")) {
return DOMTypeSupport.durationToLong(source);
} else if (source.startsWith("-P")) {
throw new IllegalArgumentException("Negative durations are not supported");
} else {
- // Treat as a Long.
- return Long.valueOf(source);
+ // Treat as a milliseconds. But note this
+ final long duration = Long.valueOf(source);
+ log.info("Deprecated duration of {} was specified. Use XML duration of {}", source,
+ DOMTypeSupport.longToDuration(duration));
+ return duration;
}
}
/** {@inheritDoc} */
- public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
+ @Override public boolean matches(TypeDescriptor sourceType, TypeDescriptor targetType) {
return targetType.hasAnnotation(Duration.class);
}
-
+
}
More information about the commits
mailing list