org.exoplatform.clouddrive.box
Class JCRLocalBoxDrive

java.lang.Object
  extended by org.exoplatform.clouddrive.CloudDrive
      extended by org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
          extended by org.exoplatform.clouddrive.box.JCRLocalBoxDrive
All Implemented Interfaces:
org.exoplatform.clouddrive.oauth2.UserTokenRefreshListener

public class JCRLocalBoxDrive
extends org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
implements org.exoplatform.clouddrive.oauth2.UserTokenRefreshListener

Local drive for Box. Created by The eXo Platform SAS.

Version:
$Id: JCRLocalBoxDrive.java 00000 Aug 30, 2013 pnedonosko $
Author:
Peter Nedonosko

Nested Class Summary
protected  class JCRLocalBoxDrive.Connect
          Connect algorithm for Box drive.
protected  class JCRLocalBoxDrive.EventsSync
          Sync algorithm for Box drive based on drive changes obtained from Events service http://developers.box.com/docs/#events.
protected  class JCRLocalBoxDrive.FileAPI
           
protected  class JCRLocalBoxDrive.FullSync
          Sync 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.clouddrive.jcr.JCRLocalCloudDrive
org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.AbstractCommand, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.AbstractFileAPI, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.CommandCallable, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.ConnectCommand, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.ExoJCREnvironment, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.ExoJCRSettings, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.FileChange, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.JCRListener, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.NoConnectCommand, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.NoSyncCommand, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.SyncCommand, org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.SyncFilesCommand
 
Nested classes/interfaces inherited from class org.exoplatform.clouddrive.CloudDrive
org.exoplatform.clouddrive.CloudDrive.Command, org.exoplatform.clouddrive.CloudDrive.CommandProgress, org.exoplatform.clouddrive.CloudDrive.ListenerSupport
 
Field Summary
static long FULL_SYNC_PERIOD
          Period to perform JCRLocalBoxDrive.FullSync as a next sync request.
protected  org.exoplatform.commons.utils.MimeTypeResolver mimeTypes
           
 
Fields inherited from class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
accentsConverter, actionDrive, ALREADY_DONE, commandEnv, commandExecutor, CURRENT_LOCALFORMAT, currentChangeId, currentConnect, currentSync, 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, MIX_REFERENCEABLE, noConnect, noSyncCommand, NT_FILE, NT_FOLDER, NT_RESOURCE, NT_UNSTRUCTURED, repository, rootNodeHolder, rootUUID, rootWorkspace, sessionProviders, syncLock, user, USER_NODEPATH, USER_SESSIONPROVIDER, USER_WORKSPACE
 
Fields inherited from class org.exoplatform.clouddrive.CloudDrive
listeners, LOG
 
Constructor Summary
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.clouddrive.jcr.NodeFinder finder)
           
  JCRLocalBoxDrive(BoxUser user, javax.jcr.Node driveNode, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.clouddrive.jcr.NodeFinder finder)
           
 
Method Summary
protected  org.exoplatform.clouddrive.CloudFileAPI createFileAPI()
          
protected  String editLink(String link)
          
protected  String findMimetype(String fileName)
           
protected  org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.ConnectCommand getConnectCommand()
          
protected  Long getSequenceId(com.box.boxjavalibv2.dao.BoxItem item)
           
 BoxAPI.ChangesLink getState()
          
protected  org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.SyncCommand getSyncCommand()
          
 BoxUser getUser()
          
protected  void initBoxItem(javax.jcr.Node localNode, com.box.boxjavalibv2.dao.BoxItem item)
          Initialize Box's common specifics of files and folders.
protected  void initDrive(javax.jcr.Node driveNode)
          
protected static BoxUser loadUser(org.exoplatform.clouddrive.box.BoxConnector.API apiBuilder, BoxProvider provider, javax.jcr.Node driveNode)
          Load user from the drive Node.
protected  boolean notInRange(String path, Collection<String> range)
           
 void onUserTokenRefresh(org.exoplatform.clouddrive.oauth2.UserToken token)
          
protected  String previewLink(String link)
          
protected  Long readChangeId()
          
protected  void refreshAccess()
          
protected  void saveChangeId(Long id)
          
