*/\r
public boolean downloadFile(String remoteFilepath, File targetFile) {\r
boolean ret = false;\r
- boolean caughtException = false;\r
GetMethod get = new GetMethod(mUri.toString() + WebdavUtils.encodePath(remoteFilepath));\r
\r
int status = -1;\r
\r
} catch (HttpException e) {\r
Log.e(TAG, "HTTP exception downloading " + remoteFilepath, e);\r
- caughtException = true;\r
\r
} catch (IOException e) {\r
Log.e(TAG, "I/O exception downloading " + remoteFilepath, e);\r
- caughtException = true;\r
\r
} catch (Exception e) {\r
Log.e(TAG, "Unexpected exception downloading " + remoteFilepath, e);\r
- caughtException = true;\r
\r
} finally {\r
if (!ret) {\r
- if (!caughtException) {\r
+ if (status >= 0) {\r
Log.e(TAG, "Download of " + remoteFilepath + " to " + targetFile + " failed with HTTP status " + status);\r
}\r
if (targetFile.exists()) {\r
*/\r
public boolean putFile(String localFile, String remoteTarget, String contentType) {\r
boolean result = false;\r
- boolean caughtException = false;\r
- int status = 0;\r
+ int status = -1;\r
\r
try {\r
File f = new File(localFile);\r
\r
} catch (HttpException e) {\r
Log.e(TAG, "HTTP exception uploading " + localFile + " to " + remoteTarget, e);\r
- caughtException = true;\r
\r
} catch (IOException e) {\r
Log.e(TAG, "I/O exception uploading " + localFile + " to " + remoteTarget, e);\r
- caughtException = true;\r
\r
} catch (Exception e) {\r
Log.e(TAG, "Unexpected exception uploading " + localFile + " to " + remoteTarget, e);\r
- caughtException = true;\r
}\r
\r
- if (!result && !caughtException) Log.e(TAG, "Upload of " + localFile + " to " + remoteTarget + " FAILED with HTTP status " + status);\r
+ if (!result && status >= 0) Log.e(TAG, "Upload of " + localFile + " to " + remoteTarget + " FAILED with HTTP status " + status);\r
\r
return result;\r
}\r
* @return 'True' when the directory is successfully created\r
*/\r
public boolean createDirectory(String path) {\r
+ boolean result = false;\r
+ int status = -1;\r
try {\r
MkColMethod mkcol = new MkColMethod(mUri.toString() + WebdavUtils.encodePath(path));\r
- int status = executeMethod(mkcol);\r
- Log.d(TAG, "Status returned " + status);\r
- Log.d(TAG, "uri: " + mkcol.getURI().toString());\r
- Log.i(TAG, "Creating dir completed");\r
- } catch (final Exception e) {\r
- e.printStackTrace();\r
- return false;\r
+ Log.d(TAG, "Creating directory " + path);\r
+ status = executeMethod(mkcol);\r
+ Log.d(TAG, "Status returned: " + status);\r
+ result = mkcol.succeeded();\r
+ \r
+ } catch (HttpException e) {\r
+ Log.e(TAG, "HTTP exception creating directory " + path, e);\r
+\r
+ } catch (IOException e) {\r
+ Log.e(TAG, "I/O exception creating directory " + path, e);\r
+\r
+ } catch (Exception e) {\r
+ Log.e(TAG, "Unexpected exception creating directory " + path, e);\r
+ \r
}\r
- return true;\r
+ if (!result && status >= 0) {\r
+ Log.e(TAG, "Creation of directory " + path + " failed with HTTP status " + status);\r
+ }\r
+ return result;\r
}\r
\r
\r