org.exoplatform.clouddrive.cmis
Class JCRLocalCMISDrive

java.lang.Object
  extended by org.exoplatform.clouddrive.CloudDrive
      extended by org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
          extended by org.exoplatform.clouddrive.cmis.JCRLocalCMISDrive
All Implemented Interfaces:
org.exoplatform.clouddrive.CloudDriveStorage

public class JCRLocalCMISDrive
extends org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive

Local drive for CMIS provider.


Nested Class Summary
protected  class JCRLocalCMISDrive.Connect
          Connect algorithm for Template drive.
protected  class JCRLocalCMISDrive.DocumentContent
           
protected  class JCRLocalCMISDrive.FileAPI
          CloudFileAPI implementation.
static interface JCRLocalCMISDrive.LocalFile
           
protected  class JCRLocalCMISDrive.Sync
          A facade SyncCommand implementation.
 
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.DriveState, 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.FilesState, org.exoplatform.clouddrive.CloudDrive.ListenerSupport
 
Field Summary
protected  AtomicLong changeIdSequencer
           
protected  String exoURL
          Platform server host URL, used for preview URL generation.
static long FULL_SYNC_PERIOD
          Period to perform FullSync as a next sync request.
 
Fields inherited from class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
accentsConverter, actionDrive, ALREADY_DONE, commandEnv, CURRENT_LOCALFORMAT, currentChangeId, currentConnect, currentSync, 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, noConnect, noSync, NT_FILE, NT_FOLDER, NT_RESOURCE, NT_UNSTRUCTURED, repository, rootNodeHolder, rootUUID, rootWorkspace, sessionProviders, state, syncFilesChanged, syncFilesMessages, syncLock, updating, user, USER_NODEPATH, USER_SESSIONPROVIDER, USER_WORKSPACE, workerExecutor
 
Fields inherited from class org.exoplatform.clouddrive.CloudDrive
listeners, LOG
 
Constructor Summary
protected JCRLocalCMISDrive(CMISConnector.API apiBuilder, javax.jcr.Node driveNode, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.clouddrive.jcr.NodeFinder finder, org.exoplatform.clouddrive.utils.ExtendedMimeTypeResolver mimeTypes, String exoURL)
           
protected JCRLocalCMISDrive(CMISUser user, javax.jcr.Node driveNode, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.clouddrive.jcr.NodeFinder finder, org.exoplatform.clouddrive.utils.ExtendedMimeTypeResolver mimeTypes, String exoURL)
           
 
Method Summary
protected  String createContentLink(String path, String fileId)
          Create a link to get this file content via eXo REST service as a proxy to remote CMIS.
protected  org.exoplatform.clouddrive.CloudFileAPI createFileAPI()
          
protected  void ensureSame(org.exoplatform.clouddrive.CloudUser user, javax.jcr.Node driveNode)
          
protected  List<javax.jcr.Node> findDocumentNode(String id, org.apache.chemistry.opencmis.client.api.CmisObject file, Map<String,List<javax.jcr.Node>> nodes)
          Find a node(s) representing a CMIS object with given ID.
protected  String findMimetype(org.apache.chemistry.opencmis.client.api.Document file, String localType)
          Find MIME type of given CMIS document.
protected  String findMimetype(String fileName, String fileType)
          Determine a MIME type of given file name if given file type is null or a default value as defined by ExtendedMimeTypeResolver.getDefaultMimeType().
protected  String findMimetype(String fileName, String fileType, String alternativeType)
          Determine a MIME type for given file name if given file type is null or a default value as defined by ExtendedMimeTypeResolver.getDefaultMimeType().
protected  String getChangeToken(javax.jcr.Node localNode)
          Read CMIS change token of a file.
Override this method to apply vendor specific logic (id type etc).
protected  org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.ConnectCommand getConnectCommand()
          
 ContentReader getFileContent(String fileId)
           
protected  org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive.SyncCommand getSyncCommand()
          
 CMISUser getUser()
          
protected  void initCMISItem(javax.jcr.Node node, org.apache.chemistry.opencmis.client.api.CmisObject item)
          Initialize CMIS specifics of files and folders.
protected  void initFile(javax.jcr.Node localNode, String title, String id, String type, String link, String previewLink, String thumbnailLink, String author, String lastUser, Calendar created, Calendar modified, long size)
          
protected static CMISUser loadUser(CMISConnector.API apiBuilder, javax.jcr.Node driveNode)
          Load user from the drive Node.
protected  String previewLink(javax.jcr.Node fileNode)
          
protected  Long readChangeId()
          
protected  void readNodes(javax.jcr.Node parent, Map<String,List<javax.jcr.Node>> nodes, boolean deep)
          
protected  void refreshAccess()
          
protected  void saveAccess(javax.jcr.Node driveNode, String password, String serviceURL, String repositoryId)
          Save user credentials in local drive.
protected  void saveChangeId(Long id)
          
protected  void setChangeToken(javax.jcr.Node localNode, String changeToken)
          Initialize CMIS Change Token of a file.
Override this method to apply vendor specific logic (id type etc).
protected  void updateAccess(org.exoplatform.clouddrive.CloudUser newUser)
          
