diff --git a/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java b/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java index c0227b8f..cce359b6 100644 --- a/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java +++ b/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java @@ -61,8 +61,8 @@ import javax.net.ssl.SSLException; */ public class RemoteOperationResult implements Serializable { - /** Generated - should be refreshed every time the class changes!! */; - private static final long serialVersionUID = -1909603208238358633L; + /** Generated - should be refreshed every time the class changes!! */; + private static final long serialVersionUID = 1129130415603799707L; private static final String TAG = RemoteOperationResult.class.getSimpleName(); @@ -100,20 +100,19 @@ public class RemoteOperationResult implements Serializable { ACCOUNT_NOT_THE_SAME, INVALID_CHARACTER_IN_NAME, SHARE_NOT_FOUND, - LOCAL_STORAGE_NOT_REMOVED, - FORBIDDEN, - SHARE_FORBIDDEN, - OK_REDIRECT_TO_NON_SECURE_CONNECTION, - INVALID_MOVE_INTO_DESCENDANT, + LOCAL_STORAGE_NOT_REMOVED, + FORBIDDEN, + SHARE_FORBIDDEN, + OK_REDIRECT_TO_NON_SECURE_CONNECTION, + INVALID_MOVE_INTO_DESCENDANT, INVALID_COPY_INTO_DESCENDANT, - PARTIAL_MOVE_DONE, + PARTIAL_MOVE_DONE, PARTIAL_COPY_DONE, SHARE_WRONG_PARAMETER, WRONG_SERVER_RESPONSE, INVALID_CHARACTER_DETECT_IN_SERVER, DELAYED_FOR_WIFI, - LOCAL_FILE_NOT_FOUND, - NOT_MODIFIED + LOCAL_FILE_NOT_FOUND } private boolean mSuccess = false; @@ -128,7 +127,7 @@ public class RemoteOperationResult implements Serializable { public RemoteOperationResult(ResultCode code) { mCode = code; - mSuccess = (code == ResultCode.OK || code == ResultCode.OK_SSL || + mSuccess = (code == ResultCode.OK || code == ResultCode.OK_SSL || code == ResultCode.OK_NO_SSL || code == ResultCode.OK_REDIRECT_TO_NON_SECURE_CONNECTION); mData = null; @@ -158,11 +157,9 @@ public class RemoteOperationResult implements Serializable { case HttpStatus.SC_INSUFFICIENT_STORAGE: mCode = ResultCode.QUOTA_EXCEEDED; break; - case HttpStatus.SC_FORBIDDEN: - mCode = ResultCode.FORBIDDEN; + case HttpStatus.SC_FORBIDDEN: + mCode = ResultCode.FORBIDDEN; break; - case HttpStatus.SC_NOT_MODIFIED: - mCode = ResultCode.NOT_MODIFIED; default: mCode = ResultCode.UNHANDLED_HTTP_CODE; Log_OC.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + @@ -409,13 +406,10 @@ public class RemoteOperationResult implements Serializable { return "The file name contains an forbidden character"; } else if (mCode == ResultCode.FILE_NOT_FOUND) { - return "Local file does not exist"; + return "Local file does not exist"; - } else if (mCode == ResultCode.SYNC_CONFLICT) { + } else if (mCode == ResultCode.SYNC_CONFLICT) { return "Synchronization conflict"; - - } else if (mCode == ResultCode.NOT_MODIFIED) { - return "Resource in server was not modified"; } return "Operation finished with HTTP status code " + mHttpCode + " (" + diff --git a/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java b/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java index de4e15f1..ef2a06fa 100644 --- a/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java +++ b/src/com/owncloud/android/lib/resources/files/ReadRemoteFolderOperation.java @@ -47,42 +47,28 @@ import com.owncloud.android.lib.common.utils.Log_OC; public class ReadRemoteFolderOperation extends RemoteOperation { - private static final String TAG = ReadRemoteFolderOperation.class.getSimpleName(); + private static final String TAG = ReadRemoteFolderOperation.class.getSimpleName(); - private static final String IF_NONE_MATCH_HEADER = "If-None-Match"; - - private String mRemotePath; - private String mETagToNotMatch; - private ArrayList mFolderAndFiles; - - /** + private String mRemotePath; + private ArrayList mFolderAndFiles; + + /** * Constructor * * @param remotePath Remote path of the file. */ - public ReadRemoteFolderOperation(String remotePath) { - mRemotePath = remotePath; - mETagToNotMatch = ""; - } + public ReadRemoteFolderOperation(String remotePath) { + mRemotePath = remotePath; + } - /** - * Constructor - * - * @param remotePath Remote path of the file. - */ - public ReadRemoteFolderOperation(String remotePath, String eTagToNotMatch) { - mRemotePath = remotePath; - mETagToNotMatch = (eTagToNotMatch == null) ? "" : eTagToNotMatch; - } - - /** + /** * Performs the read operation. * * @param client Client object to communicate with the remote ownCloud server. */ - @Override - protected RemoteOperationResult run(OwnCloudClient client) { - RemoteOperationResult result = null; + @Override + protected RemoteOperationResult run(OwnCloudClient client) { + RemoteOperationResult result = null; PropFindMethod query = null; try { @@ -90,17 +76,13 @@ public class ReadRemoteFolderOperation extends RemoteOperation { query = new PropFindMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath), WebdavUtils.getAllPropSet(), // PropFind Properties DavConstants.DEPTH_1); - if (mETagToNotMatch.length() > 0) { - query.addRequestHeader(IF_NONE_MATCH_HEADER, "\"" + mETagToNotMatch + "\""); - } - int status = client.executeMethod(query); // check and process response boolean isSuccess = ( status == HttpStatus.SC_MULTI_STATUS || status == HttpStatus.SC_OK - ); + ); if (isSuccess) { // get data from remote folder MultiStatus dataInServer = query.getResponseBodyAsMultiStatus(); @@ -113,7 +95,7 @@ public class ReadRemoteFolderOperation extends RemoteOperation { result.setData(mFolderAndFiles); } } else { - // synchronization failed, or no change in folder (mETagToNotMatch matched) + // synchronization failed client.exhaustResponse(query.getResponseBodyAsStream()); result = new RemoteOperationResult(false, status, query.getResponseHeaders()); } @@ -138,6 +120,10 @@ public class ReadRemoteFolderOperation extends RemoteOperation { } return result; + } + + public boolean isMultiStatus(int status) { + return (status == HttpStatus.SC_MULTI_STATUS); } /**