Loading src/com/owncloud/android/lib/resources/users/GetRemoteUserNameOperation.java→src/com/owncloud/android/lib/resources/users/GetRemoteUserInfoOperation.java +129 −0 Original line number Diff line number Diff line Loading @@ -37,17 +37,15 @@ import com.owncloud.android.lib.common.utils.Log_OC; /** * @author masensio * Gets information (id, display name, and e-mail address) about the user logged in. * * Get the UserName for a SAML connection, from a JSON with the format: * id * display-name * email * @author masensio * @author David A. Velasco */ public class GetRemoteUserNameOperation extends RemoteOperation { public class GetRemoteUserInfoOperation extends RemoteOperation { private static final String TAG = GetRemoteUserNameOperation.class.getSimpleName(); private static final String TAG = GetRemoteUserInfoOperation.class.getSimpleName(); // OCS Route private static final String OCS_ROUTE = "/index.php/ocs/cloud/user?format=json"; Loading @@ -59,14 +57,7 @@ public class GetRemoteUserNameOperation extends RemoteOperation { private static final String NODE_DISPLAY_NAME = "display-name"; private static final String NODE_EMAIL = "email"; private String mDisplayName; public String getDisplayName() { return mDisplayName; } public GetRemoteUserNameOperation() { public GetRemoteUserInfoOperation() { } @Override Loading @@ -88,19 +79,18 @@ public class GetRemoteUserNameOperation extends RemoteOperation { JSONObject respJSON = new JSONObject(response); JSONObject respOCS = respJSON.getJSONObject(NODE_OCS); JSONObject respData = respOCS.getJSONObject(NODE_DATA); String id = respData.getString(NODE_ID); String displayName = respData.getString(NODE_DISPLAY_NAME); String email = respData.getString(NODE_EMAIL); UserInfo userInfo = new UserInfo(); userInfo.mId = respData.getString(NODE_ID); userInfo.mDisplayName = respData.getString(NODE_DISPLAY_NAME); userInfo.mEmail = respData.getString(NODE_EMAIL); // Result result = new RemoteOperationResult(true, status, get.getResponseHeaders()); // Username in result.data ArrayList<Object> data = new ArrayList<Object>(); data.add(displayName); data.add(userInfo); result.setData(data); mDisplayName = displayName; Log_OC.d(TAG, "*** Parsed user information: " + id + " - " + displayName + " - " + email); } else { result = new RemoteOperationResult(false, status, get.getResponseHeaders()); Loading @@ -117,8 +107,10 @@ public class GetRemoteUserNameOperation extends RemoteOperation { Log_OC.e(TAG, "Exception while getting OC user information", e); } finally { if (get != null) { get.releaseConnection(); } } return result; } Loading @@ -127,4 +119,11 @@ public class GetRemoteUserNameOperation extends RemoteOperation { return (status == HttpStatus.SC_OK); } public static class UserInfo { public String mId = ""; public String mDisplayName = ""; public String mEmail = ""; } } Loading
src/com/owncloud/android/lib/resources/users/GetRemoteUserNameOperation.java→src/com/owncloud/android/lib/resources/users/GetRemoteUserInfoOperation.java +129 −0 Original line number Diff line number Diff line Loading @@ -37,17 +37,15 @@ import com.owncloud.android.lib.common.utils.Log_OC; /** * @author masensio * Gets information (id, display name, and e-mail address) about the user logged in. * * Get the UserName for a SAML connection, from a JSON with the format: * id * display-name * email * @author masensio * @author David A. Velasco */ public class GetRemoteUserNameOperation extends RemoteOperation { public class GetRemoteUserInfoOperation extends RemoteOperation { private static final String TAG = GetRemoteUserNameOperation.class.getSimpleName(); private static final String TAG = GetRemoteUserInfoOperation.class.getSimpleName(); // OCS Route private static final String OCS_ROUTE = "/index.php/ocs/cloud/user?format=json"; Loading @@ -59,14 +57,7 @@ public class GetRemoteUserNameOperation extends RemoteOperation { private static final String NODE_DISPLAY_NAME = "display-name"; private static final String NODE_EMAIL = "email"; private String mDisplayName; public String getDisplayName() { return mDisplayName; } public GetRemoteUserNameOperation() { public GetRemoteUserInfoOperation() { } @Override Loading @@ -88,19 +79,18 @@ public class GetRemoteUserNameOperation extends RemoteOperation { JSONObject respJSON = new JSONObject(response); JSONObject respOCS = respJSON.getJSONObject(NODE_OCS); JSONObject respData = respOCS.getJSONObject(NODE_DATA); String id = respData.getString(NODE_ID); String displayName = respData.getString(NODE_DISPLAY_NAME); String email = respData.getString(NODE_EMAIL); UserInfo userInfo = new UserInfo(); userInfo.mId = respData.getString(NODE_ID); userInfo.mDisplayName = respData.getString(NODE_DISPLAY_NAME); userInfo.mEmail = respData.getString(NODE_EMAIL); // Result result = new RemoteOperationResult(true, status, get.getResponseHeaders()); // Username in result.data ArrayList<Object> data = new ArrayList<Object>(); data.add(displayName); data.add(userInfo); result.setData(data); mDisplayName = displayName; Log_OC.d(TAG, "*** Parsed user information: " + id + " - " + displayName + " - " + email); } else { result = new RemoteOperationResult(false, status, get.getResponseHeaders()); Loading @@ -117,8 +107,10 @@ public class GetRemoteUserNameOperation extends RemoteOperation { Log_OC.e(TAG, "Exception while getting OC user information", e); } finally { if (get != null) { get.releaseConnection(); } } return result; } Loading @@ -127,4 +119,11 @@ public class GetRemoteUserNameOperation extends RemoteOperation { return (status == HttpStatus.SC_OK); } public static class UserInfo { public String mId = ""; public String mDisplayName = ""; public String mEmail = ""; } }