Class DocumentMcpTool
- All Implemented Interfaces:
io.meeds.mcp.server.plugin.McpToolPlugin
DocumentFileService. These tools only READ or update document
metadata / content; they carry no coupling to the AI service layer (the
AI-powered document experiences remain in the enterprise edition).-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final StringPath of the anonymous public-download portal page (global pagedownload-document); the document node id is appended as an extra path segment, mirroring how the Documents front-end builds the shareable link ({origin}/{containerName}/download-document/{nodeId}).Fields inherited from interface io.meeds.mcp.server.plugin.McpToolPlugin
DEFAULT_LIMIT, DEFAULT_OFFSET -
Constructor Summary
ConstructorsConstructorDescriptionDocumentMcpTool(org.exoplatform.documents.service.DocumentFileService documentFileService, org.exoplatform.services.attachments.service.AttachmentService attachmentService, org.exoplatform.social.attachment.AttachmentService socialAttachmentService, org.exoplatform.commons.file.services.FileService fileService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, io.meeds.social.translation.service.TranslationService translationService, org.exoplatform.social.core.profileproperty.ProfilePropertyService profilePropertyService, org.exoplatform.portal.config.UserACL userAcl, org.exoplatform.portal.config.UserPortalConfigService portalConfigService, org.exoplatform.upload.UploadService uploadService, org.exoplatform.documents.service.PublicDocumentAccessService publicDocumentAccessService, org.exoplatform.social.metadata.favorite.FavoriteService favoriteService) -
Method Summary
Modifier and TypeMethodDescriptionaddDocumentVersion(String documentId, String content, String base64, String url, String attachmentObjectType, String attachmentObjectId, String versionSummary, String uploadId) Uploads updated content onto an EXISTING file, creating a NEW version of it (the previous content stays retrievable via list_document_versions / restore_document_version).appendDocumentUploadChunk(String uploadId, Integer index, String base64) Adds the next piece of a file sent in pieces; the piece that completes the file files it, and returns the document.voidattachDocumentToContent(String documentId, String contentType, long contentId) Links an existing document to another content entity (an activity, a note, …) as an attachment, acting as the current user.copyDocument(String documentId, String destinationFolderId) Copies a file into another folder; in a call limited to a space, the destination folder must be in that space.createDocument(String parentFolderId, String name, String content) Creates a text-based document (markdown, HTML, plain text, CSV, JSON…) from a chat-authoredcontentstring.createDocumentFromTemplate(String parentFolderId, String name, String documentType) Creates a NEW EMPTY office document (Word/Excel/PowerPoint, or ODF) from the platform's blank template, by delegating to the ecmsDocumentService.voidcreateDocumentShortcut(String documentId, String destinationFolderId, String conflictAction) Creates a shortcut (symlink) to a document inside another folder, so the same file appears in a second location without being copied.createFolder(String parentFolderId, String name) Creates a folder under a parent folder, or a chain of nested folders when the name is a path: each segment ofFinances/Factures/Entrantesbut the last reuses the child folder of that name when there is one and is created otherwise, and the last one is created.createPublicLink(String documentId, String password, Long expirationDate) Creates (or refreshes) an anonymous public share link for a document so it can be downloaded without signing in, optionally protected by a password and/or an expiration date.voiddeleteDocument(String documentId) duplicateDocument(String documentId, String prefix) Duplicates a file or a folder in its own folder, with an optional prefix and a " (n)" counter, and returns the duplicate.voidfavoriteDocument(String documentId) Adds a file to the current user's favorites.getDocumentById(String documentId) Returns a document's metadata, with the user's rights on it.getDocumentContentById(String documentId) Returns the text of a document the current user can access: from the search index when it holds it, else extracted from the file itself.getDocumentOutline(String documentId) Lists a document's headings: a Word document's headings, a PDF's bookmarks, a presentation's slide titles, a spreadsheet's sheets, each with where its section starts and ends in the textread_document_textreads.getDocumentPermissions(String documentId) Tells what the current user may do on a folder or a file: the edit right as the repository checks it for the user; the delete right as the storage computes it (the document's permission entries, and any document of the user's own drive), plus the owner's, whom the repository grants every right although that computation leaves the owner out.getDocumentsByFolderId(String folderId, Boolean filesOnly, Boolean foldersOnly, Integer offset, Integer limit) Lists a page of a folder's children, folders first.getDocumentsSize(Long ownerId) getDocumentTranscriptionById(String documentId, Boolean timestamps) The transcript of an audio or video file, read with the user's rights.getFolderBreadcrumb(String folderId) getFolderTree(String folderId, Boolean withChildren) getRootFolderBySpace(Long spaceId, String spaceName) Reads the root folder of a space's documents, the space given by its id or by its name, exactly one of them.protected LonglistDocumentVersions(String documentId) listFolderChildren(String folderId, Integer offset, Integer limit, String updatedSince) Lists the direct children of a folder, folders first, or with a date only the children changed since then, the most recent first.voidmoveDocument(String documentId, String destinationFolderId, String conflictAction) Moves a file or a folder into another folder; in a call limited to a space, the destination folder must be in that space.readDocumentText(String documentId, Long offset, Integer maxChars, Integer section) Reads a part of a document's text: from an offset, or the section of one heading ofget_document_outline, at most a given number of characters, and says where the next part starts.voidrenameDocument(String documentId, String newName) Renames a file or a folder.restoreDocumentVersion(String versionId) searchDocuments(String query, Long spaceId, String spaceName, String parentFolderId, Integer offset, Integer limit, Boolean isFavorites, String updatedSince) Searches the documents the user can read, optionally in one space, given by its id or by its name (at most one of them), or under one folder.voidsetDocumentVisibility(String documentId, Boolean hidden) Hides a file or a folder from the listings, or shows it again; hiding a folder may also hide some of its direct children.voidShares a document with another user or with a space: the recipient is GRANTED read access to the file and gets it in their "Shared" folder.startDocumentUpload(String parentFolderId, String name, Long size, String onConflict) Starts sending a file in pieces, for a file too large to be sent whole in one tool call: checks the folder, the user's right to add a document to it, the file's size and that its name can take the conflict action, before any piece is sent.voidundoDeleteDocument(String documentId) Restores a document that was deleted withdelete_document: since that tool trashes immediately (delay 0), the delayed-delete cancel path is a no-op, so the node is resolved from trash (it keeps its id/uuid after the move) and restored to its original location.voidunfavoriteDocument(String documentId) Removes a file from the current user's favorites.voidupdateDocumentDescription(String documentId, String htmlDescription) updateVersionSummary(String documentId, String versionId, String summary) uploadDocument(String parentFolderId, String name, String base64, String url, String attachmentObjectType, String attachmentObjectId, String onConflict, String uploadId) Uploads a real / binary document (PDF, image, office file…) from exactly one of four sources: a file/image the user attached in the chat conversation (resolved server-side as the current user viaattachment_object_type/attachment_object_id), a file the user sent through an upload link (upload_id, filed from its staged file, never read into memory), a base64 payload, or an http(s) URL (fetched server-side behind an SSRF guard).Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.meeds.mcp.server.plugin.McpToolPlugin
getCurrentUserAclIdentity, getCurrentUserLocale, getCurrentUserLocale, getCurrentUserName, getLocale
-
Field Details
-
FOLDER_URL_FORMAT
- See Also:
-
FILE_URL_FORMAT
- See Also:
-
PUBLIC_LINK_URL_FORMAT
Path of the anonymous public-download portal page (global pagedownload-document); the document node id is appended as an extra path segment, mirroring how the Documents front-end builds the shareable link ({origin}/{containerName}/download-document/{nodeId}).- See Also:
-
-
Constructor Details
-
DocumentMcpTool
public DocumentMcpTool(org.exoplatform.documents.service.DocumentFileService documentFileService, org.exoplatform.services.attachments.service.AttachmentService attachmentService, org.exoplatform.social.attachment.AttachmentService socialAttachmentService, org.exoplatform.commons.file.services.FileService fileService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, io.meeds.social.translation.service.TranslationService translationService, org.exoplatform.social.core.profileproperty.ProfilePropertyService profilePropertyService, org.exoplatform.portal.config.UserACL userAcl, org.exoplatform.portal.config.UserPortalConfigService portalConfigService, org.exoplatform.upload.UploadService uploadService, org.exoplatform.documents.service.PublicDocumentAccessService publicDocumentAccessService, org.exoplatform.social.metadata.favorite.FavoriteService favoriteService)
-
-
Method Details
-
getScopeSpaceId
- Returns:
- the space the current call is limited to, null when it isn't
- Throws:
IllegalStateException- when the call's identity can't be read
-
getRootFolderBySpace
public DocumentFolderModel getRootFolderBySpace(Long spaceId, String spaceName) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Reads the root folder of a space's documents, the space given by its id or by its name, exactly one of them. A name is looked up among the spaces the user is a member of, and nothing is guessed.- Parameters:
spaceId- the space's id, null when the space is given by its namespaceName- the space's name, blank when the space is given by its id- Returns:
- the space's root folder
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the space doesn't exist, or no space of the user carries the name: the message says how to find itIllegalAccessException- when the user can't view the space, or a call limited to a space names another oneIllegalArgumentException- when both or neither are given, or several of the user's spaces carry the name
-
attachDocumentToContent
public void attachDocumentToContent(String documentId, String contentType, long contentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Links an existing document to another content entity (an activity, a note, …) as an attachment, acting as the current user. Validates the document id and the user's read access on it first — matching every sibling tool method — so a blank or inaccessible id fails cleanly instead of reaching the attachment service with an unchecked reference.- Parameters:
documentId- the id of the document to attachcontentType- the target content type the document is attached tocontentId- the target content id the document is attached to- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
updateDocumentDescription
public void updateDocumentDescription(String documentId, String htmlDescription) throws IllegalAccessException, Exception - Throws:
IllegalAccessExceptionException
-
getDocumentsByFolderId
public List<DocumentModel> getDocumentsByFolderId(String folderId, Boolean filesOnly, Boolean foldersOnly, Integer offset, Integer limit) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Lists a page of a folder's children, folders first. A negative limit lists nothing, as list_folder_children does: the storage would read every child.- Parameters:
folderId- the folderfilesOnly- whether only the files are keptfoldersOnly- whether only the folders are keptoffset- the first child listed, 0 by defaultlimit- the most children listed, the default page size when null or 0, at most 100- Returns:
- the folder's children on that page
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the folder doesn't existIllegalAccessException- when the user can't read the folder
-
getRootFolderForUser
-
getDocumentById
public DocumentModel getDocumentById(String documentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Returns a document's metadata, with the user's rights on it. A shortcut resolves to its target, whose metadata and edit right are returned; its delete right is left out, deleting the shortcut removing only the shortcut.- Parameters:
documentId- the document id- Returns:
- the document
- Throws:
IllegalAccessException- when the user can't read itorg.exoplatform.commons.exception.ObjectNotFoundException- when it doesn't exist
-
getDocumentContentById
public String getDocumentContentById(String documentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Returns the text of a document the current user can access: from the search index when it holds it, else extracted from the file itself. When neither gives any text, the actual reason is raised rather than an empty answer, so the agent can tell the user why instead of guessing from the file name.The reason never claims the file is still being indexed: the search index service exposes no way to know whether an indexing operation is pending for a file, and the file itself was just read without success. Only a busy extractor, a fact known for certain, is worded as worth another attempt.
A file too large to be read in one go is read as
read_document_textreads it, up to the largest file a user can attach: its first part is returned, with the length of its text and the offset to read on.- Parameters:
documentId- the document identifier- Returns:
- the text of the document
- Throws:
IllegalAccessException- when the user cannot access the documentorg.exoplatform.commons.exception.ObjectNotFoundException- when the document does not existIllegalStateException- when the document has no readable text, with the reason
-
readDocumentText
public DocumentTextPartModel readDocumentText(String documentId, Long offset, Integer maxChars, Integer section) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Reads a part of a document's text: from an offset, or the section of one heading ofget_document_outline, at most a given number of characters, and says where the next part starts. A document too large to be read in one go is read this way, part by part.- Parameters:
documentId- the document idoffset- the first character, from 0, in the whole text, as next_offset gives it; within a section, brought into it: the section's start when before itmaxChars- the most characters returnedsection- the index of the heading whose section is read, null to read by offset- Returns:
- the part read
- Throws:
IllegalAccessException- when the user cannot access the documentorg.exoplatform.commons.exception.ObjectNotFoundException- when the document does not existIllegalStateException- when the document has no readable text, with the reasonIllegalArgumentException- when the section isn't one of the outline
-
getDocumentOutline
public DocumentOutlineModel getDocumentOutline(String documentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Lists a document's headings: a Word document's headings, a PDF's bookmarks, a presentation's slide titles, a spreadsheet's sheets, each with where its section starts and ends in the textread_document_textreads.- Parameters:
documentId- the document id- Returns:
- the outline, empty when the document has no heading
- Throws:
IllegalAccessException- when the user cannot access the documentorg.exoplatform.commons.exception.ObjectNotFoundException- when the document does not existIllegalStateException- when the document has no readable text, with the reason
-
getDocumentTranscriptionById
public String getDocumentTranscriptionById(String documentId, Boolean timestamps) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException The transcript of an audio or video file, read with the user's rights. When there is none, the answer says why, from the file's transcription state (EXO-92097): queued, in progress with its progress, stopped when its run was lost (running, unchanged forTranscriptionState.STALE_MILLIS), failed with its reason, transcribed with no speech heard; a file never sent to transcription answers as before. A transcript grouped into chapters (EXO-92122) is given after the list of its chapters, each with the moment it starts, its title and its summary, so that the assistant can say where in the recording a subject was discussed. Asked with timestamps, a transcript that has timed segments is given one segment per line, each starting with the moment it was said,[mm:ss · Ns]([h:mm:ss · Ns]past an hour), where N is that moment in whole seconds (EXO-92112); without segments, the plain transcript is given, as without timestamps, or its turns when it tells who speaks. A transcript whose segments tell who speaks (EXO-92123) is given after the list of its speakers, each with its talk time, and each of its lines names who said it: the person named for the speaker, the guest's name, orSpeaker N; without timestamps, it is given one turn per line,Name: text, with no moment.- Parameters:
documentId- the file's UUIDtimestamps- true to have each segment start with its moment- Returns:
- the transcript
- Throws:
IllegalAccessException- when the user may not read the fileorg.exoplatform.commons.exception.ObjectNotFoundException- when the file does not existIllegalStateException- when the file has no transcript, saying why
-
searchDocuments
public List<DocumentFileModel> searchDocuments(String query, Long spaceId, String spaceName, String parentFolderId, Integer offset, Integer limit, Boolean isFavorites, String updatedSince) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Searches the documents the user can read, optionally in one space, given by its id or by its name (at most one of them), or under one folder.- Parameters:
query- the full-text queryspaceId- the space to search in, null for nonespaceName- the name of the space to search in, blank for noneparentFolderId- the folder to search under, which wins over the spaceoffset- the first resultlimit- the most resultsisFavorites- true to search the user's favorites onlyupdatedSince- an ISO-8601 date or date-time: only the files changed since then, the most recent first; blank for any date- Returns:
- the matching documents
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the space doesn't exist, or no space of the user carries the nameIllegalAccessException- when the user can't view the spaceIllegalArgumentException- when both a space id and a name are given, several of the user's spaces carry the name, the date can't be read, or neither a query nor a date is given
-
listFolderChildren
public List<DocumentModel> listFolderChildren(String folderId, Integer offset, Integer limit, String updatedSince) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Lists the direct children of a folder, folders first, or with a date only the children changed since then, the most recent first.Without a date, the storage pages over the listing itself. A date is checked against the same last-change date the listing shows, over the folder's children read in one go, up to
MAX_SCANNED_CHILDREN: the storage fills a page up to its limit whenever the folder holds more children, however many rows it leaves out (a shortcut whose target is gone), so a listing asked for one child more than the bound returns it exactly when the folder holds more, and such a folder is refused rather than answered with part of its changes.- Parameters:
folderId- the folder idoffset- the first childlimit- the most children, at most 100updatedSince- an ISO-8601 date or date-time, blank for any date- Returns:
- the children
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the folder doesn't existIllegalAccessException- when the user can't read the folderIllegalArgumentException- when the folder id is blank, the date can't be read, or the folder holds too many children to filter
-
getDocumentPermissions
public DocumentPermissionsModel getDocumentPermissions(String documentId) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Tells what the current user may do on a folder or a file: the edit right as the repository checks it for the user; the delete right as the storage computes it (the document's permission entries, and any document of the user's own drive), plus the owner's, whom the repository grants every right although that computation leaves the owner out. For a shortcut, the rights are its target's, named in the answer, and the delete right is left out: deleting the shortcut removes only the shortcut.- Parameters:
documentId- the folder or file id- Returns:
- the user's rights on it
- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the document doesn't existIllegalAccessException- when the user can't read the document
-
getFolderBreadcrumb
public List<BreadcrumbItemModel> getFolderBreadcrumb(String folderId) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException - Throws:
org.exoplatform.commons.exception.ObjectNotFoundExceptionIllegalAccessException
-
getFolderTree
public List<DocumentTreeItemModel> getFolderTree(String folderId, Boolean withChildren) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException - Throws:
org.exoplatform.commons.exception.ObjectNotFoundExceptionIllegalAccessException
-
listDocumentVersions
public List<DocumentVersionModel> listDocumentVersions(String documentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
getDocumentsSize
public DocumentsSizeModel getDocumentsSize(Long ownerId) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException - Throws:
org.exoplatform.commons.exception.ObjectNotFoundExceptionIllegalAccessException
-
createFolder
public DocumentModel createFolder(String parentFolderId, String name) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Creates a folder under a parent folder, or a chain of nested folders when the name is a path: each segment ofFinances/Factures/Entrantesbut the last reuses the child folder of that name when there is one and is created otherwise, and the last one is created. A whole tree then takes one call per leaf, every call naming the same parent: none of them needs the id of a folder created by another call of the same round, an id a model calling them together does not have yet and makes up instead.- Parameters:
parentFolderId- the folder the name, or the path's first segment, is created undername- the folder name, or a path of folder names separated by/- Returns:
- the last folder of the path, the one created
- Throws:
IllegalAccessException- when the user cannot read the parent folder or add a folder to itorg.exoplatform.commons.exception.ObjectNotFoundException- when no folder has the parent folder id
-
createDocument
public DocumentModel createDocument(String parentFolderId, String name, String content) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Creates a text-based document (markdown, HTML, plain text, CSV, JSON…) from a chat-authoredcontentstring. This is the chat-native way to turn generated text into a real file in the Documents app. Thenamemust include a file extension: the extension drives the stored content type via the platform MimeTypeResolver, so use a registered text extension (.txt, .html, .csv, .json, .xml…) so the file has the correct type and is readable via get_document_content_by_id.- Parameters:
parentFolderId- the folder where the document is created (get it from get_root_folder_for_user / get_root_folder_by_space / get_documents_by_folder_id)name- the document file name, including its extension (e.g. 'notes.md', 'report.txt', 'page.html'). The extension determines the file's content type (via the platform MimeTypeResolver); the name is used as-is.content- the text / markdown / HTML body- Returns:
- the created document
- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
createDocumentFromTemplate
public DocumentModel createDocumentFromTemplate(String parentFolderId, String name, String documentType) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Creates a NEW EMPTY office document (Word/Excel/PowerPoint, or ODF) from the platform's blank template, by delegating to the ecmsDocumentService. Use this when the user wants a blank Word/Excel/PowerPoint document to fill in (e.g. via the online editor): create_document cannot produce office files (they are structured packages, not text) and upload_document needs the real file bytes. The template is created synchronously; the file extension is added automatically fromdocumentType.- Parameters:
parentFolderId- the folder where the document is created (get it from get_root_folder_for_user / get_root_folder_by_space / get_documents_by_folder_id)name- the document name, WITHOUT extension (e.g. 'Q3 report'); the extension is appended automatically from documentTypedocumentType- the office document type: one of docx, xlsx, pptx. Availability depends on the installed editor add-on (onlyoffice).- Returns:
- the created document
- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
uploadDocument
public DocumentModel uploadDocument(String parentFolderId, String name, String base64, String url, String attachmentObjectType, String attachmentObjectId, String onConflict, String uploadId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Uploads a real / binary document (PDF, image, office file…) from exactly one of four sources: a file/image the user attached in the chat conversation (resolved server-side as the current user viaattachment_object_type/attachment_object_id), a file the user sent through an upload link (upload_id, filed from its staged file, never read into memory), a base64 payload, or an http(s) URL (fetched server-side behind an SSRF guard).- Parameters:
parentFolderId- the destination folder id (get it from get_root_folder_for_user / get_root_folder_by_space / get_documents_by_folder_id)name- the document file name including its extension (e.g. 'report.pdf'); when uploading from a URL or a chat attachment it may be left blank to reuse the source file namebase64- the file bytes encoded in base64, at mostCHUNK_CHARS(20000) characters, a larger file being sent in pieces (mutually exclusive with url / the chat attachment)url- an http(s) URL to download the file from, read up toDocumentUploadLimit.URL_FETCH_MAX_BYTES, or the upload size limit when it is lower (mutually exclusive with base64 / the chat attachment)attachmentObjectType- the object type of the file the user attached in chat; set automatically by the client — do not fill it from the modelattachmentObjectId- the object id of the file the user attached in chat; set automatically by the client — do not fill it from the modelonConflict- what to do when the folder holds a file of that name: keep_both (the default) or new_versionuploadId- the id start_upload returned, once its curl command sent the file: one of the user's own uploads, consumed by this call once read, whether it succeeds or fails (mutually exclusive with the other sources)- Returns:
- the created document
- Throws:
IllegalArgumentException- when a parameter is missing or wrong (the folder id, the source, the name, the conflict action), the file is empty or over the upload size limit, the upload id names no upload of the user's, or a new version is asked of a folder, a shortcut or a file that keeps no versionsIllegalStateException- when the file can't be read from its source or filed, or the upload is still being sent or failedorg.exoplatform.commons.exception.ObjectNotFoundException- when the folder or the attachment doesn't existIllegalAccessException- when the user can't read the attachment, or read the folder or add documents to it
-
startDocumentUpload
public DocumentUploadModel startDocumentUpload(String parentFolderId, String name, Long size, String onConflict) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Starts sending a file in pieces, for a file too large to be sent whole in one tool call: checks the folder, the user's right to add a document to it, the file's size and that its name can take the conflict action, before any piece is sent. The piece that completes the size files the document.- Parameters:
parentFolderId- the folder the file is filed intoname- the file name, with its extensionsize- the file's size, in bytesonConflict- what to do when the folder holds a file of that name: keep_both (the default) or new_version- Returns:
- the upload, with how to send its pieces
- Throws:
IllegalArgumentException- when a parameter is missing or wrong (the folder id, the name, the size, the conflict action), the size is over the upload size limit, or a new version is asked of a folder, a shortcut or a file that keeps no versionsIllegalStateException- when the user has too many uploads in progress, the folder can't be read to check the name, or the upload can't be stored on this serverorg.exoplatform.commons.exception.ObjectNotFoundException- when the folder doesn't existIllegalAccessException- when the user can't read the folder or add documents to it
-
appendDocumentUploadChunk
public DocumentUploadModel appendDocumentUploadChunk(String uploadId, Integer index, String base64) throws IllegalAccessException Adds the next piece of a file sent in pieces; the piece that completes the file files it, and returns the document. A piece sent again after a lost answer is acknowledged without being added twice, and the last one returns the document it was filed as.- Parameters:
uploadId- the uploadindex- the piece's number, from 0base64- the piece, base64-encoded- Returns:
- the upload, with the next piece expected, or with its document once filed
- Throws:
IllegalStateException- when the last piece is sent again while its file is being filed, which leaves the upload open, to be sent again; or when the piece can't be stored, or the file can't be filed, its folder gone included, which ends the uploadIllegalArgumentException- when the piece is refused, which leaves the upload open, or when the file is refused at its filing, a new version asked of a folder, a shortcut or a file that keeps no versions, which ends the uploadIllegalAccessException- when the user can no longer add documents to the folder, which ends the upload
-
renameDocument
public void renameDocument(String documentId, String newName) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Renames a file or a folder.- Parameters:
documentId- the file or foldernewName- its new name- Throws:
IllegalAccessException- when the user can't rename the node, or, in a call limited to a space, the node was created by the platform for the space or the call's space can't be readorg.exoplatform.commons.exception.ObjectNotFoundException- when the node doesn't exist
-
moveDocument
public void moveDocument(String documentId, String destinationFolderId, String conflictAction) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Moves a file or a folder into another folder; in a call limited to a space, the destination folder must be in that space.- Parameters:
documentId- the file or folder to movedestinationFolderId- the destination folderconflictAction- what to do when the destination holds a node of the same name,keepBothby default- Throws:
IllegalAccessException- when the user can't move the node there, or, in a call limited to a space, the destination folder isn't in that space, the node was created by the platform for the space, or the call's space can't be readorg.exoplatform.commons.exception.ObjectNotFoundException- when a node doesn't exist
-
copyDocument
public DocumentModel copyDocument(String documentId, String destinationFolderId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Copies a file into another folder; in a call limited to a space, the destination folder must be in that space.- Parameters:
documentId- the file to copydestinationFolderId- the destination folder- Returns:
- the copy
- Throws:
IllegalAccessException- when the user can't copy the node there, or, in a call limited to a space, the destination folder isn't in that space, the node was created by the platform for the space, or the call's space can't be readorg.exoplatform.commons.exception.ObjectNotFoundException- when a node doesn't existIllegalArgumentException- when the destination folder holds 1000 items or more: the copy could not be found among them afterwards, so nothing is copiedIllegalStateException- when the copy is made but cannot be found: the folder grew past 1000 items meanwhile, or no added node carries the expected name
-
duplicateDocument
public DocumentModel duplicateDocument(String documentId, String prefix) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Duplicates a file or a folder in its own folder, with an optional prefix and a " (n)" counter, and returns the duplicate.- Parameters:
documentId- the file or folder to duplicateprefix- an optional prefix of the duplicate's name- Returns:
- the duplicate, a file or a folder like the source
- Throws:
IllegalAccessException- when the user can't read or duplicate the node, or, in a call limited to a space, the node was created by the platform for the space or the call's space can't be readorg.exoplatform.commons.exception.ObjectNotFoundException- when the node doesn't existIllegalArgumentException- when the source's folder holds 1000 items or more: the duplicate could not be found among them afterwards, so nothing is duplicatedIllegalStateException- when the duplicate is made but cannot be found: the folder grew past 1000 items meanwhile, or no added node carries the expected name
-
deleteDocument
public void deleteDocument(String documentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException - Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
undoDeleteDocument
public void undoDeleteDocument(String documentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Restores a document that was deleted withdelete_document: since that tool trashes immediately (delay 0), the delayed-delete cancel path is a no-op, so the node is resolved from trash (it keeps its id/uuid after the move) and restored to its original location.- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
restoreDocumentVersion
-
updateVersionSummary
public DocumentVersionModel updateVersionSummary(String documentId, String versionId, String summary) -
setDocumentVisibility
Hides a file or a folder from the listings, or shows it again; hiding a folder may also hide some of its direct children. In a call limited to a space, only a folder the platform didn't create for the space.- Parameters:
documentId- the file or folderhidden- true to hide it, false to show it- Throws:
IllegalAccessException- in a call limited to a space, when the node is a file or was created by the platform, or the call's space can't be readIllegalStateException- when the storage refuses the change, the user's refused access included, which it reports wrapped
-
addDocumentVersion
public DocumentModel addDocumentVersion(String documentId, String content, String base64, String url, String attachmentObjectType, String attachmentObjectId, String versionSummary, String uploadId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Uploads updated content onto an EXISTING file, creating a NEW version of it (the previous content stays retrievable via list_document_versions / restore_document_version). The new bytes come from exactly one source: a chat-authored textcontentstring, abase64payload, an http(s)url, a file the user attached in the conversation, or a file the user sent through an upload link (upload_id, streamed from its staged file, never read into memory). The file's name and type are unchanged; only its content and version history are updated.- Parameters:
documentId- the id of the existing file to add a version to (get it from get_document_by_id / get_documents_by_folder_id / search_documents)content- plain text / markdown / HTML body to write as the new version (use for text files)base64- the new file bytes encoded in base64, at mostCHUNK_CHARS(20000) charactersurl- an http(s) URL to download the new content from (fetched server-side behind an SSRF guard, up toDocumentUploadLimit.URL_FETCH_MAX_BYTES, or the upload size limit when it is lower)attachmentObjectType- the object type of the file the user attached in chat; set automatically by the client — do not fill it from the modelattachmentObjectId- the object id of the file the user attached in chat; set automatically by the client — do not fill it from the modelversionSummary- an optional change note stored on the new versionuploadId- the id start_upload returned, once its curl command sent the file: one of the user's own uploads, consumed by this call once read, whether it succeeds or fails; refused in a call limited to a space- Returns:
- the updated document (with its refreshed size / modification info)
- Throws:
IllegalArgumentException- when not exactly one source is given, the document is a folder, the content is over the upload size limit or refused by a validator, or the upload id names no upload of the user'sIllegalStateException- when the content can't be read from its source, or the upload is still being sent or failedIllegalAccessException- when the user can't edit the document, or an upload id is given in a call limited to a space, or, in a call limited to a space, the file was created by the platform for the space, or the call's space can't be readorg.exoplatform.commons.exception.ObjectNotFoundException- when the document doesn't exist
-
createPublicLink
public DocumentPublicLinkModel createPublicLink(String documentId, String password, Long expirationDate) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Creates (or refreshes) an anonymous public share link for a document so it can be downloaded without signing in, optionally protected by a password and/or an expiration date. Requires edit permission on the document.- Parameters:
documentId- the id of the file to share publicly (get it from the read tools)password- an optional password required to open the linkexpirationDate- an optional expiration date, as epoch milliseconds; after it the link stops working. Leave blank for a link that never expires.- Returns:
- the shareable link, together with its password and expiration
- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
createDocumentShortcut
public void createDocumentShortcut(String documentId, String destinationFolderId, String conflictAction) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Creates a shortcut (symlink) to a document inside another folder, so the same file appears in a second location without being copied.- Parameters:
documentId- the id of the file or folder to create a shortcut todestinationFolderId- the id of the folder where the shortcut is placed (get it from get_root_folder_for_user / get_root_folder_by_space / get_documents_by_folder_id)conflictAction- behaviour when a node with the same name already exists in the destination; only 'keepBoth' is honoured, defaults to 'keepBoth'- Throws:
IllegalAccessException- when the user can't read the nodes, or, in a call limited to a space, the destination folder isn't in that space, the node was created by the platform for the space, or the call's space can't be readorg.exoplatform.commons.exception.ObjectNotFoundException- when a node doesn't exist
-
favoriteDocument
public void favoriteDocument(String documentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Adds a file to the current user's favorites. Only files can be favorited; folders have no favorites view in the Documents app.- Parameters:
documentId- the id of the file to mark as favorite- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-
unfavoriteDocument
public void unfavoriteDocument(String documentId) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Removes a file from the current user's favorites. Only files can be favorited; folders have no favorites view in the Documents app.- Parameters:
documentId- the id of the file to remove from favorites- Throws:
IllegalAccessExceptionorg.exoplatform.commons.exception.ObjectNotFoundException
-