Compare commits

...
1 Commits
Author SHA1 Message Date
tobiasKaminsky b234ea908e Fix share response type
Signed-off-by: tobiasKaminsky <[email protected]>
2021-07-08 09:13:27 +02:00
5 changed files with 24 additions and 28 deletions

No files matched your search

@@ -31,6 +31,7 @@ import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.operations.common.SyncOperation;
import java.util.ArrayList;
import java.util.List;
/**
* Creates a new public share for a given file
@@ -54,20 +55,20 @@ public class CreateShareViaLinkOperation extends SyncOperation {
password,
OCShare.NO_PERMISSION);
createOp.setGetShareDetails(true);
RemoteOperationResult result = createOp.execute(client);
RemoteOperationResult<List<OCShare>> 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);
if (result.getResultData().size() > 0) {
OCShare item = result.getResultData().get(0);
if (item != null) {
updateData(item);
} else {
ArrayList<Object> data = result.getData();
result = new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
result = new RemoteOperationResult<>(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
result.setData(data);
}
} else {
result = new RemoteOperationResult(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
result = new RemoteOperationResult<>(RemoteOperationResult.ResultCode.SHARE_NOT_FOUND);
}
}
@@ -678,25 +678,21 @@ public class RefreshFolderOperation extends RemoteOperation {
/**
* Syncs the Share resources for the files contained in the folder refreshed (children, not deeper descendants).
*
* @param client Handler of a session with an OC server.
* @return The result of the remote operation retrieving the Share resources in the folder refreshed by
* the operation.
* @param client Handler of a session with an OC server.
* @return The result of the remote operation retrieving the Share resources in the folder refreshed by the
* operation.
*/
private RemoteOperationResult refreshSharesForFolder(OwnCloudClient client) {
RemoteOperationResult result;
private RemoteOperationResult<List<OCShare>> refreshSharesForFolder(OwnCloudClient client) {
// remote request
GetSharesForFileRemoteOperation operation =
new GetSharesForFileRemoteOperation(mLocalFolder.getRemotePath(), true, true);
result = operation.execute(client);
RemoteOperationResult<List<OCShare>> result = new GetSharesForFileRemoteOperation(mLocalFolder.getRemotePath(),
true,
true)
.execute(client);
if (result.isSuccess()) {
// update local database
ArrayList<OCShare> shares = new ArrayList<>();
OCShare share;
for (Object obj : result.getData()) {
share = (OCShare) obj;
for (OCShare share : result.getResultData()) {
if (!ShareType.NO_SHARED.equals(share.getShareType())) {
shares.add(share);
}
@@ -21,13 +21,13 @@
package com.owncloud.android.operations;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.shares.GetShareRemoteOperation;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.UpdateShareRemoteOperation;
import com.owncloud.android.operations.common.SyncOperation;
import java.util.List;
/**
* Updates an existing public share for a given file
@@ -58,10 +58,9 @@ public class UpdateShareViaLinkOperation extends SyncOperation {
if (result.isSuccess()) {
// Retrieve updated share / save directly with password? -> no; the password is not to be saved
RemoteOperation getShareOp = new GetShareRemoteOperation(publicShare.getRemoteId());
result = getShareOp.execute(client);
result = new GetShareRemoteOperation(publicShare.getRemoteId()).execute(client);
if (result.isSuccess()) {
OCShare share = (OCShare) result.getData().get(0);
OCShare share = ((RemoteOperationResult<List<OCShare>>) result).getResultData().get(0);
getStorageManager().saveShare(share);
}
}
@@ -93,6 +93,7 @@ import com.owncloud.android.utils.theme.ThemeToolbarUtils;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
@@ -779,7 +780,7 @@ public abstract class FileActivity extends DrawerActivity
}
private void onCreateShareViaLinkOperationFinish(CreateShareViaLinkOperation operation,
RemoteOperationResult result) {
RemoteOperationResult<List<OCShare>> result) {
FileDetailSharingFragment sharingFragment = getShareFileFragment();
if (result.isSuccess()) {
@@ -789,8 +790,7 @@ public abstract class FileActivity extends DrawerActivity
// therefore filtering for public_link
String link = "";
OCFile file = null;
for (Object object : result.getData()) {
OCShare shareLink = (OCShare) object;
for (OCShare shareLink : result.getResultData()) {
if (TAG_PUBLIC_LINK.equalsIgnoreCase(shareLink.getShareType().name())) {
link = shareLink.getShareLink();
file = getStorageManager().getFileByPath(shareLink.getPath());
@@ -642,7 +642,7 @@ public class FileOperationsHelper {
*/
public void setPermissionsToShare(OCShare share, int permissions) {
Intent updateShareIntent = new Intent(fileActivity, OperationsService.class);
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_USER_SHARE);
updateShareIntent.setAction(OperationsService.ACTION_UPDATE_PUBLIC_SHARE);
updateShareIntent.putExtra(OperationsService.EXTRA_ACCOUNT, fileActivity.getAccount());
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_ID, share.getId());
updateShareIntent.putExtra(OperationsService.EXTRA_SHARE_PERMISSIONS, permissions);