@Test public void testMoveWithServerSideEncryptionBucketPolicy() throws Exception { final Path container = new Path("sse-test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume)); final Path test = new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)); final S3TouchFeature touch = new S3TouchFeature(session); final TransferStatus status = new TransferStatus(); status.setEncryption(S3EncryptionFeature.SSE_AES256); touch.touch(test, status); assertTrue(new S3FindFeature(session).find(test)); final Path renamed = new Path(container, new AsciiRandomStringService().random(), EnumSet.of(Path.Type.file)); new S3MoveFeature(session).move(test, renamed, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); assertFalse(new S3FindFeature(session).find(test)); assertTrue(new S3FindFeature(session).find(renamed)); new S3DefaultDeleteFeature(session).delete(Collections.singletonList(renamed), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public Path move(final Path source, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { Path copy; if(source.attributes().getCustom().containsKey(KEY_DELETE_MARKER)) { copy = new Path(renamed); copy.attributes().setVersionId(null); delete.delete(Collections.singletonMap(copy, status), connectionCallback, callback); try { final VersionOrDeleteMarkersChunk marker = session.getClient().listVersionedObjectsChunked(containerService.getContainer(renamed).getName(), containerService.getKey(renamed), String.valueOf(Path.DELIMITER), 1, null, null, false); if(marker.getItems().length == 1) { final BaseVersionOrDeleteMarker markerObject = marker.getItems()[0]; copy.attributes().withVersionId(markerObject.getVersionId()).setCustom(Collections.singletonMap(KEY_DELETE_MARKER, Boolean.TRUE.toString())); delete.delete(Collections.singletonMap(source, status), connectionCallback, callback); } else { throw new NotfoundException(String.format("Unable to find delete marker %s", renamed.getName())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Failure to read attributes of {0}", e, renamed); } } else { try { copy = new S3ThresholdCopyFeature(session, accessControlListFeature).copy(source, renamed, status.length(source.attributes().getSize()), connectionCallback); delete.delete(Collections.singletonMap(new Path(source).withAttributes(new PathAttributes(source.attributes()).withVersionId(null)), status), connectionCallback, callback); } catch(NotfoundException e) { if(source.getType().contains(Path.Type.placeholder)) { copy = session.getFeature(Directory.class).mkdir(renamed, source.attributes().getRegion(), new TransferStatus()); } else { throw e; } } } return copy; }
S3MoveFeature implements Move { @Override public Path move(final Path source, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { Path copy; if(source.attributes().getCustom().containsKey(KEY_DELETE_MARKER)) { copy = new Path(renamed); copy.attributes().setVersionId(null); delete.delete(Collections.singletonMap(copy, status), connectionCallback, callback); try { final VersionOrDeleteMarkersChunk marker = session.getClient().listVersionedObjectsChunked(containerService.getContainer(renamed).getName(), containerService.getKey(renamed), String.valueOf(Path.DELIMITER), 1, null, null, false); if(marker.getItems().length == 1) { final BaseVersionOrDeleteMarker markerObject = marker.getItems()[0]; copy.attributes().withVersionId(markerObject.getVersionId()).setCustom(Collections.singletonMap(KEY_DELETE_MARKER, Boolean.TRUE.toString())); delete.delete(Collections.singletonMap(source, status), connectionCallback, callback); } else { throw new NotfoundException(String.format("Unable to find delete marker %s", renamed.getName())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Failure to read attributes of {0}", e, renamed); } } else { try { copy = new S3ThresholdCopyFeature(session, accessControlListFeature).copy(source, renamed, status.length(source.attributes().getSize()), connectionCallback); delete.delete(Collections.singletonMap(new Path(source).withAttributes(new PathAttributes(source.attributes()).withVersionId(null)), status), connectionCallback, callback); } catch(NotfoundException e) { if(source.getType().contains(Path.Type.placeholder)) { copy = session.getFeature(Directory.class).mkdir(renamed, source.attributes().getRegion(), new TransferStatus()); } else { throw e; } } } return copy; } }
S3MoveFeature implements Move { @Override public Path move(final Path source, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { Path copy; if(source.attributes().getCustom().containsKey(KEY_DELETE_MARKER)) { copy = new Path(renamed); copy.attributes().setVersionId(null); delete.delete(Collections.singletonMap(copy, status), connectionCallback, callback); try { final VersionOrDeleteMarkersChunk marker = session.getClient().listVersionedObjectsChunked(containerService.getContainer(renamed).getName(), containerService.getKey(renamed), String.valueOf(Path.DELIMITER), 1, null, null, false); if(marker.getItems().length == 1) { final BaseVersionOrDeleteMarker markerObject = marker.getItems()[0]; copy.attributes().withVersionId(markerObject.getVersionId()).setCustom(Collections.singletonMap(KEY_DELETE_MARKER, Boolean.TRUE.toString())); delete.delete(Collections.singletonMap(source, status), connectionCallback, callback); } else { throw new NotfoundException(String.format("Unable to find delete marker %s", renamed.getName())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Failure to read attributes of {0}", e, renamed); } } else { try { copy = new S3ThresholdCopyFeature(session, accessControlListFeature).copy(source, renamed, status.length(source.attributes().getSize()), connectionCallback); delete.delete(Collections.singletonMap(new Path(source).withAttributes(new PathAttributes(source.attributes()).withVersionId(null)), status), connectionCallback, callback); } catch(NotfoundException e) { if(source.getType().contains(Path.Type.placeholder)) { copy = session.getFeature(Directory.class).mkdir(renamed, source.attributes().getRegion(), new TransferStatus()); } else { throw e; } } } return copy; } S3MoveFeature(final S3Session session);  S3MoveFeature(final S3Session session, final S3AccessControlListFeature accessControlListFeature); }
S3MoveFeature implements Move { @Override public Path move(final Path source, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { Path copy; if(source.attributes().getCustom().containsKey(KEY_DELETE_MARKER)) { copy = new Path(renamed); copy.attributes().setVersionId(null); delete.delete(Collections.singletonMap(copy, status), connectionCallback, callback); try { final VersionOrDeleteMarkersChunk marker = session.getClient().listVersionedObjectsChunked(containerService.getContainer(renamed).getName(), containerService.getKey(renamed), String.valueOf(Path.DELIMITER), 1, null, null, false); if(marker.getItems().length == 1) { final BaseVersionOrDeleteMarker markerObject = marker.getItems()[0]; copy.attributes().withVersionId(markerObject.getVersionId()).setCustom(Collections.singletonMap(KEY_DELETE_MARKER, Boolean.TRUE.toString())); delete.delete(Collections.singletonMap(source, status), connectionCallback, callback); } else { throw new NotfoundException(String.format("Unable to find delete marker %s", renamed.getName())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Failure to read attributes of {0}", e, renamed); } } else { try { copy = new S3ThresholdCopyFeature(session, accessControlListFeature).copy(source, renamed, status.length(source.attributes().getSize()), connectionCallback); delete.delete(Collections.singletonMap(new Path(source).withAttributes(new PathAttributes(source.attributes()).withVersionId(null)), status), connectionCallback, callback); } catch(NotfoundException e) { if(source.getType().contains(Path.Type.placeholder)) { copy = session.getFeature(Directory.class).mkdir(renamed, source.attributes().getRegion(), new TransferStatus()); } else { throw e; } } } return copy; } S3MoveFeature(final S3Session session);  S3MoveFeature(final S3Session session, final S3AccessControlListFeature accessControlListFeature); @Override Path move(final Path source, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback); @Override boolean isSupported(final Path source, final Path target); }
S3MoveFeature implements Move { @Override public Path move(final Path source, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { Path copy; if(source.attributes().getCustom().containsKey(KEY_DELETE_MARKER)) { copy = new Path(renamed); copy.attributes().setVersionId(null); delete.delete(Collections.singletonMap(copy, status), connectionCallback, callback); try { final VersionOrDeleteMarkersChunk marker = session.getClient().listVersionedObjectsChunked(containerService.getContainer(renamed).getName(), containerService.getKey(renamed), String.valueOf(Path.DELIMITER), 1, null, null, false); if(marker.getItems().length == 1) { final BaseVersionOrDeleteMarker markerObject = marker.getItems()[0]; copy.attributes().withVersionId(markerObject.getVersionId()).setCustom(Collections.singletonMap(KEY_DELETE_MARKER, Boolean.TRUE.toString())); delete.delete(Collections.singletonMap(source, status), connectionCallback, callback); } else { throw new NotfoundException(String.format("Unable to find delete marker %s", renamed.getName())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Failure to read attributes of {0}", e, renamed); } } else { try { copy = new S3ThresholdCopyFeature(session, accessControlListFeature).copy(source, renamed, status.length(source.attributes().getSize()), connectionCallback); delete.delete(Collections.singletonMap(new Path(source).withAttributes(new PathAttributes(source.attributes()).withVersionId(null)), status), connectionCallback, callback); } catch(NotfoundException e) { if(source.getType().contains(Path.Type.placeholder)) { copy = session.getFeature(Directory.class).mkdir(renamed, source.attributes().getRegion(), new TransferStatus()); } else { throw e; } } } return copy; } S3MoveFeature(final S3Session session);  S3MoveFeature(final S3Session session, final S3AccessControlListFeature accessControlListFeature); @Override Path move(final Path source, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback); @Override boolean isSupported(final Path source, final Path target);  }