Fixed crash when an upload is confirmed with no file selected
[pub/Android/ownCloud.git] / src / com / owncloud / android / operations / RemoteOperationResult.java
index 1415228..6470338 100644 (file)
@@ -30,6 +30,7 @@ import javax.net.ssl.SSLException;
 import org.apache.commons.httpclient.ConnectTimeoutException;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpStatus;
+import org.apache.jackrabbit.webdav.DavException;
 
 import com.owncloud.android.network.CertificateCombinedException;
 
@@ -43,7 +44,7 @@ import com.owncloud.android.network.CertificateCombinedException;
  */
 public class RemoteOperationResult implements Serializable {
     
-    /** Generated - to refresh every time the class changes */
+    /** Generated - should be refreshed every time the class changes!! */
     private static final long serialVersionUID = -7805531062432602444L;
 
     
@@ -64,8 +65,14 @@ public class RemoteOperationResult implements Serializable {
         SSL_ERROR,
         SSL_RECOVERABLE_PEER_UNVERIFIED,
         BAD_OC_VERSION,
-        STORAGE_ERROR_MOVING_FROM_TMP,
-        CANCELLED
+        CANCELLED, 
+        INVALID_LOCAL_FILE_NAME, 
+        INVALID_OVERWRITE,
+        CONFLICT, 
+        SYNC_CONFLICT,
+        LOCAL_STORAGE_FULL, 
+        LOCAL_STORAGE_NOT_MOVED, 
+        LOCAL_STORAGE_NOT_COPIED
     }
 
     private boolean mSuccess = false;
@@ -96,6 +103,9 @@ public class RemoteOperationResult implements Serializable {
                 case HttpStatus.SC_INTERNAL_SERVER_ERROR:
                     mCode = ResultCode.INSTANCE_NOT_CONFIGURED;
                     break;
+                case HttpStatus.SC_CONFLICT:
+                    mCode = ResultCode.CONFLICT;
+                    break;
                 default:
                     mCode = ResultCode.UNHANDLED_HTTP_CODE;
             }
@@ -205,11 +215,17 @@ public class RemoteOperationResult implements Serializable {
             } else if (mException instanceof UnknownHostException) {
                 return "Unknown host exception";
         
-            } else if (mException instanceof SSLException) {
-                if (mCode == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED)
+            } else if (mException instanceof CertificateCombinedException) {
+                if (((CertificateCombinedException) mException).isRecoverable())
                     return "SSL recoverable exception";
                 else
                     return "SSL exception";
+                
+            } else if (mException instanceof SSLException) {
+                return "SSL exception";
+
+            } else if (mException instanceof DavException) {
+                return "Unexpected WebDAV exception";
 
             } else if (mException instanceof HttpException) {
                 return "HTTP violation";
@@ -231,12 +247,15 @@ public class RemoteOperationResult implements Serializable {
         } else if (mCode == ResultCode.BAD_OC_VERSION) {
             return "No valid ownCloud version was found at the server";
             
-        } else if (mCode == ResultCode.STORAGE_ERROR_MOVING_FROM_TMP) {
-            return "Error while moving file from temporal to final directory";
+        } else if (mCode == ResultCode.LOCAL_STORAGE_FULL) {
+            return "Local storage full";
+            
+        } else if (mCode == ResultCode.LOCAL_STORAGE_NOT_MOVED) {
+            return "Error while moving file to final directory";
         }
         
         return "Operation finished with HTTP status code " + mHttpCode + " (" + (isSuccess()?"success":"fail") + ")";
-
+        
     }
 
 }