@Override public Space get() throws BackgroundException { final Path home = new DefaultHomeFinderService(session).find(); try { final FileStore store = Files.getFileStore(session.toPath(home)); return new Space(store.getTotalSpace() - store.getUnallocatedSpace(), store.getUnallocatedSpace()); } catch(IOException e) { throw new LocalExceptionMappingService().map("Failure to read attributes of {0}", e, home); } } }
@Override public Path find(final Path root, final String path) { if(path.startsWith(String.valueOf(Path.DELIMITER))) { // Mount absolute path final String normalized = this.normalize(path, true); return new Path(normalized, normalized.equals(String.valueOf(Path.DELIMITER)) ? EnumSet.of(Path.Type.volume, Path.Type.directory) : EnumSet.of(Path.Type.directory)); } else { if(path.startsWith(Path.HOME)) { // Relative path to the home directory return new Path(String.format("%s%s%s", root.getAbsolute(), Path.DELIMITER, this.normalize(StringUtils.removeStart( StringUtils.removeStart(path, Path.HOME), String.valueOf(Path.DELIMITER)), false)), EnumSet.of(Path.Type.directory)); } else { // Relative path return new Path(String.format("%s%s%s", root.getAbsolute(), Path.DELIMITER, this.normalize(path, false)), EnumSet.of(Path.Type.directory)); } } }
@Override public Path find() throws BackgroundException { final Path home = super.find(); if(home == DEFAULT_HOME) { final String user; final Credentials credentials = session.getHost().getCredentials(); if(StringUtils.contains(credentials.getUsername(), ':')) { user = StringUtils.splitPreserveAllTokens(credentials.getUsername(), ':')[1]; } else { user = credentials.getUsername(); } return new Path(new StringBuilder() .append(Path.DELIMITER).append(session.getRegion()) .append(Path.DELIMITER).append("home") .append(Path.DELIMITER).append(user) .toString(), EnumSet.of(Path.Type.directory, Path.Type.volume)); } return home; } }
return (T) new DefaultHomeFinderService(this);
@Override public Path find() throws BackgroundException { final Path directory = super.find(); if(directory == DEFAULT_HOME) { final String home = LocalFactory.get().getAbsolute(); return this.toPath(home); } return directory; }
@Override public Space get() throws BackgroundException { try { final Path home = new DefaultHomeFinderService(session).find(); if(!home.isRoot()) { final Node node = new NodesApi(session.getClient()).getFsNode( Long.parseLong(nodeid.getFileid(home, new DisabledListProgressListener())), StringUtils.EMPTY, null); if(null == node.getQuota()) { log.warn(String.format("No quota set for node %s", home)); } else { return new Space(node.getSize(), node.getQuota() - node.getSize()); } } final CustomerData info = new UserApi(session.getClient()).getCustomerInfo(StringUtils.EMPTY, null); return new Space(info.getSpaceUsed(), info.getSpaceLimit() - info.getSpaceUsed()); } catch(ApiException e) { throw new SDSExceptionMappingService().map("Failure to read attributes of {0}", e, new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); } } }
@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 Space get() throws BackgroundException { final Path home = new DefaultHomeFinderService(session).find(); try { final DavQuota quota = session.getClient().getQuota(new DAVPathEncoder().encode(home)); return new Space( quota.getQuotaUsedBytes() > 0 ? quota.getQuotaUsedBytes() : 0, quota.getQuotaAvailableBytes() >= 0 ? quota.getQuotaAvailableBytes() : Long.MAX_VALUE ); } catch(SardineException e) { throw new DAVExceptionMappingService().map("Failure to read attributes of {0}", e, home); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e, 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; }
if(super.alert(callback)) { final Path home = new DefaultHomeFinderService(this).find(); try { final RequestConfig context = client.context().getRequestConfig();
@Override public Path find() throws BackgroundException { final Path home = super.find(); if(home == DEFAULT_HOME) { try { // "." as referring to the current directory final String directory = session.sftp().canonicalize("."); return new Path(PathNormalizer.normalize(directory), directory.equals(String.valueOf(Path.DELIMITER)) ? EnumSet.of(Path.Type.volume, Path.Type.directory) : EnumSet.of(Path.Type.directory)); } catch(IOException e) { throw new SFTPExceptionMappingService().map(e); } } return home; } }
@Override public Space get() throws BackgroundException { final Path home = new DefaultHomeFinderService(session).find(); if(!session.isAccessible(home)) { // not accessible (important for Sharepoint)1 return new Space(0L, Long.MAX_VALUE); } final OneDriveDrive.Metadata metadata; try { // retrieve OneDriveItem from home final OneDriveItem item = session.toItem(home, true); // returns drive, which can then query metadata. metadata = item.getDrive().getMetadata(); } catch(OneDriveAPIException e) { throw new GraphExceptionMappingService().map("Failure to read attributes of {0}", e, home); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to read attributes of {0}", e, home); } return new Space( metadata.getUsed() != null ? metadata.getUsed() : 0, metadata.getTotal() != null ? metadata.getTotal() : Long.MAX_VALUE); } }
@Override public Path find() throws BackgroundException { final Path home = super.find(); if(home == DEFAULT_HOME) { final String directory; try { directory = session.getClient().printWorkingDirectory(); if(null == directory) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } return new Path(PathNormalizer.normalize(directory), directory.equals(String.valueOf(Path.DELIMITER)) ? EnumSet.of(Path.Type.volume, Path.Type.directory) : EnumSet.of(Path.Type.directory)); } catch(IOException e) { throw new FTPExceptionMappingService().map(e); } } return home; } }
final Path home = new DefaultHomeFinderService(this).find(); try { client.execute(new HttpHead(new DAVPathEncoder().encode(home)), new ValidatingResponseHandler<Void>() {
@Override public Path find() throws BackgroundException { final Host host = session.getHost(); if(host.getWorkdir() != null) { return new PathDictionary().deserialize(host.getWorkdir().serialize(SerializerFactory.get())); } else { final String path = host.getDefaultPath(); if(StringUtils.isNotBlank(path)) { return this.find(DEFAULT_HOME, path); } else { // No default path configured return DEFAULT_HOME; } } }
@Override public Path find() throws BackgroundException { final Path home = super.find(); if(home == DEFAULT_HOME) { return new MantaAccountHomeInfo(session.getHost().getCredentials().getUsername(), session.getHost().getDefaultPath()).getNormalizedHomePath(); } return home; } }