Package org.exoplatform.clouddrive.box
Class JCRLocalBoxDrive.EventsSync
- java.lang.Object
-
- org.exoplatform.clouddrive.box.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 BoxAPIapiBox API.protected Map<String,org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFile>appliedApplied items in latest state mapped by item id.protected intappliedCounterCounter of applied events in this Sync.protected org.exoplatform.clouddrive.box.BoxAPI.EventsIteratoreventsEvents from Box to apply.protected Set<String>historyCurrently applied history of the drive storage.protected com.box.sdk.BoxEventlastPostponedThe last postponed.protected LonglocalStreamPositionThe local stream position.protected Set<String>newHistoryNew history with currently applied event ids.protected com.box.sdk.BoxEventnextEventThe next event.protected LinkedList<com.box.sdk.BoxEvent>postponedQueue of events postponed due to not existing parent or source.protected intpostponedNumberThe postponed number.protected intprevPostponedNumberThe postponed number.protected intreadCounterCounter of events read from Box service.protected Set<String>removedIdsIds of removed items.protected LongsavedStreamPositionThe saved stream position.protected Map<String,com.box.sdk.BoxItem.Info>undeletedUndeleted events by item id.
-
Constructor Summary
Constructors Modifier Constructor Description protectedEventsSync()Create command for Box synchronization.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFileapplied(String itemId)Applied.protected voidapply(org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFile local)Apply.protected com.box.sdk.BoxFolderfetchChilds(String fileId, javax.jcr.Node parent)Fetch childs.protected booleanhasNextEvent()Checks for next event.protected booleanhasPostponed()Checks for postponed.protected com.box.sdk.BoxEventnextEvent()Next event.protected voidpostpone(com.box.sdk.BoxEvent event)Postpone.protected voidpreSaveChunk()protected com.box.sdk.BoxEventreadEvent()Read event.protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFileremove(String itemId, String itemPath)Removes the.protected voidsyncFiles()protected voidundelete(com.box.sdk.BoxItem.Info item)Undelete.protected com.box.sdk.BoxItem.Infoundeleted(String itemId)Undeleted.
-
-
-
Field Detail
-
api
protected final BoxAPI api
Box API.
-
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.
-
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.DriveRemovedExceptionCreate command for Box synchronization.- Throws:
javax.jcr.RepositoryException- the repository exceptionorg.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.CloudDriveExceptionjavax.jcr.RepositoryException
-
preSaveChunk
protected void preSaveChunk() throws org.exoplatform.services.cms.clouddrives.CloudDriveException, javax.jcr.RepositoryException- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveExceptionjavax.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 idparent- the parent- Returns:
- the box folder
- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveException- the cloud drive exceptionjavax.jcr.RepositoryException- the repository exception
-
readEvent
protected com.box.sdk.BoxEvent readEvent() throws org.exoplatform.services.cms.clouddrives.CloudDriveExceptionRead 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.CloudDriveExceptionChecks 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.CloudDriveExceptionNext event.- Returns:
- the box event
- Throws:
NoSuchElementException- the no such element exceptionorg.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.CloudDriveExceptionApply.- Parameters:
local- the local- Throws:
javax.jcr.RepositoryException- the repository exceptionorg.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 iditemPath- the item path- Returns:
- the JCR local cloud file
- Throws:
javax.jcr.RepositoryException- the repository exceptionorg.exoplatform.services.cms.clouddrives.CloudDriveException- the cloud drive exception
-
-