Class JCRLocalBoxDrive.EventsSync

  • All Implemented Interfaces:
    org.exoplatform.services.cms.clouddrives.CloudDrive.Command
    Enclosing class:
    JCRLocalBoxDrive

    protected class JCRLocalBoxDrive.EventsSync
    extends Object
    Sync algorithm for Box drive based on drive changes obtained from Events service http://developers.box.com/docs/#events.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected BoxAPI api
      Box API.
      protected Map<String,​org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFile> applied
      Applied items in latest state mapped by item id.
      protected int appliedCounter
      Counter of applied events in this Sync.
      protected org.exoplatform.clouddrive.box.BoxAPI.EventsIterator events
      Events from Box to apply.
      protected Set<String> history
      Currently applied history of the drive storage.
      protected com.box.sdk.BoxEvent lastPostponed
      The last postponed.
      protected Long localStreamPosition
      The local stream position.
      protected Set<String> newHistory
      New history with currently applied event ids.
      protected com.box.sdk.BoxEvent nextEvent
      The next event.
      protected LinkedList<com.box.sdk.BoxEvent> postponed
      Queue of events postponed due to not existing parent or source.
      protected int postponedNumber
      The postponed number.
      protected int prevPostponedNumber
      The postponed number.
      protected int readCounter
      Counter of events read from Box service.
      protected Set<String> removedIds
      Ids of removed items.
      protected Long savedStreamPosition
      The saved stream position.
      protected Map<String,​com.box.sdk.BoxItem.Info> undeleted
      Undeleted events by item id.
      • Fields inherited from interface org.exoplatform.services.cms.clouddrives.CloudDrive.Command

        COMPLETE
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected EventsSync()
      Create command for Box synchronization.
    • Field Detail

      • api

        protected final BoxAPI api
        Box API.
      • history

        protected final Set<String> history
        Currently applied history of the drive storage.
      • newHistory

        protected final Set<String> newHistory
        New history with currently applied event ids.
      • postponed

        protected final LinkedList<com.box.sdk.BoxEvent> postponed
        Queue of events postponed due to not existing parent or source.
      • applied

        protected final Map<String,​org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFile> applied
        Applied items in latest state mapped by item id.
      • undeleted

        protected final Map<String,​com.box.sdk.BoxItem.Info> undeleted
        Undeleted events by item id.
      • removedIds

        protected final Set<String> removedIds
        Ids of removed items.
      • events

        protected org.exoplatform.clouddrive.box.BoxAPI.EventsIterator events
        Events from Box to apply.
      • nextEvent

        protected com.box.sdk.BoxEvent nextEvent
        The next event.
      • lastPostponed

        protected com.box.sdk.BoxEvent lastPostponed
        The last postponed.
      • prevPostponedNumber

        protected int prevPostponedNumber
        The postponed number.
      • postponedNumber

        protected int postponedNumber
        The postponed number.
      • appliedCounter

        protected int appliedCounter
        Counter of applied events in this Sync. Used for multi-pass looping over the events.
      • readCounter

        protected int readCounter
        Counter of events read from Box service. Used for multi-pass looping over the events.
      • savedStreamPosition

        protected Long savedStreamPosition
        The saved stream position.
      • localStreamPosition

        protected Long localStreamPosition
        The local stream position.
    • Constructor Detail

      • EventsSync

        protected EventsSync()
                      throws javax.jcr.RepositoryException,
                             org.exoplatform.services.cms.clouddrives.DriveRemovedException
        Create command for Box 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 org.exoplatform.services.cms.clouddrives.CloudDriveException,
                                 javax.jcr.RepositoryException
        Throws:
        org.exoplatform.services.cms.clouddrives.CloudDriveException
        javax.jcr.RepositoryException
      • preSaveChunk

        protected void preSaveChunk()
                             throws org.exoplatform.services.cms.clouddrives.CloudDriveException,
                                    javax.jcr.RepositoryException
        Throws:
        org.exoplatform.services.cms.clouddrives.CloudDriveException
        javax.jcr.RepositoryException
      • fetchChilds

        protected com.box.sdk.BoxFolder fetchChilds​(String fileId,
                                                    javax.jcr.Node parent)
                                             throws org.exoplatform.services.cms.clouddrives.CloudDriveException,
                                                    javax.jcr.RepositoryException
        Fetch childs.
        Parameters:
        fileId - the file id
        parent - the parent
        Returns:
        the box folder
        Throws:
        org.exoplatform.services.cms.clouddrives.CloudDriveException - the cloud drive exception
        javax.jcr.RepositoryException - the repository exception
      • readEvent

        protected com.box.sdk.BoxEvent readEvent()
                                          throws org.exoplatform.services.cms.clouddrives.CloudDriveException
        Read event.
        Returns:
        the box event
        Throws:
        org.exoplatform.services.cms.clouddrives.CloudDriveException - the cloud drive exception
      • hasNextEvent

        protected boolean hasNextEvent()
                                throws org.exoplatform.services.cms.clouddrives.CloudDriveException
        Checks for next event.
        Returns:
        true, if successful
        Throws:
        org.exoplatform.services.cms.clouddrives.CloudDriveException - the cloud drive exception
      • nextEvent

        protected com.box.sdk.BoxEvent nextEvent()
                                          throws NoSuchElementException,
                                                 org.exoplatform.services.cms.clouddrives.CloudDriveException
        Next event.
        Returns:
        the box event
        Throws:
        NoSuchElementException - the no such element exception
        org.exoplatform.services.cms.clouddrives.CloudDriveException - the cloud drive exception
      • postpone

        protected void postpone​(com.box.sdk.BoxEvent event)
        Postpone.
        Parameters:
        event - the event
      • hasPostponed

        protected boolean hasPostponed()
        Checks for postponed.
        Returns:
        true, if successful
      • undeleted

        protected com.box.sdk.BoxItem.Info undeleted​(String itemId)
        Undeleted.
        Parameters:
        itemId - the item id
        Returns:
        the box item. info
      • undelete

        protected void undelete​(com.box.sdk.BoxItem.Info item)
        Undelete.
        Parameters:
        item - the item
      • apply

        protected void apply​(org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFile local)
                      throws javax.jcr.RepositoryException,
                             org.exoplatform.services.cms.clouddrives.CloudDriveException
        Apply.
        Parameters:
        local - the local
        Throws:
        javax.jcr.RepositoryException - the repository exception
        org.exoplatform.services.cms.clouddrives.CloudDriveException - the cloud drive exception
      • applied

        protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFile applied​(String itemId)
        Applied.
        Parameters:
        itemId - the item id
        Returns:
        the JCR local cloud file
      • remove

        protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFile remove​(String itemId,
                                                                                        String itemPath)
                                                                                 throws javax.jcr.RepositoryException,
                                                                                        org.exoplatform.services.cms.clouddrives.CloudDriveException
        Removes the.
        Parameters:
        itemId - the item id
        itemPath - the item path
        Returns:
        the JCR local cloud file
        Throws:
        javax.jcr.RepositoryException - the repository exception
        org.exoplatform.services.cms.clouddrives.CloudDriveException - the cloud drive exception