protected  void updateAccess(org.exoplatform.clouddrive.CloudUser newUser)
          
protected  org.exoplatform.clouddrive.jcr.JCRLocalCloudFile updateItem(BoxAPI api, com.box.boxjavalibv2.dao.BoxItem item, javax.jcr.Node parent, javax.jcr.Node node)
          Update or create a local node of Cloud File.
 
Methods inherited from class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
addJCRListener, checkTrashed, cleanName, cleanNode, cleanRemoved, cleanup, cleanUpdated, commitChanges, configure, connect, copyNode, createIfNotCloudFile, disconnect, fileNode, findNode, findNodes, getChangeId, getConnectDate, getFile, getId, getInitDate, getLink, getLocalUser, getOrCleanFileNode, getPath, getTitle, hasFile, hasRemoved, hasUpdated, initCommon, initCopy, initFile, initFolder, initRemove, isConnected, isDrive, isDrive, isDrive, isSameDrive, listFiles, listFiles, listFiles, loadHistory, migrateName, moveFile, nextChangeId, openFile, openFolder, readFile, readNode, readNodes, removeJCRListener, rollback, rootName, rootNode, rootTitle, saveChanges, savedChanges, session, setChangeId, synchronize, systemSession, title, tryCreateCloudFile
 
Methods inherited from class org.exoplatform.clouddrive.CloudDrive
addListener, removeListener, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FULL_SYNC_PERIOD

public static final long FULL_SYNC_PERIOD
Period to perform JCRLocalBoxDrive.FullSync as a next sync request. See implementation of getSyncCommand().

See Also:
Constant Field Values

mimeTypes

protected final org.exoplatform.commons.utils.MimeTypeResolver mimeTypes
Constructor Detail

JCRLocalBoxDrive

public JCRLocalBoxDrive(BoxUser user,
                        javax.jcr.Node driveNode,
                        org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders,
                        org.exoplatform.clouddrive.jcr.NodeFinder finder)
                 throws org.exoplatform.clouddrive.CloudDriveException,
                        javax.jcr.RepositoryException
Parameters:
user -
driveNode -
sessionProviders -
Throws:
org.exoplatform.clouddrive.CloudDriveException
javax.jcr.RepositoryException

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.clouddrive.jcr.NodeFinder finder)
                    throws javax.jcr.RepositoryException,
                           org.exoplatform.clouddrive.CloudDriveException
Throws:
javax.jcr.RepositoryException
org.exoplatform.clouddrive.CloudDriveException
Method Detail

initDrive

protected void initDrive(javax.jcr.Node driveNode)
                  throws org.exoplatform.clouddrive.CloudDriveException,
                         javax.jcr.RepositoryException

Overrides:
initDrive in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
org.exoplatform.clouddrive.CloudDriveException
javax.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.clouddrive.CloudDriveException
Load user from the drive Node.

Parameters:
apiBuilder - BoxConnector.API API builder
provider - BoxProvider
driveNode - Node root of the drive
Returns:
BoxUser
Throws:
javax.jcr.RepositoryException
BoxException
org.exoplatform.clouddrive.CloudDriveException

onUserTokenRefresh

public void onUserTokenRefresh(org.exoplatform.clouddrive.oauth2.UserToken token)
                        throws org.exoplatform.clouddrive.CloudDriveException

Specified by:
onUserTokenRefresh in interface org.exoplatform.clouddrive.oauth2.UserTokenRefreshListener
Throws:
BoxException
org.exoplatform.clouddrive.CloudDriveException

getConnectCommand

protected org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.ConnectCommand getConnectCommand()
                                                                                      throws org.exoplatform.clouddrive.DriveRemovedException,
                                                                                             javax.jcr.RepositoryException

Specified by:
getConnectCommand in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
org.exoplatform.clouddrive.DriveRemovedException
javax.jcr.RepositoryException

getSyncCommand

protected org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.SyncCommand getSyncCommand()
                                                                                throws org.exoplatform.clouddrive.DriveRemovedException,
                                                                                       org.exoplatform.clouddrive.SyncNotSupportedException,
                                                                                       javax.jcr.RepositoryException

Specified by:
getSyncCommand in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
org.exoplatform.clouddrive.DriveRemovedException
org.exoplatform.clouddrive.SyncNotSupportedException
javax.jcr.RepositoryException

