|
@@ -8,7 +8,12 @@ package com.owncloud.android.ui.asynctasks;
|
|
|
|
|
|
import android.os.AsyncTask;
|
|
import android.os.AsyncTask;
|
|
|
|
|
|
-import com.owncloud.android.lib.common.OwnCloudClient;
|
|
|
|
|
|
+import com.nextcloud.common.NextcloudClient;
|
|
|
|
+import com.nextcloud.common.OkHttpMethodBase;
|
|
|
|
+import com.nextcloud.operations.DeleteMethod;
|
|
|
|
+import com.nextcloud.operations.GetMethod;
|
|
|
|
+import com.nextcloud.operations.PostMethod;
|
|
|
|
+import com.nextcloud.operations.PutMethod;
|
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
|
import com.owncloud.android.lib.common.operations.RemoteOperation;
|
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
import com.owncloud.android.lib.resources.notifications.models.Action;
|
|
import com.owncloud.android.lib.resources.notifications.models.Action;
|
|
@@ -16,23 +21,18 @@ import com.owncloud.android.lib.resources.notifications.models.Notification;
|
|
import com.owncloud.android.ui.activity.NotificationsActivity;
|
|
import com.owncloud.android.ui.activity.NotificationsActivity;
|
|
import com.owncloud.android.ui.adapter.NotificationListAdapter;
|
|
import com.owncloud.android.ui.adapter.NotificationListAdapter;
|
|
|
|
|
|
-import org.apache.commons.httpclient.HttpMethod;
|
|
|
|
import org.apache.commons.httpclient.HttpStatus;
|
|
import org.apache.commons.httpclient.HttpStatus;
|
|
-import org.apache.commons.httpclient.methods.DeleteMethod;
|
|
|
|
-import org.apache.commons.httpclient.methods.GetMethod;
|
|
|
|
-import org.apache.commons.httpclient.methods.PutMethod;
|
|
|
|
-import org.apache.commons.httpclient.methods.Utf8PostMethod;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
|
|
public class NotificationExecuteActionTask extends AsyncTask<Action, Void, Boolean> {
|
|
public class NotificationExecuteActionTask extends AsyncTask<Action, Void, Boolean> {
|
|
|
|
|
|
- private NotificationListAdapter.NotificationViewHolder holder;
|
|
|
|
- private OwnCloudClient client;
|
|
|
|
- private Notification notification;
|
|
|
|
- private NotificationsActivity notificationsActivity;
|
|
|
|
|
|
+ private final NotificationListAdapter.NotificationViewHolder holder;
|
|
|
|
+ private final NextcloudClient client;
|
|
|
|
+ private final Notification notification;
|
|
|
|
+ private final NotificationsActivity notificationsActivity;
|
|
|
|
|
|
- public NotificationExecuteActionTask(OwnCloudClient client,
|
|
|
|
|
|
+ public NotificationExecuteActionTask(NextcloudClient client,
|
|
NotificationListAdapter.NotificationViewHolder holder,
|
|
NotificationListAdapter.NotificationViewHolder holder,
|
|
Notification notification,
|
|
Notification notification,
|
|
NotificationsActivity notificationsActivity) {
|
|
NotificationsActivity notificationsActivity) {
|
|
@@ -44,39 +44,28 @@ public class NotificationExecuteActionTask extends AsyncTask<Action, Void, Boole
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected Boolean doInBackground(Action... actions) {
|
|
protected Boolean doInBackground(Action... actions) {
|
|
- HttpMethod method;
|
|
|
|
|
|
+ OkHttpMethodBase method;
|
|
Action action = actions[0];
|
|
Action action = actions[0];
|
|
|
|
|
|
switch (action.type) {
|
|
switch (action.type) {
|
|
- case "GET":
|
|
|
|
- method = new GetMethod(action.link);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case "POST":
|
|
|
|
- method = new Utf8PostMethod(action.link);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case "DELETE":
|
|
|
|
- method = new DeleteMethod(action.link);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- case "PUT":
|
|
|
|
- method = new PutMethod(action.link);
|
|
|
|
- break;
|
|
|
|
-
|
|
|
|
- default:
|
|
|
|
|
|
+ case "GET" -> method = new GetMethod(action.link, true);
|
|
|
|
+ case "POST" -> method = new PostMethod(action.link, true, null);
|
|
|
|
+ case "DELETE" -> method = new DeleteMethod(action.link, true);
|
|
|
|
+ case "PUT" -> method = new PutMethod(action.link, true, null);
|
|
|
|
+ default -> {
|
|
// do nothing
|
|
// do nothing
|
|
- return Boolean.FALSE;
|
|
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- method.setRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE);
|
|
|
|
|
|
+ method.addRequestHeader(RemoteOperation.OCS_API_HEADER, RemoteOperation.OCS_API_HEADER_VALUE);
|
|
|
|
|
|
int status;
|
|
int status;
|
|
try {
|
|
try {
|
|
- status = client.executeMethod(method);
|
|
|
|
|
|
+ status = client.execute(method);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
Log_OC.e(this, "Execution of notification action failed: " + e);
|
|
Log_OC.e(this, "Execution of notification action failed: " + e);
|
|
- return Boolean.FALSE;
|
|
|
|
|
|
+ return false;
|
|
} finally {
|
|
} finally {
|
|
method.releaseConnection();
|
|
method.releaseConnection();
|
|
}
|
|
}
|