Skip to content

Commit

Permalink
slight reformatting of code + logging in case of fallback due to miss…
Browse files Browse the repository at this point in the history
…ing server side feature support
  • Loading branch information
AndyScherzinger committed Aug 31, 2016
1 parent 7a3bfbd commit 4a680f9
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Nextcloud Android Library is available under MIT license
*
* Copyright (C) 2016 Nextcloud
* Copyright (C) 2016 Andy Scherzinger
* Copyright (C) 2015 ownCloud Inc.
* Copyright (C) 2015 Bartosz Przybylski
* Copyright (C) 2014 Marcello Steiner
Expand Down Expand Up @@ -43,7 +44,10 @@
import java.util.ArrayList;

/**
* Gets a logged in user's quota information (free, used, total and quota).
*
* @author marcello
* @author Andy Scherzinger
*/
public class RemoteGetUserQuotaOperation extends RemoteOperation {

Expand Down Expand Up @@ -90,14 +94,20 @@ public double getRelative() {
private static final String NODE_QUOTA_TOTAL = "total";
private static final String NODE_QUOTA_RELATIVE = "relative";

/** Quota return value for a not computed space value. */
/**
* Quota return value for a not computed space value.
*/
public static final long SPACE_NOT_COMPUTED = -1;

/** Quota return value for unknown space value. */
public static final long SPACE_UNKNOWN = -2;
/**
* Quota return value for unknown space value.
*/
public static final long SPACE_UNKNOWN = -2;

/** Quota return value for unlimited space. */
public static final long SPACE_UNLIMITED = -3;
/**
* Quota return value for unlimited space.
*/
public static final long SPACE_UNLIMITED = -3;

// OCS Route
private static final String OCS_ROUTE = "/ocs/v1.php/cloud/users/";
Expand Down Expand Up @@ -128,17 +138,18 @@ protected RemoteOperationResult run(OwnCloudClient client) {
final Long quotaFree = quota.getLong(NODE_QUOTA_FREE);
final Long quotaUsed = quota.getLong(NODE_QUOTA_USED);
final Long quotaTotal = quota.getLong(NODE_QUOTA_TOTAL);
final Double quotaRelative = quota.getDouble(NODE_QUOTA_RELATIVE);
Long quotaValue;
try {
quotaValue = Long.valueOf(quota.getLong(NODE_QUOTA));
quotaValue = quota.getLong(NODE_QUOTA);
} catch (JSONException e) {
// quota value only present in NC 9.0.54+
Log_OC.i(TAG, "Legacy server in use < Nextcloud 9.0.54");
quotaValue = SPACE_UNKNOWN;
}
final Double quotaRelative = quota.getDouble(NODE_QUOTA_RELATIVE);

// Result
result = new RemoteOperationResult(true, status, get.getResponseHeaders());

// Quota data in data collection
ArrayList<Object> data = new ArrayList<>();
data.add(new Quota(quotaFree, quotaUsed, quotaTotal, quotaRelative, quotaValue));
Expand Down

0 comments on commit 4a680f9

Please sign in to comment.