use of org.springframework.core.io.VfsResource in project cas by apereo.
the class CasVersion method getDateTime.
/**
* Gets last modified date/time for the module.
* @return the date/time
*/
public static ZonedDateTime getDateTime() {
try {
final Class clazz = CasVersion.class;
final URL resource = clazz.getResource(clazz.getSimpleName() + ".class");
if ("file".equals(resource.getProtocol())) {
return DateTimeUtils.zonedDateTimeOf(new File(resource.toURI()).lastModified());
}
if ("jar".equals(resource.getProtocol())) {
final String path = resource.getPath();
final File file = new File(path.substring(5, path.indexOf('!')));
return DateTimeUtils.zonedDateTimeOf(file.lastModified());
}
if ("vfs".equals(resource.getProtocol())) {
final File file = new VfsResource(resource.openConnection().getContent()).getFile();
return DateTimeUtils.zonedDateTimeOf(file.lastModified());
}
LOGGER.warn("Unhandled url protocol: [{}] resource: [{}]", resource.getProtocol(), resource);
return ZonedDateTime.now();
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
Aggregations