+ \r
+ \r
+ /**\r
+ * Check if a file exists in the OC server\r
+ * \r
+ * @return 'Boolean.TRUE' if the file exists; 'Boolean.FALSE' it doesn't exist; NULL if couldn't be checked\r
+ */\r
+ public Boolean existsFile(String path) {\r
+ try {\r
+ HeadMethod head = new HeadMethod(mUri.toString() + WebdavUtils.encodePath(path));\r
+ int status = executeMethod(head);\r
+ return (status == HttpStatus.SC_OK);\r
+ } catch (Exception e) {\r
+ e.printStackTrace();\r
+ return null;\r
+ }\r
+ }\r
+\r
+\r
+ /**\r
+ * Requests the received method with the received timeout (milliseconds).\r
+ * \r
+ * Executes the method through the inherited HttpClient.executedMethod(method).\r
+ * \r
+ * Sets the socket timeout for the HttpMethodBase method received.\r
+ * \r
+ * @param method HTTP method request.\r
+ * @param timeout Timeout to set, in milliseconds; <= 0 means infinite.\r
+ */\r
+ public int executeMethod(HttpMethodBase method, int readTimeout) throws HttpException, IOException {\r
+ int oldSoTimeout = getParams().getSoTimeout();\r
+ try {\r
+ if (readTimeout < 0) { \r
+ readTimeout = 0;\r
+ }\r
+ HttpMethodParams params = method.getParams();\r
+ params.setSoTimeout(readTimeout); \r
+ method.setParams(params); // this should be enough...\r
+ getParams().setSoTimeout(readTimeout); // ... but this is necessary for HTTPS\r
+ return executeMethod(method);\r
+ } finally {\r
+ getParams().setSoTimeout(oldSoTimeout);\r
+ }\r
+ }\r