Class OnlyofficeEditorServiceImpl
- All Implemented Interfaces:
OnlyofficeEditorService, org.picocontainer.Startable
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.protected static final classA short-lived, single-use asset staged in-memory to be fetched by the Document Server during a Document Builder run. -
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 static final intMaximum number of expired closed configs one editor opening purges, oldest first, so that a large set of configs expiring together is purged over several openings rather than in one user request.protected final StringThe document command service url.The config.static final StringRetention for closed editor configs kept to handle late OnlyOffice callbacks.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 error recorded on a config closed because its document's content was written outside its editor session: a late open callback of its key does not reactivate it.protected final Stringprotected static final longDefault closed config retention: two hours.protected static final StringThe Constant DEFAULT_NAME.protected static final longTime-to-live of a short-lived, single-use asset staged in-memory to be fetched by the Document Server during a Document Builder run (script, the existing file being modified, images).static final StringThe URL the Document Server reaches this node at, to fetch the assets this node staged for a Document Builder run.protected final Map<String, OnlyofficeEditorServiceImpl.StagedAsset> In-memory registry of short-lived, single-use assets served to the Document Server for Document Builder runs, keyed by an unguessable random key.protected final StringThe ONLYOFFICE Document Builder (docbuilder) HTTP API url.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 OnlyofficeEditorService
EDIT_MODE, EDITOR_CLOSED_EVENT, EDITOR_ERROR_EVENT, EDITOR_OPENED_EVENT, EDITOR_SAVED_EVENT, EDITOR_VERSION_EVENT, FILLFORM_MODE, 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 intactiveConfigCount(Map<String, Config> configs) 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: the rename moves the document within its folder and sets its name properties with the user's own session, so the user needs to add nodes to and set properties on the folder, and to remove and set properties on the document.protected booleancheckout(javax.jcr.Node node) Checkout.protected voidOpportunistic cleanup of old closed configsprotected voidcloseConfigs(String key, Map<String, Config> configs) Mark every config for the key closed and retain it for late callbacks.protected longGrace period for retaining closed configs so late OnlyOffice callbacks can still be resolved.protected voidcloseSessionsAfterFailedSupersededSave(Config config, String userId) Closes the sessions of a document as a content write does, when the save of a session a content write superseded failed after its content was saved and before the head was written back: whichever content the head holds, the sessions reload it.intCloses the editor configs a document conversion (a thumbnail, an export) left active and that no editor ever opened, so that no co-editor joins their keys.voidcontentUpdatedOutsideEditor(String docId, String userId) Closes the active editor configs of a document whose content was written outside the editor session that holds them (an upload of a new version from Documents, another editor session's save), so that the next opening gets a new document key and the Document Server fetches the written content instead of serving the content it holds for the old key.byte[]convertNodeContent(javax.jcr.Node node, String format, String originalFileType, String userId) Convert the provided node to requested formatbyte[]convertNodeContentToPdf(javax.jcr.Node node, String userId) Convert the provided node to PDF fileprotected PathcopyContent(javax.jcr.Node content) Copies a document's content to a temporary file.protected ConfigcreateConfigForConversion(String userId, javax.jcr.Node node) createEditor(String schema, String host, int port, String userId, String workspace, String docId, String mode) 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 voidFire content updated outside the editor.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.protected booleanhasActiveConfigForDifferentKey(String docId, String key) 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 mapprotected booleanisClosedByOutsideWrite(Config config) Tells whether a config was closed because the document's content was written outside its editor session: no callback of its key reopens it.protected booleanbooleanisDocumentCoedited(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 booleanisSupersededKey(Config config) Tells whether a content write outside the editor superseded a config's session: any row of its key carries the marker, its user's included or a co-editor's, closed before or by the write.protected booleanprotected voidkeepActiveSessions(Config config) Leaves open, during a superseded session's save, the sessions of the document active when it starts: they hold the head.protected 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 voidObserves the content writes of the documents of the default workspace, once they are saved, to close the editor sessions they leave stale (contentUpdatedOutsideEditor(String, String)).protected voidonContentWrites(String workspace, javax.jcr.observation.EventIterator events) Closes the editor sessions a saved content write leaves stale.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 ConfigresolveStatusConfig(DocumentStatus status, Map<String, Config> configs) Resolve the config to use for a callback.protected voidrestoreConvoState(org.exoplatform.services.security.ConversationState contextState, org.exoplatform.services.jcr.ext.common.SessionProvider contextProvider) Restores the conversation state.byte[]runDocBuilderScript(String scriptBody, Map<String, byte[]> assets, String outputFormat, String outputName, String userId) Runs an ONLYOFFICE Document Server Document Builder script and returns the produced native office file (docx / xlsx / pptx / pdf) bytes.protected String[]safeUsers(DocumentStatus status) protected voidsaveContent(javax.jcr.Node node, javax.jcr.Node content, InputStream data, String userId) Saves a document's new content, or its same content to call the listeners when there is none.protected voidSave link.voidsaveNewVersion(javax.jcr.Node node, byte[] content, String userId) Writes new content onto an existing document node (as the current user) and creates a new version, so a Document Builder MODIFY result is saved as a new version of the source file.protected voidsetEditorError(Config config, String error) Records an editor error on a config, unless a content write outside the editor closed it: its error is the marker that keeps its key from being reopened (isClosedByOutsideWrite(Config)).voidsetLastModifier(String key, String userId) Sets the last modifier userId.protected booleansetUserConvoState(String userId) Sets ConversationState by userId.protected StringstageDocBuilderAsset(byte[] data, String mimeType, long expiresAt) Stages a byte asset in the in-memory registry under a fresh unguessable key and returns that key.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.protected voidwriteBackHead(javax.jcr.Node node, javax.jcr.Node content, Path head, String headModifier, Calendar headModified, String userId) Writes a document's former head back as a new version, after a save, final or forced, of a session that a content write superseded went to the history.
-
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
-
CONFIG_DS_SCHEMA
-
CONFIG_DS_ACCESS_ONLY
-
CONFIG_DS_SECRET
-
CONFIG_CLOSED_CONFIG_RETENTION_MS
Retention for closed editor configs kept to handle late OnlyOffice callbacks.- See Also:
-
DEFAULT_CLOSED_CONFIG_RETENTION_MS
protected static final long DEFAULT_CLOSED_CONFIG_RETENTION_MSDefault closed config retention: two hours.- See Also:
-
CLOSED_CONFIGS_PURGE_BATCH
protected static final int CLOSED_CONFIGS_PURGE_BATCHMaximum number of expired closed configs one editor opening purges, oldest first, so that a large set of configs expiring together is purged over several openings rather than in one user request.- See Also:
-
CONTENT_UPDATED_OUTSIDE_EDITOR
The error recorded on a config closed because its document's content was written outside its editor session: a late open callback of its key does not reactivate it.- 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
-
LAST_EDITED_DATE_FORMAT
The date format for Last Edited in editor bar- See Also:
-
TYPE_TEXT
-
TYPE_SPREADSHEET
-
TYPE_PRESENTATION
-
DEFAULT_NAME
-
RELATION_PROP
-
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,Config>> viewerCacheCache of Viewing documents. -
activeLock
Lock for updating Editing documents cache. -
config
-
uploadUrl
The upload url. -
documentserverHostName
The documentserver host name. -
documentserverUrl
The documentserver url. -
commandServiceUrl
The document command service url. -
convertUrl
-
docbuilderUrl
The ONLYOFFICE Document Builder (docbuilder) HTTP API url. -
DOCBUILDER_ASSET_TTL_MS
protected static final long DOCBUILDER_ASSET_TTL_MSTime-to-live of a short-lived, single-use asset staged in-memory to be fetched by the Document Server during a Document Builder run (script, the existing file being modified, images).- See Also:
-
DOCBUILDER_NODE_URL_PROPERTY
The URL the Document Server reaches this node at, to fetch the assets this node staged for a Document Builder run. They stay in this node's memory, and the fetch carries no user session a balancer could route by: in a cluster, each node sets its own URL. Defaults toexo.base.url.- See Also:
-
docBuilderAssets
In-memory registry of short-lived, single-use assets served to the Document Server for Document Builder runs, keyed by an unguessable random key. Each entry is removed on first fetch (single-use) or when it expires, and is served through the SAME host-restricted,validateToken-guarded/onlyoffice/editor/content/{userId}/{key}endpoint as the editor content (no new / unauthenticated file endpoint is introduced). -
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
-
fileTypes
-
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 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 exception
-
createEditor
public Config createEditor(String schema, String host, int port, String userId, String workspace, String docId, String mode) 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.
-
closedConfigRetentionMs
protected long closedConfigRetentionMs()Grace period for retaining closed configs so late OnlyOffice callbacks can still be resolved. -
cleanupExpiredClosedConfigs
protected void cleanupExpiredClosedConfigs()Opportunistic cleanup of old closed configs -
closeUnopenedConversionConfigs
public int closeUnopenedConversionConfigs()Closes the editor configs a document conversion (a thumbnail, an export) left active and that no editor ever opened, so that no co-editor joins their keys. They stay resolvable by key until the closed configs retention purges them. It clears the calling thread's JPA persistence context: call it outside any scope that holds managed entities.- Specified by:
closeUnopenedConversionConfigsin interfaceOnlyofficeEditorService- Returns:
- the number of closed configs
-
resolveStatusConfig
Resolve the config to use for a callback. OnlyOffice can send callbacks with userdata.userId, users[0], or the callback URL user. -
safeUsers
-
activeConfigCount
-
closeConfigs
-
contentUpdatedOutsideEditor
Closes the active editor configs of a document whose content was written outside the editor session that holds them (an upload of a new version from Documents, another editor session's save), so that the next opening gets a new document key and the Document Server fetches the written content instead of serving the content it holds for the old key. The configs are closed, never deleted: the sessions still open keep their callbacks resolvable until the closed configs retention purges them, and their editors are told the content changed. A write by an editor session closes nothing of its own key:DocumentStatus.getKey()of the notification is that key, null for a write outside any editor.- Specified by:
contentUpdatedOutsideEditorin interfaceOnlyofficeEditorService- Parameters:
docId- the document node's UUIDuserId- the user who wrote the content, may be null
-
isClosedByOutsideWrite
Tells whether a config was closed because the document's content was written outside its editor session: no callback of its key reopens it.- Parameters:
config- the config- Returns:
- true when its key is superseded by such a write
-
setEditorError
Records an editor error on a config, unless a content write outside the editor closed it: its error is the marker that keeps its key from being reopened (isClosedByOutsideWrite(Config)).- Parameters:
config- the configerror- the error
-
observeContentWrites
protected void observeContentWrites()Observes the content writes of the documents of the default workspace, once they are saved, to close the editor sessions they leave stale (contentUpdatedOutsideEditor(String, String)). A write sets the content (PROPERTY_CHANGED); a version restore re-creates it (PROPERTY_ADDED), as does the creation of a document, which has no editor session to close. The listener is called on the saving thread, after the storage commit: a write bydownload(DocumentStatus)is told apart by its key. -
onContentWrites
Closes the editor sessions a saved content write leaves stale.- Parameters:
workspace- the workspace of the eventsevents- the property changes saved
-
hasActiveConfigForDifferentKey
-
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
-
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
-
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
-
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
-
nodePath
-
nodePath
-
syncUsers
-
getActiveUsers
-
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
-
isSupersededKey
Tells whether a content write outside the editor superseded a config's session: any row of its key carries the marker, its user's included or a co-editor's, closed before or by the write.- Parameters:
config- the config a save resolves to- Returns:
- true when its key is superseded
-
keepActiveSessions
Leaves open, during a superseded session's save, the sessions of the document active when it starts: they hold the head.- Parameters:
config- the superseded session's config
-
closeSessionsAfterFailedSupersededSave
Closes the sessions of a document as a content write does, when the save of a session a content write superseded failed after its content was saved and before the head was written back: whichever content the head holds, the sessions reload it.- Parameters:
config- the superseded session's configuserId- the user the save runs as
-
saveContent
protected void saveContent(javax.jcr.Node node, javax.jcr.Node content, InputStream data, String userId) throws javax.jcr.RepositoryException Saves a document's new content, or its same content to call the listeners when there is none.- Parameters:
node- the document nodecontent- the document's jcr:content nodedata- the new content, or nulluserId- the user the save runs as- Throws:
javax.jcr.RepositoryException- if the content cannot be saved
-
copyContent
Copies a document's content to a temporary file.- Parameters:
content- the document's jcr:content node- Returns:
- the copy's path
- Throws:
javax.jcr.RepositoryException- if the content cannot be read
-
writeBackHead
protected void writeBackHead(javax.jcr.Node node, javax.jcr.Node content, Path head, String headModifier, Calendar headModified, String userId) throws javax.jcr.RepositoryException Writes a document's former head back as a new version, after a save, final or forced, of a session that a content write superseded went to the history.- Parameters:
node- the document nodecontent- the document's jcr:content nodehead- the former head's copyheadModifier- the former head's last modifier, or nullheadModified- the former head's last modified date, or nulluserId- the user the save runs as- Throws:
javax.jcr.RepositoryException- if the content cannot be written
-
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
-
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
-
explorerLink
-
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
-
fireGet
-
fireJoined
-
fireLeaved
-
fireSaved
-
fireContentUpdatedOutsideEditor
Fire content updated outside the editor.- Parameters:
status- the status
-
fireError
-
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
-
editorURLPath
Editor URL path.- Parameters:
docId- the doc id- Returns:
- the string
- Throws:
EditorLinkNotFoundException
-
logError
-
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
-
getDrive
Gets drive.- Parameters:
node- the node- Returns:
- the drive name
-
getDisplayPath
-
getSymlink
-
getUserId
-
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: the rename moves the document within its folder and sets its name properties with the user's own session, so the user needs to add nodes to and set properties on the folder, and to remove and set properties on 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() -
convertNodeContentToPdf
public byte[] convertNodeContentToPdf(javax.jcr.Node node, String userId) throws javax.jcr.RepositoryException Description copied from interface:OnlyofficeEditorServiceConvert the provided node to PDF file- Specified by:
convertNodeContentToPdfin interfaceOnlyofficeEditorService- Parameters:
node- Document nodeuserId- user name- Returns:
- binary content of the PDF
- Throws:
javax.jcr.RepositoryException
-
convertNodeContent
public byte[] convertNodeContent(javax.jcr.Node node, String format, String originalFileType, String userId) Description copied from interface:OnlyofficeEditorServiceConvert the provided node to requested format- Specified by:
convertNodeContentin interfaceOnlyofficeEditorService- Parameters:
node- Document nodeformat- output content formatoriginalFileType- input content formatuserId- user name- Returns:
- binary content of the PDF
-
runDocBuilderScript
public byte[] runDocBuilderScript(String scriptBody, Map<String, byte[]> assets, String outputFormat, String outputName, String userId) Description copied from interface:OnlyofficeEditorServiceRuns an ONLYOFFICE Document Server Document Builder script and returns the produced native office file (docx / xlsx / pptx / pdf) bytes. This is the single, shared, security-critical primitive used by the office MCP tools to both CREATE (builder.CreateFile) and MODIFY (builder.OpenFile) documents.Trust model. The script and every referenced asset (the existing file being modified, images) are staged in an in-memory, single-use registry and served to the (remote) Document Server through the SAME host-restricted (
canDownloadBy) and JWT-guarded (validateToken)/onlyoffice/editor/content/{userId}/{key}endpoint used for editing/conversion, at URLs built fromexo.base.url(never a request host). Keys are unguessable, entries are removed on first fetch and expire after 120000L ms; there is no path traversal (keys are opaque) and no new / unauthenticated file endpoint. The Document Server signs its ownAuthorizationheader when it fetches the script URL; in-script asset URLs (which the server fetches without a header) carry a signedtokenquery parameter thatvalidateTokenaccepts.The script must reference each asset by an
@@ASSET:<name>@@placeholder (matching a key ofassets); every placeholder is replaced with the asset's short-lived, token-guarded URL before the script is run.- Specified by:
runDocBuilderScriptin interfaceOnlyofficeEditorService- Parameters:
scriptBody- the Document Builder script, referencing assets by@@ASSET:<name>@@placeholdersassets- the assets referenced by the script (name to bytes); may benullor empty for a pure CREATE scriptoutputFormat- the produced format, e.g.docx,xlsx,pptx,pdf(used for error messages)outputName- thebuilder.SaveFileoutput name to download from the response; the first produced file is used whennulluserId- the acting user name (used only to shape the content URL)- Returns:
- the produced document bytes (never
null)
-
isCluster
protected boolean isCluster()- Returns:
- whether the platform runs as a cluster
-
stageDocBuilderAsset
-
saveNewVersion
public void saveNewVersion(javax.jcr.Node node, byte[] content, String userId) throws javax.jcr.RepositoryException Description copied from interface:OnlyofficeEditorServiceWrites new content onto an existing document node (as the current user) and creates a new version, so a Document Builder MODIFY result is saved as a new version of the source file.- Specified by:
saveNewVersionin interfaceOnlyofficeEditorService- Parameters:
node- the existing document node (resolved in the user's session)content- the new file bytesuserId- the acting user name, stored as last modifier- Throws:
javax.jcr.RepositoryException- on a storage error
-
createConfigForConversion
protected Config createConfigForConversion(String userId, javax.jcr.Node node) throws OnlyofficeEditorException, javax.jcr.RepositoryException - Throws:
OnlyofficeEditorExceptionjavax.jcr.RepositoryException
-