Package org.exoplatform.onlyoffice
Class OnlyofficeEditorServiceImpl
- java.lang.Object
-
- org.exoplatform.onlyoffice.OnlyofficeEditorServiceImpl
-
- All Implemented Interfaces:
OnlyofficeEditorService,org.picocontainer.Startable
public class OnlyofficeEditorServiceImpl extends Object implements OnlyofficeEditorService, org.picocontainer.Startable
Service implementingOnlyofficeEditorServiceandStartable. This component handles interactions with Onlyoffice Document Server and related eXo user states.
Created by The eXo Platform SAS.- Version:
- $Id: OnlyofficeEditorServiceImpl.java 00000 Jan 31, 2016 pnedonosko $
- Author:
- Peter Nedonosko
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOnlyofficeEditorServiceImpl.DocumentTypesConfigNewDocumentTypesConfig.
-
Field Summary
Fields Modifier and Type Field Description protected ReentrantLockactiveLockLock for updating Editing documents cache.protected org.exoplatform.social.core.manager.ActivityManageractivityManagerThe activity manager.protected org.exoplatform.services.security.AuthenticatorauthenticatorThe authenticator.static StringCACHE_NAMEThe Constant CACHE_NAME.protected CachedEditorConfigStoragecachedEditorConfigStorageCache of Editing documents.protected StringcommandServiceUrlThe document command service url.protected Map<String,String>configThe config.static StringCONFIG_DS_ACCESS_ONLYThe Constant CONFIG_DS_ACCESS_ONLY.static StringCONFIG_DS_ALLOWEDHOSTSConfiguration key for Document Server's allowed hosts in requests from a DS to eXo side.static StringCONFIG_DS_HOSTThe Constant CONFIG_DS_HOST.static StringCONFIG_DS_SCHEMAThe Constant CONFIG_DS_SCHEMA.static StringCONFIG_DS_SECRETThe Constant CONFIG_DS_SECRET.protected static StringDEFAULT_NAMEThe Constant DEFAULT_NAME.protected booleandocumentserverAccessOnlyThe documentserver access only.protected Set<String>documentserverAllowedhostsThe documentserver allowed hosts (can be empty if not configured).protected StringdocumentserverHostNameThe documentserver host name.protected StringdocumentserverSecretThe document server secret.protected StringdocumentserverUrlThe documentserver url.protected org.exoplatform.services.cms.documents.DocumentServicedocumentServiceThe document service.protected DocumentTypePlugindocumentTypePluginThe document type plugin.protected static StringEMPTY_TEXTThe Constant EMPTY_TEXT.protected static PatternFILE_EXPLORER_URL_SYNTAXThe Consant FILE_EXPLORER_URL_SYNTAX.protected Map<String,String>fileTypesThe file types.protected NodeFinderfinderThe finder.protected StringgroupsPathThe group drives path in JCR.protected static StringHIDDEN_FOLDERThe hidden folderprotected org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreatorhierarchyCreatorThe node hierarchy creator.protected static charHTTP_PORT_DELIMITERThe Constant HTTP_PORT_DELIMITER.protected org.exoplatform.services.security.IdentityRegistryidentityRegistryThe identity registry.protected org.exoplatform.services.jcr.RepositoryServicejcrServiceThe jcr service.protected static StringLAST_EDITED_DATE_FORMATThe date format for Last Edited in editor barprotected ConcurrentLinkedQueue<OnlyofficeEditorListener>listenersThe listeners.protected org.exoplatform.services.listener.ListenerServicelistenerServiceThe listener service.protected static intLOCK_WAIT_ATTEMTSThe Constant LOCK_WAIT_ATTEMTS.protected static longLOCK_WAIT_TIMEOUTThe Constant LOCK_WAIT_TIMEOUT.protected org.exoplatform.services.cms.lock.LockServicelockServiceThe lock service.protected static org.exoplatform.services.log.LogLOGThe Constant LOG.protected org.exoplatform.services.cms.drives.ManageDriveServicemanageDriveServiceThe manage drive serviceprotected org.exoplatform.services.organization.OrganizationServiceorganizationThe organization.protected static RandomRANDOMThe Constant RANDOM.protected static StringRELATION_PROPThe Constant RELATION_PROP.protected org.exoplatform.services.jcr.ext.app.SessionProviderServicesessionProvidersThe session providers.protected org.exoplatform.social.core.space.spi.SpaceServicespaceServiceThe space service.protected org.exoplatform.services.cms.documents.TrashServicetrashServiceThe trash service.protected static StringTYPE_PRESENTATIONThe Constant TYPE_PRESENTATION.protected static StringTYPE_SPREADSHEETThe Constant TYPE_SPREADSHEET.protected static StringTYPE_TEXTThe Constant TYPE_TEXT.protected StringuploadUrlThe upload url.protected StringusersPathThe user drives paths in JCR.static StringVIEWER_CACHE_NAMEThe Constant VIEWER_CACHE_NAME.protected org.exoplatform.services.cache.ExoCache<String,ConcurrentMap<String,Config>>viewerCacheCache of Viewing documents.-
Fields inherited from interface org.exoplatform.onlyoffice.OnlyofficeEditorService
EDIT_MODE, EDITOR_CLOSED_EVENT, EDITOR_ERROR_EVENT, EDITOR_OPENED_EVENT, EDITOR_SAVED_EVENT, EDITOR_VERSION_EVENT, VIEW_MODE
-
-
Constructor Summary
Constructors Constructor Description OnlyofficeEditorServiceImpl(org.exoplatform.services.jcr.RepositoryService jcrService, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.services.security.IdentityRegistry identityRegistry, NodeFinder finder, org.exoplatform.services.organization.OrganizationService organization, org.exoplatform.services.security.Authenticator authenticator, org.exoplatform.services.cache.CacheService cacheService, org.exoplatform.services.cms.documents.DocumentService documentService, org.exoplatform.services.cms.lock.LockService lockService, org.exoplatform.services.listener.ListenerService listenerService, org.exoplatform.services.cms.documents.TrashService trashService, org.exoplatform.social.core.space.spi.SpaceService spaceService, org.exoplatform.social.core.manager.ActivityManager activityManager, org.exoplatform.services.cms.drives.ManageDriveService manageDriveService, org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator hierarchyCreator, CachedEditorConfigStorage cachedEditorConfigStorage, org.exoplatform.container.xml.InitParams params)Cloud Drive service with storage in JCR and with managed features.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected StringaddComment(String activityId, String commentText, String userId)voidaddFilePreferences(javax.jcr.Node node, String userId, String path)Addds file preferences to the node (path for opening shared doc for particular user).voidaddListener(OnlyofficeEditorListener listener)Add listener to the service.voidaddTypePlugin(org.exoplatform.container.component.ComponentPlugin plugin)Adds DocumentTypePlugin to the service to check mimetypes of documents.protected voidbroadcastEvent(DocumentStatus status, String eventType)Broadcasts an event using the listenerService.booleancanDownloadBy(String hostName)Check does given host can download document content by this service.booleancanEditDocument(javax.jcr.Node node)Checks if the node isn't locked and can be edited by the current user.protected booleancanRenameDocument(javax.jcr.Node node)Checks if current user can rename the document.protected booleancheckout(javax.jcr.Node node)Checkout.voidcloseWithoutModification(String userId, String key)ConfigcreateEditor(String schema, String host, int port, String userId, String workspace, String docId)Create an editor configuration for given user and node.protected voidcreateVersionOfDraft(javax.jcr.Node node)Creates a version of draft.ConfigcreateViewer(String schema, String host, int port, String userId, String workspace, String docId)Creates the viewer.protected javax.jcr.Propertydata(javax.jcr.Node content)Data.protected StringdocumentType(String fileType)Document type.protected voiddownload(DocumentStatus status)Downloads document's content to the JCR node.protected voiddownloadClosed(DocumentStatus status)Downloads document's content to the JCR node when the editor is closed.voiddownloadVersion(String userId, String key, boolean coEdited, boolean forcesaved, String comment, String contentUrl)Builds status object based on params.protected voiddownloadVersion(DocumentStatus status)Downloads document's content to the JCR node creating a new version.protected StringeditorURLPath(String docId)Editor URL path.protected StringexplorerLink(String jcrPath)ECMS explorer page relative URL (within the Platform).protected URIexplorerUri(String schema, String host, int port, String ecmsLink)Explorer uri.protected StringBuilderexplorerUrl(String schema, String host, int port, String ecmsURL)Deprecated.protected StringfileType(javax.jcr.Node node)File type.protected voidfireCreated(DocumentStatus status)Fire created.protected voidfireError(DocumentStatus status)Fire error.protected voidfireGet(DocumentStatus status)Fire get.protected voidfireJoined(DocumentStatus status)Fire joined.protected voidfireLeaved(DocumentStatus status)Fire leaved.protected voidfireSaved(DocumentStatus status)Fire saved.voidforceSave(String userId, String key, boolean download, boolean coEdit, boolean forcesaved, String comment)Forces saving a document on document server.protected UUIDgenerateId(String workspace, String path)Generate id.protected String[]getActiveUsers(Map<String,Config> configs)Gets the current users.DocumentContentgetContent(String userId, String key)Get file content.protected StringgetDisplayPath(javax.jcr.Node node, String userId)Gets display path.javax.jcr.NodegetDocument(String workspace, String path)Gets the document node by its path and optionally a repository workspace.javax.jcr.NodegetDocumentById(String workspace, String uuid)Gets the document node by its id and optionally a repository workspace.StringgetDocumentId(javax.jcr.Node node)Gets the document ID for given node.protected Set<String>getDocumentserverAllowedHosts(String dsAllowedHost)Gets allowed hosts.protected StringgetDocumentserverHost(String dsSchema, String dsHost)Gets documentserver host name.StringgetDocumentServiceSecret()protected StringgetDrive(javax.jcr.Node node)Gets drive.protected ConfiggetEditor(String userId, String docId, boolean createCoEditing)Gets the editor.ConfiggetEditor(String userId, String workspace, String path)Return existing editor configuration for given user and node.ConfiggetEditorByKey(String userId, String key)Return existing editor for given temporal key.StringgetEditorLink(javax.jcr.Node node, String scheme, String host, int port)Gets the editor page URL for opening at Platform server.protected StringgetLastModified(javax.jcr.Node node)Gets lastmodified from node.Config.Editor.UsergetLastModifier(String key)Gets the last modifier userId.protected StringgetLastModifier(javax.jcr.Node node)Gets last modifier display name from node.static StringgetMimeType(javax.jcr.Node node)Get the MimeTypeChangeStategetState(String userId, String key)Local state of editing document.protected javax.jcr.NodegetSymlink(javax.jcr.Node node, String userId)Gets parent folder of the file based on file preferencesorg.exoplatform.services.organization.UsergetUser(String username)Gets the user.Config.Editor.UsergetUser(String key, String userId)Gets a user.protected StringgetUserId(String path)Gets userId from node path.protected StringgetUserLang(String userId)Gets the user lang.List<Version>getVersions(String workspace, String docId, int itemParPage, int pageNum)get the list of versions of the document with the given id.StringinitDocument(String workspace, String path)Inits the document and returns an ID for use within editors.StringinitDocument(javax.jcr.Node node)Inits the document and returns an ID for use within editors.protected voidinitFileTypes()Initializes fileTypes mapbooleanisDocumentMimeSupported(javax.jcr.Node node)Checks if the node has compatible mime-types.protected booleanisSuspendDownloadDocument()protected org.exoplatform.onlyoffice.OnlyofficeEditorServiceImpl.LockStatelock(javax.jcr.Node node, Config config)Lock the node by current user.protected voidlogError(String userId, String path, String docId, String key, String reason)Logs editor errors.protected StringlowerCase(String str)Get lower case copy of the given string.protected StringmimeType(javax.jcr.Node content)Mime type.protected javax.jcr.Nodenode(String workspace, String path)Node.protected javax.jcr.NodenodeByUUID(String workspace, String uuid)Node by UUID.protected StringnodeComment(javax.jcr.Node node)Gets comment of last version of nodeprotected javax.jcr.NodenodeContent(javax.jcr.Node node)Node content.protected CalendarnodeCreated(javax.jcr.Node node)Node created.protected StringnodePath(String workspace, String path)Node path with the pattern workspace:path/to/node.protected StringnodePath(Config config)Node path with the pattern workspace:path/to/node.protected StringnodeTitle(javax.jcr.Node node)Node title.protected StringBuilderplatformRestUrl(CharSequence platformUrl)Platform REST URL.protected StringBuilderplatformUrl(String schema, String host, int port)Platform url.voidremoveListener(OnlyofficeEditorListener listener)Remove listener from the service.protected voidrestoreConvoState(org.exoplatform.services.security.ConversationState contextState, org.exoplatform.services.jcr.ext.common.SessionProvider contextProvider)Restores the conversation state.protected voidsaveLink(String userId, String key, String url)Save link.voidsetLastModifier(String key, String userId)Sets the last modifier userId.protected booleansetUserConvoState(String userId)Sets ConversationState by userId.voidstart()On-start initializer.voidstop()On-stop finalizer.protected booleansyncUsers(Map<String,Config> configs, String[] users)Sync users.protected javax.jcr.NodesystemNode(String workspace, String path)System node.protected voidunlock(javax.jcr.Node node, org.exoplatform.onlyoffice.OnlyofficeEditorServiceImpl.LockState lock)Unlock given node.protected voidupdateCache(Config config)Updates config in the activeCache.voidupdateDocument(DocumentStatus status)Update a configuration associated with given DocumentStatus instance.voidupdateTitle(String workspace, String docId, String newTitle, String userId)Updates title of a document.protected org.exoplatform.services.security.IdentityuserIdentity(String userId)Find or create user identity.booleanvalidateToken(String token, String key)Validates the JWT token received from the document server.protected voidvalidateUser(String userId, Config config)Validate user.
-
-
-
Field Detail
-
LOG
protected static final org.exoplatform.services.log.Log LOG
The Constant LOG.
-
RANDOM
protected static final Random RANDOM
The Constant RANDOM.
-
CONFIG_DS_HOST
public static final String CONFIG_DS_HOST
The Constant CONFIG_DS_HOST.- See Also:
- Constant Field Values
-
CONFIG_DS_SCHEMA
public static final String CONFIG_DS_SCHEMA
The Constant CONFIG_DS_SCHEMA.- See Also:
- Constant Field Values
-
CONFIG_DS_ACCESS_ONLY
public static final String CONFIG_DS_ACCESS_ONLY
The Constant CONFIG_DS_ACCESS_ONLY.- See Also:
- Constant Field Values
-
CONFIG_DS_SECRET
public static final String CONFIG_DS_SECRET
The Constant CONFIG_DS_SECRET.- See Also:
- Constant Field Values
-
CONFIG_DS_ALLOWEDHOSTS
public static final String CONFIG_DS_ALLOWEDHOSTS
Configuration key for Document Server's allowed hosts in requests from a DS to eXo side.- See Also:
- Constant Field Values
-
HTTP_PORT_DELIMITER
protected static final char HTTP_PORT_DELIMITER
The Constant HTTP_PORT_DELIMITER.- See Also:
- Constant Field Values
-
HIDDEN_FOLDER
protected static final String HIDDEN_FOLDER
The hidden folder- See Also:
- Constant Field Values
-
LAST_EDITED_DATE_FORMAT
protected static final String LAST_EDITED_DATE_FORMAT
The date format for Last Edited in editor bar- See Also:
- Constant Field Values
-
TYPE_TEXT
protected static final String TYPE_TEXT
The Constant TYPE_TEXT.- See Also:
- Constant Field Values
-
TYPE_SPREADSHEET
protected static final String TYPE_SPREADSHEET
The Constant TYPE_SPREADSHEET.- See Also:
- Constant Field Values
-
TYPE_PRESENTATION
protected static final String TYPE_PRESENTATION
The Constant TYPE_PRESENTATION.- See Also:
- Constant Field Values
-
DEFAULT_NAME
protected static final String DEFAULT_NAME
The Constant DEFAULT_NAME.- See Also:
- Constant Field Values
-
RELATION_PROP
protected static final String RELATION_PROP
The Constant RELATION_PROP.- See Also:
- Constant Field Values
-
FILE_EXPLORER_URL_SYNTAX
protected static final Pattern FILE_EXPLORER_URL_SYNTAX
The Consant FILE_EXPLORER_URL_SYNTAX.
-
LOCK_WAIT_ATTEMTS
protected static final int LOCK_WAIT_ATTEMTS
The Constant LOCK_WAIT_ATTEMTS.- See Also:
- Constant Field Values
-
LOCK_WAIT_TIMEOUT
protected static final long LOCK_WAIT_TIMEOUT
The Constant LOCK_WAIT_TIMEOUT.- See Also:
- Constant Field Values
-
EMPTY_TEXT
protected static final String EMPTY_TEXT
The Constant EMPTY_TEXT.
-
CACHE_NAME
public static final String CACHE_NAME
The Constant CACHE_NAME.
-
VIEWER_CACHE_NAME
public static final String VIEWER_CACHE_NAME
The Constant VIEWER_CACHE_NAME.
-
jcrService
protected final org.exoplatform.services.jcr.RepositoryService jcrService
The jcr service.
-
sessionProviders
protected final org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders
The session providers.
-
identityRegistry
protected final org.exoplatform.services.security.IdentityRegistry identityRegistry
The identity registry.
-
finder
protected final NodeFinder finder
The finder.
-
organization
protected final org.exoplatform.services.organization.OrganizationService organization
The organization.
-
authenticator
protected final org.exoplatform.services.security.Authenticator authenticator
The authenticator.
-
documentService
protected final org.exoplatform.services.cms.documents.DocumentService documentService
The document service.
-
lockService
protected final org.exoplatform.services.cms.lock.LockService lockService
The lock service.
-
listenerService
protected final org.exoplatform.services.listener.ListenerService listenerService
The listener service.
-
trashService
protected final org.exoplatform.services.cms.documents.TrashService trashService
The trash service.
-
spaceService
protected final org.exoplatform.social.core.space.spi.SpaceService spaceService
The space service.
-
activityManager
protected final org.exoplatform.social.core.manager.ActivityManager activityManager
The activity manager.
-
hierarchyCreator
protected final org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator hierarchyCreator
The node hierarchy creator.
-
manageDriveService
protected final org.exoplatform.services.cms.drives.ManageDriveService manageDriveService
The manage drive service
-
cachedEditorConfigStorage
protected final CachedEditorConfigStorage cachedEditorConfigStorage
Cache of Editing documents.
-
viewerCache
protected final org.exoplatform.services.cache.ExoCache<String,ConcurrentMap<String,Config>> viewerCache
Cache of Viewing documents.
-
activeLock
protected final ReentrantLock activeLock
Lock for updating Editing documents cache.
-
uploadUrl
protected final String uploadUrl
The upload url.
-
documentserverHostName
protected final String documentserverHostName
The documentserver host name.
-
documentserverUrl
protected final String documentserverUrl
The documentserver url.
-
commandServiceUrl
protected final String commandServiceUrl
The document command service url.
-
documentserverSecret
protected final String documentserverSecret
The document server secret.
-
documentserverAccessOnly
protected final boolean documentserverAccessOnly
The documentserver access only.
-
groupsPath
protected final String groupsPath
The group drives path in JCR.
-
usersPath
protected final String usersPath
The user drives paths in JCR.
-
documentserverAllowedhosts
protected final Set<String> documentserverAllowedhosts
The documentserver allowed hosts (can be empty if not configured).
-
listeners
protected final ConcurrentLinkedQueue<OnlyofficeEditorListener> listeners
The listeners.
-
documentTypePlugin
protected DocumentTypePlugin documentTypePlugin
The document type plugin.
-
-
Constructor Detail
-
OnlyofficeEditorServiceImpl
public OnlyofficeEditorServiceImpl(org.exoplatform.services.jcr.RepositoryService jcrService, org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProviders, org.exoplatform.services.security.IdentityRegistry identityRegistry, NodeFinder finder, org.exoplatform.services.organization.OrganizationService organization, org.exoplatform.services.security.Authenticator authenticator, org.exoplatform.services.cache.CacheService cacheService, org.exoplatform.services.cms.documents.DocumentService documentService, org.exoplatform.services.cms.lock.LockService lockService, org.exoplatform.services.listener.ListenerService listenerService, org.exoplatform.services.cms.documents.TrashService trashService, org.exoplatform.social.core.space.spi.SpaceService spaceService, org.exoplatform.social.core.manager.ActivityManager activityManager, org.exoplatform.services.cms.drives.ManageDriveService manageDriveService, org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator hierarchyCreator, CachedEditorConfigStorage cachedEditorConfigStorage, org.exoplatform.container.xml.InitParams params) throws org.exoplatform.container.configuration.ConfigurationExceptionCloud Drive service with storage in JCR and with managed features.- Parameters:
jcrService-RepositoryServicesessionProviders-SessionProviderServiceidentityRegistry- the identity registryfinder- the finderorganization- the organizationauthenticator- the authenticatorcacheService- the cache servicedocumentService- the document service (ECMS)lockService- the lock servicelistenerService- the listener servicetrashService- the trashServicespaceService- the spaceServiceactivityManager- the activityManagermanageDriveService- the manageDriveServicehierarchyCreator- the hierarchyCreatorparams- the params- Throws:
org.exoplatform.container.configuration.ConfigurationException- the configuration exception
-
-
Method Detail
-
addListener
public void addListener(OnlyofficeEditorListener listener)
Add listener to the service.- Specified by:
addListenerin interfaceOnlyofficeEditorService- Parameters:
listener- the listener
-
removeListener
public void removeListener(OnlyofficeEditorListener listener)
Remove listener from the service.- Specified by:
removeListenerin interfaceOnlyofficeEditorService- Parameters:
listener- the listener
-
getEditor
public Config getEditor(String userId, String workspace, String path) throws OnlyofficeEditorException, javax.jcr.RepositoryException
Return existing editor configuration for given user and node. If editor not open for given node or user thennullwill be returned. If user not valid then OnlyofficeEditorException will be thrown.- Specified by:
getEditorin interfaceOnlyofficeEditorService- Parameters:
userId-Stringworkspace-Stringpath-String- Returns:
Configornull- Throws:
OnlyofficeEditorException- the onlyoffice editor exceptionjavax.jcr.RepositoryException- the repository exception
-
getEditorByKey
public Config getEditorByKey(String userId, String key) throws OnlyofficeEditorException, javax.jcr.RepositoryException
Return existing editor for given temporal key. If editor or user not found thennullwill be returned. If user not valid then OnlyofficeEditorException will be thrown.- Specified by:
getEditorByKeyin interfaceOnlyofficeEditorService- Parameters:
userId- the user idkey- the key, seeOnlyofficeEditorService.getEditor(String, String, String)- Returns:
- the editor by key
- Throws:
OnlyofficeEditorException- the onlyoffice editor exceptionjavax.jcr.RepositoryException- the repository exception
-
getEditor
protected Config getEditor(String userId, String docId, boolean createCoEditing) throws OnlyofficeEditorException, javax.jcr.RepositoryException
Gets the editor.- Parameters:
userId- the user iddocId- the node docIdcreateCoEditing- iftrueand has no editor for given user, create a copy for co-editing if document already editing by other users- Returns:
- the editor
- Throws:
OnlyofficeEditorException- the onlyoffice editor exceptionjavax.jcr.RepositoryException- the repository exception
-
createEditor
public Config createEditor(String schema, String host, int port, String userId, String workspace, String docId) throws OnlyofficeEditorException, javax.jcr.RepositoryException
Create an editor configuration for given user and node.- Specified by:
createEditorin interfaceOnlyofficeEditorService- Parameters:
schema- the schemahost- the hostport- the user postuserId-Stringworkspace-StringdocId-Stringa document reference in the workspace, seeOnlyofficeEditorService.initDocument(String, String)- Returns:
Configinstance in case of successful creation ornullif local file type not supported.- Throws:
OnlyofficeEditorException- if editor exception happenedjavax.jcr.RepositoryException- if storage exception happened
-
createViewer
public Config createViewer(String schema, String host, int port, String userId, String workspace, String docId) throws OnlyofficeEditorException, javax.jcr.RepositoryException
Creates the viewer.- Specified by:
createViewerin interfaceOnlyofficeEditorService- Parameters:
schema- the schemahost- the hostport- the portuserId- the user idworkspace- the workspacedocId- the doc id- Returns:
- the config
- Throws:
OnlyofficeEditorException- the onlyoffice editor exceptionjavax.jcr.RepositoryException- the repository exception
-
getContent
public DocumentContent getContent(String userId, String key) throws OnlyofficeEditorException, javax.jcr.RepositoryException
Get file content.- Specified by:
getContentin interfaceOnlyofficeEditorService- Parameters:
userId-Stringkey-String- Returns:
DocumentContent- Throws:
OnlyofficeEditorException- the onlyoffice editor exceptionjavax.jcr.RepositoryException- the repository exception
-
canDownloadBy
public boolean canDownloadBy(String hostName)
Check does given host can download document content by this service. It's optional feature, configurable and allow only configured Document server by default.- Specified by:
canDownloadByin interfaceOnlyofficeEditorService- Parameters:
hostName-String- Returns:
trueif client host with given name can download document content,falseotherwise.
-
getState
public ChangeState getState(String userId, String key) throws OnlyofficeEditorException
Local state of editing document.- Specified by:
getStatein interfaceOnlyofficeEditorService- Parameters:
userId-Stringkey-String- Returns:
ChangeState- Throws:
OnlyofficeEditorException- the onlyoffice editor exception
-
updateDocument
public void updateDocument(DocumentStatus status) throws OnlyofficeEditorException, javax.jcr.RepositoryException
Update a configuration associated with given DocumentStatus instance. This operation will close the editor and it will not be usable after that.- Specified by:
updateDocumentin interfaceOnlyofficeEditorService- Parameters:
status-DocumentStatus- Throws:
OnlyofficeEditorException- if editor exception happenedjavax.jcr.RepositoryException- if storage exception happened
-
initDocument
public String initDocument(javax.jcr.Node node) throws javax.jcr.RepositoryException
Inits the document and returns an ID for use within editors. Node may be saved by this method if ID generation will be required, in this case it should be allowed to edit the node (not locked and user has write permissions).- Specified by:
initDocumentin interfaceOnlyofficeEditorService- Parameters:
node- the node of the document- Returns:
- the string with document ID for use within editors
- Throws:
javax.jcr.RepositoryException- the repository exception
-
initDocument
public String initDocument(String workspace, String path) throws OnlyofficeEditorException, javax.jcr.RepositoryException
Inits the document and returns an ID for use within editors. Node will be saved by this method.- Specified by:
initDocumentin interfaceOnlyofficeEditorService- Parameters:
workspace- the workspacepath- the path- Returns:
- the string
- Throws:
OnlyofficeEditorException- the onlyoffice editor exceptionjavax.jcr.RepositoryException- the repository exception
-
getEditorLink
public String getEditorLink(javax.jcr.Node node, String scheme, String host, int port) throws javax.jcr.RepositoryException, EditorLinkNotFoundException
Gets the editor page URL for opening at Platform server.- Specified by:
getEditorLinkin interfaceOnlyofficeEditorService- Parameters:
node- the nodescheme- the schemehost- the hostport- the port- Returns:
- the editor link
- Throws:
javax.jcr.RepositoryException- the repository exceptionEditorLinkNotFoundException- the editor link not found exceptions
-
getDocumentId
public String getDocumentId(javax.jcr.Node node) throws DocumentNotFoundException, javax.jcr.RepositoryException
Gets the document ID for given node. It will return an ID for use within an editor, otherwisenullwill be returned.- Specified by:
getDocumentIdin interfaceOnlyofficeEditorService- Parameters:
node- the node- Returns:
- the document ID or
null - Throws:
DocumentNotFoundException- the document not found exceptionjavax.jcr.RepositoryException- the repository exception- See Also:
OnlyofficeEditorService.initDocument(String, String),OnlyofficeEditorService.canEditDocument(Node)
-
getDocumentById
public javax.jcr.Node getDocumentById(String workspace, String uuid) throws javax.jcr.RepositoryException, DocumentNotFoundException
Gets the document node by its id and optionally a repository workspace.- Specified by:
getDocumentByIdin interfaceOnlyofficeEditorService- Parameters:
workspace- the workspace, can benull, then a default one will be useduuid- the id of a document- Returns:
- the document or
nullif nothing found - Throws:
javax.jcr.RepositoryException- the repository exceptionDocumentNotFoundException- the document not found exception
-
getVersions
public List<Version> getVersions(String workspace, String docId, int itemParPage, int pageNum) throws Exception
get the list of versions of the document with the given id.- Specified by:
getVersionsin interfaceOnlyofficeEditorService- Parameters:
workspace- the workspacedocId- the document iditemParPage- the versions par pagepageNum- the page number to load- Returns:
- list of versions for node
- Throws:
Exception- the exception
-
getDocument
public javax.jcr.Node getDocument(String workspace, String path) throws javax.jcr.RepositoryException, BadParameterException
Gets the document node by its path and optionally a repository workspace.- Specified by:
getDocumentin interfaceOnlyofficeEditorService- Parameters:
workspace- the workspace, can benull, then a default one will be usedpath- the path of a document- Returns:
- the document or
nullif nothing found - Throws:
javax.jcr.RepositoryException- the repository exceptionBadParameterException- the bad parameter exeption
-
start
public void start()
On-start initializer.- Specified by:
startin interfaceorg.picocontainer.Startable
-
stop
public void stop()
On-stop finalizer.- Specified by:
stopin interfaceorg.picocontainer.Startable
-
addTypePlugin
public void addTypePlugin(org.exoplatform.container.component.ComponentPlugin plugin)
Adds DocumentTypePlugin to the service to check mimetypes of documents.- Specified by:
addTypePluginin interfaceOnlyofficeEditorService- Parameters:
plugin- - the plugin to be added
-
canEditDocument
public boolean canEditDocument(javax.jcr.Node node) throws javax.jcr.RepositoryExceptionChecks if the node isn't locked and can be edited by the current user.- Specified by:
canEditDocumentin interfaceOnlyofficeEditorService- Parameters:
node- the node- Returns:
- true, if the current user can edit the node
- Throws:
javax.jcr.RepositoryException- the repository exeption
-
isDocumentMimeSupported
public boolean isDocumentMimeSupported(javax.jcr.Node node) throws javax.jcr.RepositoryExceptionChecks if the node has compatible mime-types.- Specified by:
isDocumentMimeSupportedin interfaceOnlyofficeEditorService- Parameters:
node- the node- Returns:
- true, if the node mime-types are supported
- Throws:
javax.jcr.RepositoryException- the repository exeption
-
downloadVersion
public void downloadVersion(String userId, String key, boolean coEdited, boolean forcesaved, String comment, String contentUrl)
Builds status object based on params. Obtains the config- Specified by:
downloadVersionin interfaceOnlyofficeEditorService- Parameters:
userId- the userIdkey- the keycoEdited- the coEditedforcesaved- the forceSavedcomment- the commentcontentUrl- the contentUrl
-
getLastModifier
public Config.Editor.User getLastModifier(String key)
Gets the last modifier userId.- Specified by:
getLastModifierin interfaceOnlyofficeEditorService- Parameters:
key- the key- Returns:
- the editor user
-
setLastModifier
public void setLastModifier(String key, String userId)
Sets the last modifier userId.- Specified by:
setLastModifierin interfaceOnlyofficeEditorService- Parameters:
key- the keyuserId- the userId
-
getUser
public Config.Editor.User getUser(String key, String userId)
Gets a user.- Specified by:
getUserin interfaceOnlyofficeEditorService- Parameters:
key- the keyuserId- the userId- Returns:
- the user
-
forceSave
public void forceSave(String userId, String key, boolean download, boolean coEdit, boolean forcesaved, String comment)
Forces saving a document on document server.- Specified by:
forceSavein interfaceOnlyofficeEditorService- Parameters:
userId- the userIdkey- the keydownload- the downloadcoEdit- the coeditforcesaved- the forcesavedcomment- the comment
-
validateToken
public boolean validateToken(String token, String key)
Description copied from interface:OnlyofficeEditorServiceValidates the JWT token received from the document server.- Specified by:
validateTokenin interfaceOnlyofficeEditorService- Parameters:
token- the tokenkey- the document key- Returns:
- true, if the token is correct, false otherwise
-
updateTitle
public void updateTitle(String workspace, String docId, String newTitle, String userId)
Description copied from interface:OnlyofficeEditorServiceUpdates title of a document.- Specified by:
updateTitlein interfaceOnlyofficeEditorService- Parameters:
workspace- the workspacedocId- the docIdnewTitle- the titleuserId- the userId
-
getUser
public org.exoplatform.services.organization.User getUser(String username) throws OnlyofficeEditorException
Gets the user.- Specified by:
getUserin interfaceOnlyofficeEditorService- Parameters:
username- the username- Returns:
- the user
- Throws:
OnlyofficeEditorException- the onlyoffice editor exception
-
addFilePreferences
public void addFilePreferences(javax.jcr.Node node, String userId, String path) throws javax.jcr.RepositoryExceptionAddds file preferences to the node (path for opening shared doc for particular user).- Specified by:
addFilePreferencesin interfaceOnlyofficeEditorService- Parameters:
node- the nodeuserId- the userIdpath- the path- Throws:
javax.jcr.RepositoryException- the repositoryException
-
getDocumentServiceSecret
public String getDocumentServiceSecret()
- Specified by:
getDocumentServiceSecretin interfaceOnlyofficeEditorService
-
closeWithoutModification
public void closeWithoutModification(String userId, String key)
- Specified by:
closeWithoutModificationin interfaceOnlyofficeEditorService
-
saveLink
protected void saveLink(String userId, String key, String url)
Save link.- Parameters:
userId- the userIdkey- the keyurl- the url
-
downloadClosed
protected void downloadClosed(DocumentStatus status)
Downloads document's content to the JCR node when the editor is closed.- Parameters:
status- the status
-
nodeTitle
protected String nodeTitle(javax.jcr.Node node) throws javax.jcr.RepositoryException
Node title.- Parameters:
node- the node- Returns:
- the string
- Throws:
javax.jcr.RepositoryException- the repository exception
-
fileType
protected String fileType(javax.jcr.Node node) throws javax.jcr.RepositoryException
File type.- Parameters:
node- the node- Returns:
- the string
- Throws:
javax.jcr.RepositoryException- the repository exception
-
documentType
protected String documentType(String fileType)
Document type.- Parameters:
fileType- the file type- Returns:
- the string
-
getMimeType
public static String getMimeType(javax.jcr.Node node)
Get the MimeType- Parameters:
node- the node- Returns:
- the MimeType
-
nodeContent
protected javax.jcr.Node nodeContent(javax.jcr.Node node) throws javax.jcr.RepositoryExceptionNode content.- Parameters:
node- the node- Returns:
- the node
- Throws:
javax.jcr.RepositoryException- the repository exception
-
nodeCreated
protected Calendar nodeCreated(javax.jcr.Node node) throws javax.jcr.RepositoryException
Node created.- Parameters:
node- the node- Returns:
- the calendar
- Throws:
javax.jcr.RepositoryException- the repository exception
-
mimeType
protected String mimeType(javax.jcr.Node content) throws javax.jcr.RepositoryException
Mime type.- Parameters:
content- the content- Returns:
- the string
- Throws:
javax.jcr.RepositoryException- the repository exception
-
data
protected javax.jcr.Property data(javax.jcr.Node content) throws javax.jcr.RepositoryExceptionData.- Parameters:
content- the content- Returns:
- the property
- Throws:
javax.jcr.RepositoryException- the repository exception
-
generateId
protected UUID generateId(String workspace, String path)
Generate id.- Parameters:
workspace- the workspacepath- the path- Returns:
- the uuid
-
nodePath
protected String nodePath(String workspace, String path)
Node path with the pattern workspace:path/to/node.- Parameters:
workspace- the workspacepath- the path- Returns:
- the string
-
nodePath
protected String nodePath(Config config)
Node path with the pattern workspace:path/to/node.- Parameters:
config- the config- Returns:
- the string
-
syncUsers
protected boolean syncUsers(Map<String,Config> configs, String[] users)
Sync users.- Parameters:
configs- the configsusers- the users- Returns:
- true, if actually changed editor config user(s)
-
getActiveUsers
protected String[] getActiveUsers(Map<String,Config> configs)
Gets the current users.- Parameters:
configs- the configs- Returns:
- the current users
-
downloadVersion
protected void downloadVersion(DocumentStatus status)
Downloads document's content to the JCR node creating a new version.- Parameters:
status- the status
-
download
protected void download(DocumentStatus status) throws OnlyofficeEditorException, javax.jcr.RepositoryException
Downloads document's content to the JCR node.- Parameters:
status- the status- Throws:
OnlyofficeEditorException- the OnlyofficeEditorExceptionjavax.jcr.RepositoryException- the RepositoryException
-
updateCache
protected void updateCache(Config config)
Updates config in the activeCache.- Parameters:
config- the config
-
createVersionOfDraft
protected void createVersionOfDraft(javax.jcr.Node node) throws javax.jcr.RepositoryException, OnlyofficeEditorExceptionCreates a version of draft. Used to create version after manually uploaded content.- Parameters:
node- the node- Throws:
javax.jcr.RepositoryException- the repository exceptionOnlyofficeEditorException- the onlyoffice exception
-
node
protected javax.jcr.Node node(String workspace, String path) throws BadParameterException, javax.jcr.RepositoryException
Node.- Parameters:
workspace- the workspacepath- the path- Returns:
- the node
- Throws:
BadParameterException- the bad parameter exceptionjavax.jcr.RepositoryException- the repository exception
-
systemNode
protected javax.jcr.Node systemNode(String workspace, String path) throws BadParameterException, javax.jcr.RepositoryException
System node.- Parameters:
workspace- the workspacepath- the path- Returns:
- the node
- Throws:
BadParameterException- the bad parameter exceptionjavax.jcr.RepositoryException- the repository exception
-
nodeByUUID
protected javax.jcr.Node nodeByUUID(String workspace, String uuid) throws javax.jcr.RepositoryException
Node by UUID.- Parameters:
workspace- the workspaceuuid- the UUID- Returns:
- the node
- Throws:
javax.jcr.RepositoryException- the repository exception
-
checkout
protected boolean checkout(javax.jcr.Node node) throws javax.jcr.RepositoryExceptionCheckout.- Parameters:
node- the node- Returns:
- true, if successful
- Throws:
javax.jcr.RepositoryException- the repository exception
-
unlock
protected void unlock(javax.jcr.Node node, org.exoplatform.onlyoffice.OnlyofficeEditorServiceImpl.LockState lock) throws OnlyofficeEditorException, javax.jcr.RepositoryExceptionUnlock given node.- Parameters:
node- the nodelock- the lock- Throws:
OnlyofficeEditorException- the onlyoffice editor exceptionjavax.jcr.RepositoryException- the repository exception
-
lock
protected org.exoplatform.onlyoffice.OnlyofficeEditorServiceImpl.LockState lock(javax.jcr.Node node, Config config) throws OnlyofficeEditorException, javax.jcr.RepositoryExceptionLock the node by current user. If lock attempts will succeed in predefined time this method will throwOnlyofficeEditorException. If node isn't mix:lockable it will be added first and node saved.- Parameters:
node-Nodeconfig-Config- Returns:
Lockacquired by current user.- Throws:
OnlyofficeEditorException- the onlyoffice editor exceptionjavax.jcr.RepositoryException- the repository exception
-
validateUser
protected void validateUser(String userId, Config config) throws BadParameterException, OnlyofficeEditorException
Validate user.- Parameters:
userId- the user idconfig- the config- Throws:
BadParameterException- if user not foundOnlyofficeEditorException- if error searching user in organization service
-
getUserLang
protected String getUserLang(String userId)
Gets the user lang.- Parameters:
userId- the user id- Returns:
- the lang can be
nullif user has no profile or language in it or user profile error
-
platformUrl
protected StringBuilder platformUrl(String schema, String host, int port)
Platform url.- Parameters:
schema- the schemahost- the hostport- the port- Returns:
- the string builder
-
explorerUrl
@Deprecated protected StringBuilder explorerUrl(String schema, String host, int port, String ecmsURL)
Deprecated.ECMS explorer page URL.- Parameters:
schema- the schemahost- the hostport- the portecmsURL- the ECMS URL- Returns:
- the string builder
-
explorerUri
protected URI explorerUri(String schema, String host, int port, String ecmsLink)
Explorer uri.- Parameters:
schema- the schemahost- the hostport- the portecmsLink- the ecms link- Returns:
- the uri
-
explorerLink
protected String explorerLink(String jcrPath)
ECMS explorer page relative URL (within the Platform).- Parameters:
jcrPath- the jcr path- Returns:
- the string
-
platformRestUrl
protected StringBuilder platformRestUrl(CharSequence platformUrl)
Platform REST URL.- Parameters:
platformUrl- the platform URL- Returns:
- the string builder
-
broadcastEvent
protected void broadcastEvent(DocumentStatus status, String eventType)
Broadcasts an event using the listenerService.- Parameters:
status- the statuseventType- the eventType
-
fireCreated
protected void fireCreated(DocumentStatus status)
Fire created.- Parameters:
status- the status
-
fireGet
protected void fireGet(DocumentStatus status)
Fire get.- Parameters:
status- the status
-
fireJoined
protected void fireJoined(DocumentStatus status)
Fire joined.- Parameters:
status- the status
-
fireLeaved
protected void fireLeaved(DocumentStatus status)
Fire leaved.- Parameters:
status- the status
-
fireSaved
protected void fireSaved(DocumentStatus status)
Fire saved.- Parameters:
status- the status
-
fireError
protected void fireError(DocumentStatus status)
Fire error.- Parameters:
status- the status
-
userIdentity
protected org.exoplatform.services.security.Identity userIdentity(String userId)
Find or create user identity.- Parameters:
userId- the user id- Returns:
- the identity can be null if not found and cannot be created via current authenticator
-
lowerCase
protected String lowerCase(String str)
Get lower case copy of the given string.- Parameters:
str- the str- Returns:
- the string
-
editorURLPath
protected String editorURLPath(String docId) throws EditorLinkNotFoundException
Editor URL path.- Parameters:
docId- the doc id- Returns:
- the string
- Throws:
EditorLinkNotFoundException
-
logError
protected void logError(String userId, String path, String docId, String key, String reason)
Logs editor errors.- Parameters:
userId- the userIdpath- the pathdocId- the docIdkey- the keyreason- the reason
-
setUserConvoState
protected boolean setUserConvoState(String userId)
Sets ConversationState by userId.- Parameters:
userId- the userId- Returns:
- true if successful, false when the user is not found
-
restoreConvoState
protected void restoreConvoState(org.exoplatform.services.security.ConversationState contextState, org.exoplatform.services.jcr.ext.common.SessionProvider contextProvider)Restores the conversation state.- Parameters:
contextState- the contextStatecontextProvider- the contextProvider
-
initFileTypes
protected void initFileTypes()
Initializes fileTypes map
-
getDocumentserverHost
protected String getDocumentserverHost(String dsSchema, String dsHost) throws org.exoplatform.container.configuration.ConfigurationException
Gets documentserver host name.- Parameters:
dsSchema- the dsSchemadsHost- the dsHost- Returns:
- hostname
- Throws:
org.exoplatform.container.configuration.ConfigurationException- the configurationException
-
getDocumentserverAllowedHosts
protected Set<String> getDocumentserverAllowedHosts(String dsAllowedHost)
Gets allowed hosts.- Parameters:
dsAllowedHost- the dsAllowedHost- Returns:
- allowed hosts
-
getDrive
protected String getDrive(javax.jcr.Node node)
Gets drive.- Parameters:
node- the node- Returns:
- the drive name
-
getDisplayPath
protected String getDisplayPath(javax.jcr.Node node, String userId)
Gets display path.- Parameters:
node- the nodeuserId- the userId- Returns:
- the display path
-
getSymlink
protected javax.jcr.Node getSymlink(javax.jcr.Node node, String userId) throws ExceptionGets parent folder of the file based on file preferences- Parameters:
node- the nodeuserId- the userId- Returns:
- the Node
- Throws:
Exception- the exception
-
getUserId
protected String getUserId(String path)
Gets userId from node path.- Parameters:
path- the node path- Returns:
- the userId
-
nodeComment
protected String nodeComment(javax.jcr.Node node)
Gets comment of last version of node- Parameters:
node- the node- Returns:
- the comment or null
-
canRenameDocument
protected boolean canRenameDocument(javax.jcr.Node node)
Checks if current user can rename the document.- Parameters:
node- the node- Returns:
- true if user can rename
-
getLastModified
protected String getLastModified(javax.jcr.Node node) throws javax.jcr.ValueFormatException, javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
Gets lastmodified from node.- Parameters:
node- the node- Returns:
- the lastmodified
- Throws:
javax.jcr.ValueFormatException- the valueFormatExceptionjavax.jcr.PathNotFoundException- the pathNotFoundExceptionjavax.jcr.RepositoryException- the repositoryException
-
getLastModifier
protected String getLastModifier(javax.jcr.Node node) throws javax.jcr.ValueFormatException, javax.jcr.PathNotFoundException, javax.jcr.RepositoryException, OnlyofficeEditorException
Gets last modifier display name from node.- Parameters:
node- the node.- Returns:
- the display name of last modifier
- Throws:
javax.jcr.ValueFormatException- the valueFormatExceptionjavax.jcr.PathNotFoundException- the pathNotFoundExceptionjavax.jcr.RepositoryException- the repositoryExceptionOnlyofficeEditorException- the onlyofficeEditorException
-
isSuspendDownloadDocument
protected boolean isSuspendDownloadDocument()
-
-