createFileAPI

protected org.exoplatform.clouddrive.CloudFileAPI createFileAPI()
                                                         throws org.exoplatform.clouddrive.DriveRemovedException,
                                                                org.exoplatform.clouddrive.SyncNotSupportedException,
                                                                javax.jcr.RepositoryException

Specified by:
createFileAPI in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
org.exoplatform.clouddrive.DriveRemovedException
org.exoplatform.clouddrive.SyncNotSupportedException
javax.jcr.RepositoryException

readChangeId

protected Long readChangeId()
                     throws javax.jcr.RepositoryException,
                            org.exoplatform.clouddrive.CloudDriveException

Specified by:
readChangeId in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
javax.jcr.RepositoryException
org.exoplatform.clouddrive.CloudDriveException

saveChangeId

protected void saveChangeId(Long id)
                     throws org.exoplatform.clouddrive.CloudDriveException,
                            javax.jcr.RepositoryException

Specified by:
saveChangeId in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
org.exoplatform.clouddrive.CloudDriveException
javax.jcr.RepositoryException

getUser

public BoxUser getUser()

Specified by:
getUser in class org.exoplatform.clouddrive.CloudDrive

getState

public BoxAPI.ChangesLink getState()
                            throws org.exoplatform.clouddrive.DriveRemovedException,
                                   org.exoplatform.clouddrive.CloudProviderException,
                                   javax.jcr.RepositoryException,
                                   org.exoplatform.clouddrive.RefreshAccessException

Specified by:
getState in class org.exoplatform.clouddrive.CloudDrive
Throws:
org.exoplatform.clouddrive.DriveRemovedException
org.exoplatform.clouddrive.CloudProviderException
javax.jcr.RepositoryException
org.exoplatform.clouddrive.RefreshAccessException

refreshAccess

protected void refreshAccess()
                      throws org.exoplatform.clouddrive.CloudDriveException

Specified by:
refreshAccess in class org.exoplatform.clouddrive.CloudDrive
Throws:
org.exoplatform.clouddrive.CloudDriveException

updateAccess

protected void updateAccess(org.exoplatform.clouddrive.CloudUser newUser)
                     throws org.exoplatform.clouddrive.CloudDriveException,
                            javax.jcr.RepositoryException

Specified by:
updateAccess in class org.exoplatform.clouddrive.CloudDrive
Throws:
org.exoplatform.clouddrive.CloudDriveException
javax.jcr.RepositoryException

initBoxItem

protected void initBoxItem(javax.jcr.Node localNode,
                           com.box.boxjavalibv2.dao.BoxItem item)
                    throws javax.jcr.RepositoryException,
                           BoxException
Initialize Box's common specifics of files and folders.

Parameters:
localNode - Node
item - BoxItem
Throws:
javax.jcr.RepositoryException
BoxException

findMimetype

protected String findMimetype(String fileName)

updateItem

protected org.exoplatform.clouddrive.jcr.JCRLocalCloudFile updateItem(BoxAPI api,
                                                                      com.box.boxjavalibv2.dao.BoxItem item,
                                                                      javax.jcr.Node parent,
                                                                      javax.jcr.Node node)
                                                               throws javax.jcr.RepositoryException,
                                                                      org.exoplatform.clouddrive.CloudDriveException
Update or create a local node of Cloud File. If the node is null then it will be open on the given parent and created if not already exists.

Parameters:
api - BoxAPI
item - BoxItem
parent - Node
node - Node, can be null
Returns:
JCRLocalCloudFile
Throws:
javax.jcr.RepositoryException - for storage errors
org.exoplatform.clouddrive.CloudDriveException - for drive or format errors

notInRange

protected boolean notInRange(String path,
                             Collection<String> range)

getSequenceId

protected Long getSequenceId(com.box.boxjavalibv2.dao.BoxItem item)
                      throws BoxFormatException
Throws:
BoxFormatException

previewLink

protected String previewLink(String link)

Overrides:
previewLink in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive

editLink

protected String editLink(String link)

Overrides:
editLink in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive


Copyright © 2003–2014 eXo Platform SAS. All rights reserved.