protected PathAttributes toAttributes(final ObjectMetadata metadata) { final PathAttributes attributes = new PathAttributes(); attributes.setSize(Long.valueOf(metadata.getContentLength())); final String lastModified = metadata.getLastModified(); try { attributes.setModificationDate(rfc1123DateFormatter.parse(lastModified).getTime()); } catch(InvalidDateException e) { log.warn(String.format("%s is not RFC 1123 format %s", lastModified, e.getMessage())); } if(StringUtils.isNotBlank(metadata.getETag())) { final String etag = StringUtils.removePattern(metadata.getETag(), "\""); attributes.setETag(etag); if(metadata.getMetaData().containsKey(Constants.X_STATIC_LARGE_OBJECT)) { // For manifest files, the ETag in the response for a GET or HEAD on the manifest file is the MD5 sum of // the concatenated string of ETags for each of the segments in the manifest. attributes.setChecksum(Checksum.NONE); } else { attributes.setChecksum(Checksum.parse(etag)); } } return attributes; } }
attributes.setETag(resource.getEtag());
attributes.setETag(headers.get(HttpHeaders.ETAG));
public PathAttributes toAttributes(final OneDriveItem.Metadata metadata) { final PathAttributes attributes = new PathAttributes(); attributes.setETag(metadata.getETag()); attributes.setSize(metadata.getSize()); if(metadata instanceof OneDriveRemoteItem.Metadata) {
attributes.setETag(object.getETag());
attributes.setSize(object.getSize()); if(StringUtils.isNotBlank(object.getEtag())) { attributes.setETag(object.getEtag());
attributes.setSize(blob.getProperties().getLength()); attributes.setModificationDate(blob.getProperties().getLastModified().getTime()); attributes.setETag(blob.getProperties().getEtag()); if(StringUtils.isNotBlank(blob.getProperties().getContentMD5())) { attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(blob.getProperties().getContentMD5()))));
attributes.setETag(object.getEtag()); final byte[] md5Bytes = object.getMd5Bytes(); if(md5Bytes != null) {
container.downloadAttributes(null, null, context); final BlobContainerProperties properties = container.getProperties(); attributes.setETag(properties.getEtag()); attributes.setModificationDate(properties.getLastModified().getTime()); return attributes; attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(properties.getContentMD5())))); attributes.setETag(properties.getEtag()); return attributes;
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { ResultSegment<CloudBlobContainer> result; ResultContinuation token = null; try { final AttributedList<Path> containers = new AttributedList<Path>(); do { final BlobRequestOptions options = new BlobRequestOptions(); result = session.getClient().listContainersSegmented(null, ContainerListingDetails.NONE, preferences.getInteger("azure.listing.chunksize"), token, options, context); for(CloudBlobContainer container : result.getResults()) { final PathAttributes attributes = new PathAttributes(); attributes.setETag(container.getProperties().getEtag()); attributes.setModificationDate(container.getProperties().getLastModified().getTime()); containers.add(new Path(PathNormalizer.normalize(container.getName()), EnumSet.of(Path.Type.volume, Path.Type.directory), attributes)); } listener.chunk(directory, containers); token = result.getContinuationToken(); } while(result.getHasMoreResults()); return containers; } catch(StorageException e) { throw new AzureExceptionMappingService().map("Listing directory {0} failed", e, directory); } }