From 490374953822bb246f017cad691bc58e8ff4b24a Mon Sep 17 00:00:00 2001 From: Luke Owncloud Date: Thu, 30 Jan 2014 08:50:09 +0100 Subject: [PATCH 01/10] changed name of this oc_framework lib to android-library updated Android API in pom.xml --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index e811ffda..0254f0f6 100644 --- a/pom.xml +++ b/pom.xml @@ -4,21 +4,21 @@ 4.0.0 com.owncloud.android - oc_framework + owncloud-android-library ${owncloud.version} jar - oc_framework for Owncloud Android + owncloud-android-library for Owncloud Android 1.5.1-SNAPSHOT 1.6 - 4.4_r1 + 4.4.2_r2 19 - oc_framwork for Owncloud for Android + owncloud-android-library for Owncloud for Android From 8c87d88cff376038248216ea2eb00c0c5ed110e0 Mon Sep 17 00:00:00 2001 From: masensio Date: Mon, 3 Feb 2014 12:34:23 +0100 Subject: [PATCH 02/10] OC-2733: Add UnshareLinkkRemoteOperation to the library --- .../remote/UnshareLinkRemoteOperation.java | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 src/com/owncloud/android/lib/operations/remote/UnshareLinkRemoteOperation.java diff --git a/src/com/owncloud/android/lib/operations/remote/UnshareLinkRemoteOperation.java b/src/com/owncloud/android/lib/operations/remote/UnshareLinkRemoteOperation.java new file mode 100644 index 00000000..58ce6993 --- /dev/null +++ b/src/com/owncloud/android/lib/operations/remote/UnshareLinkRemoteOperation.java @@ -0,0 +1,113 @@ +/* ownCloud Android Library is available under MIT license + * Copyright (C) 2014 ownCloud (http://www.owncloud.org/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +package com.owncloud.android.lib.operations.remote; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import org.apache.commons.httpclient.HttpStatus; +import org.apache.jackrabbit.webdav.client.methods.DeleteMethod; + +import android.util.Log; + +import com.owncloud.android.lib.network.OwnCloudClient; +import com.owncloud.android.lib.operations.common.RemoteOperation; +import com.owncloud.android.lib.operations.common.RemoteOperationResult; +import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode; +import com.owncloud.android.lib.utils.ShareUtils; +import com.owncloud.android.lib.utils.ShareXMLParser; + +/** + * Remove a share + * + * @author masensio + * + */ + +public class UnshareLinkRemoteOperation extends RemoteOperation { + + private static final String TAG = UnshareLinkRemoteOperation.class.getSimpleName(); + + private int mIdShare; + + /** + * Constructor + * + * @param idShare Share ID + */ + + public UnshareLinkRemoteOperation(int idShare) { + mIdShare = idShare; + + } + + @Override + protected RemoteOperationResult run(OwnCloudClient client) { + RemoteOperationResult result = null; + int status = -1; + + DeleteMethod delete = null; + + try { + String id = "/" + String.valueOf(mIdShare); + delete = new DeleteMethod(client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE + id); + Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE + id); + + status = client.executeMethod(delete); + + if(isSuccess(status)) { + String response = delete.getResponseBodyAsString(); + Log.d(TAG, "Successful response: " + response); + + result = new RemoteOperationResult(ResultCode.OK); + + // Parse xml response + // convert String into InputStream + InputStream is = new ByteArrayInputStream(response.getBytes()); + ShareXMLParser xmlParser = new ShareXMLParser(); + xmlParser.parseXMLResponse(is); + if (xmlParser.isSuccess()) { + result = new RemoteOperationResult(ResultCode.OK); + } else if (xmlParser.isFilNotFound()){ + result = new RemoteOperationResult(ResultCode.FILE_NOT_FOUND); + } + Log.i(TAG, "Unshare " + id + ": " + result.getLogMessage()); + } + } catch (Exception e) { + result = new RemoteOperationResult(e); + Log.e(TAG, "Unshare Link Exception " + result.getLogMessage(), e); + + } finally { + if (delete != null) + delete.releaseConnection(); + } + return result; + } + + + private boolean isSuccess(int status) { + return (status == HttpStatus.SC_OK); + } +} \ No newline at end of file From 2252bd4c12263f163027bd81d0c6cafcce32eca2 Mon Sep 17 00:00:00 2001 From: masensio Date: Tue, 4 Feb 2014 12:30:29 +0100 Subject: [PATCH 03/10] Changes from comments in PR #8 --- .../common/RemoteOperationResult.java | 3 +- .../remote/CreateShareRemoteOperation.java | 2 +- .../remote/UnshareLinkRemoteOperation.java | 113 ------------------ .../android/lib/utils/ShareXMLParser.java | 2 +- 4 files changed, 4 insertions(+), 116 deletions(-) delete mode 100644 src/com/owncloud/android/lib/operations/remote/UnshareLinkRemoteOperation.java diff --git a/src/com/owncloud/android/lib/operations/common/RemoteOperationResult.java b/src/com/owncloud/android/lib/operations/common/RemoteOperationResult.java index ba5dd2c0..acd30590 100644 --- a/src/com/owncloud/android/lib/operations/common/RemoteOperationResult.java +++ b/src/com/owncloud/android/lib/operations/common/RemoteOperationResult.java @@ -97,7 +97,8 @@ public class RemoteOperationResult implements Serializable { ACCOUNT_EXCEPTION, ACCOUNT_NOT_NEW, ACCOUNT_NOT_THE_SAME, - INVALID_CHARACTER_IN_NAME + INVALID_CHARACTER_IN_NAME, + SHARE_NOT_FOUND } private boolean mSuccess = false; diff --git a/src/com/owncloud/android/lib/operations/remote/CreateShareRemoteOperation.java b/src/com/owncloud/android/lib/operations/remote/CreateShareRemoteOperation.java index 3e985da2..744ffabd 100644 --- a/src/com/owncloud/android/lib/operations/remote/CreateShareRemoteOperation.java +++ b/src/com/owncloud/android/lib/operations/remote/CreateShareRemoteOperation.java @@ -139,7 +139,7 @@ public class CreateShareRemoteOperation extends RemoteOperation { } result.setData(sharesObjects); } - } else if (xmlParser.isFilNotFound()){ + } else if (xmlParser.isFileNotFound()){ result = new RemoteOperationResult(ResultCode.FILE_NOT_FOUND); } diff --git a/src/com/owncloud/android/lib/operations/remote/UnshareLinkRemoteOperation.java b/src/com/owncloud/android/lib/operations/remote/UnshareLinkRemoteOperation.java deleted file mode 100644 index 58ce6993..00000000 --- a/src/com/owncloud/android/lib/operations/remote/UnshareLinkRemoteOperation.java +++ /dev/null @@ -1,113 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * Copyright (C) 2014 ownCloud (http://www.owncloud.org/) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -package com.owncloud.android.lib.operations.remote; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import org.apache.commons.httpclient.HttpStatus; -import org.apache.jackrabbit.webdav.client.methods.DeleteMethod; - -import android.util.Log; - -import com.owncloud.android.lib.network.OwnCloudClient; -import com.owncloud.android.lib.operations.common.RemoteOperation; -import com.owncloud.android.lib.operations.common.RemoteOperationResult; -import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode; -import com.owncloud.android.lib.utils.ShareUtils; -import com.owncloud.android.lib.utils.ShareXMLParser; - -/** - * Remove a share - * - * @author masensio - * - */ - -public class UnshareLinkRemoteOperation extends RemoteOperation { - - private static final String TAG = UnshareLinkRemoteOperation.class.getSimpleName(); - - private int mIdShare; - - /** - * Constructor - * - * @param idShare Share ID - */ - - public UnshareLinkRemoteOperation(int idShare) { - mIdShare = idShare; - - } - - @Override - protected RemoteOperationResult run(OwnCloudClient client) { - RemoteOperationResult result = null; - int status = -1; - - DeleteMethod delete = null; - - try { - String id = "/" + String.valueOf(mIdShare); - delete = new DeleteMethod(client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE + id); - Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE + id); - - status = client.executeMethod(delete); - - if(isSuccess(status)) { - String response = delete.getResponseBodyAsString(); - Log.d(TAG, "Successful response: " + response); - - result = new RemoteOperationResult(ResultCode.OK); - - // Parse xml response - // convert String into InputStream - InputStream is = new ByteArrayInputStream(response.getBytes()); - ShareXMLParser xmlParser = new ShareXMLParser(); - xmlParser.parseXMLResponse(is); - if (xmlParser.isSuccess()) { - result = new RemoteOperationResult(ResultCode.OK); - } else if (xmlParser.isFilNotFound()){ - result = new RemoteOperationResult(ResultCode.FILE_NOT_FOUND); - } - Log.i(TAG, "Unshare " + id + ": " + result.getLogMessage()); - } - } catch (Exception e) { - result = new RemoteOperationResult(e); - Log.e(TAG, "Unshare Link Exception " + result.getLogMessage(), e); - - } finally { - if (delete != null) - delete.releaseConnection(); - } - return result; - } - - - private boolean isSuccess(int status) { - return (status == HttpStatus.SC_OK); - } -} \ No newline at end of file diff --git a/src/com/owncloud/android/lib/utils/ShareXMLParser.java b/src/com/owncloud/android/lib/utils/ShareXMLParser.java index 9ada0017..828714c5 100644 --- a/src/com/owncloud/android/lib/utils/ShareXMLParser.java +++ b/src/com/owncloud/android/lib/utils/ShareXMLParser.java @@ -115,7 +115,7 @@ public class ShareXMLParser { public boolean isFailure() { return mStatusCode == FAILURE; } - public boolean isFilNotFound() { + public boolean isFileNotFound() { return mStatusCode == FILE_NOT_FOUND; } From ccb079935f53dcd97c5b21ca121f31dd611a094e Mon Sep 17 00:00:00 2001 From: masensio Date: Tue, 4 Feb 2014 12:32:55 +0100 Subject: [PATCH 04/10] Changes from comments in PR #385 --- .../remote/RemoveRemoteShareOperation.java | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 src/com/owncloud/android/lib/operations/remote/RemoveRemoteShareOperation.java diff --git a/src/com/owncloud/android/lib/operations/remote/RemoveRemoteShareOperation.java b/src/com/owncloud/android/lib/operations/remote/RemoveRemoteShareOperation.java new file mode 100644 index 00000000..8f467ff4 --- /dev/null +++ b/src/com/owncloud/android/lib/operations/remote/RemoveRemoteShareOperation.java @@ -0,0 +1,118 @@ +/* ownCloud Android Library is available under MIT license + * Copyright (C) 2014 ownCloud (http://www.owncloud.org/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +package com.owncloud.android.lib.operations.remote; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import org.apache.commons.httpclient.HttpStatus; +import org.apache.jackrabbit.webdav.client.methods.DeleteMethod; + +import android.util.Log; + +import com.owncloud.android.lib.network.OwnCloudClient; +import com.owncloud.android.lib.operations.common.RemoteOperation; +import com.owncloud.android.lib.operations.common.RemoteOperationResult; +import com.owncloud.android.lib.operations.common.RemoteOperationResult.ResultCode; +import com.owncloud.android.lib.utils.ShareUtils; +import com.owncloud.android.lib.utils.ShareXMLParser; + +/** + * Remove a share + * + * @author masensio + * + */ + +public class RemoveRemoteShareOperation extends RemoteOperation { + + private static final String TAG = RemoveRemoteShareOperation.class.getSimpleName(); + + private int mIdShare; + + /** + * Constructor + * + * @param idShare Share ID + */ + + public RemoveRemoteShareOperation(int idShare) { + mIdShare = idShare; + + } + + @Override + protected RemoteOperationResult run(OwnCloudClient client) { + RemoteOperationResult result = null; + int status = -1; + + DeleteMethod delete = null; + + try { + String id = "/" + String.valueOf(mIdShare); + delete = new DeleteMethod(client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE + id); + Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHAREAPI_ROUTE + id); + + status = client.executeMethod(delete); + + if(isSuccess(status)) { + String response = delete.getResponseBodyAsString(); + Log.d(TAG, "Successful response: " + response); + + result = new RemoteOperationResult(ResultCode.OK); + + // Parse xml response + // convert String into InputStream + InputStream is = new ByteArrayInputStream(response.getBytes()); + ShareXMLParser xmlParser = new ShareXMLParser(); + xmlParser.parseXMLResponse(is); + if (xmlParser.isSuccess()) { + result = new RemoteOperationResult(ResultCode.OK); + } else if (xmlParser.isFileNotFound()){ + result = new RemoteOperationResult(ResultCode.SHARE_NOT_FOUND); + } else { + result = new RemoteOperationResult(false, status, delete.getResponseHeaders()); + } + + Log.i(TAG, "Unshare " + id + ": " + result.getLogMessage()); + } else { + result = new RemoteOperationResult(false, status, delete.getResponseHeaders()); + } + } catch (Exception e) { + result = new RemoteOperationResult(e); + Log.e(TAG, "Unshare Link Exception " + result.getLogMessage(), e); + + } finally { + if (delete != null) + delete.releaseConnection(); + } + return result; + } + + + private boolean isSuccess(int status) { + return (status == HttpStatus.SC_OK); + } +} \ No newline at end of file From a42ac0e5adf296472625390991133a72de0149b8 Mon Sep 17 00:00:00 2001 From: masensio Date: Tue, 4 Feb 2014 14:40:07 +0100 Subject: [PATCH 05/10] OC-2736: Create unit tests for GetShares Operation --- tests/res/values/setup.xml | 32 +++++++++ .../lib/test_project/TestActivity.java | 66 +++++++++++++------ .../test_project/test/DownloadFileTest.java | 2 + .../lib/test_project/test/GetSharesTest.java | 62 +++++++++++++++++ 4 files changed, 142 insertions(+), 20 deletions(-) create mode 100644 tests/res/values/setup.xml create mode 100644 tests/test_cases/src/com/owncloud/android/lib/test_project/test/GetSharesTest.java diff --git a/tests/res/values/setup.xml b/tests/res/values/setup.xml new file mode 100644 index 00000000..4839b1bc --- /dev/null +++ b/tests/res/values/setup.xml @@ -0,0 +1,32 @@ + + + + + + /remote.php/webdav + + + true + diff --git a/tests/src/com/owncloud/android/lib/test_project/TestActivity.java b/tests/src/com/owncloud/android/lib/test_project/TestActivity.java index d6caf3c6..b63a9990 100644 --- a/tests/src/com/owncloud/android/lib/test_project/TestActivity.java +++ b/tests/src/com/owncloud/android/lib/test_project/TestActivity.java @@ -1,17 +1,24 @@ -/* ownCloud Android client application - * Copyright (C) 2012-2013 ownCloud Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . +/* ownCloud Android Library is available under MIT license + * Copyright (C) 2014 ownCloud (http://www.owncloud.org/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. * */ @@ -26,6 +33,7 @@ import com.owncloud.android.lib.operations.common.RemoteOperationResult; import com.owncloud.android.lib.operations.remote.ChunkedUploadRemoteFileOperation; import com.owncloud.android.lib.operations.remote.CreateRemoteFolderOperation; import com.owncloud.android.lib.operations.remote.DownloadRemoteFileOperation; +import com.owncloud.android.lib.operations.remote.GetRemoteSharesOperation; import com.owncloud.android.lib.operations.remote.ReadRemoteFolderOperation; import com.owncloud.android.lib.operations.remote.RemoveRemoteFileOperation; import com.owncloud.android.lib.operations.remote.RenameRemoteFileOperation; @@ -46,11 +54,12 @@ import android.view.Menu; public class TestActivity extends Activity { - // This account must exists on the simulator / device - private static final String mServerUri = "https://beta.owncloud.com/owncloud/remote.php/webdav"; - private static final String mUser = "testandroid"; - private static final String mPass = "testandroid"; - private static final boolean mChunked = true; + // This account must exists on the server side + private String mServerUri; + private String mWebdavPath; + private String mUser; + private String mPass; + private boolean mChunked; //private Account mAccount = null; private OwnCloudClient mClient; @@ -59,9 +68,18 @@ public class TestActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_test); - Uri uri = Uri.parse(mServerUri); + + mServerUri = getString(R.string.server_base_url); + mWebdavPath = getString(R.string.webdav_path); + mUser = getString(R.string.username); + mPass = getString(R.string.password); + mChunked = getResources().getBoolean(R.bool.chunked); + + Uri uri = Uri.parse(mServerUri + mWebdavPath); mClient = OwnCloudClientFactory.createOwnCloudClient(uri ,getApplicationContext(), true); mClient.setBasicCredentials(mUser, mPass); + mClient.setBaseUri(Uri.parse(mServerUri)); + } @Override @@ -171,4 +189,12 @@ public class TestActivity extends Activity { return result; } + + public RemoteOperationResult getShares(){ + + GetRemoteSharesOperation getOperation = new GetRemoteSharesOperation(); + RemoteOperationResult result = getOperation.execute(mClient); + + return result; + } } diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java b/tests/test_cases/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java index 2eb523a2..904360ab 100644 --- a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java +++ b/tests/test_cases/src/com/owncloud/android/lib/test_project/test/DownloadFileTest.java @@ -127,4 +127,6 @@ public class DownloadFileTest extends ActivityInstrumentationTestCase2 { + + private TestActivity mActivity; + + public GetSharesTest() { + super(TestActivity.class); + + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + setActivityInitialTouchMode(false); + mActivity = getActivity(); + } + + /** + * Test Get Shares: the server must support SHARE API + */ + public void testGetShares() { + RemoteOperationResult result = mActivity.getShares(); + assertTrue(result.isSuccess()); + } +} From aec92fcb12ab1f76ceb566b312b0fa085b93bad8 Mon Sep 17 00:00:00 2001 From: masensio Date: Tue, 4 Feb 2014 15:05:08 +0100 Subject: [PATCH 06/10] OC-2737: Unit Tests for Create Share --- tests/res/values/setup.xml | 6 +- .../lib/test_project/TestActivity.java | 35 +++++++++++ .../test_project/test/CreateShareTest.java | 59 +++++++++++++++++++ 3 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 tests/test_cases/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java diff --git a/tests/res/values/setup.xml b/tests/res/values/setup.xml index 4839b1bc..88bad26a 100644 --- a/tests/res/values/setup.xml +++ b/tests/res/values/setup.xml @@ -24,9 +24,9 @@ --> - + https://daily.owncloud.com/master/owncloud /remote.php/webdav - - + maria + maria true diff --git a/tests/src/com/owncloud/android/lib/test_project/TestActivity.java b/tests/src/com/owncloud/android/lib/test_project/TestActivity.java index b63a9990..3fb5b84b 100644 --- a/tests/src/com/owncloud/android/lib/test_project/TestActivity.java +++ b/tests/src/com/owncloud/android/lib/test_project/TestActivity.java @@ -30,8 +30,10 @@ import com.owncloud.android.lib.network.OwnCloudClientFactory; import com.owncloud.android.lib.network.OwnCloudClient; import com.owncloud.android.lib.operations.common.RemoteFile; import com.owncloud.android.lib.operations.common.RemoteOperationResult; +import com.owncloud.android.lib.operations.common.ShareType; import com.owncloud.android.lib.operations.remote.ChunkedUploadRemoteFileOperation; import com.owncloud.android.lib.operations.remote.CreateRemoteFolderOperation; +import com.owncloud.android.lib.operations.remote.CreateShareRemoteOperation; import com.owncloud.android.lib.operations.remote.DownloadRemoteFileOperation; import com.owncloud.android.lib.operations.remote.GetRemoteSharesOperation; import com.owncloud.android.lib.operations.remote.ReadRemoteFolderOperation; @@ -190,6 +192,11 @@ public class TestActivity extends Activity { return result; } + + /** Access to the library method to Get Shares + * + * @return + */ public RemoteOperationResult getShares(){ GetRemoteSharesOperation getOperation = new GetRemoteSharesOperation(); @@ -197,4 +204,32 @@ public class TestActivity extends Activity { return result; } + + /** Access to the library method to Create Share + * @param path Full path of the file/folder being shared. Mandatory argument + * @param shareType ‘0’ = user, ‘1’ = group, ‘3’ = Public link. Mandatory argument + * @param shareWith User/group ID with who the file should be shared. This is mandatory for shareType of 0 or 1 + * @param publicUpload If ‘false’ (default) public cannot upload to a public shared folder. + * If ‘true’ public can upload to a shared folder. Only available for public link shares + * @param password Password to protect a public link share. Only available for public link shares + * @param permissions 1 - Read only – Default for “public” shares + * 2 - Update + * 4 - Create + * 8 - Delete + * 16- Re-share + * 31- All above – Default for “private” shares + * For user or group shares. + * To obtain combinations, add the desired values together. + * For instance, for “Re-Share”, “delete”, “read”, “update”, add 16+8+2+1 = 27. + * + * @return + */ + public RemoteOperationResult createShare(String path, ShareType shareType, String shareWith, boolean publicUpload, + String password, int permissions){ + + CreateShareRemoteOperation createOperation = new CreateShareRemoteOperation(path, shareType, shareWith, publicUpload, password, permissions); + RemoteOperationResult result = createOperation.execute(mClient); + + return result; + } } diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java b/tests/test_cases/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java new file mode 100644 index 00000000..b9e89f0e --- /dev/null +++ b/tests/test_cases/src/com/owncloud/android/lib/test_project/test/CreateShareTest.java @@ -0,0 +1,59 @@ +/* ownCloud Android Library is available under MIT license + * Copyright (C) 2014 ownCloud (http://www.owncloud.org/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +package com.owncloud.android.lib.test_project.test; + +import com.owncloud.android.lib.operations.common.RemoteOperationResult; +import com.owncloud.android.lib.operations.common.ShareType; +import com.owncloud.android.lib.test_project.TestActivity; + +import android.test.ActivityInstrumentationTestCase2; + +public class CreateShareTest extends ActivityInstrumentationTestCase2 { + + /* File to share.*/ + private final String mFileToShare = "/fileToShare.png"; + + private TestActivity mActivity; + + public CreateShareTest() { + super(TestActivity.class); + + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + setActivityInitialTouchMode(false); + mActivity = getActivity(); + } + + /** + * Test Create Share: the server must support SHARE API + */ + public void testCreateShare() { + RemoteOperationResult result = mActivity.createShare(mFileToShare, ShareType.PUBLIC_LINK, "", false, "", 1); + assertTrue(result.isSuccess()); + } +} From f166bcdd8b52a64c3ad0c8725ed64ba768c1eeb5 Mon Sep 17 00:00:00 2001 From: masensio Date: Wed, 5 Feb 2014 17:14:46 +0100 Subject: [PATCH 07/10] Remove GetSharesForFileXMLParser --- .../lib/utils/GetSharesForFileXMLParser.java | 353 ------------------ 1 file changed, 353 deletions(-) delete mode 100644 src/com/owncloud/android/lib/utils/GetSharesForFileXMLParser.java diff --git a/src/com/owncloud/android/lib/utils/GetSharesForFileXMLParser.java b/src/com/owncloud/android/lib/utils/GetSharesForFileXMLParser.java deleted file mode 100644 index 3ad8b1b5..00000000 --- a/src/com/owncloud/android/lib/utils/GetSharesForFileXMLParser.java +++ /dev/null @@ -1,353 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * Copyright (C) 2014 ownCloud (http://www.owncloud.org/) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -package com.owncloud.android.lib.utils; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; - -import org.xmlpull.v1.XmlPullParser; -import org.xmlpull.v1.XmlPullParserException; -import org.xmlpull.v1.XmlPullParserFactory; - -import android.util.Log; -import android.util.Xml; - -import com.owncloud.android.lib.operations.common.OCShare; -import com.owncloud.android.lib.operations.common.ShareType; - -/** - * Parser for Share API Response: GetSharesForFile Operation - * @author masensio - * - */ -public class GetSharesForFileXMLParser { - - private static final String TAG = GetSharesForFileXMLParser.class.getSimpleName(); - - // No namespaces - private static final String ns = null; - - // NODES for XML Parser - private static final String NODE_OCS = "ocs"; - - private static final String NODE_META = "meta"; - private static final String NODE_STATUS = "status"; - private static final String NODE_STATUS_CODE = "statuscode"; - //private static final String NODE_MESSAGE = "message"; - - private static final String NODE_DATA = "data"; - private static final String NODE_ELEMENT = "element"; - private static final String NODE_ID = "id"; - private static final String NODE_ITEM_TYPE = "item_type"; - private static final String NODE_ITEM_SOURCE = "item_source"; - private static final String NODE_PARENT = "parent"; - private static final String NODE_SHARE_TYPE = "share_type"; - private static final String NODE_SHARE_WITH = "share_with"; - private static final String NODE_FILE_SOURCE = "file_source"; - private static final String NODE_PATH = "path"; - private static final String NODE_PERMISSIONS = "permissions"; - private static final String NODE_STIME = "stime"; - private static final String NODE_EXPIRATION = "expiration"; - private static final String NODE_TOKEN = "token"; - private static final String NODE_STORAGE = "storage"; - private static final String NODE_MAIL_SEND = "mail_send"; - private static final String NODE_SHARE_WITH_DISPLAY_NAME = "share_with_display_name"; - - - private static final String TYPE_FOLDER = "folder"; - - - private String mStatus; - private int mStatusCode; - - // Getters and Setters - public String getStatus() { - return mStatus; - } - - public void setStatus(String status) { - this.mStatus = status; - } - - public int getStatusCode() { - return mStatusCode; - } - - public void setStatusCode(int statusCode) { - this.mStatusCode = statusCode; - } - - // Constructor - public GetSharesForFileXMLParser() { - // TODO Auto-generated constructor stub - } - - /** - * Parse is as response of Share API - * @param is - * @return List of ShareRemoteFiles - * @throws XmlPullParserException - * @throws IOException - */ - public ArrayList parseXMLResponse(InputStream is) throws XmlPullParserException, IOException { - - try { - // XMLPullParser - XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); - factory.setNamespaceAware(true); - - XmlPullParser parser = Xml.newPullParser(); - parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); - parser.setInput(is, null); - parser.nextTag(); - return readOCS(parser); - - } finally { - is.close(); - } - } - - /** - * Parse OCS node - * @param parser - * @return List of ShareRemoteFiles - * @throws XmlPullParserException - * @throws IOException - */ - private ArrayList readOCS (XmlPullParser parser) throws XmlPullParserException, IOException { - ArrayList shares = new ArrayList(); - parser.require(XmlPullParser.START_TAG, ns , NODE_OCS); - while (parser.next() != XmlPullParser.END_TAG) { - if (parser.getEventType() != XmlPullParser.START_TAG) { - continue; - } - String name = parser.getName(); - // read NODE_META and NODE_DATA - if (name.equalsIgnoreCase(NODE_META)) { - readMeta(parser); - } else if (name.equalsIgnoreCase(NODE_DATA)) { - shares = readData(parser); - } else { - skip(parser); - } - - } - return shares; - - } - - /** - * Parse Meta node - * @param parser - * @throws XmlPullParserException - * @throws IOException - */ - private void readMeta(XmlPullParser parser) throws XmlPullParserException, IOException { - parser.require(XmlPullParser.START_TAG, ns, NODE_META); - Log.d(TAG, "---- NODE META ---"); - while (parser.next() != XmlPullParser.END_TAG) { - if (parser.getEventType() != XmlPullParser.START_TAG) { - continue; - } - String name = parser.getName(); - - if (name.equalsIgnoreCase(NODE_STATUS)) { - setStatus(readNode(parser, NODE_STATUS)); - - } else if (name.equalsIgnoreCase(NODE_STATUS_CODE)) { - setStatusCode(Integer.parseInt(readNode(parser, NODE_STATUS_CODE))); - - } else { - skip(parser); - } - - } - } - - /** - * Parse Data node - * @param parser - * @return - * @throws XmlPullParserException - * @throws IOException - */ - private ArrayList readData(XmlPullParser parser) throws XmlPullParserException, IOException { - ArrayList shares = new ArrayList(); - - parser.require(XmlPullParser.START_TAG, ns, NODE_DATA); - Log.d(TAG, "---- NODE DATA ---"); - while (parser.next() != XmlPullParser.END_TAG) { - if (parser.getEventType() != XmlPullParser.START_TAG) { - continue; - } - String name = parser.getName(); - if (name.equalsIgnoreCase(NODE_ELEMENT)) { - shares.add(readElement(parser)); - } else { - skip(parser); - - } - } - - return shares; - - } - - - /** - * Parse Element node - * @param parser - * @return - * @throws XmlPullParserException - * @throws IOException - */ - private OCShare readElement(XmlPullParser parser) throws XmlPullParserException, IOException { - parser.require(XmlPullParser.START_TAG, ns, NODE_ELEMENT); - - OCShare share = new OCShare(); - - Log.d(TAG, "---- NODE ELEMENT ---"); - while (parser.next() != XmlPullParser.END_TAG) { - if (parser.getEventType() != XmlPullParser.START_TAG) { - continue; - } - - String name = parser.getName(); - - if (name.equalsIgnoreCase(NODE_ELEMENT)) { - share = readElement(parser); - - } else if (name.equalsIgnoreCase(NODE_ID)) { - share.setIdRemoteShared(Integer.parseInt(readNode(parser, NODE_ID))); - - } else if (name.equalsIgnoreCase(NODE_ITEM_TYPE)) { - share.setIsDirectory(readNode(parser, NODE_ITEM_TYPE).equalsIgnoreCase(TYPE_FOLDER)); - - } else if (name.equalsIgnoreCase(NODE_ITEM_SOURCE)) { - share.setItemSource(Long.parseLong(readNode(parser, NODE_ITEM_SOURCE))); - - } else if (name.equalsIgnoreCase(NODE_PARENT)) { - readNode(parser, NODE_PARENT); - - } else if (name.equalsIgnoreCase(NODE_SHARE_TYPE)) { - int value = Integer.parseInt(readNode(parser, NODE_SHARE_TYPE)); - share.setShareType(ShareType.fromValue(value)); - - } else if (name.equalsIgnoreCase(NODE_SHARE_WITH)) { - share.setShareWith(readNode(parser, NODE_SHARE_WITH)); - - } else if (name.equalsIgnoreCase(NODE_FILE_SOURCE)) { - share.setFileSource(Long.parseLong(readNode(parser, NODE_FILE_SOURCE))); - - } else if (name.equalsIgnoreCase(NODE_PATH)) { - share.setPath(readNode(parser, NODE_PATH)); - - } else if (name.equalsIgnoreCase(NODE_PERMISSIONS)) { - share.setPermissions(Integer.parseInt(readNode(parser, NODE_PERMISSIONS))); - - } else if (name.equalsIgnoreCase(NODE_STIME)) { - share.setSharedDate(Long.parseLong(readNode(parser, NODE_STIME))); - - } else if (name.equalsIgnoreCase(NODE_EXPIRATION)) { - String value = readNode(parser, NODE_EXPIRATION); - if (!value.isEmpty()) { - share.setExpirationDate(Long.parseLong(readNode(parser, NODE_EXPIRATION))); // check if expiration is in long format or date format - } - - } else if (name.equalsIgnoreCase(NODE_TOKEN)) { - share.setToken(readNode(parser, NODE_TOKEN)); - - } else if (name.equalsIgnoreCase(NODE_STORAGE)) { - readNode(parser, NODE_STORAGE); - } else if (name.equalsIgnoreCase(NODE_MAIL_SEND)) { - readNode(parser, NODE_MAIL_SEND); - - } else if (name.equalsIgnoreCase(NODE_SHARE_WITH_DISPLAY_NAME)) { - share.setSharedWithDisplayName(readNode(parser, NODE_SHARE_WITH_DISPLAY_NAME)); - - } else { - skip(parser); - } - } - - return share; - } - - /** - * Parse a node, to obtain its text. Needs readText method - * @param parser - * @param node - * @return Text of the node - * @throws XmlPullParserException - * @throws IOException - */ - private String readNode (XmlPullParser parser, String node) throws XmlPullParserException, IOException{ - parser.require(XmlPullParser.START_TAG, ns, node); - String value = readText(parser); - Log.d(TAG, "node= " + node + ", value= " + value); - parser.require(XmlPullParser.END_TAG, ns, node); - return value; - } - - /** - * Read the text from a node - * @param parser - * @return Text of the node - * @throws IOException - * @throws XmlPullParserException - */ - private String readText(XmlPullParser parser) throws IOException, XmlPullParserException { - String result = ""; - if (parser.next() == XmlPullParser.TEXT) { - result = parser.getText(); - parser.nextTag(); - } - return result; - } - - /** - * Skip tags in parser procedure - * @param parser - * @throws XmlPullParserException - * @throws IOException - */ - private void skip(XmlPullParser parser) throws XmlPullParserException, IOException { - if (parser.getEventType() != XmlPullParser.START_TAG) { - throw new IllegalStateException(); - } - int depth = 1; - while (depth != 0) { - switch (parser.next()) { - case XmlPullParser.END_TAG: - depth--; - break; - case XmlPullParser.START_TAG: - depth++; - break; - } - } - } -} From aed2206804f2ca31e432e20da8c165f4cb90777a Mon Sep 17 00:00:00 2001 From: masensio Date: Thu, 6 Feb 2014 11:29:51 +0100 Subject: [PATCH 08/10] Change FILE_NOT_FOUND by SHARE_NOT_FOUND in CreateShareRemoteOperation --- .../lib/operations/remote/CreateShareRemoteOperation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/owncloud/android/lib/operations/remote/CreateShareRemoteOperation.java b/src/com/owncloud/android/lib/operations/remote/CreateShareRemoteOperation.java index 968ca71e..c5be688a 100644 --- a/src/com/owncloud/android/lib/operations/remote/CreateShareRemoteOperation.java +++ b/src/com/owncloud/android/lib/operations/remote/CreateShareRemoteOperation.java @@ -143,7 +143,7 @@ public class CreateShareRemoteOperation extends RemoteOperation { result.setData(sharesObjects); } } else if (xmlParser.isFileNotFound()){ - result = new RemoteOperationResult(ResultCode.FILE_NOT_FOUND); + result = new RemoteOperationResult(ResultCode.SHARE_NOT_FOUND); } else { result = new RemoteOperationResult(false, status, post.getResponseHeaders()); From 0f06f2f7fd3d89f3d40dce10453ae71702fa4dee Mon Sep 17 00:00:00 2001 From: masensio Date: Thu, 6 Feb 2014 13:50:33 +0100 Subject: [PATCH 09/10] OC-2738: Create unitTests in the library: unshare a item. --- tests/res/values/setup.xml | 6 +++--- .../android/lib/test_project/TestActivity.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/tests/res/values/setup.xml b/tests/res/values/setup.xml index 88bad26a..4839b1bc 100644 --- a/tests/res/values/setup.xml +++ b/tests/res/values/setup.xml @@ -24,9 +24,9 @@ --> - https://daily.owncloud.com/master/owncloud + /remote.php/webdav - maria - maria + + true diff --git a/tests/src/com/owncloud/android/lib/test_project/TestActivity.java b/tests/src/com/owncloud/android/lib/test_project/TestActivity.java index 3fb5b84b..39d16036 100644 --- a/tests/src/com/owncloud/android/lib/test_project/TestActivity.java +++ b/tests/src/com/owncloud/android/lib/test_project/TestActivity.java @@ -40,6 +40,7 @@ import com.owncloud.android.lib.operations.remote.ReadRemoteFolderOperation; import com.owncloud.android.lib.operations.remote.RemoveRemoteFileOperation; import com.owncloud.android.lib.operations.remote.RenameRemoteFileOperation; import com.owncloud.android.lib.operations.remote.UploadRemoteFileOperation; +import com.owncloud.android.lib.operations.remote.RemoveRemoteShareOperation; import com.owncloud.android.lib.test_project.R; import android.net.Uri; @@ -232,4 +233,19 @@ public class TestActivity extends Activity { return result; } + + + /** + * Access to the library method to Remove Share + * + * @param idShare Share ID + */ + + public RemoteOperationResult removeShare(int idShare) { + RemoveRemoteShareOperation removeOperation = new RemoveRemoteShareOperation(idShare); + RemoteOperationResult result = removeOperation.execute(mClient); + + return result; + + } } From 1dda56e83448a149360e1f262c4afb23a375b137 Mon Sep 17 00:00:00 2001 From: masensio Date: Thu, 6 Feb 2014 19:08:49 +0100 Subject: [PATCH 10/10] OC-2738: Create unitTests in the library: unshare a item. --- .../test_project/test/RemoveShareTest.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 tests/test_cases/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java diff --git a/tests/test_cases/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java b/tests/test_cases/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java new file mode 100644 index 00000000..ac7db165 --- /dev/null +++ b/tests/test_cases/src/com/owncloud/android/lib/test_project/test/RemoveShareTest.java @@ -0,0 +1,74 @@ +/* ownCloud Android Library is available under MIT license + * Copyright (C) 2014 ownCloud (http://www.owncloud.org/) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + */ + +package com.owncloud.android.lib.test_project.test; + +import com.owncloud.android.lib.operations.common.OCShare; +import com.owncloud.android.lib.operations.common.RemoteOperationResult; +import com.owncloud.android.lib.test_project.TestActivity; + +import android.test.ActivityInstrumentationTestCase2; +import android.util.Log; + +public class RemoveShareTest extends ActivityInstrumentationTestCase2 { + + private static final String TAG = RemoveShareTest.class.getSimpleName(); + + private TestActivity mActivity; + + public RemoveShareTest() { + super(TestActivity.class); + + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + setActivityInitialTouchMode(false); + mActivity = getActivity(); + } + + /** + * Test Remove Share: the server must support SHARE API + */ + public void testRemoveShare() { + // Get the shares + RemoteOperationResult result = mActivity.getShares(); + if (result.isSuccess()) { + int size = result.getData().size(); + + if (size > 0) { + OCShare share = ((OCShare) result.getData().get(size -1)); + long id = share.getIdRemoteShared(); + Log.d(TAG, "File to unshare: " + share.getPath() ); + result = mActivity.removeShare((int) id); // Unshare + assertTrue(result.isSuccess()); + } else { + assertTrue(true); + } + } else { + assertTrue(true); + } + } +}