@Test public void testCopyWithRenameToExistingFile() throws Exception { final StoregateIdProvider fileid = new StoregateIdProvider(session).withCache(cache); final Path top = new StoregateDirectoryFeature(session, fileid).mkdir(new Path( String.format("/My files/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory, Path.Type.volume, Path.Type.triplecrypt)), null, new TransferStatus()); final Path folder = new Path(top, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); new StoregateDirectoryFeature(session, fileid).mkdir(folder, null, new TransferStatus()); final Path test = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); new StoregateTouchFeature(session, fileid).touch(test, new TransferStatus()); final Path test2 = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); new StoregateTouchFeature(session, fileid).touch(test2, new TransferStatus()); assertNull(new StoregateCopyFeature(session, fileid).copy(test, test2, new TransferStatus().exists(true), new DisabledConnectionCallback()).attributes().getVersionId()); final Find find = new DefaultFindFeature(session); final AttributedList<Path> files = new StoregateListService(session, fileid).list(folder, new DisabledListProgressListener()); assertTrue(find.find(test)); assertTrue(find.find(test2)); new StoregateDeleteFeature(session, fileid).delete(Collections.singletonList(top), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final CopyFileRequest copy = new CopyFileRequest() .name(target.getName()) .parentID(fileid.getFileid(target.getParent(), new DisabledListProgressListener())) .mode(1); final File file = new FilesApi(session.getClient()).filesCopy( fileid.getFileid(source, new DisabledListProgressListener()), copy); return new Path(target.getParent(), target.getName(), target.getType(), new StoregateAttributesFinderFeature(session, fileid).toAttributes(file)); } catch(ApiException e) { throw new StoregateExceptionMappingService().map("Cannot copy {0}", e, source); } }
StoregateCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final CopyFileRequest copy = new CopyFileRequest() .name(target.getName()) .parentID(fileid.getFileid(target.getParent(), new DisabledListProgressListener())) .mode(1); final File file = new FilesApi(session.getClient()).filesCopy( fileid.getFileid(source, new DisabledListProgressListener()), copy); return new Path(target.getParent(), target.getName(), target.getType(), new StoregateAttributesFinderFeature(session, fileid).toAttributes(file)); } catch(ApiException e) { throw new StoregateExceptionMappingService().map("Cannot copy {0}", e, source); } } }
StoregateCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final CopyFileRequest copy = new CopyFileRequest() .name(target.getName()) .parentID(fileid.getFileid(target.getParent(), new DisabledListProgressListener())) .mode(1); final File file = new FilesApi(session.getClient()).filesCopy( fileid.getFileid(source, new DisabledListProgressListener()), copy); return new Path(target.getParent(), target.getName(), target.getType(), new StoregateAttributesFinderFeature(session, fileid).toAttributes(file)); } catch(ApiException e) { throw new StoregateExceptionMappingService().map("Cannot copy {0}", e, source); } } StoregateCopyFeature(final StoregateSession session, final StoregateIdProvider fileid); }
StoregateCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final CopyFileRequest copy = new CopyFileRequest() .name(target.getName()) .parentID(fileid.getFileid(target.getParent(), new DisabledListProgressListener())) .mode(1); final File file = new FilesApi(session.getClient()).filesCopy( fileid.getFileid(source, new DisabledListProgressListener()), copy); return new Path(target.getParent(), target.getName(), target.getType(), new StoregateAttributesFinderFeature(session, fileid).toAttributes(file)); } catch(ApiException e) { throw new StoregateExceptionMappingService().map("Cannot copy {0}", e, source); } } StoregateCopyFeature(final StoregateSession session, final StoregateIdProvider fileid); @Override Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback); @Override boolean isSupported(final Path source, final Path target); @Override boolean isRecursive(final Path source, final Path target); }
StoregateCopyFeature implements Copy { @Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { final CopyFileRequest copy = new CopyFileRequest() .name(target.getName()) .parentID(fileid.getFileid(target.getParent(), new DisabledListProgressListener())) .mode(1); final File file = new FilesApi(session.getClient()).filesCopy( fileid.getFileid(source, new DisabledListProgressListener()), copy); return new Path(target.getParent(), target.getName(), target.getType(), new StoregateAttributesFinderFeature(session, fileid).toAttributes(file)); } catch(ApiException e) { throw new StoregateExceptionMappingService().map("Cannot copy {0}", e, source); } } StoregateCopyFeature(final StoregateSession session, final StoregateIdProvider fileid); @Override Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback); @Override boolean isSupported(final Path source, final Path target); @Override boolean isRecursive(final Path source, final Path target);  }