Posted Nov 04 by Peng Qiu.
Updated Feb 27.

This doc shows a series of JSON message samples to create, update, and delete primary contents and renditions in Documentum REST Services.

Last activity Feb 27 by Peng Qiu.
339 views. 0 comments.

Get a folder resource

Assumed that you get a folder resource.

GET http://localhost:8080/dctm-rest/repositories/repo/folders/0b0000018000416b
Accept: application/json

From the response, you'll find link relations http://identifiers.emc.com/linkrel/documents and http://identifiers.emc.com/linkrel/objects which point to the folder child documents and
folder child sysobjects feeds, respectively.

{
    "name": "folder",
    ...
    "links": [
        ...
        {
            "rel": "http://identifiers.emc.com/linkrel/documents",
            "href": "http://localhost:8080/dctm-rest/repositories/repo/folders/0b0000018000416b/documents"
        },
        {
            "rel": "http://identifiers.emc.com/linkrel/objects",
            "href": "http://localhost:8080/dctm-rest/repositories/repo/folders/0b0000018000416b/objects"
        },
        ...
    ]
}

These two feeds allow you to create new documents/sysobjects under the folder.

Create a contentful document

You can post a multipart HTTP request to the feed to create a contentful document directly with both properties and a primary content. Seeing the sample:

POST http://localhost:8080/dctm-rest/repositories/repo/folders/0b0000018000416b/documents
Accept: application/json
Content-Type: multipart-form-data;boundary=—-WebKitFormBoundary7MA4YWxkTrZu0gW

Content-Disposition: form-data; name=“object”

{“properties”:{“r_object_type”: “dm_document”, “object_name”:
“readme.txt”}}

Content-Disposition: form-data; name=“content”; filename=“”
Content-Type: file

——WebKitFormBoundary7MA4YWxkTrZu0gW–

From the response, a new document resource is returned.

HTTP 201 Created
Location: http://localhost:8080/dctm-rest/repositories/repo/documents/090000018000a08f
Content-Type: application/json;charset=UTF-8

{
    "name": "document",
    "type": "dm_document",
    ...
    "links": [
        ...
        {
            "rel": "contents",
            "href": "http://localhost:8080/dctm-rest/repositories/repo/objects/090000018000a08f/contents"
        },
        {
            "rel": "http://identifiers.emc.com/linkrel/primary-content",
            "href": "http://localhost:8080/dctm-rest/repositories/repo/objects/090000018000a08f/contents/content"
        },
        ...
    ]
}

From the document resource, you'll find two link relations contents and http:// <br />identifiers.emc.com/linkrel/primary-content which point to the contents feed and the primary
content of this document, respectively.

Create a contentless document

If your client app does not support HTTP multipart POST, you can create a contentful document in 2 steps. Firstly, create a contentless document under the folder.

POST http://localhost:8080/dctm-rest/repositories/repo/folders/0b0000018000416b/documents
Accept: application/json
Content-Type: application/json

{“properties”:{“r_object_type”: “dm_document”, “object_name”: “readmeNoContent.txt”}}

Then you could create a new primary content under the document contents feed.

Create a primary content

Follow the content link relation on the document resource.

POST http://localhost:8080/dctm-rest/repositories/repo/objects/090000018000a091/contents
Content-Type: text/plain

Hello, ReSTer!!

The response returns a content metadata resource for the newly created content.

{
    "name": "content",
    "properties": {
        "r_object_id": "0600000180015710",
        "rendition": 0,
        "parent_count": 1,
        "content_size": 15,
        "full_format": "atd",
        "format": "2700000180000215",
        "encoding": "",
        "set_time": "2018-10-22T07:57:41.000+00:00",
        "full_content_size": 15,
        ...
    },
    "links": [
        {
            "rel": "self",
            "href": "http://localhost:8080/dctm-rest/repositories/repo/objects/090000018000a091/contents/content?format=atd&modifier=&page=0"
        },
        {
            "rel": "enclosure",
            "title": "ACS",
            "href": "http://localhost:9080/ACS/servlet/ACS?command=read&version=2.3&docbaseid=000001&basepath=C%3A%5CDocumentum%5Cdata%5Crepo%5Ccontent_storage_01%5C00000001&filepath..."
        },
        {
            "rel": "http://identifiers.emc.com/linkrel/content-media",
            "title": "ACS",
            "href": "http://localhost:9080/ACS/servlet/ACS?command=read&version=2.3&docbaseid=000001&basepath=C%3A%5CDocumentum%5Cdata%5Crepo%5Ccontent_storage_01%5C00000001&filepath..."
        },
        {
            "rel": "parent",
            "href": "http://localhost:8080/dctm-rest/repositories/repo/objects/090000018000a091"
        }
    ]
}

