mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Changes from comments in PR#442, in oc-project
This commit is contained in:
parent
ff4dd08dd5
commit
3bf858e2a7
@ -101,6 +101,24 @@ public class CreateRemoteShareOperation extends RemoteOperation {
|
||||
PostMethod post = null;
|
||||
|
||||
try {
|
||||
|
||||
// Check if the share link already exists
|
||||
GetRemoteSharesForFileOperation operation = new GetRemoteSharesForFileOperation(mRemoteFilePath, false, false);
|
||||
result = ((GetRemoteSharesForFileOperation)operation).execute(client);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
if (result.getData().size() > 0) {
|
||||
OCShare share = (OCShare) result.getData().get(0);
|
||||
// Update the link, build it with the token: server address + "/public.php?service=files&t=" + token
|
||||
share.setShareLink(client.getBaseUri() + ShareUtils.SHARING_LINK_TOKEN + share.getToken());
|
||||
Log.d(TAG, "Build Share link= " + share.getShareLink());
|
||||
|
||||
result = new RemoteOperationResult(ResultCode.OK);
|
||||
ArrayList<Object> sharesObjects = new ArrayList<Object>();
|
||||
sharesObjects.add(share);
|
||||
result.setData(sharesObjects);
|
||||
}
|
||||
} else {
|
||||
// Post Method
|
||||
post = new PostMethod(client.getBaseUri() + ShareUtils.SHARING_API_PATH);
|
||||
Log.d(TAG, "URL ------> " + client.getBaseUri() + ShareUtils.SHARING_API_PATH);
|
||||
@ -150,6 +168,8 @@ public class CreateRemoteShareOperation extends RemoteOperation {
|
||||
} else {
|
||||
result = new RemoteOperationResult(false, status, post.getResponseHeaders());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
result = new RemoteOperationResult(e);
|
||||
|
@ -36,4 +36,7 @@ public class ShareUtils {
|
||||
// OCS Route
|
||||
public static final String SHARING_API_PATH ="/ocs/v1.php/apps/files_sharing/api/v1/shares";
|
||||
|
||||
// String to build the link with the token of a share: server address + "/public.php?service=files&t=" + token
|
||||
public static final String SHARING_LINK_TOKEN = "/public.php?service=files&t=";
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user