@Test public void testCopyFile() throws Exception { final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final TransferStatus status = new TransferStatus(); status.setMetadata(Collections.singletonMap("cyberduck", "m")); final Path test = new S3TouchFeature(session).touch(new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)), status); final Path copy = new S3CopyFeature(session, new S3AccessControlListFeature(session)).copy(test, new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus(), new DisabledConnectionCallback()); assertTrue(new S3FindFeature(session).find(test)); assertEquals("m", new S3MetadataFeature(session, new S3AccessControlListFeature(session)).getMetadata(copy).get("cyberduck")); new S3DefaultDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); assertTrue(new S3FindFeature(session).find(copy)); new S3DefaultDeleteFeature(session).delete(Collections.singletonList(copy), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(null == status.getStorageClass()) { status.setStorageClass(new S3StorageClassFeature(session).getClass(source)); } if(Encryption.Algorithm.NONE == status.getEncryption()) { status.setEncryption(new S3EncryptionFeature(session).getEncryption(source)); } if(Acl.EMPTY == status.getAcl()) { try { status.setAcl(accessControlListFeature.getPermission(source)); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure %s", e)); } } 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; }
S3CopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(null == status.getStorageClass()) { status.setStorageClass(new S3StorageClassFeature(session).getClass(source)); } if(Encryption.Algorithm.NONE == status.getEncryption()) { status.setEncryption(new S3EncryptionFeature(session).getEncryption(source)); } if(Acl.EMPTY == status.getAcl()) { try { status.setAcl(accessControlListFeature.getPermission(source)); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure %s", e)); } } 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; } }
S3CopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(null == status.getStorageClass()) { status.setStorageClass(new S3StorageClassFeature(session).getClass(source)); } if(Encryption.Algorithm.NONE == status.getEncryption()) { status.setEncryption(new S3EncryptionFeature(session).getEncryption(source)); } if(Acl.EMPTY == status.getAcl()) { try { status.setAcl(accessControlListFeature.getPermission(source)); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure %s", e)); } } 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; } S3CopyFeature(final S3Session session);  S3CopyFeature(final S3Session session, final S3AccessControlListFeature accessControlListFeature); }
S3CopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(null == status.getStorageClass()) { status.setStorageClass(new S3StorageClassFeature(session).getClass(source)); } if(Encryption.Algorithm.NONE == status.getEncryption()) { status.setEncryption(new S3EncryptionFeature(session).getEncryption(source)); } if(Acl.EMPTY == status.getAcl()) { try { status.setAcl(accessControlListFeature.getPermission(source)); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure %s", e)); } } 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; } S3CopyFeature(final S3Session session);  S3CopyFeature(final S3Session session, final S3AccessControlListFeature accessControlListFeature); @Override Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback); @Override boolean isSupported(final Path source, final Path target); }
S3CopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { if(null == status.getStorageClass()) { status.setStorageClass(new S3StorageClassFeature(session).getClass(source)); } if(Encryption.Algorithm.NONE == status.getEncryption()) { status.setEncryption(new S3EncryptionFeature(session).getEncryption(source)); } if(Acl.EMPTY == status.getAcl()) { try { status.setAcl(accessControlListFeature.getPermission(source)); } catch(AccessDeniedException | InteroperabilityException e) { log.warn(String.format("Ignore failure %s", e)); } } 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; } S3CopyFeature(final S3Session session);  S3CopyFeature(final S3Session session, final S3AccessControlListFeature accessControlListFeature); @Override Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback); @Override boolean isSupported(final Path source, final Path target);  }