1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Prevent NullPointException when OwncloudVersion is null in CreateRemoteFolderOperation

This commit is contained in:
masensio 2015-06-16 10:39:40 +02:00
parent 060ca75f17
commit 1811be1b52

View File

@ -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());