From 1811be1b52a5d80a70eb6a9eab93201cb8063af1 Mon Sep 17 00:00:00 2001 From: masensio Date: Tue, 16 Jun 2015 10:39:40 +0200 Subject: [PATCH] Prevent NullPointException when OwncloudVersion is null in CreateRemoteFolderOperation --- .../files/CreateRemoteFolderOperation.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java b/src/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java index 89078ba3..79a7de2f 100644 --- a/src/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java +++ b/src/com/owncloud/android/lib/resources/files/CreateRemoteFolderOperation.java @@ -28,12 +28,11 @@ import org.apache.jackrabbit.webdav.client.methods.MkColMethod; import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.network.WebdavUtils; -import com.owncloud.android.lib.common.operations.InvalidCharacterExceptionParser; import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode; import com.owncloud.android.lib.common.utils.Log_OC; - +import com.owncloud.android.lib.resources.status.OwnCloudVersion; /** @@ -58,7 +57,8 @@ public class CreateRemoteFolderOperation extends RemoteOperation { * Constructor * * @param remotePath Full path to the new directory to create in the remote server. - * @param createFullPath 'True' means that all the ancestor folders should be created if don't exist yet. + * @param createFullPath 'True' means that all the ancestor folders should be created + * if don't exist yet. */ public CreateRemoteFolderOperation(String remotePath, boolean createFullPath) { mRemotePath = remotePath; @@ -73,8 +73,10 @@ public class CreateRemoteFolderOperation extends RemoteOperation { @Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result = null; - boolean noInvalidChars = FileUtils.isValidPath(mRemotePath, - client.getOwnCloudVersion().isVersionWithForbiddenCharacters()); + OwnCloudVersion version = client.getOwnCloudVersion(); + boolean versionWithForbiddenChars = + (version != null && version.isVersionWithForbiddenCharacters()); + boolean noInvalidChars = FileUtils.isValidPath(mRemotePath, versionWithForbiddenChars); if (noInvalidChars) { result = createFolder(client); if (!result.isSuccess() && mCreateFullPath && @@ -105,7 +107,8 @@ public class CreateRemoteFolderOperation extends RemoteOperation { Log_OC.d(TAG, mkcol.getResponseBodyAsString()); } else { - result = new RemoteOperationResult(mkcol.succeeded(), status, mkcol.getResponseHeaders()); + result = new RemoteOperationResult(mkcol.succeeded(), status, + mkcol.getResponseHeaders()); Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage()); } client.exhaustResponse(mkcol.getResponseBodyAsStream());