Package org.exoplatform.clouddrive.cmis
Class JCRLocalCMISDrive
- java.lang.Object
-
- org.exoplatform.services.cms.clouddrives.CloudDrive
-
- org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive
-
- org.exoplatform.clouddrive.cmis.JCRLocalCMISDrive
-
- All Implemented Interfaces:
org.exoplatform.services.cms.clouddrives.CloudDriveSecurity,org.exoplatform.services.cms.clouddrives.CloudDriveStorage
public class JCRLocalCMISDrive extends org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDriveLocal drive for CMIS provider.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classJCRLocalCMISDrive.ConnectConnect algorithm for Template drive.protected classJCRLocalCMISDrive.DocumentContentThe Class DocumentContent.protected classJCRLocalCMISDrive.FileAPICloudFileAPIimplementation.static interfaceJCRLocalCMISDrive.LocalFileThe Interface LocalFile.protected classJCRLocalCMISDrive.SyncA facadeJCRLocalCloudDrive.SyncCommandimplementation.-
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 protected AtomicLongchangeIdSequencerThe change id sequencer.protected StringexoURLPlatform server host URL, used for preview URL generation.static longFULL_SYNC_PERIODPeriod to performJCRLocalCMISDrive.Syncas a next sync request.protected static StringPREVIOUS_LOCAL_NAMEThe Constant PREVIOUS_LOCAL_NAME.protected static StringPREVIOUS_LOCAL_PARENTThe Constant PREVIOUS_LOCAL_PARENT.-
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 protectedJCRLocalCMISDrive(CMISConnector.API apiBuilder, 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, String exoURL)Instantiates a new JCR local CMIS drive.protectedJCRLocalCMISDrive(CMISUser 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, String exoURL)Instantiates a new JCR local CMIS drive.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.exoplatform.services.cms.clouddrives.CloudFileAPIcreateFileAPI()protected voidensureSame(org.exoplatform.services.cms.clouddrives.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 StringfindMimetype(String fileName, String fileType)Determine a MIME type of given file name if given file type isnullor a default value as defined byExtendedMimeTypeResolver.getDefaultMimeType().protected StringfindMimetype(String fileName, String fileType, String alternativeType)Determine a MIME type for given file name if given file type isnullor a default value as defined byExtendedMimeTypeResolver.getDefaultMimeType().protected StringfindMimetype(org.apache.chemistry.opencmis.client.api.Document file, String localType)Find MIME type of given CMIS document.protected StringgetChangeToken(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.services.cms.clouddrives.jcr.JCRLocalCloudDrive.ConnectCommandgetConnectCommand()org.exoplatform.services.cms.clouddrives.viewer.ContentReadergetFileContent(String fileId)protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive.SyncCommandgetSyncCommand()CMISUsergetUser()protected voidinitCMISItem(javax.jcr.Node node, org.apache.chemistry.opencmis.client.api.CmisObject item)Initialize CMIS specifics of files and folders.protected voidinitFile(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 CMISUserloadUser(CMISConnector.API apiBuilder, javax.jcr.Node driveNode)Load user from the drive Node.protected StringpreviewLink(String type, javax.jcr.Node fileNode)protected LongreadChangeId()protected voidreadNodes(javax.jcr.Node parent, Map<String,List<javax.jcr.Node>> nodes, boolean deep)protected voidrefreshAccess()protected voidsaveAccess(javax.jcr.Node driveNode, String password, String serviceURL, String repositoryId)Save user credentials in local drive.protected voidsaveChangeId(Long id)protected voidsetChangeToken(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 voidupdateAccess(org.exoplatform.services.cms.clouddrives.CloudUser newUser)protected org.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudFileupdateItem(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.services.cms.clouddrives.jcr.JCRLocalCloudDrive
addJCRListener, addUpdating, await, checkNotTrashed, cleanName, cleanRemoved, cleanup, cleanUpdated, commitChanges, configure, connect, copyFile, create, currentUserName, disconnect, editLink, fileNode, findNode, findNodes, fixNameConflict, getChangeId, getConnectDate, getCurentCommand, getFile, getFilePreview, getId, getInitDate, getLink, getLocalUser, getOrCleanFileNode, getPath, getState, getTitle, getWorkspace, hasChange, hasFile, hasRemoved, hasUpdated, ignore, initCommon, initCopy, initDrive, 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, 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 performJCRLocalCMISDrive.Syncas a next sync request. See implementation ofgetSyncCommand().- See Also:
- Constant Field Values
-
PREVIOUS_LOCAL_NAME
protected static final String PREVIOUS_LOCAL_NAME
The Constant PREVIOUS_LOCAL_NAME.- See Also:
- Constant Field Values
-
PREVIOUS_LOCAL_PARENT
protected static final String PREVIOUS_LOCAL_PARENT
The Constant PREVIOUS_LOCAL_PARENT.- See Also:
- Constant Field Values
-
changeIdSequencer
protected final AtomicLong changeIdSequencer
The change id sequencer.
-
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.services.cms.clouddrives.jcr.NodeFinder finder, org.exoplatform.services.cms.clouddrives.utils.ExtendedMimeTypeResolver mimeTypes, String exoURL) throws org.exoplatform.services.cms.clouddrives.CloudDriveException, javax.jcr.RepositoryException
Instantiates a new JCR local CMIS drive.- Parameters:
user- the userdriveNode- the drive nodesessionProviders- the session providersfinder- the findermimeTypes- the mime typesexoURL- the exo URL- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveException- the cloud drive exceptionjavax.jcr.RepositoryException- the repository exception
-
JCRLocalCMISDrive
protected JCRLocalCMISDrive(CMISConnector.API apiBuilder, 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, String exoURL) throws javax.jcr.RepositoryException, org.exoplatform.services.cms.clouddrives.CloudDriveException
Instantiates a new JCR local CMIS drive.- Parameters:
apiBuilder- the api builderdriveNode- the drive nodesessionProviders- the session providersfinder- the findermimeTypes- the mime typesexoURL- the exo URL- Throws:
javax.jcr.RepositoryException- the repository exceptionorg.exoplatform.services.cms.clouddrives.CloudDriveException- the cloud drive exception
-
-
Method Detail
-
loadUser
protected static CMISUser loadUser(CMISConnector.API apiBuilder, javax.jcr.Node driveNode) throws javax.jcr.RepositoryException, CMISException, org.exoplatform.services.cms.clouddrives.CloudDriveException
Load user from the drive Node.- Parameters:
apiBuilder-CMISConnector.APIAPI builderdriveNode-Noderoot of the drive- Returns:
CMISUser- Throws:
javax.jcr.RepositoryException- the repository exceptionCMISException- the CMIS exceptionorg.exoplatform.services.cms.clouddrives.CloudDriveException- the cloud drive exception
-
saveAccess
protected void saveAccess(javax.jcr.Node driveNode, String password, String serviceURL, String repositoryId) throws org.exoplatform.services.cms.clouddrives.CloudDriveExceptionSave user credentials in local drive. For use in new drive creation and forupdateAccess(CloudUser).
-
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 CMISUser getUser()
- Specified by:
getUserin classorg.exoplatform.services.cms.clouddrives.CloudDrive
-
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
-
initCMISItem
protected void initCMISItem(javax.jcr.Node node, org.apache.chemistry.opencmis.client.api.CmisObject item) throws javax.jcr.RepositoryException, CMISExceptionInitialize CMIS specifics of files and folders.- Parameters:
node-Nodeitem-CmisObject- Throws:
javax.jcr.RepositoryException- the repository exceptionCMISException- the CMIS exception
-
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:
initFilein classorg.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive- Throws:
javax.jcr.RepositoryException
-
setChangeToken
protected void setChangeToken(javax.jcr.Node localNode, String changeToken) throws javax.jcr.RepositoryException, CMISExceptionInitialize CMIS Change Token of a file.
Override this method to apply vendor specific logic (id type etc).- Parameters:
localNode-NodechangeToken-String- Throws:
javax.jcr.RepositoryException- the repository exceptionCMISException- the CMIS exception
-
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- the repository exceptionCMISException- the CMIS exception
-
updateItem
protected org.exoplatform.services.cms.clouddrives.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.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-CMISAPIitem-CmisObjectparent-Nodenode-Node, can benull- Returns:
JCRLocalCloudFile- Throws:
javax.jcr.RepositoryException- for storage errorsorg.exoplatform.services.cms.clouddrives.CloudDriveException- for drive or format errors
-
previewLink
protected String previewLink(String type, javax.jcr.Node fileNode) throws javax.jcr.RepositoryException
- Overrides:
previewLinkin classorg.exoplatform.services.cms.clouddrives.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 isnullor a default value as defined byExtendedMimeTypeResolver.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 byExtendedMimeTypeResolver.getDefaultMimeType().
-
findMimetype
protected String findMimetype(String fileName, String fileType)
Determine a MIME type of given file name if given file type isnullor a default value as defined byExtendedMimeTypeResolver.getDefaultMimeType(). If required, a MIME type will be guessed byExtendedMimeTypeResolver.getMimeType(String)and returned if found. Otherwise a default type will be returned (ExtendedMimeTypeResolver.getDefaultMimeType()).
-
findMimetype
protected String findMimetype(String fileName, String fileType, String alternativeType)
Determine a MIME type for given file name if given file type isnullor a default value as defined byExtendedMimeTypeResolver.getDefaultMimeType(). Otherwise this method returns the given file type.
If required, a MIME type will be guessed byExtendedMimeTypeResolver.getMimeType(String)and returned if found. If not, and given alternative type notnull, the alternative type will be returned. Otherwise a default type will be returned (ExtendedMimeTypeResolver.getDefaultMimeType()).
-
ensureSame
protected void ensureSame(org.exoplatform.services.cms.clouddrives.CloudUser user, javax.jcr.Node driveNode) throws javax.jcr.RepositoryException, org.exoplatform.services.cms.clouddrives.CannotConnectDriveException- Overrides:
ensureSamein classorg.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive- Throws:
javax.jcr.RepositoryExceptionorg.exoplatform.services.cms.clouddrives.CannotConnectDriveException
-
readNodes
protected void readNodes(javax.jcr.Node parent, Map<String,List<javax.jcr.Node>> nodes, boolean deep) throws javax.jcr.RepositoryException- Overrides:
readNodesin classorg.exoplatform.services.cms.clouddrives.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.services.cms.clouddrives.CloudDriveAccessException, CMISException, org.exoplatform.services.cms.clouddrives.UnauthorizedException
Find a node(s) representing a CMIS object with given ID.- Parameters:
id-Stringfile-CmisObjectremote file objectnodes- list of existing locally files' nodes in the cloud drive- Returns:
- list of nodes representing CMIS file with given ID
- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveAccessException- the cloud drive access exceptionCMISException- the CMIS exceptionorg.exoplatform.services.cms.clouddrives.UnauthorizedException- the unauthorized exception- See Also:
readNodes(Node, Map, boolean)
-
getFileContent
public org.exoplatform.services.cms.clouddrives.viewer.ContentReader getFileContent(String fileId) throws org.exoplatform.services.cms.clouddrives.CloudDriveException, org.exoplatform.services.cms.clouddrives.NotFoundException, org.exoplatform.services.cms.clouddrives.CloudDriveAccessException, org.exoplatform.services.cms.clouddrives.DriveRemovedException, org.exoplatform.services.cms.clouddrives.UnauthorizedException, javax.jcr.RepositoryException
- Specified by:
getFileContentin interfaceorg.exoplatform.services.cms.clouddrives.CloudDriveStorage- Overrides:
getFileContentin classorg.exoplatform.services.cms.clouddrives.jcr.JCRLocalCloudDrive- Throws:
org.exoplatform.services.cms.clouddrives.CloudDriveExceptionorg.exoplatform.services.cms.clouddrives.NotFoundExceptionorg.exoplatform.services.cms.clouddrives.CloudDriveAccessExceptionorg.exoplatform.services.cms.clouddrives.DriveRemovedExceptionorg.exoplatform.services.cms.clouddrives.UnauthorizedExceptionjavax.jcr.RepositoryException
-
-