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

Unverified Commit 8094fc9f authored by David Luhmer's avatar David Luhmer Committed by GitHub
Browse files

Merge pull request #411 from nextcloud/113-remove-deprecated-methods

#133 Remove deprecated methods
parents cb5a7510 f165e7d6
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@

package com.nextcloud.android.sso;

import com.nextcloud.android.sso.model.FilesAppType;

public class Constants {

    // Authenticator related constants
@@ -40,18 +38,4 @@ public class Constants {
    public static final String EXCEPTION_HTTP_REQUEST_FAILED = "CE_5";
    public static final String EXCEPTION_ACCOUNT_ACCESS_DECLINED = "CE_6";

    // package related constants
    /** @deprecated Use {@link FilesAppType#packageId} */
    @Deprecated
    public static final String PACKAGE_NAME_PROD = FilesAppType.PROD.packageId;
    /** @deprecated Use {@link FilesAppType#packageId} */
    @Deprecated
    public static final String PACKAGE_NAME_DEV = FilesAppType.DEV.packageId;
    /** @deprecated Use {@link FilesAppType#accountType} */
    @Deprecated
    public static final String ACCOUNT_TYPE_PROD = FilesAppType.PROD.accountType;
    /** @deprecated Use {@link FilesAppType#accountType} */
    @Deprecated
    public static final String ACCOUNT_TYPE_DEV = FilesAppType.DEV.accountType;

}
+3 −29
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@
package com.nextcloud.android.sso.aidl;


import androidx.core.util.ObjectsCompat;
import androidx.core.util.Pair;

import com.nextcloud.android.sso.QueryParam;

import java.io.InputStream;
@@ -31,8 +34,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import androidx.core.util.ObjectsCompat;
import androidx.core.util.Pair;
import lombok.ToString;

@ToString
@@ -97,23 +98,6 @@ public class NextcloudRequest implements Serializable {
            return this;
        }

        /**
         * Sets the parameters for this request.
         * All existing parameters will be wiped!
         * @param parameter new set of parameters
         * @return this (Builder)
         * @deprecated since this won't allow RFC 3986 compliant parameters, please use {@link #setParameter(Collection) setParameter(Collection)} instead
         */
        @Deprecated
        public Builder setParameter(Map<String, String> parameter) {
            ncr.parameter = parameter;
            ncr.parameterV2 = new ArrayList<>();
            for (Map.Entry<String, String> mapEntry : parameter.entrySet()) {
                ncr.parameterV2.add(new QueryParam(mapEntry.getKey(), mapEntry.getValue()));
            }
            return this;
        }

        /**
         * Sets the parameters for this request.
         * All existing parameters will be wiped!
@@ -236,16 +220,6 @@ public class NextcloudRequest implements Serializable {
        return this.parameterV2;
    }

    /**
     * Returns the set or parameters for this request.
     * @return set of parameters
     * @deprecated since this won't allow RFC 3986 compliant parameters, please use {@link #getParameterV2() getParameterV2()} instead
     */
    @Deprecated
    public Map<String, String> getParameter() {
        return parameter;
    }

