...
Please note that the below information is given as is with no liability taken by PI or Patrix. Do not proceed to use the below information against your repository unless you are well aware of what you do.
For running the below commands, you can use gui tools, such as, e.g., Postman, or use the terminal's curl command. Commands are given as curl, however, you can easily determine the header and body values therefrom and translate that into Postman.
Accessing an existing document to open for editing/saving back to system
...
To get the documentUID from the document's path, you must curl run a http POST against the Document.Fetch endpoint of the DMS:
Code Block |
---|
curl -X POST \ http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Document.Fetch \ -H 'authorization: Basic <userAndPassEncoded>' \ -H 'content-type: application/json' \ -d '{"params":{"value":"/default-domain/workspaces/Patricia/<documentPath>/<documentName>"}}' |
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 The above Document.Fetch endpoint returns a strong in JSON format, for example:
...
From this, you can extract the "uid" value.
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.
Deleting a document from the DMS
...
Code Block |
---|
http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Document.SetLifeCycle |
This must be called as http-POST with body information as as http POST against the DMS as follows:
Code Block |
---|
curl -X POST \ http://<nuxeoserverip>:<nuxeoport>/nuxeo/api/v1/automation/Document.SetLifeCycle \ -H 'authorization: Basic <userAndPassEncoded>' \ -H 'content-type: application/json' \ -d '{"params":{"value":"delete"},"input":"/default-domain/workspaces/Patricia/<documentPath>/<pathToDocument>","context":{}}<documentName>"}' |
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 <documentName> of a specific document can be found in PAT_DOC_LOG.DOC_FILE_NAME of the Patricia database.
Determining the document path
The document path always starts with “/default-domain/workspaces/Patricia/Documents/” but the remainder of the path is built using the components of the Patricia case reference, which can all be retrieved from the PAT_CASE table of the Patricia database along the following lines: <CASE_TYPE_ID>/<CASE_NUMBER>/<STATE_ID>/<CASE_NUMBER_EXTENSION>.
The below SQL Server function returns the path of a case for a specified case reference.
Code Block | ||
---|---|---|
| ||
CREATE FUNCTION [dbo].[GetNuxeoPath]
(
-- Add the parameters for the function here
@CaseRef NVARCHAR(20)
)
RETURNS NVARCHAR(250)
AS
BEGIN
-- Declare the return variable here
DECLARE @NuxeoPath NVARCHAR(250)
SET @NuxeoPath =
(select CAST(CASE_TYPE_ID as NVARCHAR) + '/' + CAST(CASE_NUMBER as NVARCHAR)
+ '/' + LTRIM(RTRIM(CAST(STATE_ID as nvarchar)))
+ '/' + LTRIM(RTRIM(CAST(CASE_NUMBER_EXTENSION as nvarchar)))
from dbo.PAT_CASE
where dbo.fn_case_number(CASE_ID) = @CaseRef)
-- Return the result of the function
RETURN @NuxeoPath
END |
Example at work
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:
In the above <pathToDocument> must be replaced by the appropriate path you can compute from the Pat_Doc_Log table in Patricia.