protected  org.exoplatform.clouddrive.jcr.JCRLocalCloudFile updateItem(CMISAPI api, org.apache.chemistry.opencmis.client.api.CmisObject 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, addUpdating, await, checkNotTrashed, cleanName, cleanNode, cleanRemoved, cleanup, cleanUpdated, commitChanges, configure, connect, copyNode, create, disconnect, editLink, fileNode, findNode, findNodes, getChangeId, getConnectDate, getCurentCommand, getFile, getId, getInitDate, getLink, getLocalUser, getOrCleanFileNode, getPath, getState, getTitle, hasFile, hasRemoved, hasUpdated, ignore, initCommon, initCopy, initDrive, initFolder, initRemove, initUpdating, isConnected, isDrive, isDrive, isIgnored, isInDrive, isInTrash, isLocal, isNew, isNewOrUpdating, isSameDrive, isUpdating, link, listFiles, listFiles, listFiles, loadHistory, migrateName, moveFile, nextChangeId, openFile, openFolder, readFile, readNode, removeJCRListener, removeUpdating, rollback, rollbackAllChanges, rollbackChanges, rootNode, saveChanges, savedChanges, session, setChangeId, size, synchronize, systemSession, thumbnailLink, title, unignore
 
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 FullSync as a next sync request. See implementation of getSyncCommand().

See Also:
Constant Field Values

changeIdSequencer

protected final AtomicLong changeIdSequencer

exoURL

protected final String exoURL
Platform server host URL, used for preview URL generation.

Constructor Detail

JCRLocalCMISDrive

protected JCRLocalCMISDrive(CMISUser user,
                            javax.jcr.Node driveNode,
                            org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders,
                            org.exoplatform.clouddrive.jcr.NodeFinder finder,
                            org.exoplatform.clouddrive.utils.ExtendedMimeTypeResolver mimeTypes,
                            String exoURL)
                     throws org.exoplatform.clouddrive.CloudDriveException,
                            javax.jcr.RepositoryException
Parameters:
user -
driveNode -
sessionProviders -
Throws:
org.exoplatform.clouddrive.CloudDriveException
javax.jcr.RepositoryException

JCRLocalCMISDrive

protected JCRLocalCMISDrive(CMISConnector.API apiBuilder,
                            javax.jcr.Node driveNode,
                            org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders,
                            org.exoplatform.clouddrive.jcr.NodeFinder finder,
                            org.exoplatform.clouddrive.utils.ExtendedMimeTypeResolver mimeTypes,
                            String exoURL)
                     throws javax.jcr.RepositoryException,
                            org.exoplatform.clouddrive.CloudDriveException
Throws:
javax.jcr.RepositoryException
org.exoplatform.clouddrive.CloudDriveException
Method Detail

loadUser

protected static CMISUser loadUser(CMISConnector.API apiBuilder,
                                   javax.jcr.Node driveNode)
                            throws javax.jcr.RepositoryException,
                                   CMISException,
                                   org.exoplatform.clouddrive.CloudDriveException
Load user from the drive Node.

Parameters:
apiBuilder - CMISConnector.API API builder
driveNode - Node root of the drive
Returns:
CMISUser
Throws:
javax.jcr.RepositoryException
CMISException
org.exoplatform.clouddrive.CloudDriveException

saveAccess

protected void saveAccess(javax.jcr.Node driveNode,
                          String password,
                          String serviceURL,
                          String repositoryId)
                   throws org.exoplatform.clouddrive.CloudDriveException
Save user credentials in local drive. For use in new drive creation and for updateAccess(CloudUser).

Parameters:
driveNode - String
password - String
serviceURL - String optional if it's access update
repositoryId - String optional if it's access update
Throws:
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.RefreshAccessException
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 CMISUser getUser()

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

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

initCMISItem

protected void initCMISItem(javax.jcr.Node node,
                            org.apache.chemistry.opencmis.client.api.CmisObject item)
                     throws javax.jcr.RepositoryException,
                            CMISException
Initialize CMIS specifics of files and folders.

Parameters:
node - Node
item - CmisObject
Throws:
javax.jcr.RepositoryException
CMISException

initFile

protected void initFile(javax.jcr.Node localNode,
                        String title,
                        String id,
                        String type,
                        String link,
                        String previewLink,
                        String thumbnailLink,
                        String author,
                        String lastUser,
                        Calendar created,
                        Calendar modified,
                        long size)
                 throws javax.jcr.RepositoryException

Overrides:
initFile in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
javax.jcr.RepositoryException

setChangeToken

protected void setChangeToken(javax.jcr.Node localNode,
                              String changeToken)
                       throws javax.jcr.RepositoryException,
                              CMISException
Initialize CMIS Change Token of a file.
Override this method to apply vendor specific logic (id type etc).

Parameters:
localNode - Node
changeToken - String
Throws:
javax.jcr.RepositoryException
CMISException

getChangeToken

protected String getChangeToken(javax.jcr.Node localNode)
                         throws javax.jcr.RepositoryException,
                                CMISException
Read CMIS change token of a file.
Override this method to apply vendor specific logic (id type etc).

Parameters:
localNode - Node
Returns:
String
Throws:
javax.jcr.RepositoryException
CMISException

updateItem

protected org.exoplatform.clouddrive.jcr.JCRLocalCloudFile updateItem(CMISAPI api,
                                                                      org.apache.chemistry.opencmis.client.api.CmisObject 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 - CMISAPI
item - CmisObject
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

createContentLink

protected String createContentLink(String path,
                                   String fileId)
                            throws org.exoplatform.clouddrive.DriveRemovedException,
                                   javax.jcr.RepositoryException
Create a link to get this file content via eXo REST service as a proxy to remote CMIS. It is a path relative to the current server.

Parameters:
path - String
fileId - String
Returns:
String
Throws:
org.exoplatform.clouddrive.DriveRemovedException
javax.jcr.RepositoryException

previewLink

protected String previewLink(javax.jcr.Node fileNode)
                      throws javax.jcr.RepositoryException

Overrides:
previewLink in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
javax.jcr.RepositoryException

findMimetype

protected String findMimetype(org.apache.chemistry.opencmis.client.api.Document file,
                              String localType)
Find MIME type of given CMIS document. If the document type is null or a default value as defined by ExtendedMimeTypeResolver.getDefaultMimeType(), then most relevant type will be determined and if nothing found an existing local type will be returned. Otherwise a default type will be returned as defined by ExtendedMimeTypeResolver.getDefaultMimeType().

Parameters:
file - Document CMIS document
localType - String locally stored MIME type for given file or null
Returns:
String relevant MIME type, not null

findMimetype

protected String findMimetype(String fileName,
                              String fileType)
Determine a MIME type of given file name if given file type is null or a default value as defined by ExtendedMimeTypeResolver.getDefaultMimeType(). If required, a MIME type will be guessed by ExtendedMimeTypeResolver.getMimeType(String) and returned if found. Otherwise a default type will be returned ( ExtendedMimeTypeResolver.getDefaultMimeType()).

Parameters:
fileName - String file name
fileType - String MIME type already associated with the given file
Returns:
String relevant MIME type, not null

findMimetype

protected String findMimetype(String fileName,
                              String fileType,
                              String alternativeType)
Determine a MIME type for given file name if given file type is null or a default value as defined by ExtendedMimeTypeResolver.getDefaultMimeType(). Otherwise this method returns the given file type.
If required, a MIME type will be guessed by ExtendedMimeTypeResolver.getMimeType(String) and returned if found. If not, and given alternative type not null, the alternative type will be returned. Otherwise a default type will be returned ( ExtendedMimeTypeResolver.getDefaultMimeType()).

Parameters:
fileName - String file name
fileType - String MIME type already associated with the given file name
alternativeType - String alternative (locally stored) MIME type for given file name or null
Returns:
String relevant MIME type, not null

ensureSame

protected void ensureSame(org.exoplatform.clouddrive.CloudUser user,
                          javax.jcr.Node driveNode)
                   throws javax.jcr.RepositoryException,
                          org.exoplatform.clouddrive.CannotConnectDriveException

Overrides:
ensureSame in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
javax.jcr.RepositoryException
org.exoplatform.clouddrive.CannotConnectDriveException

readNodes

protected void readNodes(javax.jcr.Node parent,
                         Map<String,List<javax.jcr.Node>> nodes,
                         boolean deep)
                  throws javax.jcr.RepositoryException

Overrides:
readNodes in class org.exoplatform.clouddrive.jcr.JCRLocalCloudDrive
Throws:
javax.jcr.RepositoryException

findDocumentNode

protected List<javax.jcr.Node> findDocumentNode(String id,
                                                org.apache.chemistry.opencmis.client.api.CmisObject file,
                                                Map<String,List<javax.jcr.Node>> nodes)
                                         throws org.exoplatform.clouddrive.CloudDriveAccessException,
                                                CMISException,
                                                org.exoplatform.clouddrive.UnauthorizedException
Find a node(s) representing a CMIS object with given ID.

Parameters:
id - String
file - CmisObject remote file object
nodes - list of existing locally files' nodes in the cloud drive
Returns:
list of nodes representing CMIS file with given ID
Throws:
org.exoplatform.clouddrive.CloudDriveAccessException
org.exoplatform.clouddrive.NotFoundException
CMISException
org.exoplatform.clouddrive.UnauthorizedException
See Also:
readNodes(Node, Map, boolean)

getFileContent

public ContentReader getFileContent(String fileId)
                             throws CMISException,
                                    org.exoplatform.clouddrive.NotFoundException,
                                    org.exoplatform.clouddrive.CloudDriveAccessException,
                                    org.exoplatform.clouddrive.DriveRemovedException,
                                    javax.jcr.RepositoryException,
                                    org.exoplatform.clouddrive.UnauthorizedException
Throws:
CMISException
org.exoplatform.clouddrive.NotFoundException
org.exoplatform.clouddrive.CloudDriveAccessException
org.exoplatform.clouddrive.DriveRemovedException
javax.jcr.RepositoryException
org.exoplatform.clouddrive.UnauthorizedException


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