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 implementing
Created by The eXo Platform SAS.
OnlyofficeEditorService and Startable.
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 ClassesModifier and TypeClassDescriptionstatic classNewDocumentTypesConfig. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ReentrantLockLock for updating Editing documents cache.protected final org.exoplatform.social.core.manager.ActivityManagerThe activity manager.protected final org.exoplatform.services.security.AuthenticatorThe authenticator.static final StringThe Constant CACHE_NAME.protected final CachedEditorConfigStorageCache of Editing documents.protected final StringThe document command service url.The config.static final StringThe Constant CONFIG_DS_ACCESS_ONLY.static final StringConfiguration key for Document Server's allowed hosts in requests from a DS to eXo side.static final StringThe Constant CONFIG_DS_HOST.static final StringThe Constant CONFIG_DS_SCHEMA.static final StringThe Constant CONFIG_DS_SECRET.protected static final StringThe Constant DEFAULT_NAME.protected final booleanThe documentserver access only.The documentserver allowed hosts (can be empty if not configured).protected final StringThe documentserver host name.protected final StringThe document server secret.protected final StringThe documentserver url.protected final org.exoplatform.services.cms.documents.DocumentServiceThe document service.protected DocumentTypePluginThe document type plugin.protected static final StringThe Constant EMPTY_TEXT.protected static final PatternThe Consant FILE_EXPLORER_URL_SYNTAX.The file types.protected final NodeFinderThe finder.protected final StringThe group drives path in JCR.protected static final StringThe hidden folderprotected final org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreatorThe node hierarchy creator.protected static final charThe Constant HTTP_PORT_DELIMITER.protected final org.exoplatform.services.security.IdentityRegistryThe identity registry.protected final org.exoplatform.services.jcr.RepositoryServiceThe jcr service.protected static final StringThe date format for Last Edited in editor barprotected final ConcurrentLinkedQueue<OnlyofficeEditorListener> The listeners.protected final org.exoplatform.services.listener.ListenerServiceThe listener service.protected static final intThe Constant LOCK_WAIT_ATTEMTS.protected static final longThe Constant LOCK_WAIT_TIMEOUT.protected final org.exoplatform.services.cms.lock.LockServiceThe lock service.protected static final org.exoplatform.services.log.LogThe Constant LOG.protected final org.exoplatform.services.cms.drives.ManageDriveServiceThe manage drive serviceprotected final org.exoplatform.services.organization.OrganizationServiceThe organization.protected static final RandomThe Constant RANDOM.protected static final StringThe Constant RELATION_PROP.protected final org.exoplatform.services.jcr.ext.app.SessionProviderServiceThe session providers.static final Stringprotected final org.exoplatform.social.core.space.spi.SpaceServiceThe space service.protected final org.exoplatform.services.cms.documents.TrashServiceThe trash service.protected static final StringThe Constant TYPE_PRESENTATION.protected static final StringThe Constant TYPE_SPREADSHEET.protected static final StringThe Constant TYPE_TEXT.protected final StringThe upload url.protected final StringThe user drives paths in JCR.static final StringThe Constant VIEWER_CACHE_NAME.protected final org.exoplatform.services.cache.ExoCache<String, ConcurrentMap<String, Config>> Cache 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
ConstructorsConstructorDescriptionOnlyofficeEditorServiceImpl(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
Modifier and TypeMethodDescriptionprotected 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) Create an editor configuration for given user and node.protected voidcreateVersionOfDraft(javax.jcr.Node node) Creates a version of draft.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.getContent(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.getDocumentId(javax.jcr.Node node) Gets the document ID for given node.getDocumentserverAllowedHosts(String dsAllowedHost) Gets allowed hosts.protected StringgetDocumentserverHost(String dsSchema, String dsHost) Gets documentserver host name.protected StringgetDrive(javax.jcr.Node node) Gets drive.protected ConfigGets the editor.Return existing editor configuration for given user and node.getEditorByKey(String userId, String key) Return existing editor for given temporal key.getEditorLink(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.getLastModifier(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 MimeTypeLocal 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.UserGets the user.Gets a user.protected StringGets userId from node path.static StringgetUserLanguage(String userId) Gets platform language of user.getVersions(String workspace, String docId, int itemParPage, int pageNum) get the list of versions of the document with the given id.initDocument(String workspace, String path) Inits the document and returns an ID for use within editors.initDocument(javax.jcr.Node node) Inits the document and returns an ID for use within editors.protected voidInitializes fileTypes mapbooleanisDocumentCoedited(String key) Checks if the document is opened for edition by multiple usersbooleanisDocumentMimeSupported(javax.jcr.Node node) Checks if the node has compatible mime-types.protected booleanprotected org.exoplatform.onlyoffice.OnlyofficeEditorServiceImpl.LockStateLock the node by current user.protected voidLogs editor errors.protected voidprotected StringGet lower case copy of the given string.protected StringmimeType(javax.jcr.Node content) Mime type.protected javax.jcr.NodeNode.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 StringNode path with the pattern workspace:path/to/node.protected StringNode 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 voidSave 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 booleanSync 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 Details
-
LOG
protected static final org.exoplatform.services.log.Log LOGThe Constant LOG. -
SPACE_APP_ID
- See Also:
-
RANDOM
The Constant RANDOM. -
CONFIG_DS_HOST
The Constant CONFIG_DS_HOST.- See Also:
-
CONFIG_DS_SCHEMA
The Constant CONFIG_DS_SCHEMA.- See Also:
-
CONFIG_DS_ACCESS_ONLY
The Constant CONFIG_DS_ACCESS_ONLY.- See Also:
-
CONFIG_DS_SECRET
The Constant CONFIG_DS_SECRET.- See Also:
-
CONFIG_DS_ALLOWEDHOSTS
Configuration key for Document Server's allowed hosts in requests from a DS to eXo side.- See Also:
-
HTTP_PORT_DELIMITER
protected static final char HTTP_PORT_DELIMITERThe Constant HTTP_PORT_DELIMITER.- See Also:
-
HIDDEN_FOLDER
The hidden folder- See Also:
-
LAST_EDITED_DATE_FORMAT
The date format for Last Edited in editor bar- See Also:
-
TYPE_TEXT
The Constant TYPE_TEXT.- See Also:
-
TYPE_SPREADSHEET
The Constant TYPE_SPREADSHEET.- See Also:
-
TYPE_PRESENTATION
The Constant TYPE_PRESENTATION.- See Also:
-
DEFAULT_NAME
The Constant DEFAULT_NAME.- See Also:
-
RELATION_PROP
The Constant RELATION_PROP.- See Also:
-
FILE_EXPLORER_URL_SYNTAX
The Consant FILE_EXPLORER_URL_SYNTAX. -
LOCK_WAIT_ATTEMTS
protected static final int LOCK_WAIT_ATTEMTSThe Constant LOCK_WAIT_ATTEMTS.- See Also:
-
LOCK_WAIT_TIMEOUT
protected static final long LOCK_WAIT_TIMEOUTThe Constant LOCK_WAIT_TIMEOUT.- See Also:
-
EMPTY_TEXT
The Constant EMPTY_TEXT. -
CACHE_NAME
The Constant CACHE_NAME. -
VIEWER_CACHE_NAME
The Constant VIEWER_CACHE_NAME. -
jcrService
protected final org.exoplatform.services.jcr.RepositoryService jcrServiceThe jcr service. -
sessionProviders
protected final org.exoplatform.services.jcr.ext.app.SessionProviderService sessionProvidersThe session providers. -
identityRegistry
protected final org.exoplatform.services.security.IdentityRegistry identityRegistryThe identity registry. -
finder
The finder. -
organization
protected final org.exoplatform.services.organization.OrganizationService organizationThe organization. -
authenticator
protected final org.exoplatform.services.security.Authenticator authenticatorThe authenticator. -
documentService
protected final org.exoplatform.services.cms.documents.DocumentService documentServiceThe document service. -
lockService
protected final org.exoplatform.services.cms.lock.LockService lockServiceThe lock service. -
listenerService
protected final org.exoplatform.services.listener.ListenerService listenerServiceThe listener service. -
trashService
protected final org.exoplatform.services.cms.documents.TrashService trashServiceThe trash service. -
spaceService
protected final org.exoplatform.social.core.space.spi.SpaceService spaceServiceThe space service. -
activityManager
protected final org.exoplatform.social.core.manager.ActivityManager activityManagerThe activity manager. -
hierarchyCreator
protected final org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator hierarchyCreatorThe node hierarchy creator. -
manageDriveService
protected final org.exoplatform.services.cms.drives.ManageDriveService manageDriveServiceThe manage drive service -
cachedEditorConfigStorage
Cache of Editing documents. -
viewerCache
protected final org.exoplatform.services.cache.ExoCache<String,ConcurrentMap<String, viewerCacheConfig>> Cache of Viewing documents. -
activeLock
Lock for updating Editing documents cache. -
config
The config. -
uploadUrl
The upload url. -
documentserverHostName
The documentserver host name. -
documentserverUrl
The documentserver url. -
commandServiceUrl
The document command service url. -
documentserverSecret
The document server secret. -
documentserverAccessOnly
protected final boolean documentserverAccessOnlyThe documentserver access only. -
groupsPath
The group drives path in JCR. -
usersPath
The user drives paths in JCR. -
documentserverAllowedhosts
The documentserver allowed hosts (can be empty if not configured). -
fileTypes
The file types. -
listeners
The listeners. -
documentTypePlugin
The document type plugin.
-
-
Constructor Details
-
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.ConfigurationException Cloud 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 Details
-
addListener
Add listener to the service.- Specified by:
addListenerin interfaceOnlyofficeEditorService- Parameters:
listener- the listener
-
removeListener
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
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
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
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:
-
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.RepositoryException Checks 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.RepositoryException Checks 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
Gets the last modifier userId.- Specified by:
getLastModifierin interfaceOnlyofficeEditorService- Parameters:
key- the key- Returns:
- the editor user
-
setLastModifier
Sets the last modifier userId.- Specified by:
setLastModifierin interfaceOnlyofficeEditorService- Parameters:
key- the keyuserId- the userId
-
getUser
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
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
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.RepositoryException Addds 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
- Specified by:
getDocumentServiceSecretin interfaceOnlyofficeEditorService
-
closeWithoutModification
- Specified by:
closeWithoutModificationin interfaceOnlyofficeEditorService
-
isDocumentCoedited
Description copied from interface:OnlyofficeEditorServiceChecks if the document is opened for edition by multiple users- Specified by:
isDocumentCoeditedin interfaceOnlyofficeEditorService- Parameters:
key- Document key- Returns:
- Boolean true if the document is opened for edition by multiple users
-
saveLink
Save link.- Parameters:
userId- the userIdkey- the keyurl- the url
-
downloadClosed
Downloads document's content to the JCR node when the editor is closed.- Parameters:
status- the status
-
nodeTitle
Node title.- Parameters:
node- the node- Returns:
- the string
- Throws:
javax.jcr.RepositoryException- the repository exception
-
fileType
File type.- Parameters:
node- the node- Returns:
- the string
- Throws:
javax.jcr.RepositoryException- the repository exception
-
documentType
Document type.- Parameters:
fileType- the file type- Returns:
- the string
-
getMimeType
Get the MimeType- Parameters:
node- the node- Returns:
- the MimeType
-
nodeContent
protected javax.jcr.Node nodeContent(javax.jcr.Node node) throws javax.jcr.RepositoryException Node content.- Parameters:
node- the node- Returns:
- the node
- Throws:
javax.jcr.RepositoryException- the repository exception
-
nodeCreated
Node created.- Parameters:
node- the node- Returns:
- the calendar
- Throws:
javax.jcr.RepositoryException- the repository exception
-
mimeType
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.RepositoryException Data.- Parameters:
content- the content- Returns:
- the property
- Throws:
javax.jcr.RepositoryException- the repository exception
-
generateId
Generate id.- Parameters:
workspace- the workspacepath- the path- Returns:
- the uuid
-
nodePath
Node path with the pattern workspace:path/to/node.- Parameters:
workspace- the workspacepath- the path- Returns:
- the string
-
nodePath
Node path with the pattern workspace:path/to/node.- Parameters:
config- the config- Returns:
- the string
-
syncUsers
Sync users.- Parameters:
configs- the configsusers- the users- Returns:
- true, if actually changed editor config user(s)
-
getActiveUsers
Gets the current users.- Parameters:
configs- the configs- Returns:
- the current users
-
downloadVersion
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
Updates config in the activeCache.- Parameters:
config- the config
-
addComment
-
createVersionOfDraft
protected void createVersionOfDraft(javax.jcr.Node node) throws javax.jcr.RepositoryException, OnlyofficeEditorException Creates 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.RepositoryException Checkout.- 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.RepositoryException Unlock 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.RepositoryException Lock 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
-
getUserLanguage
Gets platform language of user. In case of any errors return null.- Parameters:
userId- user Id- Returns:
- the platform language
-
platformUrl
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
Explorer uri.- Parameters:
schema- the schemahost- the hostport- the portecmsLink- the ecms link- Returns:
- the uri
-
explorerLink
ECMS explorer page relative URL (within the Platform).- Parameters:
jcrPath- the jcr path- Returns:
- the string
-
platformRestUrl
Platform REST URL.- Parameters:
platformUrl- the platform URL- Returns:
- the string builder
-
broadcastEvent
Broadcasts an event using the listenerService.- Parameters:
status- the statuseventType- the eventType
-
fireCreated
Fire created.- Parameters:
status- the status
-
fireGet
Fire get.- Parameters:
status- the status
-
fireJoined
Fire joined.- Parameters:
status- the status
-
fireLeaved
Fire leaved.- Parameters:
status- the status
-
fireSaved
Fire saved.- Parameters:
status- the status
-
fireError
Fire error.- Parameters:
status- the status
-
userIdentity
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
Get lower case copy of the given string.- Parameters:
str- the str- Returns:
- the string
-
editorURLPath
Editor URL path.- Parameters:
docId- the doc id- Returns:
- the string
- Throws:
EditorLinkNotFoundException
-
logError
Logs editor errors.- Parameters:
userId- the userIdpath- the pathdocId- the docIdkey- the keyreason- the reason
-
logError
-
setUserConvoState
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
Gets allowed hosts.- Parameters:
dsAllowedHost- the dsAllowedHost- Returns:
- allowed hosts
-
getDrive
Gets drive.- Parameters:
node- the node- Returns:
- the drive name
-
getDisplayPath
Gets display path.- Parameters:
node- the nodeuserId- the userId- Returns:
- the display path
-
getSymlink
Gets parent folder of the file based on file preferences- Parameters:
node- the nodeuserId- the userId- Returns:
- the Node
- Throws:
Exception- the exception
-
getUserId
Gets userId from node path.- Parameters:
path- the node path- Returns:
- the userId
-
nodeComment
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()
-