Search in sources :

Example 1 with RefreshFolderOperation

use of com.owncloud.android.operations.RefreshFolderOperation in project android by owncloud.

the class FolderPickerActivity method startSyncFolderOperation.

public void startSyncFolderOperation(OCFile folder, boolean ignoreETag) {
    mSyncInProgress = true;
    // perform folder synchronization
    SyncOperation synchFolderOp = new RefreshFolderOperation(folder, ignoreETag, getAccount(), getApplicationContext());
    synchFolderOp.execute(getStorageManager(), this, null, null);
    OCFileListFragment fileListFragment = getListOfFilesFragment();
    if (fileListFragment != null) {
        fileListFragment.setProgressBarAsIndeterminate(true);
    }
    setBackgroundText();
}
Also used : SyncOperation(com.owncloud.android.operations.common.SyncOperation) RefreshFolderOperation(com.owncloud.android.operations.RefreshFolderOperation) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment)

Example 2 with RefreshFolderOperation

use of com.owncloud.android.operations.RefreshFolderOperation in project android by nextcloud.

the class FolderPickerActivity method startSyncFolderOperation.

public void startSyncFolderOperation(OCFile folder, boolean ignoreETag) {
    long currentSyncTime = System.currentTimeMillis();
    mSyncInProgress = true;
    // perform folder synchronization
    RemoteOperation refreshFolderOperation = new RefreshFolderOperation(folder, currentSyncTime, false, getFileOperationsHelper().isSharedSupported(), ignoreETag, getStorageManager(), getAccount(), getApplicationContext());
    refreshFolderOperation.execute(getAccount(), this, null, null);
    setIndeterminate(true);
    setBackgroundText();
}
Also used : RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) RefreshFolderOperation(com.owncloud.android.operations.RefreshFolderOperation)

Example 3 with RefreshFolderOperation

use of com.owncloud.android.operations.RefreshFolderOperation in project android by nextcloud.

the class ReceiveExternalFilesActivity method startSyncFolderOperation.

private void startSyncFolderOperation(OCFile folder) {
    long currentSyncTime = System.currentTimeMillis();
    mSyncInProgress = true;
    // perform folder synchronization
    RemoteOperation syncFolderOp = new RefreshFolderOperation(folder, currentSyncTime, false, false, false, getStorageManager(), getAccount(), getApplicationContext());
    syncFolderOp.execute(getAccount(), this, null, null);
}
Also used : RemoteOperation(com.owncloud.android.lib.common.operations.RemoteOperation) RefreshFolderOperation(com.owncloud.android.operations.RefreshFolderOperation)

Example 4 with RefreshFolderOperation

use of com.owncloud.android.operations.RefreshFolderOperation in project android by nextcloud.

the class ContactsBackupFragment method refreshBackupFolder.

private void refreshBackupFolder(final String backupFolderPath, final ContactsPreferenceActivity contactsPreferenceActivity) {
    AsyncTask<String, Integer, Boolean> task = new AsyncTask<String, Integer, Boolean>() {

        @Override
        protected Boolean doInBackground(String... path) {
            FileDataStorageManager storageManager = new FileDataStorageManager(account, contactsPreferenceActivity.getContentResolver());
            OCFile folder = storageManager.getFileByPath(path[0]);
            if (folder != null) {
                RefreshFolderOperation operation = new RefreshFolderOperation(folder, System.currentTimeMillis(), false, false, false, storageManager, account, getContext());
                RemoteOperationResult result = operation.execute(account, getContext());
                return result.isSuccess();
            } else {
                return false;
            }
        }

        @Override
        protected void onPostExecute(Boolean result) {
            if (result) {
                OCFile backupFolder = contactsPreferenceActivity.getStorageManager().getFileByPath(backupFolderPath);
                List<OCFile> backupFiles = contactsPreferenceActivity.getStorageManager().getFolderContent(backupFolder, false);
                if (backupFiles == null || backupFiles.size() == 0) {
                    contactsDatePickerBtn.setVisibility(View.GONE);
                } else {
                    contactsDatePickerBtn.setVisibility(View.VISIBLE);
                }
            }
        }
    };
    task.execute(backupFolderPath);
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) RefreshFolderOperation(com.owncloud.android.operations.RefreshFolderOperation) AsyncTask(android.os.AsyncTask) FileDataStorageManager(com.owncloud.android.datamodel.FileDataStorageManager)

