Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit ed3125f4 authored by David A. Velasco's avatar David A. Velasco Committed by AndyScherzinger
Browse files

Keep http phrase in RemoteOperationResult as last chance for a detailed user message

# Conflicts:
#	src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java
#	src/com/owncloud/android/lib/resources/files/ChunkedUploadRemoteFileOperation.java
#	src/com/owncloud/android/lib/resources/files/UploadRemoteFileOperation.java
#	src/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java
#	src/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java
#	src/com/owncloud/android/lib/resources/users/RemoteGetUserQuotaOperation.java
parent cab91b1b
Loading
Loading
Loading
Loading
+2 −13
Original line number Diff line number Diff line
@@ -129,15 +129,8 @@ public class CopyRemoteFileOperation extends RemoteOperation {
                /// for other errors that could be explicitly handled, check first:
                /// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4

            } else if (status == 400) {
                result = new RemoteOperationResult(copyMethod.succeeded(),
                        copyMethod.getResponseBodyAsString(), status);
            } else {
                result = new RemoteOperationResult(
                        isSuccess(status),    // copy.succeeded()? trustful?
                        status,
                        copyMethod.getResponseHeaders()
                );
                result = new RemoteOperationResult(isSuccess(status), copyMethod);
                client.exhaustResponse(copyMethod.getResponseBodyAsStream());
            }

@@ -196,11 +189,7 @@ public class CopyRemoteFileOperation extends RemoteOperation {
        if (failFound) {
            result = new RemoteOperationResult(ResultCode.PARTIAL_COPY_DONE);
        } else {
            result = new RemoteOperationResult(
                    true,
                    HttpStatus.SC_MULTI_STATUS,
                    copyMethod.getResponseHeaders()
            );
            result = new RemoteOperationResult(true, copyMethod);
        }

        return result;
+41 −51
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import com.owncloud.android.lib.resources.status.OwnCloudVersion;
 *
 * @author David A. Velasco
 * @author masensio
 *
 */
public class CreateRemoteFolderOperation extends RemoteOperation {

@@ -100,17 +99,9 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
        MkColMethod mkcol = null;
        try {
            mkcol = new MkColMethod(client.getWebdavUri() + WebdavUtils.encodePath(mRemotePath));
    		int status =  client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);
            if ( status == 400 ) {
                result = new RemoteOperationResult(mkcol.succeeded(),
                        mkcol.getResponseBodyAsString(), status);
                Log_OC.d(TAG, mkcol.getResponseBodyAsString());

            } else {
                result = new RemoteOperationResult(mkcol.succeeded(), status,
                        mkcol.getResponseHeaders());
            client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);
            result = new RemoteOperationResult(mkcol.succeeded(), mkcol);
            Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
            }
            client.exhaustResponse(mkcol.getResponseBodyAsStream());

        } catch (Exception e) {
@@ -131,5 +122,4 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
    }



}
+41 −42
Original line number Diff line number Diff line
@@ -83,8 +83,7 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
        try {
            tmpFile.getParentFile().mkdirs();
            int status = downloadFile(client, tmpFile);
        	result = new RemoteOperationResult(isSuccess(status), status,
                    (mGet != null ? mGet.getResponseHeaders() : null));
            result = new RemoteOperationResult(isSuccess(status), mGet);
            Log_OC.i(TAG, "Download of " + mRemotePath + " to " + getTmpPath() + ": " +
                result.getLogMessage());

+6 −1
Original line number Diff line number Diff line
@@ -96,7 +96,12 @@ public class ExistenceCheckRemoteOperation extends RemoteOperation {
            client.exhaustResponse(head.getResponseBodyAsStream());
            boolean success = (status == HttpStatus.SC_OK && !mSuccessIfAbsent) ||
                    (status == HttpStatus.SC_NOT_FOUND && mSuccessIfAbsent);
            result = new RemoteOperationResult(success, status, head.getResponseHeaders());
            result = new RemoteOperationResult(
                success,
                status,
                head.getStatusText(),
                head.getResponseHeaders()
            );
            Log_OC.d(TAG, "Existence check for " + client.getWebdavUri() +
                    WebdavUtils.encodePath(mPath) + " targeting for " +
                    (mSuccessIfAbsent ? " absence " : " existence ") +
+118 −131
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ import com.owncloud.android.lib.resources.status.OwnCloudVersion;
/**
 * Remote operation moving a remote file or folder in the ownCloud server to a different folder
 * in the same account.
 * 
 * <p>
 * Allows renaming the moving file/folder at the same time.
 *
 * @author David A. Velasco
@@ -65,7 +65,7 @@ public class MoveRemoteFileOperation extends RemoteOperation {

    /**
     * Constructor.
     * 
     * <p>
     * TODO Paths should finish in "/" in the case of folders. ?
     *
     * @param srcRemotePath    Remote path of the file/folder to move.
@@ -109,7 +109,6 @@ public class MoveRemoteFileOperation extends RemoteOperation {


        /// perform remote operation
		//LocalMoveMethod move = null;
        MoveMethod move = null;
        RemoteOperationResult result = null;
        try {
@@ -133,15 +132,8 @@ public class MoveRemoteFileOperation extends RemoteOperation {
                /// for other errors that could be explicitly handled, check first:
                /// http://www.webdav.org/specs/rfc4918.html#rfc.section.9.9.4

        	} else if (status == 400) {
				result = new RemoteOperationResult(move.succeeded(),
						move.getResponseBodyAsString(), status);
            } else {
					result = new RemoteOperationResult(
							isSuccess(status), 	// move.succeeded()? trustful?
							status,
							move.getResponseHeaders()
					);
                result = new RemoteOperationResult(isSuccess(status), move);
                client.exhaustResponse(move.getResponseBodyAsStream());
            }

@@ -164,20 +156,19 @@ public class MoveRemoteFileOperation extends RemoteOperation {

    /**
     * Analyzes a multistatus response from the OC server to generate an appropriate result.
	 * 
     * <p>
     * In WebDAV, a MOVE request on collections (folders) can be PARTIALLY successful: some
     * children are moved, some other aren't.
	 *  
     * <p>
     * According to the WebDAV specification, a multistatus response SHOULD NOT include partial
     * successes (201, 204) nor for descendants of already failed children (424) in the response
     * entity. But SHOULD NOT != MUST NOT, so take carefully.
     *
     * @param move Move operation just finished with a multistatus response
	 *  @return	A result for the {@link MoveRemoteFileOperation} caller
	 *  
     * @throws IOException  If the response body could not be parsed
     * @throws DavException If the status code is other than MultiStatus or if obtaining
     *                      the response XML document fails
     * @return A result for the {@link MoveRemoteFileOperation} caller
     */
    private RemoteOperationResult processPartialError(MoveMethod move)
        throws IOException, DavException {
@@ -201,11 +192,7 @@ public class MoveRemoteFileOperation extends RemoteOperation {
        if (failFound) {
            result = new RemoteOperationResult(ResultCode.PARTIAL_MOVE_DONE);
        } else {
    		result = new RemoteOperationResult(
            		true,
            		HttpStatus.SC_MULTI_STATUS, 
            		move.getResponseHeaders()
    		);
            result = new RemoteOperationResult(true, move);
        }

        return result;
Loading