@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 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))); } } }
if(super.alert(callback)) { final Path home = new DefaultHomeFinderService(this).find(); try { final RequestConfig context = client.context().getRequestConfig();
final Path home = new DefaultHomeFinderService(this).find(); try { client.execute(new HttpHead(new DAVPathEncoder().encode(home)), new ValidatingResponseHandler<Void>() {
@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 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); } }
return (T) new DefaultHomeFinderService(this);