move all operation to library

rename library operation to RemoteOperation
some cleanups

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2018-11-01 19:59:01 +01:00
parent 9f9adfe9af
commit 43ce903559
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
50 changed files with 304 additions and 563 deletions

View file

@ -209,9 +209,9 @@ dependencies {
// dependencies for app building
implementation 'com.android.support:multidex:1.0.3'
// implementation project('nextcloud-android-library')
genericImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
gplayImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
versionDevImplementation "com.github.nextcloud:android-library:master-SNAPSHOT"
genericImplementation 'com.github.nextcloud:android-library:b5ac5ddc30'
gplayImplementation 'com.github.nextcloud:android-library:b5ac5ddc30'
versionDevImplementation 'com.github.nextcloud:android-library:b5ac5ddc30'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "com.android.support:support-v4:${supportLibraryVersion}"
implementation "com.android.support:design:${supportLibraryVersion}"

View file

@ -41,8 +41,8 @@ import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
import com.owncloud.android.lib.common.network.WebdavEntry;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
@ -209,12 +209,10 @@ public class FileDataStorageManager {
if (sameRemotePath ||
fileExists(file.getFileId())) { // for renamed files; no more delete and create
OCFile oldFile;
if (sameRemotePath) {
oldFile = getFileByPath(file.getRemotePath());
OCFile oldFile = getFileByPath(file.getRemotePath());
file.setFileId(oldFile.getFileId());
} else {
oldFile = getFileById(file.getFileId());
}
overridden = true;
@ -269,7 +267,7 @@ public class FileDataStorageManager {
OCFile returnFile;
if (parentFile == null) {
// remote request
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(parentPath);
ReadFileRemoteOperation operation = new ReadFileRemoteOperation(parentPath);
RemoteOperationResult result = operation.execute(getAccount(), context);
if (result.isSuccess()) {
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
@ -400,7 +398,7 @@ public class FileDataStorageManager {
if (results != null) {
long newId;
Iterator<OCFile> filesIt = updatedFiles.iterator();
OCFile file = null;
OCFile file;
for (ContentProviderResult result : results) {
if (filesIt.hasNext()) {
file = filesIt.next();
@ -653,8 +651,8 @@ public class FileDataStorageManager {
/// 2. prepare a batch of update operations to change all the descendants
ArrayList<ContentProviderOperation> operations = new ArrayList<>(c.getCount());
String defaultSavePath = FileStorageUtils.getSavePath(account.name);
List<String> originalPathsToTriggerMediaScan = new ArrayList<String>();
List<String> newPathsToTriggerMediaScan = new ArrayList<String>();
List<String> originalPathsToTriggerMediaScan = new ArrayList<>();
List<String> newPathsToTriggerMediaScan = new ArrayList<>();
if (c.moveToFirst()) {
int lengthOfOldPath = file.getRemotePath().length();
int lengthOfOldStoragePath = defaultSavePath.length() + lengthOfOldPath;
@ -891,7 +889,7 @@ public class FileDataStorageManager {
}
private Cursor getFileCursorForValue(String key, String value) {
Cursor c = null;
Cursor c;
if (getContentResolver() != null) {
c = getContentResolver()
.query(ProviderTableMeta.CONTENT_URI,
@ -1125,7 +1123,7 @@ public class FileDataStorageManager {
* @return First {@link OCShare} instance found in DB bound to the file in 'path'
*/
public OCShare getFirstShareByPathAndType(String path, ShareType type, String shareWith) {
Cursor cursor = null;
Cursor cursor;
if (shareWith == null) {
shareWith = "";
}
@ -1511,7 +1509,7 @@ public class FileDataStorageManager {
public void removeSharesForFile(String remotePath) {
resetShareFlagInAFile(remotePath);
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
ArrayList<ContentProviderOperation> operations = new ArrayList<>();
operations = prepareRemoveSharesInFile(remotePath, operations);
// apply operations in batch
if (operations.size() > 0) {
@ -1533,7 +1531,7 @@ public class FileDataStorageManager {
public void saveSharesInFolder(ArrayList<OCShare> shares, OCFile folder) {
resetShareFlagsInFolder(folder);
ArrayList<ContentProviderOperation> operations = new ArrayList<ContentProviderOperation>();
ArrayList<ContentProviderOperation> operations = new ArrayList<>();
operations = prepareRemoveSharesInFolder(folder, operations);
if (shares != null) {
@ -1667,8 +1665,8 @@ public class FileDataStorageManager {
cursor = null;
}
}
ArrayList<OCShare> shares = new ArrayList<OCShare>();
OCShare share = null;
ArrayList<OCShare> shares = new ArrayList<>();
OCShare share;
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
@ -2009,7 +2007,7 @@ public class FileDataStorageManager {
}
public OCCapability getCapability(String accountName) {
OCCapability capability = null;
OCCapability capability;
Cursor c = getCapabilityCursorForAccount(accountName);
if (c.moveToFirst()) {

View file

@ -35,7 +35,7 @@ import com.owncloud.android.R;
import com.owncloud.android.lib.common.network.WebdavEntry;
import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ServerFileInterface;
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
import com.owncloud.android.utils.MimeType;
import java.io.File;

View file

@ -51,8 +51,8 @@ import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ServerFileInterface;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import com.owncloud.android.ui.TextDrawable;
import com.owncloud.android.ui.adapter.DiskLruImageCache;
import com.owncloud.android.ui.fragment.FileFragment;
@ -397,7 +397,7 @@ public final class ThumbnailsCacheManager {
Account account, List<ThumbnailGenerationTask> asyncTasks)
throws IllegalArgumentException {
// Use a WeakReference to ensure the ImageView can be garbage collected
mImageViewReference = new WeakReference<ImageView>(imageView);
mImageViewReference = new WeakReference<>(imageView);
if (storageManager == null) {
throw new IllegalArgumentException("storageManager must not be NULL");
}
@ -421,7 +421,7 @@ public final class ThumbnailsCacheManager {
public ThumbnailGenerationTask(ImageView imageView) {
// Use a WeakReference to ensure the ImageView can be garbage collected
mImageViewReference = new WeakReference<ImageView>(imageView);
mImageViewReference = new WeakReference<>(imageView);
}
@SuppressFBWarnings("Dm")

View file

@ -21,38 +21,18 @@
package com.owncloud.android.operations;
import android.util.Log;
import com.google.gson.GsonBuilder;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.comments.CommentFileRemoteOperation;
import com.owncloud.android.operations.common.SyncOperation;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* Restore a {@link com.owncloud.android.lib.resources.files.FileVersion}.
* Comment file
*/
public class CommentFileOperation extends SyncOperation {
private static final String TAG = CommentFileOperation.class.getSimpleName();
private static final int POST_READ_TIMEOUT = 30000;
private static final int POST_CONNECTION_TIMEOUT = 5000;
private static final String ACTOR_ID = "actorId";
private static final String ACTOR_TYPE = "actorType";
private static final String ACTOR_TYPE_VALUE = "users";
private static final String VERB = "verb";
private static final String VERB_VALUE = "comment";
private static final String MESSAGE = "message";
private String message;
private String fileId;
private String userId;
@ -76,37 +56,12 @@ public class CommentFileOperation extends SyncOperation {
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result = new CommentFileRemoteOperation(message, fileId, userId).execute(client, true);
RemoteOperationResult result;
try {
String url = client.getNewWebdavUri() + "/comments/files/" + fileId;
PostMethod postMethod = new PostMethod(url);
postMethod.addRequestHeader("Content-type", "application/json");
Map<String, String> values = new HashMap<>();
values.put(ACTOR_ID, userId);
values.put(ACTOR_TYPE, ACTOR_TYPE_VALUE);
values.put(VERB, VERB_VALUE);
values.put(MESSAGE, message);
String json = new GsonBuilder().create().toJson(values, Map.class);
postMethod.setRequestEntity(new StringRequestEntity(json));
int status = client.executeMethod(postMethod, POST_READ_TIMEOUT, POST_CONNECTION_TIMEOUT);
result = new RemoteOperationResult(isSuccess(status), postMethod);
client.exhaustResponse(postMethod.getResponseBodyAsStream());
} catch (IOException e) {
result = new RemoteOperationResult(e);
Log.e(TAG, "Post comment to file with id " + fileId + " failed: " + result.getLogMessage(), e);
if (!result.isSuccess()) {
Log_OC.e(this, "File with Id " + fileId + " could not be commented");
}
return result;
}
private boolean isSuccess(int status) {
return status == HttpStatus.SC_CREATED;
}
}

View file

@ -20,7 +20,7 @@ import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.resources.files.CopyRemoteFileOperation;
import com.owncloud.android.lib.resources.files.CopyFileRemoteOperation;
import com.owncloud.android.operations.common.SyncOperation;
@ -74,13 +74,7 @@ public class CopyFileOperation extends SyncOperation {
if (mFile.isFolder()) {
targetPath += OCFile.PATH_SEPARATOR;
}
CopyRemoteFileOperation operation = new CopyRemoteFileOperation(
mSrcPath,
targetPath,
false
);
RemoteOperationResult result = operation.execute(client);
RemoteOperationResult result = new CopyFileRemoteOperation(mSrcPath, targetPath, false).execute(client);
/// 3. local copy
if (result.isSuccess()) {

View file

@ -27,9 +27,9 @@ import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.CreateRemoteFolderOperation;
import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.MimeType;
@ -61,12 +61,11 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
CreateRemoteFolderOperation operation = new CreateRemoteFolderOperation(mRemotePath, mCreateFullPath);
RemoteOperationResult result = operation.execute(client, true);
RemoteOperationResult result = new CreateFolderRemoteOperation(mRemotePath, mCreateFullPath).execute(client);
if (result.isSuccess()) {
ReadRemoteFolderOperation remoteFolderOperation = new ReadRemoteFolderOperation(mRemotePath);
RemoteOperationResult remoteFolderOperationResult = remoteFolderOperation.execute(client, true);
RemoteOperationResult remoteFolderOperationResult = new ReadFolderRemoteOperation(mRemotePath)
.execute(client, true);
createdRemoteFolder = (RemoteFile) remoteFolderOperationResult.getData().get(0);
saveFolderInDB();
@ -79,7 +78,7 @@ public class CreateFolderOperation extends SyncOperation implements OnRemoteOper
@Override
public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
if (operation instanceof CreateRemoteFolderOperation) {
if (operation instanceof CreateFolderRemoteOperation) {
onCreateRemoteFolderOperationFinish(result);
}
}

View file

@ -1,4 +1,4 @@
/**
/*
* ownCloud Android client application
*
* @author David A. Velasco
@ -34,7 +34,7 @@ import com.owncloud.android.lib.common.operations.OperationCancelledException;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.DownloadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.DownloadFileRemoteOperation;
import com.owncloud.android.utils.EncryptionUtils;
import com.owncloud.android.utils.FileStorageUtils;
@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* Remote mDownloadOperation performing the download of a file to an ownCloud server
*/
public class DownloadFileOperation extends RemoteOperation {
private static final String TAG = DownloadFileOperation.class.getSimpleName();
private Account mAccount;
@ -60,13 +60,13 @@ public class DownloadFileOperation extends RemoteOperation {
private long mModificationTimestamp;
private String mEtag = "";
private final AtomicBoolean mCancellationRequested = new AtomicBoolean(false);
private DownloadRemoteFileOperation mDownloadOperation;
private DownloadFileRemoteOperation mDownloadOperation;
private String mActivityName;
private String mPackageName;
public DownloadFileOperation(Account account, OCFile file, String behaviour, String activityName,
public DownloadFileOperation(Account account, OCFile file, String behaviour, String activityName,
String packageName, Context context) {
if (account == null) {
throw new IllegalArgumentException("Illegal null account in DownloadFileOperation " +
@ -76,7 +76,7 @@ public class DownloadFileOperation extends RemoteOperation {
throw new IllegalArgumentException("Illegal null file in DownloadFileOperation " +
"creation");
}
mAccount = account;
mFile = file;
mBehaviour = behaviour;
@ -89,7 +89,7 @@ public class DownloadFileOperation extends RemoteOperation {
public Account getAccount() {
return mAccount;
}
public OCFile getFile() {
return mFile;
}
@ -107,15 +107,15 @@ public class DownloadFileOperation extends RemoteOperation {
}
return FileStorageUtils.getDefaultSavePathFor(mAccount.name, mFile);
}
public String getTmpPath() {
return FileStorageUtils.getTemporalPath(mAccount.name) + mFile.getRemotePath();
}
public String getTmpFolder() {
return FileStorageUtils.getTemporalPath(mAccount.name);
}
public String getRemotePath() {
return mFile.getRemotePath();
}
@ -138,11 +138,11 @@ public class DownloadFileOperation extends RemoteOperation {
}
return mimeType;
}
public long getSize() {
return mFile.getFileLength();
}
public long getModificationTimestamp() {
return mModificationTimestamp > 0 ? mModificationTimestamp : mFile.getModificationTimestamp();
}
@ -168,14 +168,14 @@ public class DownloadFileOperation extends RemoteOperation {
File tmpFile = new File(getTmpPath());
String tmpFolder = getTmpFolder();
mDownloadOperation = new DownloadRemoteFileOperation(mFile.getRemotePath(), tmpFolder);
mDownloadOperation = new DownloadFileRemoteOperation(mFile.getRemotePath(), tmpFolder);
Iterator<OnDatatransferProgressListener> listener = mDataTransferListeners.iterator();
while (listener.hasNext()) {
mDownloadOperation.addDatatransferProgressListener(listener.next());
}
result = mDownloadOperation.execute(client, client.useNextcloudUserAgent());
if (result.isSuccess()) {
mModificationTimestamp = mDownloadOperation.getModificationTimestamp();
mEtag = mDownloadOperation.getEtag();
@ -217,7 +217,7 @@ public class DownloadFileOperation extends RemoteOperation {
}
Log_OC.i(TAG, "Download of " + mFile.getRemotePath() + " to " + getSavePath() + ": " +
result.getLogMessage());
return result;
}
@ -234,7 +234,7 @@ public class DownloadFileOperation extends RemoteOperation {
mDataTransferListeners.add(listener);
}
}
public void removeDatatransferProgressListener(OnDatatransferProgressListener listener) {
synchronized (mDataTransferListeners) {
mDataTransferListeners.remove(listener);

View file

@ -1,83 +0,0 @@
/*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2018 Tobias Kaminsky
* Copyright (C) 2018 Nextcloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.owncloud.android.operations;
import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.operations.common.SyncOperation;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.jackrabbit.webdav.client.methods.DeleteMethod;
import java.io.IOException;
/**
* Empty trashbin.
*/
public class EmptyTrashbinFileOperation extends SyncOperation {
private static final String TAG = EmptyTrashbinFileOperation.class.getSimpleName();
private static final int RESTORE_READ_TIMEOUT = 30000;
private static final int RESTORE_CONNECTION_TIMEOUT = 5000;
private String userId;
/**
* Constructor
*
* @param userId to access correct trashbin
*/
public EmptyTrashbinFileOperation(String userId) {
this.userId = userId;
}
/**
* Performs the operation.
*
* @param client Client object to communicate with the remote Nextcloud server.
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result;
try {
DeleteMethod delete = new DeleteMethod(client.getNewWebdavUri() + "/trashbin/" + userId + "/trash");
int status = client.executeMethod(delete, RESTORE_READ_TIMEOUT, RESTORE_CONNECTION_TIMEOUT);
result = new RemoteOperationResult(isSuccess(status), delete);
client.exhaustResponse(delete.getResponseBodyAsStream());
} catch (IOException e) {
result = new RemoteOperationResult(e);
Log.e(TAG, "Empty trashbin failed: " + result.getLogMessage(), e);
}
return result;
}
private boolean isSuccess(int status) {
return status == HttpStatus.SC_NO_CONTENT;
}
}

View file

@ -23,7 +23,7 @@ import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.resources.files.MoveRemoteFileOperation;
import com.owncloud.android.lib.resources.files.MoveFileRemoteOperation;
import com.owncloud.android.operations.common.SyncOperation;
@ -31,16 +31,16 @@ import com.owncloud.android.operations.common.SyncOperation;
* Operation mmoving an {@link OCFile} to a different folder.
*/
public class MoveFileOperation extends SyncOperation {
//private static final String TAG = MoveFileOperation.class.getSimpleName();
private String mSrcPath;
private String mTargetParentPath;
private OCFile mFile;
/**
* Constructor
*
*
* @param srcPath Remote path of the {@link OCFile} to move.
* @param targetParentPath Path to the folder where the file will be moved into.
*/
@ -50,13 +50,13 @@ public class MoveFileOperation extends SyncOperation {
if (!mTargetParentPath.endsWith(OCFile.PATH_SEPARATOR)) {
mTargetParentPath += OCFile.PATH_SEPARATOR;
}
mFile = null;
}
/**
* Performs the operation.
*
*
* @param client Client object to communicate with the remote ownCloud server.
*/
@Override
@ -69,27 +69,22 @@ public class MoveFileOperation extends SyncOperation {
if (mFile == null) {
return new RemoteOperationResult(ResultCode.FILE_NOT_FOUND);
}
/// 2. remote move
String targetPath = mTargetParentPath + mFile.getFileName();
if (mFile.isFolder()) {
targetPath += OCFile.PATH_SEPARATOR;
}
MoveRemoteFileOperation operation = new MoveRemoteFileOperation(
mSrcPath,
targetPath,
false
);
RemoteOperationResult result = operation.execute(client);
RemoteOperationResult result = new MoveFileRemoteOperation(mSrcPath, targetPath, false).execute(client);
/// 3. local move
if (result.isSuccess()) {
getStorageManager().moveLocalFile(mFile, targetPath, mTargetParentPath);
}
}
// TODO handle ResultCode.PARTIAL_MOVE_DONE in client Activity, for the moment
return result;
}
}

View file

@ -34,9 +34,9 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.lib.resources.shares.GetRemoteSharesForFileOperation;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
@ -263,8 +263,8 @@ public class RefreshFolderOperation extends RemoteOperation {
Log_OC.d(TAG, "Checking changes in " + mAccount.name + remotePath);
// remote request
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(remotePath);
result = operation.execute(client, true);
result = new ReadFileRemoteOperation(remotePath).execute(client, true);
if (result.isSuccess()) {
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
@ -305,8 +305,7 @@ public class RefreshFolderOperation extends RemoteOperation {
private RemoteOperationResult fetchAndSyncRemoteFolder(OwnCloudClient client) {
String remotePath = mLocalFolder.getRemotePath();
ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(remotePath);
RemoteOperationResult result = operation.execute(client, true);
RemoteOperationResult result = new ReadFolderRemoteOperation(remotePath).execute(client, true);
Log_OC.d(TAG, "Synchronizing " + mAccount.name + remotePath);
if (result.isSuccess()) {

View file

@ -31,7 +31,7 @@ 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.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.resources.files.RemoveRemoteFileOperation;
import com.owncloud.android.lib.resources.files.RemoveFileRemoteOperation;
import com.owncloud.android.operations.common.SyncOperation;
@ -46,14 +46,14 @@ public class RemoveFileOperation extends SyncOperation {
private Account account;
private boolean inBackground;
private Context context;
/**
* Constructor
*
* @param remotePath RemotePath of the OCFile instance describing the remote file or
*
* @param remotePath RemotePath of the OCFile instance describing the remote file or
* folder to remove from the server
* @param onlyLocalCopy When 'true', and a local copy of the file exists, only this is
* @param onlyLocalCopy When 'true', and a local copy of the file exists, only this is
* removed.
*/
public RemoveFileOperation(String remotePath, boolean onlyLocalCopy, Account account, boolean inBackground,
@ -64,11 +64,11 @@ public class RemoveFileOperation extends SyncOperation {
this.inBackground = inBackground;
this.context = context;
}
/**
* Getter for the file to remove (or removed, if the operation was successfully performed).
*
*
* @return File to remove or already removed.
*/
public OCFile getFile() {
@ -78,10 +78,10 @@ public class RemoveFileOperation extends SyncOperation {
public boolean isInBackground() {
return inBackground;
}
/**
* Performs the remove operation
*
*
* @param client Client object to communicate with the remote ownCloud server.
*/
@Override
@ -103,25 +103,25 @@ public class RemoveFileOperation extends SyncOperation {
operation = new RemoveRemoteEncryptedFileOperation(remotePath, parent.getLocalId(), account, context,
fileToRemove.getEncryptedFileName());
} else {
operation = new RemoveRemoteFileOperation(remotePath);
operation = new RemoveFileRemoteOperation(remotePath);
}
result = operation.execute(client);
if (result.isSuccess() || result.getCode() == ResultCode.FILE_NOT_FOUND) {
localRemovalFailed = !(getStorageManager().removeFile(fileToRemove, true, true));
}
} else {
localRemovalFailed = !(getStorageManager().removeFile(fileToRemove, false, true));
if (!localRemovalFailed) {
result = new RemoteOperationResult(ResultCode.OK);
}
}
if (localRemovalFailed) {
result = new RemoteOperationResult(ResultCode.LOCAL_STORAGE_NOT_REMOVED);
}
return result;
}
}

View file

@ -35,10 +35,10 @@ import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.GetMetadataOperation;
import com.owncloud.android.lib.resources.files.LockFileOperation;
import com.owncloud.android.lib.resources.files.UnlockFileOperation;
import com.owncloud.android.lib.resources.files.UpdateMetadataOperation;
import com.owncloud.android.lib.resources.e2ee.GetMetadataRemoteOperation;
import com.owncloud.android.lib.resources.e2ee.LockFileRemoteOperation;
import com.owncloud.android.lib.resources.e2ee.UnlockFileRemoteOperation;
import com.owncloud.android.lib.resources.e2ee.UpdateMetadataRemoteOperation;
import com.owncloud.android.utils.EncryptionUtils;
import org.apache.commons.httpclient.HttpStatus;
@ -67,8 +67,8 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
* @param remotePath RemotePath of the remote file or folder to remove from the server
* @param parentId local id of parent folder
*/
public RemoveRemoteEncryptedFileOperation(String remotePath, String parentId, Account account, Context context,
String fileName) {
RemoveRemoteEncryptedFileOperation(String remotePath, String parentId, Account account, Context context,
String fileName) {
this.remotePath = remotePath;
this.parentId = parentId;
this.account = account;
@ -93,8 +93,7 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
try {
// Lock folder
LockFileOperation lockFileOperation = new LockFileOperation(parentId);
RemoteOperationResult lockFileOperationResult = lockFileOperation.execute(client, true);
RemoteOperationResult lockFileOperationResult = new LockFileRemoteOperation(parentId).execute(client, true);
if (lockFileOperationResult.isSuccess()) {
token = (String) lockFileOperationResult.getData().get(0);
@ -105,8 +104,8 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
}
// refresh metadata
GetMetadataOperation getMetadataOperation = new GetMetadataOperation(parentId);
RemoteOperationResult getMetadataOperationResult = getMetadataOperation.execute(client, true);
RemoteOperationResult getMetadataOperationResult = new GetMetadataRemoteOperation(parentId)
.execute(client, true);
if (getMetadataOperationResult.isSuccess()) {
// decrypt metadata
@ -137,9 +136,8 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
String serializedFolderMetadata = EncryptionUtils.serializeJSON(encryptedFolderMetadata);
// upload metadata
UpdateMetadataOperation storeMetadataOperation = new UpdateMetadataOperation(parentId,
serializedFolderMetadata, token);
RemoteOperationResult uploadMetadataOperationResult = storeMetadataOperation.execute(client, true);
RemoteOperationResult uploadMetadataOperationResult = new UpdateMetadataRemoteOperation(parentId,
serializedFolderMetadata, token).execute(client, true);
if (!uploadMetadataOperationResult.isSuccess()) {
throw new RemoteOperationFailedException("Metadata not uploaded!");
@ -158,8 +156,8 @@ public class RemoveRemoteEncryptedFileOperation extends RemoteOperation {
// unlock file
if (token != null) {
UnlockFileOperation unlockFileOperation = new UnlockFileOperation(parentId, token);
RemoteOperationResult unlockFileOperationResult = unlockFileOperation.execute(client, true);
RemoteOperationResult unlockFileOperationResult = new UnlockFileRemoteOperation(parentId, token)
.execute(client, true);
if (!unlockFileOperationResult.isSuccess()) {
Log_OC.e(TAG, "Failed to unlock " + parentId);

View file

@ -1,4 +1,4 @@
/**
/*
* ownCloud Android client application
*
* @author David A. Velasco
@ -27,7 +27,7 @@ import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.RenameRemoteFileOperation;
import com.owncloud.android.lib.resources.files.RenameFileRemoteOperation;
import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.utils.FileStorageUtils;
@ -39,17 +39,17 @@ import java.io.IOException;
* Remote operation performing the rename of a remote file (or folder?) in the ownCloud server.
*/
public class RenameFileOperation extends SyncOperation {
private static final String TAG = RenameFileOperation.class.getSimpleName();
private OCFile mFile;
private String mRemotePath;
private String mNewName;
private String mNewRemotePath;
/**
* Constructor
*
*
* @param remotePath RemotePath of the OCFile instance describing the remote file or
* folder to rename
* @param newName New name to set as the name of file.
@ -59,23 +59,23 @@ public class RenameFileOperation extends SyncOperation {
mNewName = newName;
mNewRemotePath = null;
}
public OCFile getFile() {
return mFile;
}
/**
* Performs the rename operation.
*
*
* @param client Client object to communicate with the remote ownCloud server.
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result = null;
mFile = getStorageManager().getFileByPath(mRemotePath);
// check if the new name is valid in the local file system
try {
if (!isValidNewName()) {
@ -92,11 +92,9 @@ public class RenameFileOperation extends SyncOperation {
if (getStorageManager().getFileByPath(mNewRemotePath) != null) {
return new RemoteOperationResult(ResultCode.INVALID_OVERWRITE);
}
RenameRemoteFileOperation operation = new RenameRemoteFileOperation(mFile.getFileName(),
mFile.getRemotePath(),
mNewName, mFile.isFolder());
result = operation.execute(client);
result = new RenameFileRemoteOperation(mFile.getFileName(), mFile.getRemotePath(), mNewName,
mFile.isFolder()).execute(client);
if (result.isSuccess()) {
if (mFile.isFolder()) {
@ -107,7 +105,7 @@ public class RenameFileOperation extends SyncOperation {
saveLocalFile();
}
}
} catch (IOException e) {
Log_OC.e(TAG, "Rename " + mFile.getRemotePath() + " to " + ((mNewRemotePath==null) ?
mNewName : mNewRemotePath) + ": " +
@ -141,22 +139,22 @@ public class RenameFileOperation extends SyncOperation {
// can't be updated
// TODO - study conditions when this could be a problem
}
getStorageManager().saveFile(mFile);
}
/**
* Checks if the new name to set is valid in the file system
*
* Checks if the new name to set is valid in the file system
*
* The only way to be sure is trying to create a file with that name. It's made in the
* temporal directory for downloads, out of any account, and then removed.
*
*
* IMPORTANT: The test must be made in the same file system where files are download.
* The internal storage could be formatted with a different file system.
*
*
* TODO move this method, and maybe FileDownload.get***Path(), to a class with utilities
* specific for the interactions with the file system
*
*
* @return 'True' if a temporal file named with the name to set could be
* created in the file system where local files are stored.
* @throws IOException When the temporal folder can not be created.
@ -182,11 +180,11 @@ public class RenameFileOperation extends SyncOperation {
return false;
}
boolean result = testFile.exists() && testFile.isFile();
// cleaning ; result is ignored, since there is not much we could do in case of failure,
// but repeat and repeat...
testFile.delete();
return result;
}
}

View file

@ -1,93 +0,0 @@
/*
* Nextcloud Android client application
*
* @author Tobias Kaminsky
* Copyright (C) 2018 Tobias Kaminsky
* Copyright (C) 2018 Nextcloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.owncloud.android.operations;
import android.util.Log;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.network.WebdavUtils;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.operations.common.SyncOperation;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.jackrabbit.webdav.client.methods.MoveMethod;
import java.io.IOException;
/**
* Restore a {@link com.owncloud.android.lib.resources.files.TrashbinFile}.
*/
public class RestoreTrashbinFileOperation extends SyncOperation {
private static final String TAG = RestoreTrashbinFileOperation.class.getSimpleName();
private static final int RESTORE_READ_TIMEOUT = 30000;
private static final int RESTORE_CONNECTION_TIMEOUT = 5000;
private String sourcePath;
private String fileName;
private String userId;
/**
* Constructor
*
* @param sourcePath Remote path of the {@link com.owncloud.android.lib.resources.files.TrashbinFile} to restore
* @param fileName original filename
* @param userId userId to access correct trashbin
*/
public RestoreTrashbinFileOperation(String sourcePath, String fileName, String userId) {
this.sourcePath = sourcePath;
this.fileName = fileName;
this.userId = userId;
}
/**
* Performs the operation.
*
* @param client Client object to communicate with the remote ownCloud server.
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result;
try {
String source = client.getNewWebdavUri() + WebdavUtils.encodePath(sourcePath);
String target = client.getNewWebdavUri() + "/trashbin/" + userId + "/restore/" + fileName;
MoveMethod move = new MoveMethod(source, target, true);
int status = client.executeMethod(move, RESTORE_READ_TIMEOUT, RESTORE_CONNECTION_TIMEOUT);
result = new RemoteOperationResult(isSuccess(status), move);
client.exhaustResponse(move.getResponseBodyAsStream());
} catch (IOException e) {
result = new RemoteOperationResult(e);
Log.e(TAG, "Restore trashbin file " + sourcePath + " failed: " + result.getLogMessage(), e);
}
return result;
}
private boolean isSuccess(int status) {
return status == HttpStatus.SC_CREATED || status == HttpStatus.SC_NO_CONTENT;
}
}

View file

@ -1,4 +1,4 @@
/**
/*
* ownCloud Android client application
*
* @author David A. Velasco
@ -32,8 +32,8 @@ import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.utils.FileStorageUtils;
@ -192,7 +192,7 @@ public class SynchronizeFileOperation extends SyncOperation {
/// local copy in the device -> need to think a bit more before do anything
if (mServerFile == null) {
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(mRemotePath);
ReadFileRemoteOperation operation = new ReadFileRemoteOperation(mRemotePath);
result = operation.execute(client);
if (result.isSuccess()) {
mServerFile = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));

View file

@ -1,4 +1,4 @@
/**
/*
* ownCloud Android client application
*
* @author David A. Velasco
@ -33,9 +33,9 @@ import com.owncloud.android.lib.common.operations.OperationCancelledException;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.services.OperationsService;
import com.owncloud.android.utils.FileStorageUtils;
@ -78,9 +78,6 @@ public class SynchronizeFolderOperation extends SyncOperation {
/** Locally cached information about folder to synchronize */
private OCFile mLocalFolder;
/** Files and folders contained in the synchronized folder after a successful operation */
//private List<OCFile> mChildren;
/** Counter of conflicts found between local and remote files */
private int mConflictsFound;
@ -113,20 +110,12 @@ public class SynchronizeFolderOperation extends SyncOperation {
mAccount = account;
mContext = context;
mRemoteFolderChanged = false;
mFilesForDirectDownload = new Vector<OCFile>();
mFilesToSyncContents = new Vector<SyncOperation>();
mFilesForDirectDownload = new Vector<>();
mFilesToSyncContents = new Vector<>();
mCancellationRequested = new AtomicBoolean(false);
}
public int getConflictsFound() {
return mConflictsFound;
}
public int getFailsInFileSyncsFound() {
return mFailsInFileSyncsFound;
}
/**
* Performs the synchronization.
*
@ -134,7 +123,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
*/
@Override
protected RemoteOperationResult run(OwnCloudClient client) {
RemoteOperationResult result = null;
RemoteOperationResult result;
mFailsInFileSyncsFound = 0;
mConflictsFound = 0;
@ -178,7 +167,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
}
// remote request
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(mRemotePath);
ReadFileRemoteOperation operation = new ReadFileRemoteOperation(mRemotePath);
RemoteOperationResult result = operation.execute(client);
if (result.isSuccess()) {
OCFile remoteFolder = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
@ -215,7 +204,7 @@ public class SynchronizeFolderOperation extends SyncOperation {
throw new OperationCancelledException();
}
ReadRemoteFolderOperation operation = new ReadRemoteFolderOperation(mRemotePath);
ReadFolderRemoteOperation operation = new ReadFolderRemoteOperation(mRemotePath);
RemoteOperationResult result = operation.execute(client);
Log_OC.d(TAG, "Synchronizing " + mAccount.name + mRemotePath);
@ -253,8 +242,6 @@ public class SynchronizeFolderOperation extends SyncOperation {
* Synchronizes the data retrieved from the server about the contents of the target folder
* with the current data in the local database.
*
* Grants that mChildren is updated with fresh data after execution.
*
* @param folderAndFiles Remote folder and children files in Folder
*/
private void synchronizeData(List<Object> folderAndFiles) throws OperationCancelledException {
@ -284,9 +271,9 @@ public class SynchronizeFolderOperation extends SyncOperation {
}
// loop to synchronize every child
OCFile remoteFile = null;
OCFile localFile = null;
OCFile updatedFile = null;
OCFile remoteFile;
OCFile localFile;
OCFile updatedFile;
RemoteFile r;
for (int i=1; i<folderAndFiles.size(); i++) {
/// new OCFile instance with the data from the server

View file

@ -47,16 +47,16 @@ import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ChunkedUploadRemoteFileOperation;
import com.owncloud.android.lib.resources.e2ee.GetMetadataRemoteOperation;
import com.owncloud.android.lib.resources.e2ee.LockFileRemoteOperation;
import com.owncloud.android.lib.resources.e2ee.StoreMetadataRemoteOperation;
import com.owncloud.android.lib.resources.e2ee.UnlockFileRemoteOperation;
import com.owncloud.android.lib.resources.e2ee.UpdateMetadataRemoteOperation;
import com.owncloud.android.lib.resources.files.ChunkedFileUploadRemoteOperation;
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
import com.owncloud.android.lib.resources.files.GetMetadataOperation;
import com.owncloud.android.lib.resources.files.LockFileOperation;
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.StoreMetadataOperation;
import com.owncloud.android.lib.resources.files.UnlockFileOperation;
import com.owncloud.android.lib.resources.files.UpdateMetadataOperation;
import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.operations.common.SyncOperation;
import com.owncloud.android.utils.ConnectivityUtils;
import com.owncloud.android.utils.EncryptionUtils;
@ -116,8 +116,8 @@ public class UploadFileOperation extends SyncOperation {
private String mFolderUnlockToken;
private boolean mRemoteFolderToBeCreated;
private boolean mForceOverwrite;
private int mLocalBehaviour = FileUploader.LOCAL_BEHAVIOUR_COPY;
private int mCreatedBy = CREATED_BY_USER;
private int mLocalBehaviour;
private int mCreatedBy;
private boolean mOnWifiOnly;
private boolean mWhileChargingOnly;
private boolean mIgnoringPowerSaveMode;
@ -136,7 +136,7 @@ public class UploadFileOperation extends SyncOperation {
private Context mContext;
private UploadRemoteFileOperation mUploadOperation;
private UploadFileRemoteOperation mUploadOperation;
protected RequestEntity mEntity;
@ -391,7 +391,8 @@ public class UploadFileOperation extends SyncOperation {
// try to unlock folder with stored token, e.g. when upload needs to be resumed or app crashed
// the parent folder should exist as it is a resume of a broken upload
if (mFolderUnlockToken != null && !mFolderUnlockToken.isEmpty()) {
UnlockFileOperation unlockFileOperation = new UnlockFileOperation(parent.getLocalId(), mFolderUnlockToken);
UnlockFileRemoteOperation unlockFileOperation = new UnlockFileRemoteOperation(parent.getLocalId(),
mFolderUnlockToken);
RemoteOperationResult unlockFileOperationResult = unlockFileOperation.execute(client, true);
if (!unlockFileOperationResult.isSuccess()) {
@ -445,7 +446,7 @@ public class UploadFileOperation extends SyncOperation {
/***** E2E *****/
// Lock folder
LockFileOperation lockFileOperation = new LockFileOperation(parentFile.getLocalId());
LockFileRemoteOperation lockFileOperation = new LockFileRemoteOperation(parentFile.getLocalId());
RemoteOperationResult lockFileOperationResult = lockFileOperation.execute(client, true);
if (lockFileOperationResult.isSuccess()) {
@ -460,7 +461,7 @@ public class UploadFileOperation extends SyncOperation {
}
// Update metadata
GetMetadataOperation getMetadataOperation = new GetMetadataOperation(parentFile.getLocalId());
GetMetadataRemoteOperation getMetadataOperation = new GetMetadataRemoteOperation(parentFile.getLocalId());
RemoteOperationResult getMetadataOperationResult = getMetadataOperation.execute(client, true);
DecryptedFolderMetadata metadata;
@ -573,12 +574,12 @@ public class UploadFileOperation extends SyncOperation {
}
/// perform the upload
if (size > ChunkedUploadRemoteFileOperation.CHUNK_SIZE) {
mUploadOperation = new ChunkedUploadRemoteFileOperation(mContext, encryptedTempFile.getAbsolutePath(),
if (size > ChunkedFileUploadRemoteOperation.CHUNK_SIZE) {
mUploadOperation = new ChunkedFileUploadRemoteOperation(mContext, encryptedTempFile.getAbsolutePath(),
mFile.getParentRemotePath() + encryptedFileName, mFile.getMimeType(),
mFile.getEtagInConflict(), timeStamp);
} else {
mUploadOperation = new UploadRemoteFileOperation(encryptedTempFile.getAbsolutePath(),
mUploadOperation = new UploadFileRemoteOperation(encryptedTempFile.getAbsolutePath(),
mFile.getParentRemotePath() + encryptedFileName, mFile.getMimeType(),
mFile.getEtagInConflict(), timeStamp);
}
@ -622,13 +623,13 @@ public class UploadFileOperation extends SyncOperation {
RemoteOperationResult uploadMetadataOperationResult;
if (metadataExists) {
// update metadata
UpdateMetadataOperation storeMetadataOperation = new UpdateMetadataOperation(parentFile.getLocalId(),
serializedFolderMetadata, token);
UpdateMetadataRemoteOperation storeMetadataOperation = new UpdateMetadataRemoteOperation(
parentFile.getLocalId(), serializedFolderMetadata, token);
uploadMetadataOperationResult = storeMetadataOperation.execute(client, true);
} else {
// store metadata
StoreMetadataOperation storeMetadataOperation = new StoreMetadataOperation(parentFile.getLocalId(),
serializedFolderMetadata);
StoreMetadataRemoteOperation storeMetadataOperation = new StoreMetadataRemoteOperation(
parentFile.getLocalId(), serializedFolderMetadata);
uploadMetadataOperationResult = storeMetadataOperation.execute(client, true);
}
@ -699,7 +700,7 @@ public class UploadFileOperation extends SyncOperation {
private RemoteOperationResult unlockFolder(OCFile parentFolder, OwnCloudClient client, String token) {
if (token != null) {
return new UnlockFileOperation(parentFolder.getLocalId(), token).execute(client, true);
return new UnlockFileRemoteOperation(parentFolder.getLocalId(), token).execute(client, true);
} else {
return new RemoteOperationResult(new Exception("No token available"));
}
@ -812,11 +813,11 @@ public class UploadFileOperation extends SyncOperation {
}
// perform the upload
if (size > ChunkedUploadRemoteFileOperation.CHUNK_SIZE) {
mUploadOperation = new ChunkedUploadRemoteFileOperation(mContext, mFile.getStoragePath(),
if (size > ChunkedFileUploadRemoteOperation.CHUNK_SIZE) {
mUploadOperation = new ChunkedFileUploadRemoteOperation(mContext, mFile.getStoragePath(),
mFile.getRemotePath(), mFile.getMimeType(), mFile.getEtagInConflict(), timeStamp);
} else {
mUploadOperation = new UploadRemoteFileOperation(mFile.getStoragePath(),
mUploadOperation = new UploadFileRemoteOperation(mFile.getStoragePath(),
mFile.getRemotePath(), mFile.getMimeType(), mFile.getEtagInConflict(), timeStamp);
}
@ -1312,7 +1313,7 @@ public class UploadFileOperation extends SyncOperation {
path = getRemotePath();
}
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(path);
ReadFileRemoteOperation operation = new ReadFileRemoteOperation(path);
RemoteOperationResult result = operation.execute(client, mFile.isEncrypted());
if (result.isSuccess()) {
updateOCFile(file, (RemoteFile) result.getData().get(0));

View file

@ -52,7 +52,7 @@ import com.owncloud.android.lib.common.operations.OnRemoteOperationListener;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.FileVersion;
import com.owncloud.android.lib.resources.files.model.FileVersion;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import com.owncloud.android.lib.resources.users.GetRemoteUserInfoOperation;
@ -195,7 +195,7 @@ public class OperationsService extends Service {
Account account = intent.getParcelableExtra(EXTRA_ACCOUNT);
String remotePath = intent.getStringExtra(EXTRA_REMOTE_PATH);
Pair<Account, String> itemSyncKey = new Pair<Account , String>(account, remotePath);
Pair<Account, String> itemSyncKey = new Pair<>(account, remotePath);
Pair<Target, RemoteOperation> itemToQueue = newOperation(intent);
if (itemToQueue != null) {
@ -431,7 +431,7 @@ public class OperationsService extends Service {
//Log_OC.e(TAG, "nextOperation init" );
Pair<Target, RemoteOperation> next = null;
Pair<Target, RemoteOperation> next;
synchronized(mPendingOperations) {
next = mPendingOperations.peek();
}
@ -746,12 +746,7 @@ public class OperationsService extends Service {
final OnRemoteOperationListener listener = listeners.next();
final Handler handler = mOperationsBinder.mBoundListeners.get(listener);
if (handler != null) {
handler.post(new Runnable() {
@Override
public void run() {
listener.onRemoteOperationFinish(operation, result);
}
});
handler.post(() -> listener.onRemoteOperationFinish(operation, result));
count += 1;
}
}

View file

@ -1,4 +1,4 @@
/**
/*
* Nextcloud Android client application
*
* Copyright (C) 2018 Edvard Holst
@ -21,6 +21,7 @@ package com.owncloud.android.ui.activities;
import android.content.Intent;
import android.graphics.PorterDuff;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.ActionBar;
@ -39,7 +40,7 @@ import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.activities.models.RichObject;
import com.owncloud.android.lib.resources.activities.model.RichObject;
import com.owncloud.android.lib.resources.files.FileUtils;
import com.owncloud.android.ui.activities.data.Injection;
import com.owncloud.android.ui.activity.FileActivity;
@ -179,7 +180,7 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int visibleItemCount = recyclerView.getChildCount();
@ -230,7 +231,7 @@ public class ActivitiesActivity extends FileActivity implements ActivityListInte
super.onResume();
setDrawerMenuItemChecked(R.id.nav_activity);
setupContent();
}

View file

@ -1,4 +1,4 @@
/**
/*
* Nextcloud Android client application
*
* Copyright (C) 2018 Edvard Holst
@ -19,7 +19,7 @@
package com.owncloud.android.ui.activities.data.activities;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.resources.activities.models.Activity;
import com.owncloud.android.lib.resources.activities.model.Activity;
import java.util.List;

View file

@ -32,7 +32,7 @@ import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.activities.GetRemoteActivitiesOperation;
import com.owncloud.android.lib.resources.activities.GetActivitiesRemoteOperation;
import org.apache.commons.httpclient.HttpStatus;
@ -79,7 +79,7 @@ public class ActivitiesServiceApiImpl implements ActivitiesServiceApi {
getClientFor(ocAccount, MainApp.getAppContext());
ownCloudClient.setOwnCloudVersion(AccountUtils.getServerVersion(currentAccount));
GetRemoteActivitiesOperation getRemoteNotificationOperation = new GetRemoteActivitiesOperation();
GetActivitiesRemoteOperation getRemoteNotificationOperation = new GetActivitiesRemoteOperation();
if (pageUrl != null) {
getRemoteNotificationOperation.setNextUrl(pageUrl);
}

View file

@ -1,4 +1,4 @@
/**
/*
* Nextcloud Android client application
*
* Copyright (C) 2018 Edvard Holst
@ -33,8 +33,8 @@ import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.operations.RefreshFolderOperation;
import com.owncloud.android.ui.activity.BaseActivity;
import com.owncloud.android.utils.FileStorageUtils;
@ -80,8 +80,8 @@ public class FilesServiceApiImpl implements FilesServiceApi {
getClientFor(ocAccount, MainApp.getAppContext());
ownCloudClient.setOwnCloudVersion(AccountUtils.getServerVersion(currentAccount));
// always update file as it could be an old state saved in database
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(fileUrl);
RemoteOperationResult resultRemoteFileOp = operation.execute(ownCloudClient);
RemoteOperationResult resultRemoteFileOp = new ReadFileRemoteOperation(fileUrl).execute(ownCloudClient);
if (resultRemoteFileOp.isSuccess()) {
OCFile temp = FileStorageUtils.fillOCFile((RemoteFile) resultRemoteFileOp.getData().get(0));
remoteOcFile = baseActivity.getStorageManager().saveFileWithParent(temp, context);

View file

@ -77,7 +77,7 @@ import com.owncloud.android.lib.common.accounts.ExternalLinksOperation;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.SearchOperation;
import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
import com.owncloud.android.lib.resources.status.CapabilityBooleanType;
import com.owncloud.android.lib.resources.status.OCCapability;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
@ -406,11 +406,11 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
EventBus.getDefault().post(new ChangeMenuEvent());
break;
case R.id.nav_favorites:
handleSearchEvents(new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH,
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.FAVORITE_SEARCH,
SearchEvent.UnsetType.NO_UNSET), menuItem.getItemId());
break;
case R.id.nav_photos:
handleSearchEvents(new SearchEvent("image/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
handleSearchEvents(new SearchEvent("image/%", SearchRemoteOperation.SearchType.CONTENT_TYPE_SEARCH,
SearchEvent.UnsetType.NO_UNSET), menuItem.getItemId());
break;
case R.id.nav_on_device:
@ -474,19 +474,19 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
break;
case R.id.nav_recently_added:
handleSearchEvents(new SearchEvent("%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
handleSearchEvents(new SearchEvent("%", SearchRemoteOperation.SearchType.CONTENT_TYPE_SEARCH,
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
break;
case R.id.nav_recently_modified:
handleSearchEvents(new SearchEvent("", SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
break;
case R.id.nav_shared:
handleSearchEvents(new SearchEvent("", SearchOperation.SearchType.SHARED_SEARCH,
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_SEARCH,
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
break;
case R.id.nav_videos:
handleSearchEvents(new SearchEvent("video/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
handleSearchEvents(new SearchEvent("video/%", SearchRemoteOperation.SearchType.CONTENT_TYPE_SEARCH,
SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR), menuItem.getItemId());
break;
case Menu.NONE:
@ -1442,7 +1442,7 @@ public abstract class DrawerActivity extends ToolbarActivity implements DisplayU
externalLinksProvider.deleteAllExternalLinks();
Log_OC.d("ExternalLinks", "links disabled");
}
runOnUiThread(() -> updateExternalLinksInDrawer());
runOnUiThread(this::updateExternalLinksInDrawer);
});
t.start();

View file

@ -13,8 +13,8 @@ import android.widget.TextView;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.resources.activities.models.Activity;
import com.owncloud.android.lib.resources.files.FileVersion;
import com.owncloud.android.lib.resources.activities.model.Activity;
import com.owncloud.android.lib.resources.files.model.FileVersion;
import com.owncloud.android.ui.interfaces.ActivityListInterface;
import com.owncloud.android.ui.interfaces.VersionListInterface;
import com.owncloud.android.utils.DisplayUtils;

View file

@ -56,9 +56,9 @@ import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.activities.models.Activity;
import com.owncloud.android.lib.resources.activities.models.RichElement;
import com.owncloud.android.lib.resources.activities.models.RichObject;
import com.owncloud.android.lib.resources.activities.model.Activity;
import com.owncloud.android.lib.resources.activities.model.RichElement;
import com.owncloud.android.lib.resources.activities.model.RichObject;
import com.owncloud.android.lib.resources.files.FileUtils;
import com.owncloud.android.ui.interfaces.ActivityListInterface;
import com.owncloud.android.utils.DisplayUtils;
@ -102,11 +102,11 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
public void setActivityItems(List<Object> activityItems, OwnCloudClient client, boolean clear) {
this.client = client;
String sTime = "";
if (clear) {
values.clear();
}
for (Object o : activityItems) {
Activity activity = (Activity) o;
String time;
@ -312,12 +312,12 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
idx2 = idx1 + name.length();
ssb.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
public void onClick(@NonNull View widget) {
activityListInterface.onActivityClicked(richObject);
}
@Override
public void updateDrawState(TextPaint ds) {
public void updateDrawState(@NonNull TextPaint ds) {
ds.setUnderlineText(false);
}
}, idx1, idx2, 0);

View file

@ -54,8 +54,8 @@ import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.operations.RefreshFolderOperation;
@ -583,8 +583,9 @@ public class OCFileListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
shares.add(ocShare);
// get ocFile from Server to have an up-to-date copy
ReadRemoteFileOperation operation = new ReadRemoteFileOperation(ocShare.getPath());
RemoteOperationResult result = operation.execute(mAccount, mContext);
RemoteOperationResult result = new ReadFileRemoteOperation(ocShare.getPath()).execute(mAccount,
mContext);
if (result.isSuccess()) {
OCFile file = FileStorageUtils.fillOCFile((RemoteFile) result.getData().get(0));
searchForLocalFileInDefaultPath(file);

View file

@ -39,7 +39,7 @@ import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.db.PreferenceManager;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import com.owncloud.android.ui.interfaces.TrashbinActivityInterface;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.FileSortOrder;

View file

@ -19,7 +19,7 @@
*/
package com.owncloud.android.ui.events;
import com.owncloud.android.lib.resources.files.SearchOperation;
import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
import org.parceler.Parcel;
@ -30,7 +30,7 @@ import org.parceler.Parcel;
public class SearchEvent {
private String searchQuery;
private SearchOperation.SearchType searchType;
private SearchRemoteOperation.SearchType searchType;
private UnsetType unsetType;
@ -44,7 +44,7 @@ public class SearchEvent {
}
public SearchEvent(String searchQuery, SearchOperation.SearchType searchType, UnsetType unsetType) {
public SearchEvent(String searchQuery, SearchRemoteOperation.SearchType searchType, UnsetType unsetType) {
this.searchQuery = searchQuery;
this.searchType = searchType;
@ -60,7 +60,7 @@ public class SearchEvent {
return searchQuery;
}
public SearchOperation.SearchType getSearchType() {
public SearchRemoteOperation.SearchType getSearchType() {
return searchType;
}
}

View file

@ -66,7 +66,7 @@ import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.db.PreferenceManager;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.SearchOperation;
import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
import com.owncloud.android.ui.EmptyRecyclerView;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.activity.FolderPickerActivity;
@ -305,8 +305,8 @@ public class ExtendedListFragment extends Fragment
public void run() {
if (AccountUtils.hasSearchSupport(AccountUtils.
getCurrentOwnCloudAccount(MainApp.getAppContext()))) {
EventBus.getDefault().post(new SearchEvent(query, SearchOperation.SearchType.FILE_SEARCH,
SearchEvent.UnsetType.NO_UNSET));
EventBus.getDefault().post(new SearchEvent(query,
SearchRemoteOperation.SearchType.FILE_SEARCH, SearchEvent.UnsetType.NO_UNSET));
} else {
OCFileListAdapter fileListListAdapter = (OCFileListAdapter) adapter;
fileListListAdapter.getFilter().filter(query);

View file

@ -54,10 +54,10 @@ import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.activities.GetRemoteActivitiesOperation;
import com.owncloud.android.lib.resources.activities.models.RichObject;
import com.owncloud.android.lib.resources.files.FileVersion;
import com.owncloud.android.lib.resources.files.ReadFileVersionsOperation;
import com.owncloud.android.lib.resources.activities.GetActivitiesRemoteOperation;
import com.owncloud.android.lib.resources.activities.model.RichObject;
import com.owncloud.android.lib.resources.files.ReadFileVersionsRemoteOperation;
import com.owncloud.android.lib.resources.files.model.FileVersion;
import com.owncloud.android.lib.resources.status.OCCapability;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import com.owncloud.android.operations.CommentFileOperation;
@ -247,7 +247,7 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int visibleItemCount = recyclerView.getChildCount();
@ -289,7 +289,7 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
ownCloudClient.setOwnCloudVersion(AccountUtils.getServerVersion(currentAccount));
isLoadingActivities = true;
GetRemoteActivitiesOperation getRemoteNotificationOperation = new GetRemoteActivitiesOperation(
GetActivitiesRemoteOperation getRemoteNotificationOperation = new GetActivitiesRemoteOperation(
file.getLocalId());
if (pageUrl != null) {
@ -301,7 +301,7 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
ArrayList<Object> versions = null;
if (restoreFileVersionSupported) {
ReadFileVersionsOperation readFileVersionsOperation = new ReadFileVersionsOperation(
ReadFileVersionsRemoteOperation readFileVersionsOperation = new ReadFileVersionsRemoteOperation(
file.getLocalId(), userId);
RemoteOperationResult result1 = readFileVersionsOperation.execute(ownCloudClient);
@ -459,4 +459,4 @@ public class FileDetailActivitiesFragment extends Fragment implements ActivityLi
}
}
}
}
}

View file

@ -74,9 +74,9 @@ import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.SearchOperation;
import com.owncloud.android.lib.resources.files.ToggleEncryptionOperation;
import com.owncloud.android.lib.resources.files.ToggleFavoriteOperation;
import com.owncloud.android.lib.resources.e2ee.ToggleEncryptionRemoteOperation;
import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
import com.owncloud.android.lib.resources.files.ToggleFavoriteRemoteOperation;
import com.owncloud.android.lib.resources.shares.GetRemoteSharesOperation;
import com.owncloud.android.lib.resources.status.OCCapability;
import com.owncloud.android.ui.activity.FileActivity;
@ -362,22 +362,22 @@ public class OCFileListFragment extends ExtendedListFragment implements
private void prepareCurrentSearch(SearchEvent event) {
if (isSearchEventSet(event)) {
if (SearchOperation.SearchType.FILE_SEARCH.equals(event.getSearchType())) {
if (SearchRemoteOperation.SearchType.FILE_SEARCH.equals(event.getSearchType())) {
currentSearchType = SearchType.FILE_SEARCH;
} else if (SearchOperation.SearchType.CONTENT_TYPE_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.CONTENT_TYPE_SEARCH.equals(event.getSearchType())) {
if ("image/%".equals(event.getSearchQuery())) {
currentSearchType = SearchType.PHOTO_SEARCH;
} else if ("video/%".equals(event.getSearchQuery())) {
currentSearchType = SearchType.VIDEO_SEARCH;
}
} else if (SearchOperation.SearchType.FAVORITE_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.FAVORITE_SEARCH.equals(event.getSearchType())) {
currentSearchType = SearchType.FAVORITE_SEARCH;
} else if (SearchOperation.SearchType.RECENTLY_ADDED_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.RECENTLY_ADDED_SEARCH.equals(event.getSearchType())) {
currentSearchType = SearchType.RECENTLY_ADDED_SEARCH;
} else if (SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH.equals(event.getSearchType())) {
currentSearchType = SearchType.RECENTLY_MODIFIED_SEARCH;
} else if (SearchOperation.SearchType.SHARED_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.SHARED_SEARCH.equals(event.getSearchType())) {
currentSearchType = SearchType.SHARED_FILTER;
}
@ -1316,19 +1316,19 @@ public class OCFileListFragment extends ExtendedListFragment implements
private void prepareActionBarItems(SearchEvent event) {
if (event != null) {
if (SearchOperation.SearchType.CONTENT_TYPE_SEARCH.equals(event.getSearchType())) {
if (SearchRemoteOperation.SearchType.CONTENT_TYPE_SEARCH.equals(event.getSearchType())) {
if ("image/%".equals(event.getSearchQuery())) {
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_GRID_AND_SORT;
} else if ("video/%".equals(event.getSearchQuery())) {
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_SEARCH;
}
} else if (SearchOperation.SearchType.FAVORITE_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.FAVORITE_SEARCH.equals(event.getSearchType())) {
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_SORT;
} else if (SearchOperation.SearchType.RECENTLY_ADDED_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.RECENTLY_ADDED_SEARCH.equals(event.getSearchType())) {
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_SORT;
} else if (SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH.equals(event.getSearchType())) {
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_SORT;
} else if (SearchOperation.SearchType.SHARED_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.SHARED_SEARCH.equals(event.getSearchType())) {
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_SEARCH;
}
}
@ -1341,21 +1341,21 @@ public class OCFileListFragment extends ExtendedListFragment implements
private void setEmptyView(SearchEvent event) {
if (event != null) {
if (SearchOperation.SearchType.FILE_SEARCH.equals(event.getSearchType())) {
if (SearchRemoteOperation.SearchType.FILE_SEARCH.equals(event.getSearchType())) {
setEmptyListMessage(SearchType.FILE_SEARCH);
} else if (event.getSearchType().equals(SearchOperation.SearchType.CONTENT_TYPE_SEARCH)) {
} else if (event.getSearchType().equals(SearchRemoteOperation.SearchType.CONTENT_TYPE_SEARCH)) {
if ("image/%".equals(event.getSearchQuery())) {
setEmptyListMessage(SearchType.PHOTO_SEARCH);
} else if ("video/%".equals(event.getSearchQuery())) {
setEmptyListMessage(SearchType.VIDEO_SEARCH);
}
} else if (SearchOperation.SearchType.FAVORITE_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.FAVORITE_SEARCH.equals(event.getSearchType())) {
setEmptyListMessage(SearchType.FAVORITE_SEARCH);
} else if (SearchOperation.SearchType.RECENTLY_ADDED_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.RECENTLY_ADDED_SEARCH.equals(event.getSearchType())) {
setEmptyListMessage(SearchType.RECENTLY_ADDED_SEARCH);
} else if (SearchOperation.SearchType.RECENTLY_MODIFIED_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH.equals(event.getSearchType())) {
setEmptyListMessage(SearchType.RECENTLY_MODIFIED_SEARCH);
} else if (SearchOperation.SearchType.SHARED_SEARCH.equals(event.getSearchType())) {
} else if (SearchRemoteOperation.SearchType.SHARED_SEARCH.equals(event.getSearchType())) {
setEmptyListMessage(SearchType.SHARED_FILTER);
}
}
@ -1398,8 +1398,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
userId = mClient.getCredentials().getUsername();
}
ToggleFavoriteOperation toggleFavoriteOperation = new ToggleFavoriteOperation(event.shouldFavorite,
event.remotePath, userId);
ToggleFavoriteRemoteOperation toggleFavoriteOperation = new ToggleFavoriteRemoteOperation(
event.shouldFavorite, event.remotePath, userId);
RemoteOperationResult remoteOperationResult = toggleFavoriteOperation.execute(mClient);
if (remoteOperationResult.isSuccess()) {
@ -1472,8 +1472,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
String userId = AccountManager.get(MainApp.getAppContext()).getUserData(currentAccount,
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);
remoteOperation = new SearchOperation(event.getSearchQuery(), event.getSearchType(), searchOnlyFolders,
userId);
remoteOperation = new SearchRemoteOperation(event.getSearchQuery(), event.getSearchType(),
searchOnlyFolders, userId);
} else {
remoteOperation = new GetRemoteSharesOperation();
}
@ -1540,8 +1540,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
OwnCloudClient mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, MainApp.getAppContext());
ToggleEncryptionOperation toggleEncryptionOperation = new ToggleEncryptionOperation(event.localId,
event.remotePath, event.shouldBeEncrypted);
ToggleEncryptionRemoteOperation toggleEncryptionOperation = new ToggleEncryptionRemoteOperation(
event.localId, event.remotePath, event.shouldBeEncrypted);
RemoteOperationResult remoteOperationResult = toggleEncryptionOperation.execute(mClient, true);
if (remoteOperationResult.isSuccess()) {

View file

@ -53,8 +53,8 @@ import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.CheckEtagOperation;
import com.owncloud.android.lib.resources.files.FileVersion;
import com.owncloud.android.lib.resources.files.CheckEtagRemoteOperation;
import com.owncloud.android.lib.resources.files.model.FileVersion;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.lib.resources.status.OCCapability;
@ -81,6 +81,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -201,7 +202,8 @@ public class FileOperationsHelper {
}
// check for changed eTag
CheckEtagOperation checkEtagOperation = new CheckEtagOperation(file.getRemotePath(), file.getEtag());
CheckEtagRemoteOperation checkEtagOperation = new CheckEtagRemoteOperation(file.getRemotePath(),
file.getEtag());
RemoteOperationResult result = checkEtagOperation.execute(account, mFileActivity);
// eTag changed, sync file

View file

@ -1,6 +1,6 @@
package com.owncloud.android.ui.interfaces;
import com.owncloud.android.lib.resources.activities.models.RichObject;
import com.owncloud.android.lib.resources.activities.model.RichObject;
/**
* Created by alejandro on 12/05/17.

View file

@ -22,7 +22,7 @@ package com.owncloud.android.ui.interfaces;
import android.view.View;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import com.owncloud.android.ui.adapter.OCFileListAdapter;
/**

View file

@ -21,7 +21,7 @@
package com.owncloud.android.ui.interfaces;
import com.owncloud.android.lib.resources.files.FileVersion;
import com.owncloud.android.lib.resources.files.model.FileVersion;
public interface VersionListInterface {

View file

@ -33,11 +33,11 @@ import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.ReadRemoteTrashbinFolderOperation;
import com.owncloud.android.lib.resources.files.RemoveTrashbinFileOperation;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.operations.EmptyTrashbinFileOperation;
import com.owncloud.android.operations.RestoreTrashbinFileOperation;
import com.owncloud.android.lib.resources.trashbin.EmptyTrashbinRemoteOperation;
import com.owncloud.android.lib.resources.trashbin.ReadTrashbinFolderRemoteOperation;
import com.owncloud.android.lib.resources.trashbin.RemoveTrashbinFileRemoteOperation;
import com.owncloud.android.lib.resources.trashbin.RestoreTrashbinFileRemoteOperation;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import java.util.List;
@ -48,7 +48,7 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
private String userId;
private OwnCloudClient client;
public RemoteTrashbinRepository(Context context) {
RemoteTrashbinRepository(Context context) {
AccountManager accountManager = AccountManager.get(context);
Account account = AccountUtils.getCurrentOwnCloudAccount(context);
@ -81,9 +81,8 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
@Override
protected Boolean doInBackground(Void... voids) {
RemoveTrashbinFileOperation removeTrashbinFileOperation = new RemoveTrashbinFileOperation(
file.getFullRemotePath());
RemoteOperationResult result = removeTrashbinFileOperation.execute(client);
RemoteOperationResult result = new RemoveTrashbinFileRemoteOperation(file.getFullRemotePath())
.execute(client);
return result.isSuccess();
}
@ -114,7 +113,7 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
@Override
protected Boolean doInBackground(Void... voids) {
EmptyTrashbinFileOperation emptyTrashbinFileOperation = new EmptyTrashbinFileOperation(userId);
EmptyTrashbinRemoteOperation emptyTrashbinFileOperation = new EmptyTrashbinRemoteOperation(userId);
RemoteOperationResult result = emptyTrashbinFileOperation.execute(client);
return result.isSuccess();
@ -150,11 +149,8 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
@Override
protected Boolean doInBackground(Void... voids) {
RestoreTrashbinFileOperation restoreTrashbinFileOperation = new RestoreTrashbinFileOperation(
file.getFullRemotePath(), file.getFileName(), userId);
RemoteOperationResult result = restoreTrashbinFileOperation.execute(client);
RemoteOperationResult result = new RestoreTrashbinFileRemoteOperation(
file.getFullRemotePath(), file.getFileName(), userId).execute(client);
return result.isSuccess();
}
@ -190,10 +186,7 @@ public class RemoteTrashbinRepository implements TrashbinRepository {
@Override
protected Boolean doInBackground(Void... voids) {
ReadRemoteTrashbinFolderOperation readRemoteTrashbinFolderOperation =
new ReadRemoteTrashbinFolderOperation(remotePath, userId);
RemoteOperationResult result = readRemoteTrashbinFolderOperation.execute(client);
RemoteOperationResult result = new ReadTrashbinFolderRemoteOperation(remotePath, userId).execute(client);
if (result.isSuccess()) {
trashbinFiles = result.getData();

View file

@ -37,7 +37,7 @@ import android.widget.TextView;
import com.owncloud.android.R;
import com.owncloud.android.db.PreferenceManager;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import com.owncloud.android.ui.EmptyRecyclerView;
import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.FileDisplayActivity;

View file

@ -20,7 +20,7 @@
*/
package com.owncloud.android.ui.trashbin;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import java.util.List;

View file

@ -21,7 +21,7 @@
package com.owncloud.android.ui.trashbin;
import com.owncloud.android.R;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import java.io.File;
import java.util.List;

View file

@ -20,7 +20,7 @@
*/
package com.owncloud.android.ui.trashbin;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import java.util.List;

View file

@ -69,7 +69,7 @@ import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.datamodel.ThumbnailsCacheManager;
import com.owncloud.android.lib.common.OwnCloudAccount;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.SearchOperation;
import com.owncloud.android.lib.resources.files.SearchRemoteOperation;
import com.owncloud.android.ui.TextDrawable;
import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.events.MenuItemClickEvent;
@ -463,7 +463,7 @@ public final class DisplayUtils {
ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(context.getContentResolver());
String serverName = account.name.substring(account.name.lastIndexOf('@') + 1, account.name.length());
String serverName = account.name.substring(account.name.lastIndexOf('@') + 1);
String eTag = arbitraryDataProvider.getValue(userId + "@" + serverName, ThumbnailsCacheManager.AVATAR);
String avatarKey = "a_" + userId + "_" + serverName + "_" + eTag;
@ -589,14 +589,14 @@ public final class DisplayUtils {
break;
case R.id.nav_bar_favorites:
SearchEvent favoritesEvent = new SearchEvent("",
SearchOperation.SearchType.FAVORITE_SEARCH,
SearchRemoteOperation.SearchType.FAVORITE_SEARCH,
SearchEvent.UnsetType.UNSET_DRAWER);
switchToSearchFragment(activity, favoritesEvent);
break;
case R.id.nav_bar_photos:
SearchEvent photosEvent = new SearchEvent("image/%",
SearchOperation.SearchType.CONTENT_TYPE_SEARCH,
SearchRemoteOperation.SearchType.CONTENT_TYPE_SEARCH,
SearchEvent.UnsetType.UNSET_DRAWER);
switchToSearchFragment(activity, photosEvent);

View file

@ -37,7 +37,7 @@ import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.GetMetadataOperation;
import com.owncloud.android.lib.resources.e2ee.GetMetadataRemoteOperation;
import org.apache.commons.codec.binary.Hex;
@ -49,6 +49,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
@ -216,8 +217,8 @@ public final class EncryptionUtils {
public static @Nullable
DecryptedFolderMetadata downloadFolderMetadata(OCFile folder, OwnCloudClient client,
Context context, Account account) {
GetMetadataOperation getMetadataOperation = new GetMetadataOperation(folder.getLocalId());
RemoteOperationResult getMetadataOperationResult = getMetadataOperation.execute(client, true);
RemoteOperationResult getMetadataOperationResult = new GetMetadataRemoteOperation(folder.getLocalId())
.execute(client, true);
if (!getMetadataOperationResult.isSuccess()) {
return null;
@ -374,14 +375,14 @@ public final class EncryptionUtils {
public static String encryptStringAsymmetric(String string, String cert)
throws NoSuchAlgorithmException,
NoSuchPaddingException, InvalidKeyException,
BadPaddingException, IllegalBlockSizeException, IOException,
CertificateException {
BadPaddingException, IllegalBlockSizeException,
CertificateException {
Cipher cipher = Cipher.getInstance(RSA_CIPHER);
String trimmedCert = cert.replace("-----BEGIN CERTIFICATE-----\n", "")
.replace("-----END CERTIFICATE-----\n", "");
byte[] encodedCert = trimmedCert.getBytes("UTF-8");
byte[] encodedCert = trimmedCert.getBytes(StandardCharsets.UTF_8);
byte[] decodedCert = org.apache.commons.codec.binary.Base64.decodeBase64(encodedCert);
CertificateFactory certFactory = CertificateFactory.getInstance("X.509");
@ -478,7 +479,7 @@ public final class EncryptionUtils {
int delimiterPosition = string.lastIndexOf(ivDelimiter);
String cipherString = string.substring(0, delimiterPosition);
String ivString = string.substring(delimiterPosition + ivDelimiter.length(), string.length());
String ivString = string.substring(delimiterPosition + ivDelimiter.length());
byte[] iv = new IvParameterSpec(decodeStringToBase64Bytes(ivString)).getIV();

View file

@ -21,7 +21,7 @@
package com.owncloud.android.utils;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import java.io.File;
import java.util.Collections;

View file

@ -21,7 +21,7 @@
package com.owncloud.android.utils;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import java.io.File;
import java.util.Collections;

View file

@ -21,7 +21,7 @@
package com.owncloud.android.utils;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import java.io.File;
import java.util.Collections;

View file

@ -21,7 +21,7 @@
package com.owncloud.android.utils;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.resources.files.TrashbinFile;
import com.owncloud.android.lib.resources.trashbin.model.TrashbinFile;
import java.io.File;
import java.util.Collections;

View file

@ -28,7 +28,7 @@ import com.owncloud.android.MainApp;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.files.RemoteFile;
import com.owncloud.android.lib.resources.files.model.RemoteFile;
import java.io.File;
import java.io.FileInputStream;

View file

@ -28,7 +28,7 @@ import android.webkit.MimeTypeMap;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.lib.common.network.WebdavEntry;
import com.owncloud.android.lib.resources.files.ServerFileInterface;
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
import java.io.File;
import java.util.ArrayList;
@ -157,7 +157,7 @@ public final class MimeTypeUtil {
* @return Identifier of an image resource.
*/
public static Drawable getFolderTypeIcon(boolean isSharedViaUsers, boolean isSharedViaLink,
boolean isEncrypted, Account account, WebdavEntry.MountType mountType,
boolean isEncrypted, Account account, WebdavEntry.MountType mountType,
Context context) {
int drawableId;

View file

@ -24,7 +24,7 @@
package third_parties.daveKoeller;
import com.owncloud.android.lib.resources.files.ServerFileInterface;
import com.owncloud.android.lib.resources.files.model.ServerFileInterface;
import java.io.File;
import java.io.Serializable;
@ -34,17 +34,17 @@ import java.util.Comparator;
/*
* This is an updated version with enhancements made by Daniel Migowski, Andre Bogus, and David Koelle
* *
* *
* To convert to use Templates (Java 1.5+):
* - Change "implements Comparator" to "implements Comparator<String>"
* - Change "compare(Object o1, Object o2)" to "compare(String s1, String s2)"
* - Remove the type checking and casting in compare().
*
*
* To use this class:
* Use the static "sort" method from the java.util.Collections class:
* Collections.sort(your list, new AlphanumComparator());
*
* Adapted to fit
*
* Adapted to fit
* https://github.com/nextcloud/server/blob/9a4253ef7c34f9dc71a6a9f7828a10df769f0c32/tests/lib/NaturalSortTest.php
* by Tobias Kaminsky
*/
@ -155,7 +155,7 @@ public class AlphanumComparator<T> implements Comparator<T>, Serializable {
BigInteger thatChunkValue = new BigInteger(thatChunk.substring(0, countThat));
result = thisChunkValue.compareTo(thatChunkValue);
if (result == 0) {
// value is equal, compare leading zeros
result = Integer.compare(thisChunkZeroCount, thatChunkZeroCount);