@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 equals(Object o) { if(this == o) { return true; } if(o == null || getClass() != o.getClass()) { return false; } TransferItem that = (TransferItem) o; if(!Objects.equals(local, that.local)) { return false; } if(remote != null ? !new SimplePathPredicate(remote).equals(new SimplePathPredicate(that.remote)) : that.remote != null) { return false; } return true; }
@Override public boolean test(final Path test) { return this.hashCode() == new SimplePathPredicate(test).hashCode(); } }
final Path found = list.find(new SimplePathPredicate(container)); if(null != found) { return Boolean.valueOf(found.attributes().getCustom().get(SDSAttributesFinderFeature.KEY_ENCRYPTED));
@Override public boolean test(final Path test) { if(test.attributes().isDuplicate()) { // Ignore trashed files return false; } return super.test(test); } }
@Override public boolean equals(final Object o) { if(null == o) { return false; } if(o instanceof CacheReference) { return this.hashCode() == o.hashCode(); } return false; }
final Path found = list.find(new SimplePathPredicate(file)); if(null != found) { if(StringUtils.isNotBlank(found.attributes().getVersionId())) {
@Override public boolean contains(final Path file) { if(this.isUnlocked()) { return new SimplePathPredicate(file).test(home) || file.isChild(home); } return false; }
@Override public String getFileid(final Path file, final ListProgressListener listener) throws BackgroundException { if(StringUtils.isNotBlank(file.attributes().getVersionId())) { return file.attributes().getVersionId(); } if(cache.isCached(file.getParent())) { final AttributedList<Path> list = cache.get(file.getParent()); final Path found = list.find(new SimplePathPredicate(file)); if(null != found) { if(StringUtils.isNotBlank(found.attributes().getVersionId())) { return this.set(file, found.attributes().getVersionId()); } } } final AttributedList<Path> list = session._getFeature(ListService.class).list(file.getParent(), listener); final Path found = list.find(new SimplePathPredicate(file)); if(null == found) { throw new NotfoundException(file.getAbsolute()); } return this.set(file, found.attributes().getVersionId()); }
@Override public int hashCode() { int result = remote != null ? new SimplePathPredicate(remote).hashCode() : 0; result = 31 * result + (local != null ? local.hashCode() : 0); return result; }
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; }
protected Path search(final Path file) throws BackgroundException { final AttributedList<Path> list; if(!cache.isCached(file.getParent())) { // Do not decrypt filenames to match with input list = session._getFeature(ListService.class).list(file.getParent(), new CachingListProgressListener(cache)); } else { list = cache.get(file.getParent()); } // Search with specific version and region final Path path = list.find(new DefaultPathPredicate(file)); if(path != null) { return path; } // Try to match path only as the version might have changed in the meantime return list.find(session.getCase() == Session.Case.insensitive ? new CaseInsensitivePathPredicate(file) : new SimplePathPredicate(file)); }
throw new NotfoundException(directory.getAbsolute()); if(new SimplePathPredicate(directory).test(home) || directory.isChild(home)) { final PathAttributes attributes = new PathAttributes(directory.attributes()); if(new SimplePathPredicate(directory).test(home)) {
final Path found = list.find(new SimplePathPredicate(file)); if(null != found) { if(StringUtils.isNotBlank(found.attributes().getVersionId())) { final AttributedList<Path> list = new B2ListService(session, this).list(file.getParent(), listener); cache.put(file.getParent(), list); final Path found = list.find(new SimplePathPredicate(file)); if(null == found) { throw new NotfoundException(file.getAbsolute()); final Path found = list.find(new SimplePathPredicate(file)); if(null != found) { if(StringUtils.isNotBlank(found.attributes().getVersionId())) {
/** * @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; } }
new SimplePathPredicate(file) ); if(null == found) {
@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); } }
@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); }
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;
if(!new SimplePathPredicate(file.getParent()).test(renamed.getParent())) {