mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +00:00
Grant that GetUserNameRemoteOperation always return a non null result
This commit is contained in:
parent
1c44c7ac22
commit
5b4f63ebdb
@ -171,7 +171,7 @@ public class OwnCloudClient extends HttpClient {
|
|||||||
customRedirectionNeeded = mFollowRedirects;
|
customRedirectionNeeded = mFollowRedirects;
|
||||||
}
|
}
|
||||||
if (mSsoSessionCookie != null && mSsoSessionCookie.length() > 0) {
|
if (mSsoSessionCookie != null && mSsoSessionCookie.length() > 0) {
|
||||||
method.setRequestHeader("Cookie", mSsoSessionCookie);
|
method.addRequestHeader("Cookie", mSsoSessionCookie);
|
||||||
}
|
}
|
||||||
int status = super.executeMethod(method);
|
int status = super.executeMethod(method);
|
||||||
int redirectionsCount = 0;
|
int redirectionsCount = 0;
|
||||||
|
@ -73,21 +73,18 @@ public class GetUserNameRemoteOperation extends RemoteOperation {
|
|||||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||||
RemoteOperationResult result = null;
|
RemoteOperationResult result = null;
|
||||||
int status = -1;
|
int status = -1;
|
||||||
|
GetMethod get = null;
|
||||||
// Get Method
|
|
||||||
GetMethod get = new GetMethod(client.getBaseUri() + OCS_ROUTE);
|
|
||||||
Log.d(TAG, "URL ------> " + client.getBaseUri() + OCS_ROUTE);
|
|
||||||
// Add the Header
|
|
||||||
get.addRequestHeader(HEADER_OCS_API, HEADER_OCS_API_VALUE);
|
|
||||||
|
|
||||||
//Get the user
|
//Get the user
|
||||||
try {
|
try {
|
||||||
|
get = new GetMethod(client.getBaseUri() + OCS_ROUTE);
|
||||||
|
Log.e(TAG, "Getting OC user information from " + client.getBaseUri() + OCS_ROUTE);
|
||||||
|
// Add the Header
|
||||||
|
get.addRequestHeader(HEADER_OCS_API, HEADER_OCS_API_VALUE);
|
||||||
status = client.executeMethod(get);
|
status = client.executeMethod(get);
|
||||||
if(isSuccess(status)) {
|
if(isSuccess(status)) {
|
||||||
Log.d(TAG, "Obtain RESPONSE");
|
|
||||||
String response = get.getResponseBodyAsString();
|
String response = get.getResponseBodyAsString();
|
||||||
|
Log.d(TAG, "Successful response: " + response);
|
||||||
Log.d(TAG, "GET RESPONSE.................... " + response);
|
|
||||||
|
|
||||||
// Parse the response
|
// Parse the response
|
||||||
JSONObject respJSON = new JSONObject(response);
|
JSONObject respJSON = new JSONObject(response);
|
||||||
@ -98,21 +95,25 @@ public class GetUserNameRemoteOperation extends RemoteOperation {
|
|||||||
String email = respData.getString(NODE_EMAIL);
|
String email = respData.getString(NODE_EMAIL);
|
||||||
|
|
||||||
// Result
|
// Result
|
||||||
result = new RemoteOperationResult(isSuccess(status), status, (get != null ? get.getResponseHeaders() : null));
|
result = new RemoteOperationResult(true, status, get.getResponseHeaders());
|
||||||
mUserName = displayName;
|
mUserName = displayName;
|
||||||
|
|
||||||
Log.d(TAG, "Response: " + id + " - " + displayName + " - " + email);
|
Log.d(TAG, "*** Parsed user information: " + id + " - " + displayName + " - " + email);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
result = new RemoteOperationResult(false, status, get.getResponseHeaders());
|
||||||
|
String response = get.getResponseBodyAsString();
|
||||||
|
Log.e(TAG, "Failed response while getting user information ");
|
||||||
|
if (response != null) {
|
||||||
|
Log.e(TAG, "*** status code: " + status + " ; response message: " + response);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "*** status code: " + status);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (HttpException e) {
|
} catch (Exception e) {
|
||||||
result = new RemoteOperationResult(e);
|
result = new RemoteOperationResult(e);
|
||||||
e.printStackTrace();
|
Log.e(TAG, "Exception while getting OC user information", e);
|
||||||
} catch (IOException e) {
|
|
||||||
result = new RemoteOperationResult(e);
|
|
||||||
e.printStackTrace();
|
|
||||||
} catch (JSONException e) {
|
|
||||||
result = new RemoteOperationResult(e);
|
|
||||||
e.printStackTrace();
|
|
||||||
} finally {
|
} finally {
|
||||||
get.releaseConnection();
|
get.releaseConnection();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user