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)); }
public CryptoDirectoryProvider(final Path vault, final CryptoVault cryptomator) { this.home = vault; this.dataRoot = new Path(vault, DATA_DIR_NAME, vault.getType()); this.cryptomator = cryptomator; }
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 void upload(final Host bookmark, final List<Local> files, final Path destination) { final List<TransferItem> roots = new ArrayList<TransferItem>(); for(Local file : files) { roots.add(new TransferItem(new Path(destination, file.getName(), file.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file)), file)); } final TransferController t = TransferControllerFactory.get(); t.start(new UploadTransfer(bookmark, roots), new TransferOptions()); }
public CryptoVault(final Path home, final String masterkey, final byte[] pepper) { this.home = home; this.masterkey = new Path(home, masterkey, EnumSet.of(Path.Type.file, Path.Type.vault)); this.pepper = pepper; // New vault home with vault flag set for internal use final EnumSet<AbstractPath.Type> type = EnumSet.copyOf(home.getType()); type.add(Path.Type.vault); final Path vault = new Path(home.getAbsolute(), type, new PathAttributes(home.attributes())); this.filenameProvider = new CryptoFilenameProvider(vault); this.directoryProvider = new CryptoDirectoryProvider(vault, this); }
public Path parse(final String uri) { final Host host = new HostParser(factory).get(uri); if(StringUtils.isBlank(host.getDefaultPath())) { return new Path(String.valueOf(Path.DELIMITER), EnumSet.of(detector.detect(host.getDefaultPath()))); } return new Path(PathNormalizer.normalize(host.getDefaultPath()), EnumSet.of(detector.detect(host.getDefaultPath()))); } }
@Override public void callback(final int returncode) { final Path directory = new UploadTargetFinder(workdir).find(selected); switch(returncode) { case DEFAULT_OPTION: case ALTERNATE_OPTION: this.callback(returncode, new Path(directory, inputField.stringValue(), EnumSet.of(Path.Type.file))); break; } }
@Override public Path find(final Path root, final String path) { final Path home = super.find(root, path); if(containerService.isContainer(home)) { return new Path(home.getParent(), home.getName(), EnumSet.of(Path.Type.volume, Path.Type.directory)); } return home; } }
@Override public Path find() throws BackgroundException { final Path home = super.find(); if(containerService.isContainer(home)) { return new Path(home.getParent(), home.getName(), EnumSet.of(Path.Type.volume, Path.Type.directory)); } return home; }
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; } }
private Path inflate(final Session<?> session, final Path file) throws BackgroundException { final String fileName = file.getName(); if(filenameProvider.isDeflated(fileName)) { final String filename = filenameProvider.inflate(session, fileName); return new Path(file.getParent(), filename, EnumSet.of(Path.Type.file), file.attributes()); } return file; }
@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 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)); }