Class JCRLocalGoogleDrive.Sync
- java.lang.Object
-
- org.exoplatform.services.cms.clouddrives.gdrive.JCRLocalGoogleDrive.Sync
-
- All Implemented Interfaces:
org.exoplatform.services.cms.clouddrives.CloudDrive.Command
- Enclosing class:
- JCRLocalGoogleDrive
protected class JCRLocalGoogleDrive.Sync extends Object
Sync algorithm for Google Drive.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.exoplatform.services.cms.clouddrives.gdrive.GoogleDriveAPIapiGoogle Drive service API.protected org.exoplatform.services.cms.clouddrives.gdrive.GoogleDriveAPI.ChangesIteratorchangesThe changes.protected LonglastChangeIdLast change ID fetched and applied to the drive.
-
Constructor Summary
Constructors Modifier Constructor Description protectedSync()Create command for Google Drive synchronization.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddeleteFile(String fileId)Remove file node.protected String[]getParents(com.google.api.services.drive.model.File gfile)Gets the parents.protected booleanisRemoved(com.google.api.services.drive.model.File gfile)Check if file isn't deleted/trashed in Google Drive, explicitly or as a part of its ancestor deletion/trashing.protected voidpreSaveChunk()protected voidsyncFiles()protected voidsyncNext()Sync next.protected voidupdateFile(com.google.api.services.drive.model.File gf, String[] parentIds)Create or update file's node.
-
-
-
Field Detail
-
api
protected final org.exoplatform.services.cms.clouddrives.gdrive.GoogleDriveAPI api
Google Drive service API.
-
changes
protected org.exoplatform.services.cms.clouddrives.gdrive.GoogleDriveAPI.ChangesIterator changes
The changes.
-
lastChangeId
protected Long lastChangeId
Last change ID fetched and applied to the drive. Used bypreSaveChunk().
-
-
Constructor Detail
-
Sync
protected Sync() throws javax.jcr.RepositoryException, org.exoplatform.services.cms.clouddrives.DriveRemovedExceptionCreate command for Google Drive synchronization.- Throws:
javax.jcr.RepositoryException- the repository exceptionorg.exoplatform.services.cms.clouddrives.DriveRemovedException- the drive removed exception
-
-
Method Detail
-
syncFiles
protected void syncFiles() throws javax.jcr.RepositoryException, org.exoplatform.services.cms.clouddrives.CloudDriveException- Throws:
javax.jcr.RepositoryExceptionorg.exoplatform.services.cms.clouddrives.CloudDriveException
-
syncNext
protected void syncNext() throws javax.jcr.RepositoryException, org.exoplatform.services.cms.clouddrives.CloudDriveExceptionSync next.- Throws:
javax.jcr.RepositoryException- the repository exceptionorg.exoplatform.services.cms.clouddrives.CloudDriveException- the cloud drive exception
-
preSaveChunk
protected void preSaveChunk() throws org.exoplatform.services.cms.clouddrives.CloudDriveException, javax.jcr.RepositoryException- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveExceptionjavax.jcr.RepositoryException
-
deleteFile
protected void deleteFile(String fileId) throws javax.jcr.RepositoryException, org.exoplatform.services.cms.clouddrives.CloudDriveException
Remove file node.- Parameters:
fileId-String- Throws:
javax.jcr.RepositoryException- the repository exceptionorg.exoplatform.services.cms.clouddrives.CloudDriveException- the cloud drive exception
-
updateFile
protected void updateFile(com.google.api.services.drive.model.File gf, String[] parentIds) throws org.exoplatform.services.cms.clouddrives.CloudDriveException, javax.jcr.RepositoryExceptionCreate or update file's node.- Parameters:
gf-FileparentIds- array of Ids of parents (folders)- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveException- the cloud drive exceptionjavax.jcr.RepositoryException- the repository exception
-
getParents
protected String[] getParents(com.google.api.services.drive.model.File gfile)
Gets the parents.- Parameters:
gfile- the gfile- Returns:
- the parents
-
isRemoved
protected boolean isRemoved(com.google.api.services.drive.model.File gfile) throws GoogleDriveExceptionCheck if file isn't deleted/trashed in Google Drive, explicitly or as a part of its ancestor deletion/trashing.- Parameters:
gfile- the gfile- Returns:
Booleantrueif the file or its ancestor was deleted or trashed,falseotherwise- Throws:
GoogleDriveException- the google drive exception
-
-