Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a680f93 authored by Andy Scherzinger's avatar Andy Scherzinger
Browse files

slight reformatting of code + logging in case of fallback due to missing...

slight reformatting of code + logging in case of fallback due to missing server side feature support
parent 7a3bfbde
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
/* 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
@@ -43,7 +44,10 @@ import org.json.JSONObject;
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 {

@@ -90,13 +94,19 @@ public class RemoteGetUserQuotaOperation extends RemoteOperation {
    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. */
    /**
     * Quota return value for unknown space value.
     */
    public static final long SPACE_UNKNOWN = -2;

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

    // OCS Route
@@ -128,17 +138,18 @@ public class RemoteGetUserQuotaOperation extends RemoteOperation {
                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));