...
Note: The behaviour of DocIntegrate is influenced by the <editableFileTypes> key in the settings.xml file in /Workspace/Settings/ of your repository.
Please check the information given here to access a document for editing.
...
Code Block |
---|
http://<nuxeoserverip>:<nuxeoport><casebrowserport>/casebrowser/download//<caseRef>,<documentUID>/true |
Note: This is a casebrowser endpoint so you need to use the casebrowser server IP and port.
To get the documentUID from the document's path, you must can run a http POST against the Document.Fetch Query endpoint of the DMS:
Code Block |
---|
curl -X POST \ http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Document.FetchQuery \ -H 'authorization: Basic <userAndPassEncoded>' \ -H 'content-type: application/json' \ -d '{"params":{"valuequery":"/default-domain/workspaces/Patricia/<documentPath>/<documentName>SELECT * FROM Document WHERE dc:title='\''<documentName>'\'' AND ecm:path STARTSWITH '\''<casePath>'\''"}}' |
Here, the <userAndPassEncoded> represents a Base64 encoded string of the format 'Username:Password'. So, 'Username:Password' would be represented as 'VXNlcm5hbWU6UGFzc3dvcmQ='.
To determine the <documentPath>, please see below. The <documentName> of a specific document can be found in PAT_DOC_LOG.DOC_FILE_NAME of the Patricia database.
The Document.Fetch Query endpoint returns a strong an array of the documents in JSON format, for example:
Code Block |
---|
{ "entity-type": "documents", "isPaginable": true, "resultsCount": 1, "pageSize": 0, "maxPageSize": 1000, "currentPageSize": 1, "currentPageIndex": 0, "numberOfPages": 1, "isPreviousPageAvailable": false, "isNextPageAvailable": false, "isLastPageAvailable": false, "isSortable": true, "hasError": false, "errorMessage": null, "totalSize": 1, "pageIndex": 0, "pageCount": 1, "entries": [ { "entity-type": "document", "repository": "default", "uid": "1241650864acbaf8-5414c963-4eb046a6-9452a5fc-10f2c368e222a7e703826625", "path": "/default-domain/workspaces/Patricia/docDocuments/2/1000/DE/00/Sample.docx", "type": "File", "state": "deletedproject", "parentRef": "c188a02a650d7a6c-185a9927-45c94485-983585c4-28c01bbcf8954d2cc9b9f08f", "isCheckedOut": true, "changeToken": "15078900290761529682744601", "title": "docSample.docx", "lastModified": "20172018-1006-13T1022T15:2052:2924.07Z60Z", "facets": [ "Versionable", "Publishable", "Commentable", "PiFileFacet", "PiFacet", "HasRelatedText", "Downloadable" ] } ] } |
From this, you can extract the "uid" value.
Since DMS version 1.9.8.2.3-3, the download endpoint allows downloading of multiple documents as follows:
Code Block |
---|
http://<nuxeoserverip>:<nuxeoport>/casebrowser/download/<caseRef1>,<documentUID1>;<caseRef2>,<documentUID2>;<caseRef3>,<documentUID3>;.../true |
Creating a document in the DMS
Creating a document in the DMS is a bit more complex. In Nuxeo, a document is made up of a document container, think of it as a shell with some metadata attached to it, and the binary/binaries. To create document in the DMS, you must thus first create a container and then add the binary to it.
a) Creating the "container"
Code Block |
---|
http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Document.Create |
This can be curled as http POST against the DMS as follows:
Code Block |
---|
curl \
-H "authorization: Basic <userAndPassEncoded>" \
-H "Content-Type: application/json" \
-d "{\"params\":{\"entity-type\":\"document\",\"type\":\"File\",\"name\":\"testdoc.txt\",\"properties\":{\"dc:title\":\"testdoc.txt\",\"pifile:docCategoryId\":\"1\"}},\"input\":\"/default-domain/workspaces/Patricia/<documentPath>\"}" \
-X POST http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Document.Create |
Again, the <userAndPassEncoded> represents a Base64 encoded string of the format 'Username:Password'. So, 'Username:Password' would be represented as 'VXNlcm5hbWU6UGFzc3dvcmQ='.
To determine the <documentPath>, please see below. The <docName> is the name that the new document should have. <categoryID> is the category that the document will be posted into; pleas take that from the Patricia database.
Following the document creation, the PAT_DOC_LOG of Patricia will also be updated to include the document.
b) Creating the document content
Following successful creation of the container (see above), the following endpoint is used to fill the container with content:
Code Block |
---|
http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Blob.Attach |
This can be curled as http POST against the DMS as follows:
Code Block |
---|
curl \
-H "authorization: Basic <userAndPassEncoded>" \
-H "content-type: application/json" \
-F "{\"params\":{\"mime-type\":\"<docMimeType>\",\"document\":\"/default-domain/workspaces/Patricia/<documentPath>/<docName>\",\"save\":\"true\",\"xpath\":\"file:content\"}}" \
-F =@/<pathToSourceFile>
-X POST http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Blob.Attach \ |
The <mimeType> should be set according to the document type (eg. "text/html" for a html document). <pathToSourceFile> is your local file path of the binary document to upload.
To determine the <documentPath>, please see below. The <docName> is the name that the new document has as per the creation of the container above.
Note:
For the above document creation to work, <documentPath> must exist. As the case may be, you may require creation of the folder path as follows:
Code Block |
---|
curl \
-H "authorization: Basic <...>" \
-H "Content-Type: application/json" \
-d "{\"params\":{\"entity-type\":\"document\",\"type\":\"Folder\",\"name\":\"<folderName>\",\"input\":\"/default-domain/workspaces/Patricia/<folderPath>\"}" \
-X POST http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Document.Create |
whereby <folderPath>/<folderName> will be created. Note that the folder tree needs to be build recursively (i.e. <folderPath> must also exist).
Deleting a document from the DMS
...
Code Block |
---|
http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Document.SetLifeCycle |
This must can be called curled as http POST against the DMS as follows:
...
Torben Rees of Greaves Brewster deserves great kudos for having developed an integrating tool that uploads documents to the DMS and creating an excellent piece of documentation of which we used parts above. Please see his complete document here:
View file | ||||
---|---|---|---|---|
|