Class 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.GoogleDriveAPI api
      Google Drive service API.
      protected org.exoplatform.services.cms.clouddrives.gdrive.GoogleDriveAPI.ChangesIterator changes
      The changes.
      protected Long lastChangeId
      Last change ID fetched and applied to the drive.
      • Fields inherited from interface org.exoplatform.services.cms.clouddrives.CloudDrive.Command

        COMPLETE
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Sync()
      Create command for Google Drive synchronization.
    • 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 by preSaveChunk().
    • Constructor Detail

      • Sync

        protected Sync()
                throws javax.jcr.RepositoryException,
                       org.exoplatform.services.cms.clouddrives.DriveRemovedException
        Create command for Google Drive synchronization.
        Throws:
        javax.jcr.RepositoryException - the repository exception
        org.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.RepositoryException
        org.exoplatform.services.cms.clouddrives.CloudDriveException
      • syncNext

        protected void syncNext()
                         throws javax.jcr.RepositoryException,
                                org.exoplatform.services.cms.clouddrives.CloudDriveException
        Sync next.
        Throws:
        javax.jcr.RepositoryException - the repository exception
        org.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.CloudDriveException
        javax.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 exception
        org.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.RepositoryException
        Create or update file's node.
        Parameters:
        gf - File
        parentIds - array of Ids of parents (folders)
        Throws:
        org.exoplatform.services.cms.clouddrives.CloudDriveException - the cloud drive exception
        javax.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 GoogleDriveException
        Check if file isn't deleted/trashed in Google Drive, explicitly or as a part of its ancestor deletion/trashing.
        Parameters:
        gfile - the gfile
        Returns:
        Boolean true if the file or its ancestor was deleted or trashed, false otherwise
        Throws:
        GoogleDriveException - the google drive exception