@Test public void testCopyFileWithRename() throws Exception { final StoregateIdProvider fileid = new StoregateIdProvider(session).withCache(cache); final Path room = 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 test = new StoregateTouchFeature(session, fileid).touch(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); final Path copy = new Path(new StoregateDirectoryFeature(session, fileid).mkdir(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), null, new TransferStatus()), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); assertNull(new StoregateCopyFeature(session, fileid).copy(test, copy, new TransferStatus(), new DisabledConnectionCallback()).attributes().getVersionId()); assertTrue(new DefaultFindFeature(session).find(test)); assertTrue(new DefaultFindFeature(session).find(copy)); new StoregateDeleteFeature(session, fileid).delete(Collections.singletonList(room), 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);  }