1 /* ownCloud Android client application
2 * Copyright (C) 2014 ownCloud Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package com
.owncloud
.android
.operations
;
21 * Creates a new share from a given file
27 import com
.owncloud
.android
.datamodel
.FileDataStorageManager
;
28 import com
.owncloud
.android
.lib
.network
.OwnCloudClient
;
29 import com
.owncloud
.android
.lib
.operations
.common
.RemoteOperation
;
30 import com
.owncloud
.android
.lib
.operations
.common
.RemoteOperationResult
;
31 import com
.owncloud
.android
.lib
.operations
.common
.ShareType
;
32 import com
.owncloud
.android
.lib
.operations
.remote
.CreateShareRemoteOperation
;
34 public class CreateShareOperation
extends RemoteOperation
{
36 private static final String TAG
= CreateShareOperation
.class.getSimpleName();
38 protected FileDataStorageManager mStorageManager
;
41 private ShareType mShareType
;
42 private String mShareWith
;
43 private boolean mPublicUpload
;
44 private String mPassword
;
45 private int mPermissions
;
49 * @param path Full path of the file/folder being shared. Mandatory argument
50 * @param shareType \910\92 = user, \911\92 = group, \913\92 = Public link. Mandatory argument
51 * @param shareWith User/group ID with who the file should be shared. This is mandatory for shareType of 0 or 1
52 * @param publicUpload If \91false\92 (default) public cannot upload to a public shared folder.
53 * If \91true\92 public can upload to a shared folder. Only available for public link shares
54 * @param password Password to protect a public link share. Only available for public link shares
55 * @param permissions 1 - Read only \96 Default for \93public\94 shares
60 * 31- All above \96 Default for \93private\94 shares
61 * For user or group shares.
62 * To obtain combinations, add the desired values together.
63 * For instance, for \93Re-Share\94, \93delete\94, \93read\94, \93update\94, add 16+8+2+1 = 27.
65 public CreateShareOperation(String path
, ShareType shareType
, String shareWith
, boolean publicUpload
,
66 String password
, int permissions
) {
69 mShareType
= shareType
;
70 mShareWith
= shareWith
;
71 mPublicUpload
= publicUpload
;
73 mPermissions
= permissions
;
77 protected RemoteOperationResult
run(OwnCloudClient client
) {
78 CreateShareRemoteOperation operation
= new CreateShareRemoteOperation(mPath
, mShareType
, mShareWith
, mPublicUpload
, mPassword
, mPermissions
);
79 RemoteOperationResult result
= operation
.execute(client
);
81 if (result
.isSuccess()) {
83 // Update DB with the response