Package org.exoplatform.clouddrive.box
Class JCRLocalBoxDrive
- java.lang.Object
-
- org.exoplatform.services.cms.clouddrives.CloudDrive
-
- org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive
-
- org.exoplatform.clouddrive.box.JCRLocalBoxDrive
-
- All Implemented Interfaces:
org.exoplatform.services.cms.clouddrives.CloudDriveSecurity,org.exoplatform.services.cms.clouddrives.CloudDriveStorage,org.exoplatform.services.cms.clouddrives.oauth2.UserTokenRefreshListener
public class JCRLocalBoxDrive extends org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive implements org.exoplatform.services.cms.clouddrives.oauth2.UserTokenRefreshListenerLocal drive for Box. Created by The eXo Platform SAS.- Version:
- $Id: JCRLocalBoxDrive.java 00000 Aug 30, 2013 pnedonosko $
- Author:
- Peter Nedonosko
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classJCRLocalBoxDrive.BoxStateThe Class BoxState.protected classJCRLocalBoxDrive.ConnectConnect algorithm for Box drive.protected classJCRLocalBoxDrive.EventsSyncSync algorithm for Box drive based on drive changes obtained from Events service http://developers.box.com/docs/#events.protected classJCRLocalBoxDrive.FileAPIThe Class FileAPI.protected classJCRLocalBoxDrive.FullSyncSync algorithm for Box drive based on all remote files traversing: we do compare all remote files with locals by its Etag and fetch an item if the tags differ.-
Nested classes/interfaces inherited from class org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive
org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.AbstractCommand, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.AbstractFileAPI, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.CommandCallable, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.ConnectCommand, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.DriveState, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.ExoJCREnvironment, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.ExoJCRSettings, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.FileChange, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.JCRListener, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.NoConnectCommand, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.NoSyncCommand, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.SyncCommand, org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.SyncFilesCommand
-
Nested classes/interfaces inherited from class org.exoplatform.services.cms.clouddrives.CloudDrive
org.exoplatform.services.cms.clouddrives.CloudDrive.Command, org.exoplatform.services.cms.clouddrives.CloudDrive.CommandProgress, org.exoplatform.services.cms.clouddrives.CloudDrive.FilesState, org.exoplatform.services.cms.clouddrives.CloudDrive.ListenerSupport
-
Nested classes/interfaces inherited from interface org.exoplatform.services.cms.clouddrives.CloudDriveStorage
org.exoplatform.services.cms.clouddrives.CloudDriveStorage.Change<R extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description static longFULL_SYNC_PERIODPeriod to performJCRLocalBoxDrive.FullSyncas a next sync request.-
Fields inherited from class org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive
accentsConverter, actionDrive, ALREADY_DONE, COMMAND_CHANGES_CHUNK, commandEnv, CURRENT_LOCALFORMAT, currentChangeId, currentConnect, currentSync, delayedSyncFiles, driveCommands, DUMMY_DATA, ECD_CLOUDDRIVE, ECD_CLOUDFILE, ECD_CLOUDFILERESOURCE, ECD_CLOUDFOLDER, ECD_IGNORED, ECD_LOCALFORMAT, EXO_DATETIME, EXO_MODIFY, EXO_THUMBNAIL, EXO_THUMBNAILS, EXO_TRASHFOLDER, fileAPI, fileChanges, fileChangeSequencer, fileCopies, fileHistory, fileRemovals, fileSynchronizers, fileTrash, finder, HISTORY_EXPIRATION, HISTORY_MAX_LENGTH, jcrListener, mimeTypes, MIX_REFERENCEABLE, MIX_VERSIONABLE, noConnect, noSync, NT_FILE, NT_FOLDER, NT_RESOURCE, NT_UNSTRUCTURED, repository, rootNodeHolder, rootSystemNodeHolder, rootUUID, rootWorkspace, sessionProviders, state, syncFilesMessages, syncLock, updating, user, USER_NODEPATH, USER_SESSIONPROVIDER, USER_WORKSPACE, workerExecutor
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJCRLocalBoxDrive(org.exoplatform.clouddrive.box.BoxConnector.API apiBuilder, BoxProvider provider, javax.jcr.Node driveNode, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.services.cms.clouddrives.jcr.NodeFinder finder, org.exoplatform.services.cms.clouddrives.utils.ExtendedMimeTypeResolver mimeTypes)Instantiates a new JCR local box drive.protectedJCRLocalBoxDrive(BoxUser user, javax.jcr.Node driveNode, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.services.cms.clouddrives.jcr.NodeFinder finder, org.exoplatform.services.cms.clouddrives.utils.ExtendedMimeTypeResolver mimeTypes)Instantiates a new JCR local box drive.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.exoplatform.services.cms.clouddrives.CloudFileAPIcreateFileAPI()protected StringfindMimetype(String fileName)Find mimetype.protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.ConnectCommandgetConnectCommand()protected LonggetSequenceId(com.box.sdk.BoxItem.Info item)Gets the sequence id.JCRLocalBoxDrive.BoxStategetState()protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.SyncCommandgetSyncCommand()BoxUsergetUser()protected booleaninitBoxItem(javax.jcr.Node localNode, com.box.sdk.BoxItem.Info item)Initialize Box's common specifics of files and folders.protected voidinitDrive(javax.jcr.Node driveNode)protected static BoxUserloadUser(org.exoplatform.clouddrive.box.BoxConnector.API apiBuilder, BoxProvider provider, javax.jcr.Node driveNode)Load user from the drive Node.protected booleannotInRange(String path, Collection<String> range)Not in range.voidonUserTokenRefresh(org.exoplatform.services.cms.clouddrives.oauth2.UserToken token)voidonUserTokenRemove()protected StringpreviewLink(String type, javax.jcr.Node fileNode)protected LongreadChangeId()protected voidrefreshAccess()protected voidsaveChangeId(Long id)protected voidupdateAccess(org.exoplatform.services.cms.clouddrives.CloudUser newUser)protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFileupdateItem(BoxAPI api, com.box.sdk.BoxItem.Info item, javax.jcr.Node parent, javax.jcr.Node node)Update or create a local node of Cloud File.-
Methods inherited from class org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive
addJCRListener, addUpdating, await, checkNotTrashed, cleanName, cleanRemoved, cleanup, cleanUpdated, commitChanges, configure, connect, copyFile, create, currentUserName, disconnect, editLink, ensureSame, fileNode, findNode, findNodes, fixNameConflict, getChangeId, getConnectDate, getCurentCommand, getFile, getFileContent, getFilePreview, getId, getInitDate, getLink, getLocalUser, getOrCleanFileNode, getPath, getTitle, getWorkspace, hasChange, hasFile, hasRemoved, hasUpdated, ignore, initCommon, initCopy, initFile, initFolder, initRemove, initUpdating, isConnected, isDrive, isDrive, isIgnored, isInDrive, isInTrash, isLocal, isNew, isNewOrUpdating, isPrivilegedUser, isSameDrive, isSharingSupported, isUpdating, link, listFiles, listFiles, loadHistory, localChange, migrateName, moveFile, nextChangeId, nodeName, openFile, openFolder, parentPath, readFile, readNode, readNodes, removeJCRListener, removeLinks, removeLinks, removeNode, removeUpdating, rollback, rollbackAllChanges, rootNode, rootNode, saveChanges, savedChanges, session, setChangeId, shareFile, size, synchronize, systemSession, thumbnailLink, title, unignore, unshareFile
-
-
-
-
Field Detail
-
FULL_SYNC_PERIOD
public static final long FULL_SYNC_PERIOD
Period to performJCRLocalBoxDrive.FullSyncas a next sync request. See implementation ofgetSyncCommand().- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JCRLocalBoxDrive
protected JCRLocalBoxDrive(BoxUser user, javax.jcr.Node driveNode, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.services.cms.clouddrives.jcr.NodeFinder finder, org.exoplatform.services.cms.clouddrives.utils.ExtendedMimeTypeResolver mimeTypes) throws org.exoplatform.services.cms.clouddrives.CloudDriveException, javax.jcr.RepositoryException
Instantiates a new JCR local box drive.- Parameters:
user- the userdriveNode- the drive nodesessionProviders- the session providersfinder- the findermimeTypes- the mime types- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveException- the cloud drive exceptionjavax.jcr.RepositoryException- the repository exception
-
JCRLocalBoxDrive
protected JCRLocalBoxDrive(org.exoplatform.clouddrive.box.BoxConnector.API apiBuilder, BoxProvider provider, javax.jcr.Node driveNode, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.services.cms.clouddrives.jcr.NodeFinder finder, org.exoplatform.services.cms.clouddrives.utils.ExtendedMimeTypeResolver mimeTypes) throws javax.jcr.RepositoryException, org.exoplatform.services.cms.clouddrives.CloudDriveExceptionInstantiates a new JCR local box drive.- Parameters:
apiBuilder- the api builderprovider- the providerdriveNode- the drive nodesessionProviders- the session providersfinder- the findermimeTypes- the mime types- Throws:
javax.jcr.RepositoryException- the repository exceptionorg.exoplatform.services.cms.clouddrives.CloudDriveException- the cloud drive exception
-
-
Method Detail
-
initDrive
protected void initDrive(javax.jcr.Node driveNode) throws org.exoplatform.services.cms.clouddrives.CloudDriveException, javax.jcr.RepositoryException- Overrides:
initDrivein classorg.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveExceptionjavax.jcr.RepositoryException
-
loadUser
protected static BoxUser loadUser(org.exoplatform.clouddrive.box.BoxConnector.API apiBuilder, BoxProvider provider, javax.jcr.Node driveNode) throws javax.jcr.RepositoryException, BoxException, org.exoplatform.services.cms.clouddrives.CloudDriveException
Load user from the drive Node.- Parameters:
apiBuilder-BoxConnector.APIAPI builderprovider-BoxProviderdriveNode-Noderoot of the drive- Returns:
BoxUser- Throws:
javax.jcr.RepositoryException- the repository exceptionBoxException- the box exceptionorg.exoplatform.services.cms.clouddrives.CloudDriveException- the cloud drive exception
-
onUserTokenRefresh
public void onUserTokenRefresh(org.exoplatform.services.cms.clouddrives.oauth2.UserToken token) throws org.exoplatform.services.cms.clouddrives.CloudDriveException- Specified by:
onUserTokenRefreshin interfaceorg.exoplatform.services.cms.clouddrives.oauth2.UserTokenRefreshListener- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveException
-
onUserTokenRemove
public void onUserTokenRemove() throws org.exoplatform.services.cms.clouddrives.CloudDriveException- Specified by:
onUserTokenRemovein interfaceorg.exoplatform.services.cms.clouddrives.oauth2.UserTokenRefreshListener- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveException
-
getConnectCommand
protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.ConnectCommand getConnectCommand() throws org.exoplatform.services.cms.clouddrives.DriveRemovedException, javax.jcr.RepositoryException- Specified by:
getConnectCommandin classorg.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive- Throws:
org.exoplatform.services.cms.clouddrives.DriveRemovedExceptionjavax.jcr.RepositoryException
-
getSyncCommand
protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.SyncCommand getSyncCommand() throws org.exoplatform.services.cms.clouddrives.DriveRemovedException, org.exoplatform.services.cms.clouddrives.SyncNotSupportedException, javax.jcr.RepositoryException- Specified by:
getSyncCommandin classorg.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive- Throws:
org.exoplatform.services.cms.clouddrives.DriveRemovedExceptionorg.exoplatform.services.cms.clouddrives.SyncNotSupportedExceptionjavax.jcr.RepositoryException
-
createFileAPI
protected org.exoplatform.services.cms.clouddrives.CloudFileAPI createFileAPI() throws org.exoplatform.services.cms.clouddrives.DriveRemovedException, org.exoplatform.services.cms.clouddrives.SyncNotSupportedException, javax.jcr.RepositoryException- Specified by:
createFileAPIin classorg.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive- Throws:
org.exoplatform.services.cms.clouddrives.DriveRemovedExceptionorg.exoplatform.services.cms.clouddrives.SyncNotSupportedExceptionjavax.jcr.RepositoryException
-
readChangeId
protected Long readChangeId() throws javax.jcr.RepositoryException, org.exoplatform.services.cms.clouddrives.CloudDriveException
- Specified by:
readChangeIdin classorg.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive- Throws:
javax.jcr.RepositoryExceptionorg.exoplatform.services.cms.clouddrives.CloudDriveException
-
saveChangeId
protected void saveChangeId(Long id) throws org.exoplatform.services.cms.clouddrives.CloudDriveException, javax.jcr.RepositoryException
- Specified by:
saveChangeIdin classorg.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveExceptionjavax.jcr.RepositoryException
-
getUser
public BoxUser getUser()
- Specified by:
getUserin classorg.exoplatform.services.cms.clouddrives.CloudDrive
-
getState
public JCRLocalBoxDrive.BoxState getState() throws org.exoplatform.services.cms.clouddrives.DriveRemovedException, org.exoplatform.services.cms.clouddrives.CloudProviderException, javax.jcr.RepositoryException, org.exoplatform.services.cms.clouddrives.RefreshAccessException
- Overrides:
getStatein classorg.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive- Throws:
org.exoplatform.services.cms.clouddrives.DriveRemovedExceptionorg.exoplatform.services.cms.clouddrives.CloudProviderExceptionjavax.jcr.RepositoryExceptionorg.exoplatform.services.cms.clouddrives.RefreshAccessException
-
refreshAccess
protected void refreshAccess() throws org.exoplatform.services.cms.clouddrives.CloudDriveException- Specified by:
refreshAccessin classorg.exoplatform.services.cms.clouddrives.CloudDrive- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveException
-
updateAccess
protected void updateAccess(org.exoplatform.services.cms.clouddrives.CloudUser newUser) throws org.exoplatform.services.cms.clouddrives.CloudDriveException, javax.jcr.RepositoryException- Specified by:
updateAccessin classorg.exoplatform.services.cms.clouddrives.CloudDrive- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveExceptionjavax.jcr.RepositoryException
-
initBoxItem
protected boolean initBoxItem(javax.jcr.Node localNode, com.box.sdk.BoxItem.Info item) throws javax.jcr.RepositoryException, BoxExceptionInitialize Box's common specifics of files and folders.- Parameters:
localNode-Nodeitem-BoxItem.Info- Returns:
- boolean
trueif Box file was changed comparing to previous state,false - Throws:
javax.jcr.RepositoryException- the repository exceptionBoxException- the box exception
-
findMimetype
protected String findMimetype(String fileName)
Find mimetype.- Parameters:
fileName- the file name- Returns:
- the string
-
updateItem
protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFile updateItem(BoxAPI api, com.box.sdk.BoxItem.Info item, javax.jcr.Node parent, javax.jcr.Node node) throws javax.jcr.RepositoryException, org.exoplatform.services.cms.clouddrives.CloudDriveException
Update or create a local node of Cloud File. If the node isnullthen it will be open on the given parent and created if not already exists.- Parameters:
api-BoxAPIitem-BoxItem.Infoparent-Nodenode-Node, can benull- Returns:
JCRLocalCloudFile- Throws:
javax.jcr.RepositoryException- for storage errorsorg.exoplatform.services.cms.clouddrives.CloudDriveException- for drive or format errors
-
notInRange
protected boolean notInRange(String path, Collection<String> range)
Not in range.- Parameters:
path- the pathrange- the range- Returns:
- true, if successful
-
getSequenceId
protected Long getSequenceId(com.box.sdk.BoxItem.Info item) throws BoxFormatException
Gets the sequence id.- Parameters:
item- the item- Returns:
- the sequence id
- Throws:
BoxFormatException- the box format exception
-
-