mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Implement GetRemoteCapabilities using new wrapper
This commit is contained in:
		
							parent
							
								
									a730980c34
								
							
						
					
					
						commit
						82b7bef113
					
				| @ -1,8 +1,39 @@ | |||||||
|  | /* ownCloud Android Library is available under MIT license | ||||||
|  |  *   Copyright (C) 2018 ownCloud 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.common.http; | package com.owncloud.android.lib.common.http; | ||||||
| 
 | 
 | ||||||
| import okhttp3.Request; | import okhttp3.Request; | ||||||
| import okhttp3.Response; | import okhttp3.Response; | ||||||
| 
 | 
 | ||||||
|  | /** | ||||||
|  |  * Wrapper to perform http calls transparently by using: | ||||||
|  |  *  - OkHttp for non webdav methods | ||||||
|  |  *  - Dav4Android for webdav methods | ||||||
|  |  * | ||||||
|  |  * @author David González Verdugo | ||||||
|  |  */ | ||||||
| public abstract class HttpBaseMethod { | public abstract class HttpBaseMethod { | ||||||
|     public abstract Response execute() throws Exception; |     public abstract Response execute() throws Exception; | ||||||
|     protected Request mRequest; |     protected Request mRequest; | ||||||
|  | |||||||
| @ -1,3 +1,27 @@ | |||||||
|  | /* ownCloud Android Library is available under MIT license | ||||||
|  |  *   Copyright (C) 2018 ownCloud 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.common.http; | package com.owncloud.android.lib.common.http; | ||||||
| 
 | 
 | ||||||
| public class HttpConstants { | public class HttpConstants { | ||||||
|  | |||||||
| @ -1,3 +1,27 @@ | |||||||
|  | /* ownCloud Android Library is available under MIT license | ||||||
|  |  *   Copyright (C) 2018 ownCloud 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.common.http.nonwebdav; | package com.owncloud.android.lib.common.http.nonwebdav; | ||||||
| 
 | 
 | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| @ -6,6 +30,10 @@ import okhttp3.OkHttpClient; | |||||||
| import okhttp3.Request; | import okhttp3.Request; | ||||||
| import okhttp3.Response; | import okhttp3.Response; | ||||||
| 
 | 
 | ||||||
|  | /** | ||||||
|  |  * OkHttp get calls wrapper | ||||||
|  |  * @author David González Verdugo | ||||||
|  |  */ | ||||||
| public class GetMethod extends HttpMethod { | public class GetMethod extends HttpMethod { | ||||||
| 
 | 
 | ||||||
|     public GetMethod(OkHttpClient okHttpClient, Request baseRequest) { |     public GetMethod(OkHttpClient okHttpClient, Request baseRequest) { | ||||||
|  | |||||||
| @ -1,3 +1,27 @@ | |||||||
|  | /* ownCloud Android Library is available under MIT license | ||||||
|  |  *   Copyright (C) 2018 ownCloud 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.common.http.nonwebdav; | package com.owncloud.android.lib.common.http.nonwebdav; | ||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.http.HttpBaseMethod; | import com.owncloud.android.lib.common.http.HttpBaseMethod; | ||||||
| @ -5,6 +29,10 @@ import com.owncloud.android.lib.common.http.HttpBaseMethod; | |||||||
| import okhttp3.OkHttpClient; | import okhttp3.OkHttpClient; | ||||||
| import okhttp3.Request; | import okhttp3.Request; | ||||||
| 
 | 
 | ||||||
|  | /** | ||||||
|  |  * Wrapper to perform OkHttp calls | ||||||
|  |  * @author David González Verdugo | ||||||
|  |  */ | ||||||
| public abstract class HttpMethod extends HttpBaseMethod { | public abstract class HttpMethod extends HttpBaseMethod { | ||||||
| 
 | 
 | ||||||
|     protected OkHttpClient mOkHttpClient; |     protected OkHttpClient mOkHttpClient; | ||||||
|  | |||||||
| @ -1,3 +1,27 @@ | |||||||
|  | /* ownCloud Android Library is available under MIT license | ||||||
|  |  *   Copyright (C) 2018 ownCloud 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.common.http.webdav; | package com.owncloud.android.lib.common.http.webdav; | ||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.http.HttpBaseMethod; | import com.owncloud.android.lib.common.http.HttpBaseMethod; | ||||||
| @ -7,6 +31,10 @@ import at.bitfire.dav4android.DavResource; | |||||||
| import okhttp3.HttpUrl; | import okhttp3.HttpUrl; | ||||||
| import okhttp3.OkHttpClient; | import okhttp3.OkHttpClient; | ||||||
| 
 | 
 | ||||||
|  | /** | ||||||
|  |  * Wrapper to perform WebDAV (dav4android) calls | ||||||
|  |  * @author David González Verdugo | ||||||
|  |  */ | ||||||
| public abstract class DavMethod extends HttpBaseMethod { | public abstract class DavMethod extends HttpBaseMethod { | ||||||
| 
 | 
 | ||||||
|     protected DavResource mDavResource; |     protected DavResource mDavResource; | ||||||
|  | |||||||
| @ -1,3 +1,27 @@ | |||||||
|  | /* ownCloud Android Library is available under MIT license | ||||||
|  |  *   Copyright (C) 2018 ownCloud 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.common.http.webdav; | package com.owncloud.android.lib.common.http.webdav; | ||||||
| 
 | 
 | ||||||
| import java.io.IOException; | import java.io.IOException; | ||||||
| @ -12,6 +36,10 @@ import okhttp3.HttpUrl; | |||||||
| import okhttp3.OkHttpClient; | import okhttp3.OkHttpClient; | ||||||
| import okhttp3.Response; | import okhttp3.Response; | ||||||
| 
 | 
 | ||||||
|  | /** | ||||||
|  |  * Propfind calls wrapper | ||||||
|  |  * @author David González Verdugo | ||||||
|  |  */ | ||||||
| public class PropfindMethod extends DavMethod { | public class PropfindMethod extends DavMethod { | ||||||
| 
 | 
 | ||||||
|     private int mDepth; |     private int mDepth; | ||||||
|  | |||||||
| @ -29,26 +29,32 @@ package com.owncloud.android.lib.resources.status; | |||||||
| import android.net.Uri; | import android.net.Uri; | ||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.OwnCloudClient; | import com.owncloud.android.lib.common.OwnCloudClient; | ||||||
|  | import com.owncloud.android.lib.common.http.HttpConstants; | ||||||
|  | import com.owncloud.android.lib.common.http.nonwebdav.GetMethod; | ||||||
| import com.owncloud.android.lib.common.operations.RemoteOperation; | import com.owncloud.android.lib.common.operations.RemoteOperation; | ||||||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult; | import com.owncloud.android.lib.common.operations.RemoteOperationResult; | ||||||
| import com.owncloud.android.lib.common.utils.Log_OC; | import com.owncloud.android.lib.common.utils.Log_OC; | ||||||
| 
 | 
 | ||||||
| import org.apache.commons.httpclient.HttpStatus; |  | ||||||
| import org.apache.commons.httpclient.methods.GetMethod; |  | ||||||
| import org.json.JSONObject; | import org.json.JSONObject; | ||||||
| 
 | 
 | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| 
 | 
 | ||||||
|  | import okhttp3.Request; | ||||||
|  | import okhttp3.Response; | ||||||
|  | 
 | ||||||
|  | import static com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode.OK; | ||||||
|  | 
 | ||||||
| /** | /** | ||||||
|  * Get the Capabilities from the server |  * Get the Capabilities from the server | ||||||
|  * |  | ||||||
|  * Save in Result.getData in a OCCapability object |  * Save in Result.getData in a OCCapability object | ||||||
|  |  * | ||||||
|  |  * @author masensio | ||||||
|  |  * @author David González Verdugo | ||||||
|  */ |  */ | ||||||
| public class GetRemoteCapabilitiesOperation extends RemoteOperation { | public class GetRemoteCapabilitiesOperation extends RemoteOperation { | ||||||
| 
 | 
 | ||||||
|     private static final String TAG = GetRemoteCapabilitiesOperation.class.getSimpleName(); |     private static final String TAG = GetRemoteCapabilitiesOperation.class.getSimpleName(); | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     // OCS Routes |     // OCS Routes | ||||||
|     private static final String OCS_ROUTE = "ocs/v2.php/cloud/capabilities"; |     private static final String OCS_ROUTE = "ocs/v2.php/cloud/capabilities"; | ||||||
| 
 | 
 | ||||||
| @ -116,9 +122,7 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation { | |||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     protected RemoteOperationResult run(OwnCloudClient client) { |     protected RemoteOperationResult run(OwnCloudClient client) { | ||||||
|         RemoteOperationResult result = null; |         RemoteOperationResult result; | ||||||
|         int status; |  | ||||||
|         GetMethod get = null; |  | ||||||
| 
 | 
 | ||||||
|         try { |         try { | ||||||
|             Uri requestUri = client.getBaseUri(); |             Uri requestUri = client.getBaseUri(); | ||||||
| @ -126,18 +130,22 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation { | |||||||
|             uriBuilder.appendEncodedPath(OCS_ROUTE);    // avoid starting "/" in this method |             uriBuilder.appendEncodedPath(OCS_ROUTE);    // avoid starting "/" in this method | ||||||
|             uriBuilder.appendQueryParameter(PARAM_FORMAT, VALUE_FORMAT); |             uriBuilder.appendQueryParameter(PARAM_FORMAT, VALUE_FORMAT); | ||||||
| 
 | 
 | ||||||
|             // Get Method |             String url = uriBuilder.build().toString(); | ||||||
|             get = new GetMethod(uriBuilder.build().toString()); |  | ||||||
|             get.addRequestHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE); |  | ||||||
| 
 | 
 | ||||||
|             status = client.executeMethod(get); |             final Request request = new Request.Builder() | ||||||
|  |                     .url(url) | ||||||
|  |                     .addHeader(OCS_API_HEADER, OCS_API_HEADER_VALUE) | ||||||
|  |                     .build(); | ||||||
| 
 | 
 | ||||||
|             if(isSuccess(status)) { |             GetMethod getMethod = new GetMethod(client.getOkHttpClient(), request); | ||||||
|                 String response = get.getResponseBodyAsString(); | 
 | ||||||
|  |             final Response response = client.executeHttpMethod(getMethod); | ||||||
|  | 
 | ||||||
|  |             if(isSuccess(response.code())) { | ||||||
|                 Log_OC.d(TAG, "Successful response: " + response); |                 Log_OC.d(TAG, "Successful response: " + response); | ||||||
| 
 | 
 | ||||||
|                 // Parse the response |                 // Parse the response | ||||||
|                 JSONObject respJSON = new JSONObject(response); |                 JSONObject respJSON = new JSONObject(response.body().string()); | ||||||
|                 JSONObject respOCS = respJSON.getJSONObject(NODE_OCS); |                 JSONObject respOCS = respJSON.getJSONObject(NODE_OCS); | ||||||
|                 JSONObject respMeta = respOCS.getJSONObject(NODE_META); |                 JSONObject respMeta = respOCS.getJSONObject(NODE_META); | ||||||
|                 JSONObject respData = respOCS.getJSONObject(NODE_DATA); |                 JSONObject respData = respOCS.getJSONObject(NODE_DATA); | ||||||
| @ -255,7 +263,7 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation { | |||||||
|                     } |                     } | ||||||
|                     // Result |                     // Result | ||||||
|                     data.add(capability); |                     data.add(capability); | ||||||
|                     result = new RemoteOperationResult(true, get); |                     result = new RemoteOperationResult(OK); | ||||||
|                     result.setData(data); |                     result.setData(data); | ||||||
| 
 | 
 | ||||||
|                     Log_OC.d(TAG, "*** Get Capabilities completed "); |                     Log_OC.d(TAG, "*** Get Capabilities completed "); | ||||||
| @ -266,29 +274,24 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation { | |||||||
|                 } |                 } | ||||||
| 
 | 
 | ||||||
|             } else { |             } else { | ||||||
|                 result = new RemoteOperationResult(false, get); |                 result = new RemoteOperationResult(false, getMethod.getRequest(), response); | ||||||
|                 String response = get.getResponseBodyAsString(); |  | ||||||
|                 Log_OC.e(TAG, "Failed response while getting capabilities from the server "); |                 Log_OC.e(TAG, "Failed response while getting capabilities from the server "); | ||||||
|                 if (response != null) { |                 if (response.body().string() != null) { | ||||||
|                     Log_OC.e(TAG, "*** status code: " + status + "; response message: " + response); |                     Log_OC.e(TAG, "*** status code: " + response.code() + "; response message: " + | ||||||
|  |                             response.body().string()); | ||||||
|                 } else { |                 } else { | ||||||
|                     Log_OC.e(TAG, "*** status code: " + status); |                     Log_OC.e(TAG, "*** status code: " + response.code()); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|         } catch (Exception e) { |         } catch (Exception e) { | ||||||
|             result = new RemoteOperationResult(e); |             result = new RemoteOperationResult(e); | ||||||
|             Log_OC.e(TAG, "Exception while getting capabilities", e); |             Log_OC.e(TAG, "Exception while getting capabilities", e); | ||||||
| 
 |  | ||||||
|         } finally { |  | ||||||
|             if (get != null) { |  | ||||||
|                 get.releaseConnection(); |  | ||||||
|             } |  | ||||||
|         } |         } | ||||||
|         return result; |         return result; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private boolean isSuccess(int status) { |     private boolean isSuccess(int status) { | ||||||
|         return (status == HttpStatus.SC_OK); |         return (status == HttpConstants.HTTP_OK); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -24,28 +24,22 @@ | |||||||
| 
 | 
 | ||||||
| package com.owncloud.android.lib.resources.status; | package com.owncloud.android.lib.resources.status; | ||||||
| 
 | 
 | ||||||
| import java.util.ArrayList; |  | ||||||
| 
 |  | ||||||
| import org.apache.commons.httpclient.HttpStatus; |  | ||||||
| 
 |  | ||||||
| import com.owncloud.android.lib.common.http.HttpConstants; |  | ||||||
| import com.owncloud.android.lib.common.http.nonwebdav.GetMethod; |  | ||||||
| import org.apache.commons.httpclient.params.HttpMethodParams; |  | ||||||
| import org.apache.commons.httpclient.params.HttpParams; |  | ||||||
| import org.json.JSONException; |  | ||||||
| import org.json.JSONObject; |  | ||||||
| 
 |  | ||||||
| import android.content.Context; | import android.content.Context; | ||||||
| import android.net.ConnectivityManager; | import android.net.ConnectivityManager; | ||||||
| import android.net.Uri; | import android.net.Uri; | ||||||
| 
 | 
 | ||||||
| import com.owncloud.android.lib.common.OwnCloudClient; | import com.owncloud.android.lib.common.OwnCloudClient; | ||||||
| import com.owncloud.android.lib.common.OwnCloudClientManagerFactory; | import com.owncloud.android.lib.common.http.HttpConstants; | ||||||
| import com.owncloud.android.lib.common.accounts.AccountUtils; | import com.owncloud.android.lib.common.http.nonwebdav.GetMethod; | ||||||
| import com.owncloud.android.lib.common.operations.RemoteOperation; | import com.owncloud.android.lib.common.operations.RemoteOperation; | ||||||
| import com.owncloud.android.lib.common.operations.RemoteOperationResult; | import com.owncloud.android.lib.common.operations.RemoteOperationResult; | ||||||
| import com.owncloud.android.lib.common.utils.Log_OC; | import com.owncloud.android.lib.common.utils.Log_OC; | ||||||
| 
 | 
 | ||||||
|  | import org.json.JSONException; | ||||||
|  | import org.json.JSONObject; | ||||||
|  | 
 | ||||||
|  | import java.util.ArrayList; | ||||||
|  | 
 | ||||||
| import okhttp3.Request; | import okhttp3.Request; | ||||||
| import okhttp3.Response; | import okhttp3.Response; | ||||||
| 
 | 
 | ||||||
| @ -121,7 +115,7 @@ public class GetRemoteStatusOperation extends RemoteOperation { | |||||||
| //                redirectedLocation = mLatestResult.getRedirectedLocation(); | //                redirectedLocation = mLatestResult.getRedirectedLocation(); | ||||||
| //            } | //            } | ||||||
| 
 | 
 | ||||||
|             if (response.code() == HttpStatus.SC_OK) { |             if (response.code() == HttpConstants.HTTP_OK) { | ||||||
| 
 | 
 | ||||||
|                 JSONObject respJSON = new JSONObject(response.body().string()); |                 JSONObject respJSON = new JSONObject(response.body().string()); | ||||||
|                 if (!respJSON.getBoolean(NODE_INSTALLED)) { |                 if (!respJSON.getBoolean(NODE_INSTALLED)) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user