DDF Content REST CRUD Endpoint
Description
The Content REST Endpoint allows clients to perform CRUD operations on the Content Repository using REST, a simple architectural style that performs communication using HTTP.
The URL exposing the REST functionality will be located at http://<DDF_HOST>:<DDF_PORT>/services/content
, where DDF_HOST
is the IP address of where
DDF
is installed andDDF_PORT
is the port number DDF
is listening on.The Content REST CRUD Endpoint provides the capability to read, create, update, and delete content in the Content Repository as well as create, update, and delete Metacards in the catalog provider, i.e., the Metadata Catalog (MDC). Furthermore, this endpoint allows the client to perform the create/update/delete operations on just the Content Repository, or just the MDC, or both in one operation.
The Content Framework is currently transactional only for create operations. Therefore, if the client sends a create request to create content in the DDF Content Repository and also process the content to create a Metacard, and ingest it into the MDC (i.e., directive=STORE_AND_PROCESS), if a problem is encountered during the catalog ingest the content is removed from the DDF Content Repository, analogous to a rollback. This is so that the DDF Content Repository and the MDC are kept in sync.
The Content Framework does not support rollback capability for update or delete operations that affect both the DDF Content Repository and the MDC.
Usage
The Content REST CRUD Endpoint provides the capability to read, create, update, and delete content in the DDF Content Repository as well as create, update, and delete Metacards in the catalog provider as follows. Sample requests and repsonses
are provided in a separate table.
Operation | HTTP Request | Details | Example URL |
---|---|---|---|
Create Content and Catalog Entry | HTTP POST | The multipart/form-data REST request that contains the binary data to be stored in the DDF Content Repository and to be parsed to create a Metacard for ingest into the MDC. This binary data can be included in the request's body or as a file attachment. An HTTP 201 CREATED status code is returned to the client with:
|
where the and the
|
Create Content Only | HTTP POST | The multipart/form-data REST request that contains the binary data to be stored in the DDF Content Repository. This binary data can be included in the request's body or as a file attachment. An HTTP 201 CREATED status code is returned to the client with:
|
where the and the
|
Create Catalog Entry Only | HTTP POST | The multipart/form-data REST request that contains the binary data to be parsed to create a Metacard for ingest into the MDC. This binary data can be included in the request's body or as a file attachment. An HTTP 200 OK status code is returned to the client with:
|
where the and the and the
|
Update Content and Catalog Entry | HTTP PUT | The ID of the content item in the DDF Content Repository to be updated is appended to the end of the URL. The body of the REST request contains the binary data to update the DDF Content Repository. An HTTP 200 OK status code is returned to the client with:
|
|
Update Content Only | HTTP PUT | The ID of the content item in the DDF Content Repository to be updated is appended to the end of the URL. The body of the REST request contains the binary data to update the DDF Content Repository. An HTTP 200 OK status code is returned to the client with:
|
|
Update Catalog Entry Only | HTTP PUT | The URI of the content item in the MDC to be updated is specified in the The body of the REST request contains the binary data to update the catalog entry in the MDC. An HTTP 200 OK status code is returned to the client with:
|
|
Delete Content and Catalog Entry | HTTP DELETE | The ID of the content item in the DDF Content Repository to be deleted is appended to the end of the URL. HTTP status code of 204 NO CONTENT is returned upon successful deletion.
|
|
Delete Content Only | HTTP DELETE | The ID of the content item in the DDF Content Repository to be deleted is appended to the end of the URL. HTTP status code of 204 NO CONTENT is returned upon successful deletion. |
|
Delete Catalog Entry Only | HTTP DELETE | The URI of the content item in theMDC to be deleted is specified in the HTTP status code of 204 NO CONTENT is returned to the client upon successful deletion with:
|
|
Read | HTTP GET | The ID of the content item in the DDF Content Repository to be retrieved is appended to the end of the URL. An HTTP 200 OK status code is returned upon successful read and the contents of the retrieved content item are contained in the HTTP body. |
ABC123 is the ID of the content item to be retrieved |
Note that for all Content REST CRUD commands only one content item ID is supported in the URL, i.e., bulk operations are not supported.
Interacting with REST endpoint
Any web browser can be used to perform a REST read. Various other tools and libraries can be used to perform the other HTTP operations on the REST endpoint (e.g., soapUI, cURL, etc.)
Create Request Multipart/Form-Data Parameters
The create
(HTTP POST
) request is a multipart/form-data request, allowing the binary data (i.e., the content) to be either included in the request's body or attached as a file. This binary data is defined in a Content-Disposition
part of the request where the name
parameter is set to file
and the optional filename
parameter indicates the name of the file that the content should be stored as.
Optional form parameters for the create
request are the directive
and contentUri
. The directive
form parameter's value can be either STORE, PROCESS, or STORE_AND_PROCESS, indicating if the content should be only stored in the Content Repository, only processed to generate a Metacard and then ingested into the MDC, or both. the directive
form parameter will default to STORE_AND_PROCESS
if it is not specified.
The contentUri
form parameter allows the client to specify the URI of a product stored remotely/externally (relative to DDF). This contentUri
is used to indicate that the client will manage the content storage but wants the Content Framework to parse the content and create/update/delete a catalog entry in the MDC using this content URI as the entry's product URI. This parameter is used when the directive
is set to PROCESS.
Update and Delete Request HTTP Header Parameters
Two optional HTTP header parameters are available on the update
and delete
RESTful URLs.
The directive
header parameter allows the client to optionally direct the Content Framework to:
- only store the content in the DDF Content Repository (
directive=STORE
) - store the content in the repository and parse the content to create a Metacard (
directive=STORE_AND_PROCESS
); this metacard is then created/updated/deleted in the Metadata Catalog (by invoking the Catalog Framework operations).
STORE_AND_PROCESS
is the default value for the directive
header parameter. The directive
header parameter is only used on the PUT
and DELETE
RESTful URLs that have a contentId
in the URL.
The contentUri
header parameter allows the client to specify the URI of a product stored remotely/externally (relative to DDF). The contentUri
header parameter is only used with the PUT
and DELETE
RESTful URLs where the contentId
is not appended to the URL.
Sample Requests and Responses
The table below illustrates sample REST requests and their responses for each of the operations supported by the Content REST Endpoint.
For the examples below, DDF was running on host DDF_HOST on port DDF_PORT. Also, for all examples below the binary data, i.e., the "content", is not included in the request's body.
Operation | Request | Response |
---|---|---|
Create Content and Catalog Entry |
|
|
Create Content Only |
|
|
Create Catalog Entry Only |
|
|
Update Content and Catalog Entry |
<content included in payload but omitted here for brevity> |
|
Update Content Only |
<content included in payload but omitted here for brevity> |
|
Update Catalog Entry Only |
<content included in payload but omitted here for brevity> |
|
Delete Content and Catalog Entry |
|
|
Delete Content Only |
|
|
Delete Catalog Entry Only |
|
|
Read |
|
... (remaining data of content item retrieved omitted for brevity) ... |
cURL Commands
The table below illustrates sample cURL commands corresponding to a few of the above REST requests. Pay special attention to the flags, as they vary between operations.
For these examples, DDF was running on host DDF_HOST on port DDF_PORT. We ingested/updated a file named geojson_valid.json whose MIME type was application/json;id=geojson, and whose content ID ended up being CONTENT_ID.
To perform each operation without using the catalog, replace STORE_AND_PROCESS
with STORE
, and to manipulate the catalog entry only, replace it with PROCESS
.
Operation | Command |
---|---|
Create Content and Catalog Entry | curl -i -X POST -F "directive=STORE_AND_PROCESS" -F "filename=geojson_valid.json" -F "file=@geojson_valid.json;type=application/json;id=geojson" http://DDF_HOST:DDF_PORT/services/content/ |
Update Content and Catalog Entry |
|
Delete Content and Catalog Entry |
|
Read |
|
Installation and Uninstallation
The Content REST CRUD Endpoint, packaged as the content-rest-endpoint
feature, can be installed and uninstalled using the normal processes described in the Configuration section.
Configuration
The Content REST CRUD Endpoint has no configurable properties. It can only be installed or uninstalled.