@Override public boolean accept(final Path file) { if(file.attributes().isDuplicate()) { if(log.isDebugEnabled()) { log.debug(String.format("Reject duplicate %s", file)); } return false; } return true; } }
@Override protected int compareFirst(final Path p1, final Path p2) { if(p1.attributes().getSize() > p2.attributes().getSize()) { return ascending ? 1 : -1; } else if(p1.attributes().getSize() < p2.attributes().getSize()) { return ascending ? -1 : 1; } return 0; } }
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; }
public WritePermissionWorker(final List<Path> files, final PermissionOverwrite overwrite, final RecursiveCallback<Permission> callback, final ProgressListener listener) { this.files = files; this.permissions = new HashMap<>(); for(Path f : files) { this.permissions.put(f, overwrite.resolve(f.attributes().getPermission())); } this.callback = callback; this.listener = listener; }
@Override public Long run(final Session<?> session) throws BackgroundException { for(Path next : files) { next.attributes().setSize(this.calculateSize(session, next)); } return total; }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.attributes().getLink() != null) { list.add(file.attributes().getLink()); } return list; } }
@Override public boolean test(final Path test) { if(test.attributes().isDuplicate()) { // Ignore trashed files return false; } return super.test(test); } }
/** * @param workdir Working directory in browser * @param name Folder name or null if unknown * @return True if creating directory will succeed */ default boolean isSupported(Path workdir, String name) { return workdir.attributes().getPermission().isWritable(); }
@Override public String getTooltip(final Path file) { return sizeFormatter.format(file.attributes().getSize(), true); } }
/** * @param workdir Working directory * @return True if creating an empty file is possible. */ default boolean isSupported(Path workdir) { return workdir.attributes().getPermission().isWritable(); }
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 boolean isSupported(final Path source, final Path target) { if(Boolean.valueOf(containerService.getContainer(source).attributes().getCustom().get(SDSAttributesFinderFeature.KEY_ENCRYPTED)) ^ Boolean.valueOf(containerService.getContainer(target).attributes().getCustom().get(SDSAttributesFinderFeature.KEY_ENCRYPTED))) { return session.getFeature(Copy.class).isSupported(source, target); } return proxy.isSupported(source, target); }
@Override public DescriptiveUrlBag toUrl(final Path file) { final DescriptiveUrlBag list = new DescriptiveUrlBag(); if(file.isFile()) { if(file.attributes().getLink() != null) { list.add(file.attributes().getLink()); } } return list; } }
@Override public ChecksumCompute checksum(final Path file) { if(Boolean.valueOf(containerService.getContainer(file).attributes().getCustom().get(SDSAttributesFinderFeature.KEY_ENCRYPTED))) { return new CryptoWriteFeature(session, proxy).checksum(file); } return proxy.checksum(file); } }
@Override public Acl getPermission(final Path file) { if(containerService.isContainer(file)) { return containerService.getContainer(file).attributes().getAcl(); } return Acl.EMPTY; }
/** * @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; }
@Override public Path move(final Path file, final Path renamed, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { final Path copy = new SwiftCopyFeature(session, regionService).copy(file, renamed, new TransferStatus().length(file.attributes().getSize()), connectionCallback); delete.delete(Collections.singletonList(file), connectionCallback, callback); return copy; }
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { final GroupItem group = new GroupItem(session.getClient(), directory.attributes().getVersionId()); final GroupDrivesIterator iterator = new GroupDrivesIterator(session.getClient(), group); return this.iterate(iterator, directory, listener); }
@Override public Path touch(final Path file, final TransferStatus status) throws BackgroundException { // Write header final Cryptor cryptor = vault.getCryptor(); final FileHeader header = cryptor.fileHeaderCryptor().create(); status.setHeader(cryptor.fileHeaderCryptor().encryptHeader(header)); status.setNonces(new RandomNonceGenerator()); final Path target = proxy.touch(vault.encrypt(session, file), status); final Path decrypt = vault.decrypt(session, target); decrypt.attributes().withVersionId(target.attributes().getVersionId()); return decrypt; }