Search in sources :

Example 1 with CreateShareRemoteOperation

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);
}
Also used : CreateFolderRemoteOperation(com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation) ExistenceCheckRemoteOperation(com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) Activity(android.app.Activity) SearchEvent(com.owncloud.android.ui.events.SearchEvent) CreateShareRemoteOperation(com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation) Test(org.junit.Test)

Example 2 with CreateShareRemoteOperation

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;
}
Also used : RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) OCShare(com.owncloud.android.lib.resources.shares.OCShare) CreateShareRemoteOperation(com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation)

Example 3 with CreateShareRemoteOperation

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;
}
Also used : RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) OCShare(com.owncloud.android.lib.resources.shares.OCShare) CreateShareRemoteOperation(com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation)

Aggregations

CreateShareRemoteOperation (com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation)3 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)2 OCShare (com.owncloud.android.lib.resources.shares.OCShare)2 Activity (android.app.Activity)1 CreateFolderRemoteOperation (com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation)1 ExistenceCheckRemoteOperation (com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation)1 FileDisplayActivity (com.owncloud.android.ui.activity.FileDisplayActivity)1 SearchEvent (com.owncloud.android.ui.events.SearchEvent)1 Test (org.junit.Test)1