mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-08 00:16:09 +00:00
Prevent NullPointException when OwncloudVersion is null in CreateRemoteFolderOperation
This commit is contained in:
parent
060ca75f17
commit
1811be1b52
@ -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.OwnCloudClient;
|
||||||
import com.owncloud.android.lib.common.network.WebdavUtils;
|
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.RemoteOperation;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
||||||
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
|
||||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
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
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param remotePath Full path to the new directory to create in the remote server.
|
* @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) {
|
public CreateRemoteFolderOperation(String remotePath, boolean createFullPath) {
|
||||||
mRemotePath = remotePath;
|
mRemotePath = remotePath;
|
||||||
@ -73,8 +73,10 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
|||||||
@Override
|
@Override
|
||||||
protected RemoteOperationResult run(OwnCloudClient client) {
|
protected RemoteOperationResult run(OwnCloudClient client) {
|
||||||
RemoteOperationResult result = null;
|
RemoteOperationResult result = null;
|
||||||
boolean noInvalidChars = FileUtils.isValidPath(mRemotePath,
|
OwnCloudVersion version = client.getOwnCloudVersion();
|
||||||
client.getOwnCloudVersion().isVersionWithForbiddenCharacters());
|
boolean versionWithForbiddenChars =
|
||||||
|
(version != null && version.isVersionWithForbiddenCharacters());
|
||||||
|
boolean noInvalidChars = FileUtils.isValidPath(mRemotePath, versionWithForbiddenChars);
|
||||||
if (noInvalidChars) {
|
if (noInvalidChars) {
|
||||||
result = createFolder(client);
|
result = createFolder(client);
|
||||||
if (!result.isSuccess() && mCreateFullPath &&
|
if (!result.isSuccess() && mCreateFullPath &&
|
||||||
@ -105,7 +107,8 @@ public class CreateRemoteFolderOperation extends RemoteOperation {
|
|||||||
Log_OC.d(TAG, mkcol.getResponseBodyAsString());
|
Log_OC.d(TAG, mkcol.getResponseBodyAsString());
|
||||||
|
|
||||||
} else {
|
} 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());
|
Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
|
||||||
}
|
}
|
||||||
client.exhaustResponse(mkcol.getResponseBodyAsStream());
|
client.exhaustResponse(mkcol.getResponseBodyAsStream());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user