Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make run() always work, even with old ocClient #1471

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.text.TextUtils;

import com.nextcloud.common.DNSCache;
import com.nextcloud.common.NextcloudClient;
import com.nextcloud.common.NextcloudUriDelegate;
import com.owncloud.android.lib.common.accounts.AccountUtils;
import com.owncloud.android.lib.common.network.AdvancedX509KeyManager;
Expand Down Expand Up @@ -67,6 +68,8 @@ public class OwnCloudClient extends HttpClient {

private AdvancedX509KeyManager keyManager;

private Context context;

/**
* Constructor
*/
Expand All @@ -76,6 +79,7 @@ public OwnCloudClient(Uri baseUri, HttpConnectionManager connectionMgr, Context
if (baseUri == null) {
throw new IllegalArgumentException("Parameter 'baseUri' cannot be NULL");
}
this.context = context;
this.keyManager = new AdvancedX509KeyManager(context);
nextcloudUriDelegate = new NextcloudUriDelegate(baseUri);

Expand Down Expand Up @@ -449,4 +453,18 @@ public OwnCloudCredentials getCredentials() {
public void setFollowRedirects(boolean followRedirects) {
this.followRedirects = followRedirects;
}

public Context getContext() {
return context;
}

public NextcloudClient toNextcloudClient() {
return OwnCloudClientFactory.createNextcloudClient(
getBaseUri(),
getUserId(),
getCredentials().toOkHttpCredentials(),
getContext(),
isFollowRedirects()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ public abstract class RemoteOperation<T> implements Runnable {
*/
@Deprecated
protected RemoteOperationResult<T> run(OwnCloudClient client) {
Log_OC.d(this, "Not used anymore");
throw new UnsupportedOperationException("Not used anymore");
Log_OC.w(this, "Only temporary! Please upgrade to NextcloudClient!");
NextcloudClient nextcloudClient = client.toNextcloudClient();

return run(nextcloudClient);
ZetaTom marked this conversation as resolved.
Show resolved Hide resolved
}

public RemoteOperationResult<T> run(NextcloudClient client) {
Expand Down
Loading