@Override public boolean equals(final Object o) { if(this == o) { return true; } if(!(o instanceof CryptoVault)) { return false; } final CryptoVault that = (CryptoVault) o; return new SimplePathPredicate(home).test(that.home); }
@Override public boolean test(final Path test) { if(test.attributes().isDuplicate()) { // Ignore trashed files return false; } return super.test(test); } }
private String toDirectoryId(final Session<?> session, final Path directory, final String directoryId) throws BackgroundException { if(new SimplePathPredicate(home).test(directory)) { return ROOT_DIR_ID; } if(StringUtils.isBlank(directoryId)) { if(cache.containsKey(new DefaultPathPredicate(directory))) { return cache.get(new DefaultPathPredicate(directory)); } final String id = this.load(session, directory); cache.put(new DefaultPathPredicate(directory), id); return id; } cache.put(new DefaultPathPredicate(directory), directoryId); return directoryId; }
@Override public boolean contains(final Path file) { if(this.isUnlocked()) { return new SimplePathPredicate(file).test(home) || file.isChild(home); } return false; }
@Override public Path move(final Path source, final Path target, final TransferStatus status, final Delete.Callback callback, final ConnectionCallback connectionCallback) throws BackgroundException { if(containerService.isContainer(source)) { if(new SimplePathPredicate(source.getParent()).test(target.getParent())) { // Rename only return proxy.move(source, target, status, callback, connectionCallback); } } if(nodeid.isEncrypted(source) ^ nodeid.isEncrypted(target)) { // Moving into or from an encrypted room final Copy copy = session.getFeature(Copy.class); if(log.isDebugEnabled()) { log.debug(String.format("Move %s to %s using copy feature %s", source, target, copy)); } final Path c = copy.copy(source, target, status, connectionCallback); // Delete source file after copy is complete final Delete delete = session.getFeature(Delete.class); if(delete.isSupported(source)) { delete.delete(Collections.singletonList(source), connectionCallback, callback); } return c; } else { return proxy.move(source, target, status, callback, connectionCallback); } }
/** * @param directory Parent directory * @return True if this is a child in the path hierarchy of the argument passed */ public boolean isChild(final Path directory) { if(directory.isFile()) { // If a file we don't have any children at all return false; } if(this.isRoot()) { // Root cannot be a child of any other path return false; } if(directory.isRoot()) { // Any other path is a child return true; } if(Objects.equals(this.getParent(), directory.getParent())) { // Cannot be a child if the same parent return false; } for(Path parent = this.getParent(); !parent.isRoot(); parent = parent.getParent()) { if(new SimplePathPredicate(parent).test(directory)) { return true; } } return false; } }
return file; if(new SimplePathPredicate(file).test(home)) { log.warn(String.format("Skip vault home %s because the root has no metadata file", file)); return file;
@Override public boolean isSupported(final Path source, final Path target) { if(containerService.isContainer(source)) { if(!new SimplePathPredicate(source.getParent()).test(target.getParent())) { // Cannot move data room but only rename return false; } } if(target.getParent().isRoot() && !source.getParent().isRoot()) { // Cannot move file or directory to root but only rename data rooms return false; } final SDSPermissionsFeature acl = new SDSPermissionsFeature(session, nodeid); return acl.containsRole(source, SDSPermissionsFeature.CHANGE_ROLE) && acl.containsRole(source, SDSPermissionsFeature.DELETE_ROLE) && acl.containsRole(target, SDSPermissionsFeature.CREATE_ROLE); }
if(!new SimplePathPredicate(file.getParent()).test(renamed.getParent())) {