1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-08 00:16:09 +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. * @param context Android context for the component calling the method.
* @return Result of the operation. * @return Result of the operation.
*/ */
public final RemoteOperationResult execute(Account account, Context context) { public RemoteOperationResult execute(Account account, Context context) {
if (account == null) if (account == null)
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Account"); throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Account");
if (context == null) 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. * @param client Client object to reach an ownCloud server during the execution of the operation.
* @return Result of the operation. * @return Result of the operation.
*/ */
public final RemoteOperationResult execute(OwnCloudClient client) { public RemoteOperationResult execute(OwnCloudClient client) {
if (client == null) if (client == null)
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL OwnCloudClient"); throw new IllegalArgumentException("Trying to execute a remote operation with a NULL OwnCloudClient");
mClient = client; 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. * @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. * @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) if (account == null)
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Account"); throw new IllegalArgumentException("Trying to execute a remote operation with a NULL Account");
if (context == null) 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. * @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. * @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) { if (client == null) {
throw new IllegalArgumentException("Trying to execute a remote operation with a NULL OwnCloudClient"); 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; 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 * Asynchronous execution of the operation
* started by {@link RemoteOperation#execute(OwnCloudClient, OnRemoteOperationListener, Handler)}, * started by {@link RemoteOperation#execute(OwnCloudClient, OnRemoteOperationListener, Handler)},

View File

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