Example 5 with RefreshFolderOperation

use of com.owncloud.android.operations.RefreshFolderOperation in project android by nextcloud.

the class FileSyncAdapter method synchronizeFolder.

/**
 *  Synchronizes the list of files contained in a folder identified with its remote path.
 *
 *  Fetches the list and properties of the files contained in the given folder, including their
 *  properties, and updates the local database with them.
 *
 *  Enters in the child folders to synchronize their contents also, following a recursive
 *  depth first strategy.
 *
 *  @param folder                   Folder to synchronize.
 */
private void synchronizeFolder(OCFile folder) {
    if (mFailedResultsCounter > MAX_FAILED_RESULTS || isFinisher(mLastFailedResult)) {
        return;
    }
    // folder synchronization
    RefreshFolderOperation synchFolderOp = new RefreshFolderOperation(folder, mCurrentSyncTime, true, mIsShareSupported, false, getStorageManager(), getAccount(), getContext());
    RemoteOperationResult result = synchFolderOp.execute(getClient());
    // synchronized folder -> notice to UI - ALWAYS, although !result.isSuccess
    sendLocalBroadcast(EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED, folder.getRemotePath(), result);
    // check the result of synchronizing the folder
    if (result.isSuccess() || result.getCode() == ResultCode.SYNC_CONFLICT) {
        if (result.getCode() == ResultCode.SYNC_CONFLICT) {
            mConflictsFound += synchFolderOp.getConflictsFound();
            mFailsInFavouritesFound += synchFolderOp.getFailsInKeptInSyncFound();
        }
        if (synchFolderOp.getForgottenLocalFiles().size() > 0) {
            mForgottenLocalFiles.putAll(synchFolderOp.getForgottenLocalFiles());
        }
        if (result.isSuccess()) {
            // synchronize children folders
            List<OCFile> children = synchFolderOp.getChildren();
            // beware of the 'hidden' recursion here!
            syncChildren(children);
        }
    } else if (result.getCode() != ResultCode.FILE_NOT_FOUND) {
        // in failures, the statistics for the global result are updated
        if (RemoteOperationResult.ResultCode.UNAUTHORIZED.equals(result.getCode())) {
            mSyncResult.stats.numAuthExceptions++;
        } else if (result.getException() instanceof DavException) {
            mSyncResult.stats.numParseExceptions++;
        } else if (result.getException() instanceof IOException) {
            mSyncResult.stats.numIoExceptions++;
        }
        mFailedResultsCounter++;
        mLastFailedResult = result;
    }
// else, ResultCode.FILE_NOT_FOUND is ignored, remote folder was
// removed from other thread or other client during the synchronization,
// before this thread fetched its contents
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) DavException(org.apache.jackrabbit.webdav.DavException) RemoteOperationResult(com.owncloud.android.lib.common.operations.RemoteOperationResult) RefreshFolderOperation(com.owncloud.android.operations.RefreshFolderOperation) IOException(java.io.IOException)

Aggregations

RefreshFolderOperation (com.owncloud.android.operations.RefreshFolderOperation)7 OCFile (com.owncloud.android.datamodel.OCFile)3 RemoteOperation (com.owncloud.android.lib.common.operations.RemoteOperation)3 RemoteOperationResult (com.owncloud.android.lib.common.operations.RemoteOperationResult)3 SyncOperation (com.owncloud.android.operations.common.SyncOperation)2 Intent (android.content.Intent)1 AsyncTask (android.os.AsyncTask)1 BindString (butterknife.BindString)1 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)1 RichObject (com.owncloud.android.lib.resources.activities.models.RichObject)1 ReadRemoteFileOperation (com.owncloud.android.lib.resources.files.ReadRemoteFileOperation)1 RemoteFile (com.owncloud.android.lib.resources.files.RemoteFile)1 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)1 IOException (java.io.IOException)1 DavException (org.apache.jackrabbit.webdav.DavException)1