Search in sources :

Example 1 with SpaceAllocation

use of com.dropbox.core.v2.users.SpaceAllocation in project cyberduck by iterate-ch.

the class DropboxQuotaFeature method get.

@Override
public Space get() throws BackgroundException {
    try {
        final SpaceUsage usage = new DbxUserUsersRequests(session.getClient()).getSpaceUsage();
        final SpaceAllocation allocation = usage.getAllocation();
        if (allocation.isIndividual()) {
            long remaining = allocation.getIndividualValue().getAllocated() - usage.getUsed();
            return new Space(usage.getUsed(), remaining);
        } else if (allocation.isTeam()) {
            long remaining = allocation.getTeamValue().getAllocated() - usage.getUsed();
            return new Space(usage.getUsed(), remaining);
        }
        return unknown;
    } catch (DbxException e) {
        throw new DropboxExceptionMappingService().map("Failure to read attributes of {0}", e, new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory)));
    }
}
Also used : Path(ch.cyberduck.core.Path) SpaceUsage(com.dropbox.core.v2.users.SpaceUsage) SpaceAllocation(com.dropbox.core.v2.users.SpaceAllocation) DbxUserUsersRequests(com.dropbox.core.v2.users.DbxUserUsersRequests) DbxException(com.dropbox.core.DbxException)

Aggregations

Path (ch.cyberduck.core.Path)1 DbxException (com.dropbox.core.DbxException)1 DbxUserUsersRequests (com.dropbox.core.v2.users.DbxUserUsersRequests)1 SpaceAllocation (com.dropbox.core.v2.users.SpaceAllocation)1 SpaceUsage (com.dropbox.core.v2.users.SpaceUsage)1