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

Granted that GetRemoteSharesOperation returns a result when the server responses with an error

This commit is contained in:
David A. Velasco 2014-01-31 12:13:05 +01:00
parent 8ab453d630
commit d731ff0e66

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;
@ -70,11 +67,12 @@ public class GetRemoteSharesOperation extends RemoteOperation {
int status = -1;
// Get Method
GetMethod get = new GetMethod(client.getBaseUri() + SHAREAPI_ROUTE);
Log.d(TAG, "URL ------> " + client.getBaseUri() + SHAREAPI_ROUTE);
GetMethod get = null;
// Get the response
try{
get = new GetMethod(client.getBaseUri() + SHAREAPI_ROUTE);
Log.d(TAG, "URL ------> " + client.getBaseUri() + SHAREAPI_ROUTE);
status = client.executeMethod(get);
if(isSuccess(status)) {
Log.d(TAG, "Obtain RESPONSE");
@ -95,19 +93,19 @@ 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 {
if (get != null) {
get.releaseConnection();
}
}
return result;
}