1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Merge branch 'develop' into share_link__new_share

This commit is contained in:
masensio 2014-01-31 12:21:30 +01:00
commit 30a5eedf7e
2 changed files with 16 additions and 41 deletions

View File

@ -91,7 +91,7 @@ public abstract class RemoteOperation implements Runnable {
* @param context Android context for the component calling the method.
* @return Result of the operation.
*/
public final RemoteOperationResult execute(Account account, Context context) {
public RemoteOperationResult execute(Account account, Context context) {
if (account == null)
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Account");
if (context == null)
@ -116,7 +116,7 @@ public abstract class RemoteOperation implements Runnable {
* @param client Client object to reach an ownCloud server during the execution of the operation.
* @return Result of the operation.
*/
public final RemoteOperationResult execute(OwnCloudClient client) {
public RemoteOperationResult execute(OwnCloudClient client) {
if (client == null)
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL OwnCloudClient");
mClient = client;
@ -135,7 +135,7 @@ public abstract class RemoteOperation implements Runnable {
* @param listenerHandler Handler associated to the thread where the methods of the listener objects must be called.
* @return Thread were the remote operation is executed.
*/
public final Thread execute(Account account, Context context, OnRemoteOperationListener listener, Handler listenerHandler, Activity callerActivity) {
public Thread execute(Account account, Context context, OnRemoteOperationListener listener, Handler listenerHandler, Activity callerActivity) {
if (account == null)
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Account");
if (context == null)
@ -163,7 +163,7 @@ public abstract class RemoteOperation implements Runnable {
* @param listenerHandler Handler associated to the thread where the methods of the listener objects must be called.
* @return Thread were the remote operation is executed.
*/
public final Thread execute(OwnCloudClient client, OnRemoteOperationListener listener, Handler listenerHandler) {
public Thread execute(OwnCloudClient client, OnRemoteOperationListener listener, Handler listenerHandler) {
if (client == null) {
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL OwnCloudClient");
}
@ -184,29 +184,6 @@ public abstract class RemoteOperation implements Runnable {
return runnerThread;
}
/**
* Synchronously retries the remote operation using the same OwnCloudClient in the last call to {@link RemoteOperation#execute(OwnCloudClient)}
*
* @param listener Listener to be notified about the execution of the operation.
* @param listenerHandler Handler associated to the thread where the methods of the listener objects must be called.
* @return Thread were the remote operation is executed.
*/
public final RemoteOperationResult retry() {
return execute(mClient);
}
/**
* Asynchronously retries the remote operation using the same OwnCloudClient in the last call to {@link RemoteOperation#execute(OwnCloudClient, OnRemoteOperationListener, Handler)}
*
* @param listener Listener to be notified about the execution of the operation.
* @param listenerHandler Handler associated to the thread where the methods of the listener objects must be called.
* @return Thread were the remote operation is executed.
*/
public final Thread retry(OnRemoteOperationListener listener, Handler listenerHandler) {
return execute(mClient, listener, listenerHandler);
}
/**
* Asynchronous execution of the operation
* started by {@link RemoteOperation#execute(OwnCloudClient, OnRemoteOperationListener, Handler)},

View File

@ -25,14 +25,11 @@
package com.owncloud.android.lib.operations.remote;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.http.HttpStatus;
import org.xmlpull.v1.XmlPullParserException;
import com.owncloud.android.lib.network.OwnCloudClient;
import com.owncloud.android.lib.operations.common.RemoteOperation;
@ -68,11 +65,12 @@ public class GetRemoteSharesOperation extends RemoteOperation {
int status = -1;
// Get Method
GetMethod get = new GetMethod(client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE);
Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE);
GetMethod get = null;
// Get the response
try{
get = new GetMethod(client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE);
Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE);
status = client.executeMethod(get);
if(isSuccess(status)) {
Log.d(TAG, "Obtain RESPONSE");
@ -93,18 +91,18 @@ public class GetRemoteSharesOperation extends RemoteOperation {
}
result.setData(sharesObjects);
}
} else {
result = new RemoteOperationResult(false, status, get.getResponseHeaders());
}
} catch (HttpException e) {
} catch (Exception e) {
result = new RemoteOperationResult(e);
e.printStackTrace();
} catch (IOException e) {
result = new RemoteOperationResult(e);
e.printStackTrace();
} catch (XmlPullParserException e) {
result = new RemoteOperationResult(e);
e.printStackTrace();
Log.e(TAG, "Exception while getting remote shares ", e);
} finally {
get.releaseConnection();
if (get != null) {
get.releaseConnection();
}
}
return result;
}