The content metadata resource contains both metadata and media links of the content.

Please note that the format of the content is set as atd according to its mime type text/plain. This is due to the fact of one-many mapping between mime type and formats in Content Server format types. The REST server picks up the default format for the mime type( in name ascending sequence) if the format is not set by the client explicitly. You could customized it in two ways:

  • Append a URI query parameter format=<YOUR_PREFERRED_FORMAT_NAME> at the contents feed URI for POST
  • Update REST server runtime properties to specify the default mime-to-format mapping in dctm-rest.war/WEB-INF/classes/rest-api-runtime.properties file.

rest.mime.format.mapping.enabled=true

# [repositoryName].[mime_type]=[format], support wildcard repository name

*.text/plain=text
my_repository.application/msword=msw12

Create a rendition

Besides the primary content, you can also create renditions under the same contents feed.

POST http://localhost:8080/dctm-rest/repositories/repo/objects/090000018000a091/contents?format=crtext&page=0&primary=false
Accept: application/json
Content-Type: text/plain

Hello, ReSTer, for rendition!

For the rendition creation, you need to explicitly specify the format name, page number or
page modifier. And it is mandatory to set primary=false if the content to create is actually a
rendition.

The REST server returns you a rendition.

{
    "name": "content",
    "properties": {
        "r_object_id": "0600000180015711",
        "rendition": 2,
        "parent_count": 1,
        "content_size": 29,
        "full_format": "crtext",
        "format": "270000018000011b",
        ...
        "parent_id": [
            "090000018000a091"
        ],
        ...
    },
    "links": [
        {
            "rel": "self",
            "href": "http://localhost:8080/dctm-rest/repositories/repo/objects/090000018000a091/contents/content?format=crtext&modifier=&page=0"
        },
        {
            "rel": "enclosure",
            "title": "ACS",
            "href": "http://localhost:9080/ACS/servlet/ACS?command=read&version=2.3&docbaseid=000001&basepath=C%3A%5CDocumentum%5Cdata%5Crepo%5Ccontent_storage_01%5C00000001..."
        },
        {
            "rel": "http://identifiers.emc.com/linkrel/content-media",
            "title": "ACS",
            "href": "http://localhost:9080/ACS/servlet/ACS?command=read&version=2.3&docbaseid=000001&basepath=C%3A%5CDocumentum%5Cdata%5Crepo%5Ccontent_storage_01%5C00000001..."
        },
        {
            "rel": "parent",
            "href": "http://localhost:8080/dctm-rest/repositories/repo/objects/090000018000a091"
        }
    ]
}

The property "rendition": 2 means that this content is a rendition.

Update a content/rendition

To update an existing content or rendition, POST on the contents feed with the binary of
the new content/rendition. In the URI of the contents feed, you need to specify on which
format, page number and page modifier to update, and it is required to set the parameter
“overwrite=true”. For instance,

POST http://localhost:8080/dctm-rest/repositories/repo/objects/090000018000a091/contents?format=crtext&page=0&primary=false&overwrite=true
Accept: application/json
Content-Type: text/plain

Hello, ReSTer, for rendition update!!

Delete a content/rendition

To delete an existing content or rendition, DELTE on self link relation of the content resource.

DELETE http://localhost:8080/dctm-rest/repositories/repo/objects/090000018000a091/contents/content?format=crtext&page=0

Demo of large contentful document creation

In below screenshot, I demonstrated a large content (a 500MB file) import using a REST client Postman.

postman demo

In Postman, I added two parts to form the request, where the first is the properties of the new document, and the latter is the content file. Since I am not able to specify the media type for each part, I worked around it a bit. Documentum REST Services takes JSON as the default media type, so I used JSON representation for the properties. Besides, I specified the content format in the URI query, to overcome the limitation that I am not able to specify the media type for the 2nd part. The request takes around 8 minute to complete the 500MB file upload. As a result, the response returns the new document representation.


Table of Contents

Your comment

To leave a comment, please sign in.