Skip to main content

CMIS document repository

Page under construction

The CMIS server is under development. This section describes the current state: browsing, creating, renaming and deleting folders and documents, and reading and replacing document content, and versioning of documents (checkOut, checkIn, cancelCheckOut).

Mercury DB (HgDB) can act as a document repository available through the CMIS standard (Content Management Interoperability Services), implemented with Apache Chemistry OpenCMIS 1.1.0.

How CMIS maps to Mercury​

CMISMercury DB
RepositoryMount point of the case catalog (Case2CaseMountPoint); the identifier of the repository is the name of the mount point
Folder (cmis:folder)Case of a type that is not a document type (predefined type CmisFolder)
Document (cmis:document)Case of a type with the isDocumentType flag set (predefined type CmisDocument)
Content of a documentFile stored by the Mercury file mechanism (directory mercury.upload.file.target)
Root folderCase of the type CmisFolder, created at the first start of the server

Custom case types are exposed as subtypes of cmis:folder or cmis:document, depending on the isDocumentType flag of the type.

Name of an object​

The CMIS name (cmis:name) is stored in the case field CmisName. A type without this field (for example a type imported from BPM) stores the name in the inventory code of the case (inventoryCode). The name is read in the same order: the field CmisName, then the inventory code, and when both are empty the value CID:<case identifier>. A new object is created in either kind of type, and so is a rename.

Limitations of the inventory code

The inventory code should be unique, but the mechanisms that handle it are not implemented yet, so it is empty for ordinary cases. Only the CMIS server checks that a name is unique within a folder. The same name in different folders gives the same inventory code, and renaming such an object changes the inventory code seen by other functions of the system. When the inventory code mechanisms are ready, renaming objects of types without the field CmisName is going to be blocked.

Required fields​

A field is required in the CMIS type definition (required: true) when the case type marks it as required, or when the field is part of the uniqueness rule of the type (the formula of unique values, with elements separated by ||; literals in apostrophes are skipped). Mercury rejects a case without a value of such a field, so a client has to send it when it creates an object, for example bpmProcessInstanceId for the type BpmBPDInstance.

Deleting objects and allowable actions​

  • deleteObject removes one document or one empty folder. A non-empty folder ends with the error constraint, as the standard requires. The root folder cannot be deleted. Deleting a document also deletes its content file. For a document, allVersions=true (the default) removes the whole version series with the content of every version, and allVersions=false removes only the latest version, so the previous one becomes the latest again (only the latest version can be removed this way). A series checked out for editing cannot be removed (error constraint): check in or cancel the check out first. Removing a working copy with allVersions=false cancels the check out.
  • deleteTree removes a folder together with its content, starting from the leaves. It is not one transaction: when an error stops the operation, part of the objects stays deleted. The response lists the identifiers that were not deleted (the parent folder as well, when its content remains). The root folder is protected.
  • The allowable actions (includeAllowableActions=true) depend on the kind of the object: a folder allows browsing and creating, a document allows reading, replacing and deleting the content and listing the versions, and every object except the root folder allows changing properties and deleting. A document that is the latest version and is not checked out also allows canCheckOut, and a working copy allows canCheckIn and canCancelCheckOut. The list shows what the server can do. It does not evaluate the privileges of the user, so a denied operation returns permissionDenied only when it is executed.

Versioning of documents​

Every document type is versionable (versionable: true). A version series is the chain of cases of one document: the earlier versions have the status Z (closed), the latest has the status A.

OperationResult
checkOutCreates a private working copy (PWC): a case in the status O that points at the latest version. The copy has its own content file, a copy of the content of that version. The series has one working copy at most; a second checkOut ends with the error constraint.
checkInPromotes the working copy to the new latest version (status A), the earlier version becomes Z. The request may change properties and content and carries a comment (checkinComment). major=true raises the first number of the label and zeroes the second one, major=false raises the second number.
cancelCheckOutRemoves the working copy with its content. The latest version does not change.
getAllVersionsThe working copy (if any) and then the versions from the newest to the oldest.
getObjectOfLatestVersionThe latest version of the series (a working copy is not the latest version).
createDocumentFromSourceCreates a new document (a new series, label 1.0) with the type, the field values and an own copy of the content of the source. The properties of the request replace the values taken from the source.