    public String getRequestBody() {
        return this.requestBody;
    }
+0 −80
Original line number Diff line number Diff line
@@ -198,86 +198,6 @@ public class AidlNetworkRequest extends NetworkRequest {
        }
    }

    /**
     * The InputStreams needs to be closed after reading from it
     *
     * @deprecated Use {@link #performNetworkRequestV2(NextcloudRequest, InputStream)}
     * @see <a href="https://github.com/nextcloud/Android-SingleSignOn/issues/133">Issue #133</a>
     * @param request                {@link NextcloudRequest} request to be executed on server via Files app
     * @param requestBodyInputStream inputstream to be sent to the server
     * @return InputStream answer from server as InputStream
     * @throws Exception or SSOException
     */
    @Deprecated
    public InputStream performNetworkRequest(NextcloudRequest request, InputStream requestBodyInputStream) throws Exception {
        InputStream os = null;
        Exception exception;
        try {
            os = new ParcelFileDescriptor.AutoCloseInputStream(performAidlNetworkRequest(request, requestBodyInputStream));
            exception = deserializeObject(os);
        } catch (ClassNotFoundException e) {
            //e.printStackTrace();
            exception = e;
        }

        // Handle Remote Exceptions
        if (exception != null) {
            // close os stream if something goes wrong and no response will be created
            os.close();
            if (exception.getMessage() != null) {
                exception = parseNextcloudCustomException(exception);
            }
            throw exception;
        }

        // os stream needs to stay open to be able to read response
        return os;
    }

    /**
     * <strong>DO NOT CALL THIS METHOD DIRECTLY</strong> - use {@link #performNetworkRequest} instead
     *
     * @deprecated Use {@link #performAidlNetworkRequestV2(NextcloudRequest, InputStream)}
     * @see <a href="https://github.com/nextcloud/Android-SingleSignOn/issues/133">Issue #133</a>
     * @param request
     * @return
     * @throws IOException
     */
    @Deprecated
    private ParcelFileDescriptor performAidlNetworkRequest(@NonNull NextcloudRequest request,
                                                           @Nullable InputStream requestBodyInputStream)
            throws IOException, RemoteException, NextcloudApiNotRespondingException {

        // Check if we are on the main thread
        if (Looper.myLooper() == Looper.getMainLooper()) {
            throw new NetworkOnMainThreadException();
        }

        if (mDestroyed) {
            throw new IllegalStateException("Nextcloud API already destroyed. Please report this issue.");
        }

        // Wait for api to be initialized
        waitForApi();

        // Log.d(TAG, request.url);
        request.setAccountName(getAccountName());
        request.setToken(getAccountToken());

        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final ObjectOutputStream oos = new ObjectOutputStream(baos);
        oos.writeObject(request);
        oos.close();
        baos.close();
        InputStream is = new ByteArrayInputStream(baos.toByteArray());

        try (ParcelFileDescriptor input = pipeFrom(is, thread -> Log.d(TAG, "copy data from service finished"))) {
            return requestBodyInputStream == null
                    ? mService.performNextcloudRequest(input)
                    : mService.performNextcloudRequestAndBodyStream(input, pipeFrom(requestBodyInputStream, thread -> Log.d(TAG, "copy data from service finished")));
        }
    }

    /**
     * <strong>DO NOT CALL THIS METHOD DIRECTLY</strong> - use {@link #performNetworkRequestV2} instead
     *
+0 −2
Original line number Diff line number Diff line
@@ -34,8 +34,6 @@ public abstract class NetworkRequest {
        }
    }

    protected abstract InputStream performNetworkRequest(NextcloudRequest request, InputStream requestBodyInputStream) throws Exception;

    protected abstract Response performNetworkRequestV2(NextcloudRequest request, InputStream requestBodyInputStream) throws Exception;

    protected void connectApiWithBackoff() {
+0 −40
Original line number Diff line number Diff line
@@ -107,22 +107,6 @@ public class NextcloudAPI {
        networkRequest.stop();
    }

    /**
     * @deprecated Use {@link #performRequestObservableV2(Type, NextcloudRequest)}
     * @see <a href="https://github.com/nextcloud/Android-SingleSignOn/issues/133">Issue #133</a>
     */
    @Deprecated
    public <T> Observable<T> performRequestObservable(final Type type, final NextcloudRequest request) {
        return Observable.fromPublisher( s -> {
            try {
                s.onNext(performRequest(type, request));
                s.onComplete();
            } catch (Exception e) {
                s.onError(e);
            }
        });
    }

    public <T> Observable<ParsedResponse<T>> performRequestObservableV2(final Type type, final NextcloudRequest request) {
        return Observable.fromPublisher( s -> {
            try {
@@ -135,16 +119,6 @@ public class NextcloudAPI {
        });
    }

    /**
     * @deprecated Use {@link #performRequestV2(Type, NextcloudRequest)}
     * @see <a href="https://github.com/nextcloud/Android-SingleSignOn/issues/133">Issue #133</a>
     */
    @Deprecated
    public <T> T performRequest(final @NonNull Type type, NextcloudRequest request) throws Exception {
        Log.d(TAG, "performRequest() called with: type = [" + type + "], request = [" + request + "]");
        return convertStreamToTargetEntity(performNetworkRequest(request), type);
    }

    public <T> T performRequestV2(final @NonNull Type type, NextcloudRequest request) throws Exception {
        Log.d(TAG, "performRequestV2() called with: type = [" + type + "], request = [" + request + "]");
        final Response response = performNetworkRequestV2(request);
@@ -174,20 +148,6 @@ public class NextcloudAPI {
        return result;
    }

    /**
     * The InputStreams needs to be closed after reading from it
     *
     * @param request {@link NextcloudRequest} request to be executed on server via Files app
     * @return InputStream answer from server as InputStream
     * @throws Exception or {@link SSOException}
     * @see <a href="https://github.com/nextcloud/Android-SingleSignOn/issues/133">Issue #133</a>
     * @deprecated Use {@link #performNetworkRequestV2(NextcloudRequest)}
     */
    @Deprecated
    public InputStream performNetworkRequest(NextcloudRequest request) throws Exception {
        return networkRequest.performNetworkRequest(request, request.getBodyAsStream());
    }

    /**
     * The InputStreams needs to be closed after reading from it
     *
Loading