Loading src/com/owncloud/android/lib/ocs/OCSResponse.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* ownCloud Android Library is available under MIT license * Copyright (C) 2018 Bartosz Przybylski * Copyright (C) 2018 Nextcloud GmbH * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ package com.owncloud.android.lib.ocs; import com.google.gson.annotations.SerializedName; /** * Wrapper for server OCS response * * @author Bartosz Przybylski */ public class OCSResponse<T extends Object> { @SerializedName("data") public T data; } src/com/owncloud/android/lib/ocs/ServerResponse.java 0 → 100644 +38 −0 Original line number Diff line number Diff line /* ownCloud Android Library is available under MIT license * Copyright (C) 2018 Bartosz Przybylski * Copyright (C) 2018 Nextcloud GmbH * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ package com.owncloud.android.lib.ocs; import com.google.gson.annotations.SerializedName; /** * Wrapper for server response * * @author Bartosz Przybylski */ public class ServerResponse<T extends Object> { @SerializedName("ocs") public OCSResponse<T> ocs; } src/com/owncloud/android/lib/resources/users/GetRemoteUserInfoOperation.java +6 −8 Original line number Diff line number Diff line Loading @@ -30,21 +30,21 @@ import android.text.TextUtils; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; import com.owncloud.android.lib.common.OwnCloudBasicCredentials; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.Quota; import com.owncloud.android.lib.common.UserInfo; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.ocs.OCSResponse; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.methods.GetMethod; import org.json.JSONException; import org.json.JSONObject; import java.lang.reflect.Type; import java.util.ArrayList; /** Loading @@ -58,9 +58,6 @@ public class GetRemoteUserInfoOperation extends RemoteOperation { private static final String TAG = GetRemoteUserInfoOperation.class.getSimpleName(); private static final String NODE_OCS = "ocs"; private static final String NODE_DATA = "data"; // OCS Route private static final String OCS_ROUTE_SELF = "/ocs/v1.php/cloud/user"; private static final String OCS_ROUTE_SEARCH = "/ocs/v1.php/cloud/users/"; Loading Loading @@ -129,9 +126,10 @@ public class GetRemoteUserInfoOperation extends RemoteOperation { Gson gson = new Gson(); JsonParser parser = new JsonParser(); JsonObject respJson = (JsonObject)parser.parse(response); Type respType = new TypeToken<OCSResponse<UserInfo>>(){}.getType(); OCSResponse<UserInfo> ocsResponse = gson.fromJson(respJson, respType); JsonObject respData = respJson.getAsJsonObject(NODE_OCS).getAsJsonObject(NODE_DATA); UserInfo userInfo = gson.fromJson(respData, UserInfo.class); UserInfo userInfo = ocsResponse.data; if (userInfo.getId() == null) { if (TextUtils.isEmpty(userID)) Loading Loading
src/com/owncloud/android/lib/ocs/OCSResponse.java 0 → 100644 +39 −0 Original line number Diff line number Diff line /* ownCloud Android Library is available under MIT license * Copyright (C) 2018 Bartosz Przybylski * Copyright (C) 2018 Nextcloud GmbH * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ package com.owncloud.android.lib.ocs; import com.google.gson.annotations.SerializedName; /** * Wrapper for server OCS response * * @author Bartosz Przybylski */ public class OCSResponse<T extends Object> { @SerializedName("data") public T data; }
src/com/owncloud/android/lib/ocs/ServerResponse.java 0 → 100644 +38 −0 Original line number Diff line number Diff line /* ownCloud Android Library is available under MIT license * Copyright (C) 2018 Bartosz Przybylski * Copyright (C) 2018 Nextcloud GmbH * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * */ package com.owncloud.android.lib.ocs; import com.google.gson.annotations.SerializedName; /** * Wrapper for server response * * @author Bartosz Przybylski */ public class ServerResponse<T extends Object> { @SerializedName("ocs") public OCSResponse<T> ocs; }
src/com/owncloud/android/lib/resources/users/GetRemoteUserInfoOperation.java +6 −8 Original line number Diff line number Diff line Loading @@ -30,21 +30,21 @@ import android.text.TextUtils; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.google.gson.reflect.TypeToken; import com.owncloud.android.lib.common.OwnCloudBasicCredentials; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.Quota; import com.owncloud.android.lib.common.UserInfo; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.lib.ocs.OCSResponse; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.methods.GetMethod; import org.json.JSONException; import org.json.JSONObject; import java.lang.reflect.Type; import java.util.ArrayList; /** Loading @@ -58,9 +58,6 @@ public class GetRemoteUserInfoOperation extends RemoteOperation { private static final String TAG = GetRemoteUserInfoOperation.class.getSimpleName(); private static final String NODE_OCS = "ocs"; private static final String NODE_DATA = "data"; // OCS Route private static final String OCS_ROUTE_SELF = "/ocs/v1.php/cloud/user"; private static final String OCS_ROUTE_SEARCH = "/ocs/v1.php/cloud/users/"; Loading Loading @@ -129,9 +126,10 @@ public class GetRemoteUserInfoOperation extends RemoteOperation { Gson gson = new Gson(); JsonParser parser = new JsonParser(); JsonObject respJson = (JsonObject)parser.parse(response); Type respType = new TypeToken<OCSResponse<UserInfo>>(){}.getType(); OCSResponse<UserInfo> ocsResponse = gson.fromJson(respJson, respType); JsonObject respData = respJson.getAsJsonObject(NODE_OCS).getAsJsonObject(NODE_DATA); UserInfo userInfo = gson.fromJson(respData, UserInfo.class); UserInfo userInfo = ocsResponse.data; if (userInfo.getId() == null) { if (TextUtils.isEmpty(userID)) Loading