@Test(expected = BackgroundException.class) public void testMoveLargeObjectToDifferentBucket() throws Exception { final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); container.attributes().setRegion("IAD"); final Path originFolder = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)); final Path sourceFile = new Path(originFolder, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final SwiftRegionService regionService = new SwiftRegionService(session); final SwiftSegmentService segmentService = new SwiftSegmentService(session, ".segments-test/"); prepareFile(sourceFile, regionService, segmentService); final SwiftFindFeature findFeature = new SwiftFindFeature(session); assertTrue(findFeature.find(sourceFile)); final List<Path> sourceSegments = segmentService.list(sourceFile); final Path targetBucket = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume)); targetBucket.attributes().setRegion("DFW"); final Path targetFolder = new Path(targetBucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)); final Path targetFile = new Path(targetFolder, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final Path movedFile = new SwiftMoveFeature(session, regionService).move(sourceFile, targetFile, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); assertFalse(findFeature.find(sourceFile)); assertTrue(findFeature.find(movedFile)); assertTrue(sourceSegments.stream().noneMatch(p -> { try { return findFeature.find(p); } catch(BackgroundException e) { return false; } })); final List<Path> targetSegments = segmentService.list(targetFile); assertTrue(targetSegments.size() != 0); assertTrue(targetSegments.stream().allMatch(p -> { try { return findFeature.find(p); } catch(BackgroundException e) { return false; } })); new SwiftDeleteFeature(session, segmentService, regionService).delete( Collections.singletonMap(targetFile, new TransferStatus()), new DisabledPasswordCallback(), new Delete.DisabledCallback(), true); assertFalse(findFeature.find(movedFile)); }
@Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { if(containerService.getContainer(file).equals(containerService.getContainer(renamed))) { final Path rename = new SwiftDefaultCopyFeature(session, regionService).copy(file, renamed, new TransferStatus().length(file.attributes().getSize()), connectionCallback); new SwiftDeleteFeature(session).delete(Collections.singletonMap(file, status), connectionCallback, callback, false); return rename; } else { final Path copy = new SwiftSegmentCopyService(session, regionService).copy(file, renamed, new TransferStatus().length(file.attributes().getSize()), connectionCallback); new SwiftDeleteFeature(session).delete(Collections.singletonMap(file, status), connectionCallback, callback); return copy; } }
SwiftMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { if(containerService.getContainer(file).equals(containerService.getContainer(renamed))) { final Path rename = new SwiftDefaultCopyFeature(session, regionService).copy(file, renamed, new TransferStatus().length(file.attributes().getSize()), connectionCallback); new SwiftDeleteFeature(session).delete(Collections.singletonMap(file, status), connectionCallback, callback, false); return rename; } else { final Path copy = new SwiftSegmentCopyService(session, regionService).copy(file, renamed, new TransferStatus().length(file.attributes().getSize()), connectionCallback); new SwiftDeleteFeature(session).delete(Collections.singletonMap(file, status), connectionCallback, callback); return copy; } } }
SwiftMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { if(containerService.getContainer(file).equals(containerService.getContainer(renamed))) { final Path rename = new SwiftDefaultCopyFeature(session, regionService).copy(file, renamed, new TransferStatus().length(file.attributes().getSize()), connectionCallback); new SwiftDeleteFeature(session).delete(Collections.singletonMap(file, status), connectionCallback, callback, false); return rename; } else { final Path copy = new SwiftSegmentCopyService(session, regionService).copy(file, renamed, new TransferStatus().length(file.attributes().getSize()), connectionCallback); new SwiftDeleteFeature(session).delete(Collections.singletonMap(file, status), connectionCallback, callback); return copy; } } SwiftMoveFeature(final SwiftSession session);  SwiftMoveFeature(final SwiftSession session, final SwiftRegionService regionService); }
SwiftMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { if(containerService.getContainer(file).equals(containerService.getContainer(renamed))) { final Path rename = new SwiftDefaultCopyFeature(session, regionService).copy(file, renamed, new TransferStatus().length(file.attributes().getSize()), connectionCallback); new SwiftDeleteFeature(session).delete(Collections.singletonMap(file, status), connectionCallback, callback, false); return rename; } else { final Path copy = new SwiftSegmentCopyService(session, regionService).copy(file, renamed, new TransferStatus().length(file.attributes().getSize()), connectionCallback); new SwiftDeleteFeature(session).delete(Collections.singletonMap(file, status), connectionCallback, callback); return copy; } } SwiftMoveFeature(final SwiftSession session);  SwiftMoveFeature(final SwiftSession session, final SwiftRegionService regionService); @Override Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback); @Override boolean isSupported(final Path source, final Path target); }
SwiftMoveFeature implements Move { @Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { if(containerService.getContainer(file).equals(containerService.getContainer(renamed))) { final Path rename = new SwiftDefaultCopyFeature(session, regionService).copy(file, renamed, new TransferStatus().length(file.attributes().getSize()), connectionCallback); new SwiftDeleteFeature(session).delete(Collections.singletonMap(file, status), connectionCallback, callback, false); return rename; } else { final Path copy = new SwiftSegmentCopyService(session, regionService).copy(file, renamed, new TransferStatus().length(file.attributes().getSize()), connectionCallback); new SwiftDeleteFeature(session).delete(Collections.singletonMap(file, status), connectionCallback, callback); return copy; } } SwiftMoveFeature(final SwiftSession session);  SwiftMoveFeature(final SwiftSession session, final SwiftRegionService regionService); @Override Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback); @Override boolean isSupported(final Path source, final Path target);  }