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 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
  • Field Details

    • 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:
    • CONFIG_DS_SCHEMA

      public static final String CONFIG_DS_SCHEMA
      The Constant CONFIG_DS_SCHEMA.
      See Also:
    • CONFIG_DS_ACCESS_ONLY

      public static final String CONFIG_DS_ACCESS_ONLY
      The Constant CONFIG_DS_ACCESS_ONLY.
      See Also:
    • CONFIG_DS_SECRET

      public static final String CONFIG_DS_SECRET
      The Constant CONFIG_DS_SECRET.
      See Also:
    • 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:
    • HTTP_PORT_DELIMITER

      protected static final char HTTP_PORT_DELIMITER
      The Constant HTTP_PORT_DELIMITER.
      See Also:
    • HIDDEN_FOLDER

      protected static final String HIDDEN_FOLDER
      The hidden folder
      See Also:
    • LAST_EDITED_DATE_FORMAT

      protected static final String LAST_EDITED_DATE_FORMAT
      The date format for Last Edited in editor bar
      See Also:
    • TYPE_TEXT

      protected static final String TYPE_TEXT
      The Constant TYPE_TEXT.
      See Also:
    • TYPE_SPREADSHEET

      protected static final String TYPE_SPREADSHEET
      The Constant TYPE_SPREADSHEET.
      See Also:
    • TYPE_PRESENTATION

      protected static final String TYPE_PRESENTATION
      The Constant TYPE_PRESENTATION.
      See Also:
    • DEFAULT_NAME

      protected static final String DEFAULT_NAME
      The Constant DEFAULT_NAME.
      See Also:
    • RELATION_PROP

      protected static final String RELATION_PROP
      The Constant RELATION_PROP.
      See Also:
    • 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:
    • LOCK_WAIT_TIMEOUT

      protected static final long LOCK_WAIT_TIMEOUT
      The Constant LOCK_WAIT_TIMEOUT.
      See Also:
    • 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.
    • config

      protected final Map<String,String> config
      The config.
    • 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).
    • fileTypes

      protected final Map<String,String> fileTypes
      The file types.
    • listeners

      protected final ConcurrentLinkedQueue<OnlyofficeEditorListener> listeners
      The listeners.
    • documentTypePlugin

      protected DocumentTypePlugin 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 - RepositoryService
      sessionProviders - SessionProviderService
      identityRegistry - the identity registry
      finder - the finder
      organization - the organization
      authenticator - the authenticator
      cacheService - the cache service
      documentService - the document service (ECMS)
      lockService - the lock service
      listenerService - the listener service
      trashService - the trashService
      spaceService - the spaceService
      activityManager - the activityManager
      manageDriveService - the manageDriveService
      hierarchyCreator - the hierarchyCreator
      params - the params
      Throws:
      org.exoplatform.container.configuration.ConfigurationException - the configuration exception
  • Method Details

    • addListener

      public void addListener(OnlyofficeEditorListener listener)
      Add listener to the service.
      Specified by:
      addListener in interface OnlyofficeEditorService
      Parameters:
      listener - the listener
    • removeListener

      public void removeListener(OnlyofficeEditorListener listener)
      Remove listener from the service.
      Specified by:
      removeListener in interface OnlyofficeEditorService
      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 then null will be returned. If user not valid then OnlyofficeEditorException will be thrown.
      Specified by:
      getEditor in interface OnlyofficeEditorService
      Parameters:
      userId - String
      workspace - String
      path - String
      Returns:
      Config or null
      Throws:
      OnlyofficeEditorException - the onlyoffice editor exception
      javax.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 then null will be returned. If user not valid then OnlyofficeEditorException will be thrown.
      Specified by:
      getEditorByKey in interface OnlyofficeEditorService
      Parameters:
      userId - the user id
      key - the key, see OnlyofficeEditorService.getEditor(String, String, String)
      Returns:
      the editor by key
      Throws:
      OnlyofficeEditorException - the onlyoffice editor exception
      javax.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 id
      docId - the node docId
      createCoEditing - if true and 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 exception
      javax.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:
      createEditor in interface OnlyofficeEditorService
      Parameters:
      schema - the schema
      host - the host
      port - the user post
      userId - String
      workspace - String
      docId - String a document reference in the workspace, see OnlyofficeEditorService.initDocument(String, String)
      Returns:
      Config instance in case of successful creation or null if local file type not supported.
      Throws:
      OnlyofficeEditorException - if editor exception happened
      javax.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:
      createViewer in interface OnlyofficeEditorService
      Parameters:
      schema - the schema
      host - the host
      port - the port
      userId - the user id
      workspace - the workspace
      docId - the doc id
      Returns:
      the config
      Throws:
      OnlyofficeEditorException - the onlyoffice editor exception
      javax.jcr.RepositoryException - the repository exception
    • getContent

      public DocumentContent getContent(String userId, String key) throws OnlyofficeEditorException, javax.jcr.RepositoryException
      Get file content.
      Specified by:
      getContent in interface OnlyofficeEditorService
      Parameters:
      userId - String
      key - String
      Returns:
      DocumentContent
      Throws:
      OnlyofficeEditorException - the onlyoffice editor exception
      javax.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:
      canDownloadBy in interface OnlyofficeEditorService
      Parameters:
      hostName - String
      Returns:
      true if client host with given name can download document content, false otherwise.
    • getState

      public ChangeState getState(String userId, String key) throws OnlyofficeEditorException
      Local state of editing document.
      Specified by:
      getState in interface OnlyofficeEditorService
      Parameters:
      userId - String
      key - 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:
      updateDocument in interface OnlyofficeEditorService
      Parameters:
      status - DocumentStatus
      Throws:
      OnlyofficeEditorException - if editor exception happened
      javax.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:
      initDocument in interface OnlyofficeEditorService
      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:
      initDocument in interface OnlyofficeEditorService
      Parameters:
      workspace - the workspace
      path - the path
      Returns:
      the string
      Throws:
      OnlyofficeEditorException - the onlyoffice editor exception
      javax.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:
      getEditorLink in interface OnlyofficeEditorService
      Parameters:
      node - the node
      scheme - the scheme
      host - the host
      port - the port
      Returns:
      the editor link
      Throws:
      javax.jcr.RepositoryException - the repository exception
      EditorLinkNotFoundException - 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, otherwise null will be returned.
      Specified by:
      getDocumentId in interface OnlyofficeEditorService
      Parameters:
      node - the node
      Returns:
      the document ID or null
      Throws:
      DocumentNotFoundException - the document not found exception
      javax.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:
      getDocumentById in interface OnlyofficeEditorService
      Parameters:
      workspace - the workspace, can be null, then a default one will be used
      uuid - the id of a document
      Returns:
      the document or null if nothing found
      Throws:
      javax.jcr.RepositoryException - the repository exception
      DocumentNotFoundException - 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:
      getVersions in interface OnlyofficeEditorService
      Parameters:
      workspace - the workspace
      docId - the document id
      itemParPage - the versions par page
      pageNum - 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:
      getDocument in interface OnlyofficeEditorService
      Parameters:
      workspace - the workspace, can be null, then a default one will be used
      path - the path of a document
      Returns:
      the document or null if nothing found
      Throws:
      javax.jcr.RepositoryException - the repository exception
      BadParameterException - the bad parameter exeption
    • start

      public void start()
      On-start initializer.
      Specified by:
      start in interface org.picocontainer.Startable
    • stop

      public void stop()
      On-stop finalizer.
      Specified by:
      stop in interface org.picocontainer.Startable
    • addTypePlugin

      public void addTypePlugin(org.exoplatform.container.component.ComponentPlugin plugin)
      Adds DocumentTypePlugin to the service to check mimetypes of documents.
      Specified by:
      addTypePlugin in interface OnlyofficeEditorService
      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:
      canEditDocument in interface OnlyofficeEditorService
      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:
      isDocumentMimeSupported in interface OnlyofficeEditorService
      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:
      downloadVersion in interface OnlyofficeEditorService
      Parameters:
      userId - the userId
      key - the key
      coEdited - the coEdited
      forcesaved - the forceSaved
      comment - the comment
      contentUrl - the contentUrl
    • getLastModifier

      public Config.Editor.User getLastModifier(String key)
      Gets the last modifier userId.
      Specified by:
      getLastModifier in interface OnlyofficeEditorService
      Parameters:
      key - the key
      Returns:
      the editor user
    • setLastModifier

      public void setLastModifier(String key, String userId)
      Sets the last modifier userId.
      Specified by:
      setLastModifier in interface OnlyofficeEditorService
      Parameters:
      key - the key
      userId - the userId
    • getUser

      public Config.Editor.User getUser(String key, String userId)
      Gets a user.
      Specified by:
      getUser in interface OnlyofficeEditorService
      Parameters:
      key - the key
      userId - 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:
      forceSave in interface OnlyofficeEditorService
      Parameters:
      userId - the userId
      key - the key
      download - the download
      coEdit - the coedit
      forcesaved - the forcesaved
      comment - the comment
    • validateToken

      public boolean validateToken(String token, String key)
      Description copied from interface: OnlyofficeEditorService
      Validates the JWT token received from the document server.
      Specified by:
      validateToken in interface OnlyofficeEditorService
      Parameters:
      token - the token
      key - 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: OnlyofficeEditorService
      Updates title of a document.
      Specified by:
      updateTitle in interface OnlyofficeEditorService
      Parameters:
      workspace - the workspace
      docId - the docId
      newTitle - the title
      userId - the userId
    • getUser

      public org.exoplatform.services.organization.User getUser(String username) throws OnlyofficeEditorException
      Gets the user.
      Specified by:
      getUser in interface OnlyofficeEditorService
      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:
      addFilePreferences in interface OnlyofficeEditorService
      Parameters:
      node - the node
      userId - the userId
      path - the path
      Throws:
      javax.jcr.RepositoryException - the repositoryException
    • getDocumentServiceSecret

      public String getDocumentServiceSecret()
      Specified by:
      getDocumentServiceSecret in interface OnlyofficeEditorService
    • closeWithoutModification

      public void closeWithoutModification(String userId, String key)
      Specified by:
      closeWithoutModification in interface OnlyofficeEditorService
    • isDocumentCoedited

      public boolean isDocumentCoedited(String key)
      Description copied from interface: OnlyofficeEditorService
      Checks if the document is opened for edition by multiple users
      Specified by:
      isDocumentCoedited in interface OnlyofficeEditorService
      Parameters:
      key - Document key
      Returns:
      Boolean true if the document is opened for edition by multiple users
    • saveLink

      protected void saveLink(String userId, String key, String url)
      Save link.
      Parameters:
      userId - the userId
      key - the key
      url - 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.RepositoryException
      Node 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.RepositoryException
      Data.
      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 workspace
      path - 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 workspace
      path - 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 configs
      users - 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 OnlyofficeEditorException
      javax.jcr.RepositoryException - the RepositoryException
    • updateCache

      protected void updateCache(Config config)
      Updates config in the activeCache.
      Parameters:
      config - the config
    • addComment

      protected String addComment(String activityId, String commentText, String userId)
    • 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 exception
      OnlyofficeEditorException - the onlyoffice exception
    • node

      protected javax.jcr.Node node(String workspace, String path) throws BadParameterException, javax.jcr.RepositoryException
      Node.
      Parameters:
      workspace - the workspace
      path - the path
      Returns:
      the node
      Throws:
      BadParameterException - the bad parameter exception
      javax.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 workspace
      path - the path
      Returns:
      the node
      Throws:
      BadParameterException - the bad parameter exception
      javax.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 workspace
      uuid - 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 node
      lock - the lock
      Throws:
      OnlyofficeEditorException - the onlyoffice editor exception
      javax.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 throw OnlyofficeEditorException. If node isn't mix:lockable it will be added first and node saved.
      Parameters:
      node - Node
      config - Config
      Returns:
      Lock acquired by current user.
      Throws:
      OnlyofficeEditorException - the onlyoffice editor exception
      javax.jcr.RepositoryException - the repository exception
    • validateUser

      protected void validateUser(String userId, Config config) throws BadParameterException, OnlyofficeEditorException
      Validate user.
      Parameters:
      userId - the user id
      config - the config
      Throws:
      BadParameterException - if user not found
      OnlyofficeEditorException - if error searching user in organization service
    • getUserLanguage

      public static String getUserLanguage(String userId)
      Gets platform language of user. In case of any errors return null.
      Parameters:
      userId - user Id
      Returns:
      the platform language
    • platformUrl

      protected StringBuilder platformUrl(String schema, String host, int port)
      Platform url.
      Parameters:
      schema - the schema
      host - the host
      port - 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 schema
      host - the host
      port - the port
      ecmsURL - the ECMS URL
      Returns:
      the string builder
    • explorerUri

      protected URI explorerUri(String schema, String host, int port, String ecmsLink)
      Explorer uri.
      Parameters:
      schema - the schema
      host - the host
      port - the port
      ecmsLink - 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 status
      eventType - 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 userId
      path - the path
      docId - the docId
      key - the key
      reason - the reason
    • logError

      protected void logError(String userId, String path, String docId, String key, String reason, Throwable e)
    • 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 contextState
      contextProvider - 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 dsSchema
      dsHost - 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 node
      userId - the userId
      Returns:
      the display path
    • getSymlink

      protected javax.jcr.Node getSymlink(javax.jcr.Node node, String userId) throws Exception
      Gets parent folder of the file based on file preferences
      Parameters:
      node - the node
      userId - 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 valueFormatException
      javax.jcr.PathNotFoundException - the pathNotFoundException
      javax.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 valueFormatException
      javax.jcr.PathNotFoundException - the pathNotFoundException
      javax.jcr.RepositoryException - the repositoryException
      OnlyofficeEditorException - the onlyofficeEditorException
    • isSuspendDownloadDocument

      protected boolean isSuspendDownloadDocument()