diff options
author | Mert Tumer <merttumer@outlook.com> | 2018-07-08 08:04:54 -0700 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2018-07-12 15:55:47 +0200 |
commit | ec025525eb892b22a1874a295772f9653624c608 (patch) | |
tree | 117ceb606e3d2acb0a7d09716a949d8f7def5cf0 /android | |
parent | 7e04333c194eaeb161291a984a777a2fe67da104 (diff) |
tdf#118622 fix unhandled exception when selecting remove server
Change-Id: I5f0f9a1ed4a4e0a62555a33209296128572c4ffb
Reviewed-on: https://gerrit.libreoffice.org/57159
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'android')
-rw-r--r-- | android/source/src/java/org/libreoffice/storage/owncloud/OwnCloudProvider.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/android/source/src/java/org/libreoffice/storage/owncloud/OwnCloudProvider.java b/android/source/src/java/org/libreoffice/storage/owncloud/OwnCloudProvider.java index 7ae22a2d7c5f..0852ab617660 100644 --- a/android/source/src/java/org/libreoffice/storage/owncloud/OwnCloudProvider.java +++ b/android/source/src/java/org/libreoffice/storage/owncloud/OwnCloudProvider.java @@ -23,6 +23,7 @@ import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation; import com.owncloud.android.lib.resources.files.RemoteFile; + /** * Implementation of IDocumentProvider for ownCloud servers. */ @@ -79,15 +80,20 @@ public class OwnCloudProvider implements IDocumentProvider, @Override public IFile createFromUri(Context context, URI uri) { - ReadRemoteFileOperation refreshOperation = new ReadRemoteFileOperation( - uri.getPath()); - this.result = refreshOperation.execute(client); - if (!result.isSuccess()) { - throw buildRuntimeExceptionForResultCode(result.getCode()); - } - if (result.getData().size() > 0) { - return new OwnCloudFile(this, (RemoteFile) result.getData().get(0)); + if(serverUrl != "" || userName != "" || password != ""){ + ReadRemoteFileOperation refreshOperation = new ReadRemoteFileOperation( + uri.getPath()); + this.result = refreshOperation.execute(client); + if (!result.isSuccess()) { + throw buildRuntimeExceptionForResultCode(result.getCode()); + } + if (result.getData().size() > 0) { + return new OwnCloudFile(this, (RemoteFile) result.getData().get(0)); + } + } else { + throw buildRuntimeExceptionForResultCode(ResultCode.WRONG_CONNECTION); } + return null; } |