The version label has the form major.minor and is stored in the field CmisVersionLabel (the first version is 1.0). A type without this field shows the label 1.0. Version properties: cmis:isLatestVersion, cmis:isMajorVersion, cmis:versionLabel, cmis:isVersionSeriesCheckedOut, cmis:versionSeriesCheckedOutId, cmis:versionSeriesCheckedOutBy, cmis:isPrivateWorkingCopy. A folder shows and the queries return only the latest version of a document.

Who may finish a check out

checkIn and cancelCheckOut are allowed only for the user who did the checkOut. The exception is a user with the role mrc-sysadmin.

Queries (CMIS QL)​

The repository answers CMIS queries (query) about one type, without JOIN. The result contains the current version of objects in the repository that the user may read (privileges to case types apply).

Example
SELECT cmis:name, Title FROM cmis:document
WHERE IN_TREE('CmisFolder.5783302') AND cmis:name LIKE 'offer%' AND cmis:creationDate >= TIMESTAMP '2026-01-01T00:00:00.000Z'
ORDER BY cmis:creationDate DESC
ElementSupport
FROMcmis:document, cmis:folder or the code of a Mercury type. Fields of a type can be used in conditions only when the type is named in FROM.
Conditions=, <>, <, <=, >, >= (numbers and dates), IN, NOT IN, LIKE, NOT LIKE, IS [NOT] NULL (string fields), AND, OR, NOT, IN_FOLDER, IN_TREE, CONTAINS
IN_TREEThe folder and its subfolders from the catalog; up to 900 folders, more ends with the error constraint.
ORDER BYSingle-valued, not analyzed fields. cmis:name only for a named type (in cmis:document the name can be in two fields).
Not supportedJOIN, ANY, SCORE(), searching all versions, = and LIKE and ORDER BY on analyzed fields (types Text and Lob, use CONTAINS), < and > on text. Such a query ends with the error notSupported.
Index

The queries use the Lucene index, which the index secretary updates a few seconds after a change. A deleted object disappears from the results after the next run of the secretary; the CMIS server wakes the secretary up after every deletion. Objects indexed before the fields mrc_mountPoints, mrc_mountPointParents and mrc_isLatestVersion were added are not found, so the index has to be rebuilt: send the identifiers of all cases and documents to the buffer of the index secretary, wake the secretary up and wait until it finishes.

Configuration​

The parameters are placed in the mercury.properties file:

ParameterDescriptionDefault
mercury.cmis.repositoriesList of repository identifiers separated by commas. Each one becomes a mount point with a root folder.documents
mercury.cmis.maxContentSizeThe largest size of a document content in bytes. The content is processed in memory.10485760 (10 MB)
mercury.cmis.repositories.<id>.rolesRoles allowed to use the repository <id>, separated by commas. A user with any of them has access. Without the entry every authenticated user has access (the privileges to case types still apply). A repository closed for the user is not listed and returns permissionDenied.not set
mercury.cmis.security.oauthClientIdOAuth client whose realm verifies the user name and password sent with the Basic scheme.not set
mercury.cmis.security.oauthClientSecretSecret of that OAuth client.not set

Addresses and authentication​

Addresses are relative to the application mercury-ws-app, for example http://localhost:8080/mercury-ws-app/browser:

BindingAddress
Browser (JSON)/browser
AtomPub, CMIS 1.1/atom11
AtomPub, CMIS 1.0/atom

Every request requires authentication. The server accepts the Authorization header with:

  • Bearer <token>: an OAuth token, the same as in the REST services,
  • Basic <base64(user:password)>: the user is verified in the realm of the OAuth client set by mercury.cmis.security.oauthClientId.

Without valid credentials the server returns 401 with the header WWW-Authenticate: Basic realm="CMIS".

Content of this section​