/** * @param changed Changed files and directories * @return Set of parent folders to reload */ public Set<Path> find(final List<Path> changed) { final Set<Path> folders = new HashSet<Path>(); for(Path file : changed) { folders.add(file.getParent()); } return folders; } }
public Path find(final Path selected) { if(null == selected) { return workdir; } if(selected.getType().contains(Path.Type.volume)) { return selected; } return selected.getParent(); } }
public boolean isContainer(final Path file) { if(file.isRoot()) { return false; } return file.getParent().isRoot(); }
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); } } }
@Override public Set<TransferItem> find(final CommandLine input, final TerminalAction action, final Path remote) { if(StringUtils.containsAny(remote.getName(), '*')) { // Treat asterisk as wildcard return Collections.singleton(new TransferItem(remote.getParent())); } return Collections.singleton(new TransferItem(remote)); } }
@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; } }
private Path getWorkdirFromSelection() { if(this.getSelectionCount() == 1) { final Path selected = this.getSelectedPath(); if(null != selected) { return selected.getParent(); } } return this.workdir(); }
/** * @param source Source file or folder * @param target Target file or folder * @return False if not supported for given files */ default boolean isSupported(Path source, Path target) { return target.getParent().attributes().getPermission().isWritable(); }
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; }
/** * @param path Filename * @return Unarchive command */ public String getDecompressCommand(final Path path) { return MessageFormat.format(preferences.getProperty(String.format("archive.command.expand.%s", this.getIdentifier())), this.escape(path.getAbsolute()), this.escape(path.getParent().getAbsolute())); }
public DescriptiveUrl getRemote() { if(this.roots.size() == 1) { return new DefaultUrlProvider(host).toUrl(this.getRoot().remote).find(DescriptiveUrl.Type.provider); } else { return new DefaultUrlProvider(host).toUrl(this.getRoot().remote.getParent()).find(DescriptiveUrl.Type.provider); } }
@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 boolean isSupported(final Path file) { if(containerService.isContainer(file)) { if(PreferencesFactory.get().getBoolean("sds.delete.dataroom.enable")) { // Need the query permission on the parent data room if file itself is subroom new SDSPermissionsFeature(session, nodeid).containsRole(containerService.getContainer(file.getParent()), SDSPermissionsFeature.MANAGE_ROLE); } return false; } return new SDSPermissionsFeature(session, nodeid).containsRole(file, SDSPermissionsFeature.DELETE_ROLE); }
@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 mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { final IRODSFileSystemAO fs = session.getClient(); final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(folder.getAbsolute()); fs.mkdir(f, false); return new Path(folder.getParent(), folder.getName(), folder.getType(), new IRODSAttributesFinderFeature(session).find(folder)); } catch(JargonException e) { throw new IRODSExceptionMappingService().map("Cannot create folder {0}", e, 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)); } new DefaultStreamCloser().close(writer.write(file, status, new DisabledConnectionCallback())); return new Path(file.getParent(), file.getName(), file.getType(), new AzureAttributesFinderFeature(session, context).find(file)); }