@Override public boolean isSupported(final Path source, final Path target) { if(target.isRoot()) { return false; } return !source.getType().contains(Path.Type.placeholder); } }
@Override public boolean isSupported(final Path source, final Path target) { if(target.isRoot()) { return false; } return !source.getType().contains(Path.Type.placeholder); } }
@Override public boolean isContainer(final Path file) { return super.isContainer(file) || file.getType().contains(Path.Type.volume); } }
public CryptoDirectoryProvider(final Path vault, final CryptoVault cryptomator) { this.home = vault; this.dataRoot = new Path(vault, DATA_DIR_NAME, vault.getType()); this.cryptomator = cryptomator; }
public Path find(final Path selected) { if(null == selected) { return workdir; } if(selected.getType().contains(Path.Type.volume)) { return selected; } return selected.getParent(); } }
@Override public void visit(final AttributedList<Path> list, final int index, final Path f) { try { f.getType().add(Path.Type.encrypted); list.set(index, vault.decrypt(session, f)); } catch(BackgroundException e) { log.error(String.format("Failure decrypting %s. %s", f, e.getDetail())); f.getType().remove(Path.Type.encrypted); } }
public Path resolve(final String filename) { // Intermediate directory final Path first = new Path(metadataRoot, filename.substring(0, 2), metadataRoot.getType()); // Intermediate directory final Path second = new Path(first, filename.substring(2, 4), metadataRoot.getType()); return new Path(second, filename, EnumSet.of(Path.Type.file, Path.Type.encrypted, Path.Type.vault)); }
protected void setObjectValueForItem(final Path item, final NSObject value, final String identifier) { if(log.isDebugEnabled()) { log.debug(String.format("Set new value %s for item %s", value, item)); } if(identifier.equals(BrowserColumn.filename.name())) { if(StringUtils.isNotBlank(value.toString()) && !item.getName().equals(value.toString())) { final Path renamed = new Path(item.getParent(), value.toString(), item.getType(), item.attributes()); new MoveController(controller).rename(item, renamed); } } }
private Path toDecrypted(final Path file) { if(file.getType().contains(Path.Type.encrypted)) { if(null == file.attributes().getDecrypted()) { log.error(String.format("Missing decrypted reference for %s", file)); } return file.attributes().getDecrypted(); } return file; }
protected Path expand(final Path remote, final String format) { if(remote.getAbsolute().startsWith(format)) { return new Path(StringUtils.replaceOnce(remote.getAbsolute(), format, workdir.getAbsolute()), remote.getType()); } return remote; } }
@Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { if(status.isExists()) { new LocalDeleteFeature(session).delete(Collections.singletonList(renamed), new DisabledPasswordCallback(), callback); } if(!session.toPath(file).toFile().renameTo(session.toPath(renamed).toFile())) { throw new LocalExceptionMappingService().map("Cannot rename {0}", new NoSuchFileException(file.getName()), file); } // Copy attributes from original file return new Path(renamed.getParent(), renamed.getName(), renamed.getType(), new LocalAttributesFinderFeature(session).find(renamed)); }
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { Files.createDirectory(session.toPath(folder)); } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot create folder {0}", e, folder); } return new Path(folder.getParent(), folder.getName(), folder.getType(), new LocalAttributesFinderFeature(session).find(folder)); }
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { Files.copy(session.toPath(source), session.toPath(target), StandardCopyOption.REPLACE_EXISTING); // Copy attributes from original file return new Path(target.getParent(), target.getName(), target.getType(), new LocalAttributesFinderFeature(session).find(target)); } catch(IOException e) { throw new LocalExceptionMappingService().map("Cannot copy {0}", e, source); } }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(Checksum.NONE == status.getChecksum()) { status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status)); } status.setTimestamp(System.currentTimeMillis()); final StatusOutputStream<BaseB2Response> out = writer.write(file, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); return new Path(file.getParent(), file.getName(), file.getType(), new B2AttributesFinderFeature(session, fileid).toAttributes((B2FileResponse) out.getStatus())); }
@Override public Path touch(final Path file, final TransferStatus transferStatus) throws BackgroundException { final SpectraBulkService bulk = new SpectraBulkService(session); final TransferStatus status = new TransferStatus(); bulk.pre(Transfer.Type.upload, Collections.singletonMap(new TransferItem(file), status.length(0L)), new DisabledConnectionCallback()); final StatusOutputStream<StorageObject> out = writer.write(file, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final S3Object metadata = (S3Object) out.getStatus(); return new Path(file.getParent(), file.getName(), file.getType(), new S3AttributesFinderFeature(session).toAttributes(metadata)); }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { status.setLength(0L); final StatusOutputStream<StorageObject> out = writer.write(file, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(file.getParent(), file.getName(), file.getType(), new SwiftAttributesFinderFeature(session, regionService).toAttributes(metadata)); }
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final CreateFolderResult result = new DbxUserFilesRequests(session.getClient()).createFolderV2(folder.getAbsolute(), false); return new Path(folder.getParent(), folder.getName(), folder.getType(), new DropboxAttributesFinderFeature(session).toAttributes(result.getMetadata())); } catch(DbxException e) { throw new DropboxExceptionMappingService().map(e); } }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(Checksum.NONE == status.getChecksum()) { status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status)); } new DefaultStreamCloser().close(writer.write(file, status, new DisabledConnectionCallback())); return new Path(file.getParent(), file.getName(), file.getType(), new AzureAttributesFinderFeature(session, context).find(file)); }
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(!session.getClient().makeDirectory(folder.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } } catch(IOException e) { throw new FTPExceptionMappingService().map("Cannot create folder {0}", e, folder); } return new Path(folder.getParent(), folder.getName(), folder.getType(), new DefaultAttributesFinderFeature(session).find(folder)); }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { if(Checksum.NONE == status.getChecksum()) { status.setChecksum(writer.checksum(file).compute(new NullInputStream(0L), status)); } status.setLength(0L); final StatusOutputStream<StorageObject> out = writer.write(file, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final S3Object metadata = (S3Object) out.getStatus(); return new Path(file.getParent(), file.getName(), file.getType(), new S3AttributesFinderFeature(session).toAttributes(metadata)); }