public PathAttributes withVersionId(final String versionId) { this.setVersionId(versionId); return this; }
protected String set(final Path file, final String id) { file.attributes().setVersionId(id); return id; }
protected String set(final Path file, final String id) { file.attributes().setVersionId(id); return id; }
protected String set(final Path file, final String id) { file.attributes().setVersionId(id); return id; }
protected String set(final Path file, final String id) { file.attributes().setVersionId(id); return id; }
protected PathAttributes toAttributes(final B2FileResponse response) { final PathAttributes attributes = new PathAttributes(); attributes.setSize(response.getContentLength()); if(response.getFileInfo().containsKey(X_BZ_INFO_LARGE_FILE_SHA1)) { attributes.setChecksum(Checksum.parse(response.getFileInfo().get(X_BZ_INFO_LARGE_FILE_SHA1))); } else { attributes.setChecksum(Checksum.parse(StringUtils.removeStart(StringUtils.lowerCase(response.getContentSha1(), Locale.ROOT), "unverified:"))); } final Map<String, String> metadata = new HashMap<>(); for(Map.Entry<String, String> entry : response.getFileInfo().entrySet()) { metadata.put(entry.getKey(), entry.getValue()); } attributes.setMetadata(metadata); attributes.setVersionId(response.getFileId()); if(response.getFileInfo().containsKey(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS)) { attributes.setModificationDate(Long.valueOf(response.getFileInfo().get(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS))); } return attributes; }
protected final AttributedList<Path> iterate(final Iterator<OneDriveDrive.Metadata> iterator, final Path directory, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> children = new AttributedList<>(); while(iterator.hasNext()) { final OneDriveDrive.Metadata metadata; try { metadata = iterator.next(); } catch(OneDriveRuntimeException e) { log.warn(e.getMessage()); continue; } final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(metadata.getId()); attributes.setSize(metadata.getTotal()); String name = metadata.getName(); if(StringUtils.isBlank(metadata.getName())) { name = metadata.getId(); } children.add(new Path(directory, name, EnumSet.of(Path.Type.directory, Path.Type.volume), attributes)); listener.chunk(directory, children); } return children; }
public PathAttributes toAttributes(final Node node) throws BackgroundException { final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(String.valueOf(node.getId())); attributes.setRevision(node.getBranchVersion()); attributes.setChecksum(Checksum.parse(node.getHash())); attributes.setCreationDate(node.getCreatedAt() != null ? node.getCreatedAt().getMillis() : -1L); attributes.setModificationDate(node.getUpdatedAt() != null ? node.getUpdatedAt().getMillis() : -1L); attributes.setSize(node.getSize()); attributes.setPermission(this.toPermission(node)); attributes.setAcl(this.toAcl(node)); final Map<String, String> custom = new HashMap<>(); if(null != node.getCntDownloadShares()) { custom.put(SDSAttributesFinderFeature.KEY_CNT_DOWNLOADSHARES, String.valueOf(node.getCntDownloadShares())); } if(null != node.getCntUploadShares()) { custom.put(SDSAttributesFinderFeature.KEY_CNT_UPLOADSHARES, String.valueOf(node.getCntUploadShares())); } custom.put(SDSAttributesFinderFeature.KEY_ENCRYPTED, String.valueOf(node.getIsEncrypted())); attributes.setCustom(custom); return attributes; }
final OneDriveRemoteItem.Metadata remoteMetadata = (OneDriveRemoteItem.Metadata) metadata; final OneDriveItem.Metadata originMetadata = remoteMetadata.getRemoteItem(); attributes.setVersionId(String.join(String.valueOf(Path.DELIMITER), metadata.getParentReference().getDriveId(), metadata.getId(), originMetadata.getParentReference().getDriveId(), originMetadata.getId())); attributes.setVersionId(String.join(String.valueOf(Path.DELIMITER), metadata.getParentReference().getDriveId(), metadata.getId()));
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { final AttributedList<Path> children = new AttributedList<>(); final GroupsIterator groupsIterator = new GroupsIterator(session.getClient()); while(groupsIterator.hasNext()) { final GroupItem.Metadata metadata; try { metadata = groupsIterator.next(); } catch(OneDriveRuntimeException e) { log.warn(e.getMessage()); continue; } final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(metadata.getId()); children.add(new Path(directory, metadata.getDisplayName(), EnumSet.of(Path.Type.directory, Path.Type.volume), attributes)); listener.chunk(directory, children); } return children; }
/** * @param response List filenames response from server * @return Null when respone filename is not child of working directory directory */ protected PathAttributes parse(final B2FileInfoResponse response) { final PathAttributes attributes = new PathAttributes(); attributes.setChecksum( Checksum.parse(StringUtils.removeStart(StringUtils.lowerCase(response.getContentSha1(), Locale.ROOT), "unverified:")) ); final long timestamp = response.getUploadTimestamp(); if(response.getFileInfo().containsKey(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS)) { attributes.setModificationDate(Long.valueOf(response.getFileInfo().get(X_BZ_INFO_SRC_LAST_MODIFIED_MILLIS))); } else { attributes.setModificationDate(timestamp); } attributes.setVersionId(response.getFileId()); switch(response.getAction()) { case hide: // File version marking the file as hidden, so that it will not show up in b2_list_file_names case start: // Large file has been started, but not finished or canceled attributes.setDuplicate(true); attributes.setSize(-1L); break; default: attributes.setSize(response.getSize()); } return attributes; }
attributes.setVersionId(f.getId()); if(f.getModifiedTime() != null) { attributes.setModificationDate(f.getModifiedTime().getValue());
final BaseVersionOrDeleteMarker version = versions.getItems()[0]; if(version.getKey().equals(common)) { attributes.setVersionId("null".equals(version.getVersionId()) ? null : version.getVersionId()); if(version.isDeleteMarker()) { attributes.setCustom(ImmutableMap.of(KEY_DELETE_MARKER, Boolean.TRUE.toString()));
for(MultipartUpload upload : new S3DefaultMultipartService(session).find(directory)) { final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(upload.getUploadId()); attributes.setModificationDate(upload.getInitiatedDate().getTime()); objects.add(new Path(directory, upload.getObjectKey(), EnumSet.of(Path.Type.file, Path.Type.upload), attributes));
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { final String directoryId = random.random(); final Path encrypt = vault.encrypt(session, folder, directoryId, false); // Create metadata file for directory final Path directoryMetadataFile = vault.encrypt(session, folder, true); if(log.isDebugEnabled()) { log.debug(String.format("Write metadata %s for folder %s", directoryMetadataFile, folder)); } new ContentWriter(session).write(directoryMetadataFile, directoryId.getBytes(Charset.forName("UTF-8"))); final Path intermediate = encrypt.getParent(); if(!session._getFeature(Find.class).find(intermediate)) { session._getFeature(Directory.class).mkdir(intermediate, region, new TransferStatus()); } // Write header final Cryptor cryptor = vault.getCryptor(); final FileHeader header = cryptor.fileHeaderCryptor().create(); status.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header)); status.setNonces(new RandomNonceGenerator()); final Path target = proxy.mkdir(encrypt, region, status); // Implementation may return new copy of attributes without encryption attributes target.attributes().setDirectoryId(directoryId); target.attributes().setDecrypted(encrypt.attributes().getDecrypted()); // Make reference of encrypted path in attributes of decrypted file point to metadata file final Path decrypt = vault.decrypt(session, vault.encrypt(session, target, true)); decrypt.attributes().setVersionId(target.attributes().getVersionId()); return decrypt; }
attributes.setVersionId(dict.stringForKey("Version")); final String duplicateObj = dict.stringForKey("Duplicate"); if(duplicateObj != null) {
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(source.isFile() || source.isPlaceholder()) { if(null == status.getStorageClass()) { // Keep same storage class status.setStorageClass(new S3StorageClassFeature(session).getClass(source)); } if(Encryption.Algorithm.NONE == status.getEncryption()) { // Keep encryption setting status.setEncryption(new S3EncryptionFeature(session).getEncryption(source)); } if(Acl.EMPTY == status.getAcl()) { // Apply non standard ACL try { status.setAcl(accessControlListFeature.getPermission(source)); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure %s", e.getDetail())); } } final S3Object destination = new S3WriteFeature(session).getDetails(target, status); destination.setAcl(accessControlListFeature.convert(status.getAcl())); destination.setBucketName(containerService.getContainer(target).getName()); destination.replaceAllMetadata(new HashMap<String, Object>(new S3MetadataFeature(session, accessControlListFeature).getMetadata(source))); final String version = this.copy(source, destination, status); target.attributes().setVersionId(version); } return target; }
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final OneDriveCopyOperation copyOperation = new OneDriveCopyOperation(); if(!StringUtils.equals(source.getName(), target.getName())) { copyOperation.rename(target.getName()); } if(status.isExists()) { new GraphDeleteFeature(session).delete(Collections.singletonList(target), callback, new Delete.DisabledCallback()); } final OneDriveFolder targetItem = session.toFolder(target.getParent()); copyOperation.copy(targetItem); final OneDriveItem item = session.toItem(source); try { item.copy(copyOperation).await(statusObject -> logger.info(String.format("Copy Progress Operation %s progress %f status %s", statusObject.getOperation(), statusObject.getPercentage(), statusObject.getStatus()))); target.attributes().setVersionId(null); return new Path(target.getParent(), target.getName(), target.getType(), new GraphAttributesFinderFeature(session).find(target)); } catch(OneDriveAPIException e) { throw new GraphExceptionMappingService().map("Cannot copy {0}", e, source); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot copy {0}", e, source); } }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try { final AttributedList<Path> buckets = new AttributedList<Path>(); for(B2BucketResponse bucket : session.getClient().listBuckets()) { final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(bucket.getBucketId()); switch(bucket.getBucketType()) { case allPublic: attributes.setAcl(new Acl(new Acl.GroupUser(Acl.GroupUser.EVERYONE, false), new Acl.Role(Acl.Role.READ))); break; } buckets.add(new Path(PathNormalizer.normalize(bucket.getBucketName()), EnumSet.of(Path.Type.directory, Path.Type.volume), attributes)); } listener.chunk(directory, buckets); return buckets; } catch(B2ApiException e) { throw new B2ExceptionMappingService().map("Listing directory {0} failed", e, directory); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
delete.delete(Collections.singletonList(renamed), connectionCallback, callback); renamed.attributes().setVersionId(null);