use of com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation in project android by nextcloud.
the class FileDisplayActivityIT method showShares.
@Test
public // @ScreenshotTest // todo run without real server
void showShares() {
assertTrue(new ExistenceCheckRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareToGroup/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareViaLink/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/noShare/", true).execute(client).isSuccess());
// assertTrue(new CreateFolderRemoteOperation("/shareToCircle/", true).execute(client).isSuccess());
// share folder to user "admin"
assertTrue(new CreateShareRemoteOperation("/shareToAdmin/", ShareType.USER, "admin", false, "", OCShare.MAXIMUM_PERMISSIONS_FOR_FOLDER).execute(client).isSuccess());
// share folder via public link
assertTrue(new CreateShareRemoteOperation("/shareViaLink/", ShareType.PUBLIC_LINK, "", true, "", OCShare.READ_PERMISSION_FLAG).execute(client).isSuccess());
// share folder to group
Assert.assertTrue(new CreateShareRemoteOperation("/shareToGroup/", ShareType.GROUP, "users", false, "", OCShare.NO_PERMISSION).execute(client).isSuccess());
// share folder to circle
// get share
// RemoteOperationResult searchResult = new GetShareesRemoteOperation("publicCircle", 1, 50).execute(client);
// assertTrue(searchResult.getLogMessage(), searchResult.isSuccess());
//
// JSONObject resultJson = (JSONObject) searchResult.getData().get(0);
// String circleId = resultJson.getJSONObject("value").getString("shareWith");
//
// assertTrue(new CreateShareRemoteOperation("/shareToCircle/",
// ShareType.CIRCLE,
// circleId,
// false,
// "",
// OCShare.DEFAULT_PERMISSION)
// .execute(client).isSuccess());
Activity sut = activityRule.launchActivity(null);
getInstrumentation().waitForIdleSync();
EventBus.getDefault().post(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER));
shortSleep();
shortSleep();
screenshot(sut);
}
use of com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation in project android by nextcloud.
the class CreateShareWithShareeOperation method run.
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
CreateShareRemoteOperation operation = new CreateShareRemoteOperation(path, shareType, shareeName, false, sharePassword, permissions);
operation.setGetShareDetails(true);
RemoteOperationResult result = operation.execute(client);
if (result.isSuccess() && result.getData().size() > 0) {
OCShare share = (OCShare) result.getData().get(0);
// once creating share link update other information
UpdateShareInfoOperation updateShareInfoOperation = new UpdateShareInfoOperation(share, getStorageManager());
updateShareInfoOperation.setExpirationDateInMillis(expirationDateInMillis);
updateShareInfoOperation.setHideFileDownload(hideFileDownload);
updateShareInfoOperation.setNote(noteMessage);
updateShareInfoOperation.setLabel(label);
// execute and save the result in database
RemoteOperationResult updateShareInfoResult = updateShareInfoOperation.execute(client);
if (updateShareInfoResult.isSuccess() && updateShareInfoResult.getData().size() > 0) {
OCShare shareUpdated = (OCShare) updateShareInfoResult.getData().get(0);
updateData(shareUpdated);
}
}
return result;
}
use of com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation in project android by nextcloud.
the class CreateShareViaLinkOperation method run.
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
CreateShareRemoteOperation createOp = new CreateShareRemoteOperation(path, ShareType.PUBLIC_LINK, "", false, password, OCShare.NO_PERMISSION);
createOp.setGetShareDetails(true);
RemoteOperationResult result = createOp.execute(client);
if (result.isSuccess()) {
if (result.getData().size() > 0) {
Object item = result.getData().get(0);
if (item instanceof OCShare) {
updateData((OCShare) item);
} else {
ArrayList<Object> data = result.getData();
result = new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
result.setData(data);
}
} else {
result = new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
}
}
return result;
}
Aggregations