use of java.nio.file.attribute.UserDefinedFileAttributeView in project Singularity by HubSpot.
the class SingularityUploader method getFileAttributes.
UploaderFileAttributes getFileAttributes(Path file) {
Set<String> supportedViews = FileSystems.getDefault().supportedFileAttributeViews();
LOG.trace("Supported attribute views are {}", supportedViews);
if (supportedViews.contains("user")) {
try {
UserDefinedFileAttributeView view = Files.getFileAttributeView(file, UserDefinedFileAttributeView.class);
List<String> attributes = view.list();
LOG.debug("Found file attributes {} for file {}", attributes, file);
Optional<Long> maybeStartTime = readFileAttributeAsLong(file, LOG_START_TIME_ATTR, view, attributes);
Optional<Long> maybeEndTime = readFileAttributeAsLong(file, LOG_END_TIME_ATTR, view, attributes);
return new UploaderFileAttributes(maybeStartTime, maybeEndTime);
} catch (Exception e) {
LOG.error("Could not get extra file metadata for {}", file, e);
}
}
return new UploaderFileAttributes(Optional.empty(), Optional.empty());
}
Aggregations