/** * Checks if a file with the new name already exists. * * @return 'True' if the target path is already used by an existing file. */ private boolean targetPathIsUsed(OwnCloudClient client) { ExistenceCheckRemoteOperation existenceCheckRemoteOperation = new ExistenceCheckRemoteOperation(mNewRemotePath, false, false); RemoteOperationResult exists = existenceCheckRemoteOperation.run(client); return exists.isSuccess(); } }
/** * Performs the operation * * @param client Client object to communicate with the remote ownCloud server. */ @Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result; result = createFolder(client); if (!result.isSuccess() && mCreateFullPath && RemoteOperationResult.ResultCode.CONFLICT == result.getCode()) { result = createParentFolder(FileUtils.getParentPath(mRemotePath), client); if (result.isSuccess()) { result = createFolder(client); // second (and last) try } } return result; }
@Override public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) { if (!result.isSuccess()) { Toast.makeText(this, R.string.todo_operation_finished_in_fail, Toast.LENGTH_SHORT).show(); Log.e(LOG_TAG, result.getLogMessage(), result.getException()); } else if (operation instanceof ReadRemoteFolderOperation) { onSuccessfulRefresh((ReadRemoteFolderOperation)operation, result); } else if (operation instanceof com.owncloud.android.lib.resources.files.UploadRemoteFileOperation) { onSuccessfulUpload((com.owncloud.android.lib.resources.files.UploadRemoteFileOperation)operation, result); } else if (operation instanceof RemoveRemoteFileOperation ) { onSuccessfulRemoteDeletion((RemoveRemoteFileOperation)operation, result); } else if (operation instanceof DownloadRemoteFileOperation ) { onSuccessfulDownload(); } else { Toast.makeText(this, R.string.todo_operation_finished_in_success, Toast.LENGTH_SHORT).show(); } }
(isSuccess() ? "success" : "fail") + ")";
(isSuccess() ? "success" : "fail") + ")";
@Test public void testCreateNonExistingSubFolder() { String path = "/testFolder/1/2/3/4/5/"; String top = "/testFolder/"; assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); // verify folder assertTrue(new ReadFolderRemoteOperation(path).execute(client).isSuccess()); // remove folder assertTrue(new RemoveFileRemoteOperation(top).execute(client).isSuccess()); } }
@Test public void testCreateFolderSuccess() { String path = "/testFolder/"; // create folder assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); // verify folder assertTrue(new ReadFolderRemoteOperation(path).execute(client).isSuccess()); // remove folder assertTrue(new RemoveFileRemoteOperation(path).execute(client).isSuccess()); }
@Test public void testCreateFolderFailure() { String path = "/testFolder/"; // create folder assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); // create folder a second time will fail assertFalse(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess()); // remove folder assertTrue(new RemoveFileRemoteOperation(path).execute(client).isSuccess()); }
/** * Performs the operation * * @param client Client object to communicate with the remote ownCloud server. */ @Override protected RemoteOperationResult run(OwnCloudClient client) { RemoteOperationResult result; OwnCloudVersion version = client.getOwnCloudVersion(); boolean versionWithForbiddenChars = (version != null && version.isVersionWithForbiddenCharacters()); boolean noInvalidChars = FileUtils.isValidPath(mRemotePath, versionWithForbiddenChars); if (noInvalidChars) { result = createFolder(client); if (!result.isSuccess() && mCreateFullPath && RemoteOperationResult.ResultCode.CONFLICT == result.getCode()) { result = createParentFolder(FileUtils.getParentPath(mRemotePath), client); if (result.isSuccess()) { result = createFolder(client); // second (and last) try } } } else { result = new RemoteOperationResult<>(ResultCode.INVALID_CHARACTER_IN_NAME); } return result; }
result = parser.parse(getMethod.getResponseBodyAsString()); if (result.isSuccess()) { Log_OC.d(TAG, "Got " + result.getData().getShares().size() + " shares");
result = parser.parse(postMethod.getResponseBodyAsString()); if (result.isSuccess() && mGetShareDetails) {
result = new RemoteOperationResult<>(e); } finally { if (result.isSuccess()) { Log_OC.i(TAG, "Synchronized " + mRemotePath + ": " + result.getLogMessage()); } else {
result = parser.parse(response); if (result.isSuccess()) { Log_OC.d(TAG, "Got " + result.getData().size() + " shares");
result = parser.parse(response); if (result.isSuccess() && mGetShareDetails) {
if (remoteFolderOperationResult.isSuccess() && remoteFolderOperationResult.getData().size() > 1) { return new RemoteOperationResult(false, "Non empty", HttpStatus.SC_FORBIDDEN);
if (result.isSuccess()) { result.setData(mFolderAndFiles);