Configuring REST ServicesArticle Link

 

Author: Eike Stepper

CDO Graph REST exposes selected repositories as typed, revision-based object graphs over HTTP. The transport-neutral service reads native CDO revisions and submits modifications through the ordinary repository commit path. Its REST wire contract is version 1.0.0 at /api/cdo/v1. The REST wire version does not track CDO bundle or Maven artifact versions.

This guide covers installation, repository exposure, transports, access protection, service limits, and discovery. Implementation concepts and lifecycle are described in the REST Architecture article. The endpoint and schema contract is available from the generated REST API Reference and from the service's static OpenAPI document.

Application developers can follow the practical tutorial in Developing REST Applications.

Table of Contents

1 Installing and selecting REST components
2 Configuring repository exposure
3 Serving explicitly configured static resources
4 Configuring service limits
5 Selecting transports and TLS
6 Discovering the API and understanding commit behavior

1  Installing and selecting REST componentsChapter Link

The org.eclipse.emf.cdo.server.rest feature installs the REST core and its Jetty Core and Jakarta Servlet adapters. Maven deployments use the same three artifacts: org.eclipse.emf.cdo.server.rest contains the transport-neutral service, org.eclipse.emf.cdo.server.rest.jetty provides the native Jetty adapter, and org.eclipse.emf.cdo.server.rest.servlet.jakarta integrates with a Jakarta Servlet container. Import the CDO project-release BOM to obtain their Maven artifact versions. The REST wire version and OSGi bundle versions remain independent coordinates.

Select the core with the adapter required by the deployment. The Jetty adapter does not require Jetty EE or a Servlet API. The Jakarta Servlet adapter leaves its API to the host container. The REST core does not depend on either adapter.

A programmatic embedding supplies an explicit IRepositoryProvider. Its aliases define which repositories REST can expose. Applications can construct a CDORestService, optionally pass a mutable CDORestConfiguration, activate the service, and call service(CDORestRequest, CDORestResponse) from their own HTTP adapter. The service starts only transports added with addTransport(CDORestTransport); a customer-owned adapter retains ownership of its listener. Activate the service before forwarding requests. See REST Architecture for repository-session and request-state management.

See Also:

2  Configuring repository exposureChapter Link

Add a rest contribution inside each repository that should be exposed. The service name groups contributions into one service and listener; the alias is the REST route name. Repositories without an explicit contribution are not exposed through that service. Contributions to one service must use the same transport and limit settings. An authenticator is configured separately for each repository alias. An alias without an authenticator remains anonymous only when no CDO permission manager protects its repository; exposing a protected repository without an authenticator is rejected.

The following XML example      
<cdoServer>

  
<!-- An unprotected repository with no authenticator is accessible anonymously. -->
  
<repository name="repo1">
    
<store type="db"/>
    
<rest service="company-api" alias="company"
        maxRequestBytes=
"1048576" maxOperations="1000" maxGraphObjects="10000" userIDRetentionTimeout="-1">
      
<transport type="jetty" host="127.0.0.1" port="8080" path="/cdo" tls="false"/>
    
</rest>
  
</repository>

  
<!-- This repository has CDO authorization; each REST request is mapped to a CDO user ID by its bearer token. -->
  
<repository name="repo2">
    
<store type="db"/>
    
<securityManager type="default" description="/security:annotation:home(/home)">
      
<permissionCache type="default"/>
    
</securityManager>
    
<rest service="company-api" alias="catalog"
        maxRequestBytes=
"1048576" maxOperations="1000" maxGraphObjects="10000" userIDRetentionTimeout="0">
      
<authenticator type="bearer">
        
<token value="$$$system_property(cdo.rest.token)$$$" userID="$$$system_property(cdo.rest.userID)$$$"/>
        
<token value="$$$system_property(cdo.rest.backupToken)$$$" userID="$$$system_property(cdo.rest.userID)$$$"/>
      
</authenticator>
      
<transport type="jetty" host="127.0.0.1" port="8080" path="/cdo" tls="false"/>
    
</rest>
  
</repository>

  
<!--
    For a host transport that supplies an authenticated Servlet principal, select:
    <authenticator type="principal"/>
    The standalone Jetty transport does not create a principal by itself.
  -->


</cdoServer>

exposes two repository aliases through one loopback listener.

A repository provider may also be supplied programmatically. Enumerable providers make their configured aliases available at GET /api/cdo/v1/repositories; lookup-only providers still support direct routes. The userIDRetentionTimeout attribute controls permission-manager identity state in milliseconds: -1 retains it until the REST session is deactivated, 0 releases it when the last concurrent request completes, and a positive value releases it after that much inactivity. The default is -1; values below -1 are invalid.

See Also:

3  Serving explicitly configured static resourcesChapter Link

The standalone Jetty transport can serve selected public files beside its REST context. Add one static child for each directory; for example . An embedder can configure the same mapping before activation with server.addStaticResource(new StaticResourceMapping("/company", "/opt/cdo/web/company")). The resource base is resolved as a filesystem path by the server process and must be an existing readable directory. In the configured-server Maven example, cdo.web.company.path is forwarded to the server JVM and defaults to the example's web/company directory, independently of Maven's invocation directory. Multiple distinct non-nested paths are supported. The REST context and static paths must not collide. Static resources use index.html as the welcome file, disable directory listings, and are served by Jetty's resource handler with its MIME type mapping.

Static contexts share the listener's bind address, port, and TLS configuration, so the web application and REST API can be same-origin. Static content is public: it does not use a repository authenticator and does not inherit CDO object permissions. Expose only dedicated web directories; do not point a mapping at configuration, database, credential, or general server directories. These mappings belong to the standalone Jetty adapter, not to the transport-neutral Graph REST API. See Developing REST Applications for the Company editor tutorial.

4  Configuring service limitsChapter Link

A mutable CDORestConfiguration can be adjusted with its setters before it is passed to a service. The service adopts a defensive copy, so later caller changes do not alter the running service. XML attributes on rest override the effective system-property values. Defaults are read through OMPlatform.INSTANCE.getProperty(...) once when CDORestConfiguration is initialized. Limits use -1 to disable them, and depth and offset limits may also be zero. The default collection limit may be -1 for an unbounded page; a finite maximum collection limit caps the effective default. Graph reads remain subject to the maximum graph-values limit. The response from GET /api/cdo/v1/capabilities reports the effective values in its nested limits object.

The system properties and fallback values are:

Read requests default to containment depth one, non-containment reference depth zero, and a collection page of 100 values unless configured otherwise. The revision reference chunk controls partial collection loading and defaults to 64. XML attributes use the same setting names without the property prefix. Operation limits constrain the supplied HTTP request and response traversal; they do not impose extra limits on the number of existing CDO objects or descendants affected indirectly by an otherwise valid repository modification.

5  Selecting transports and TLSChapter Link

The native Jetty adapter owns its listener when configured as a REST transport. It binds to loopback by default, accepts an explicit host and port, and can use TLS with the existing JSSE keystore configuration. TLS is an operator choice independent of the bind address; a non-loopback HTTP listener can be used behind a protected reverse proxy or network boundary. The Jakarta Servlet adapter is mounted by its host and uses the host's listener, TLS, and lifecycle configuration.

The service supports repository-specific authentication. The built-in bearer authenticator checks each request's bearer token against configured token mappings and maps it to an opaque CDO user ID. Configure token values through trusted deployment properties or a secret store; REST does not issue, rotate, or refresh tokens. Static bearer credentials must be sent only over TLS because anyone who can observe a token can replay it. JWT validation is not built in; applications can integrate an external identity provider through a custom CDORestAuthenticator. Such an implementation can be registered with an AnnotationFactory in the org.eclipse.emf.cdo.server.rest.authenticators product group and selected by its factory type in XML.

Authentication maps a request credential or a trusted transport principal to a CDO user ID. Authorization is a separate decision made by the repository's existing permission manager. The built-in principal authenticator uses the exact name from CDORestRequest.getPrincipal(); the Jakarta Servlet adapter supplies the host container's HttpServletRequest.getUserPrincipal(), while arbitrary identity headers are never trusted. Use it only when the host transport actually supplies an authenticated principal.

The authenticator runs for every repository-specific request. Identity retention only reuses permission-manager user information and caches; it does not cache successful authentication or extend credential validity. Reads evaluate the effective permission at the selected branch point. A revision with permission NONE is still returned with its object identity and type, but protected features and ordinary metadata are omitted; CDO resource path features remain available for namespace navigation. The optional metadata=permission selection reports the effective NONE, READ, or WRITE permission. Denied writes return HTTP 403 and continue to use native CDO commit authorization. Missing or invalid credentials return HTTP 401 and may include WWW-Authenticate. Public discovery and OpenAPI remain accessible.

Use the repository provider and XML contributions to limit which aliases are reachable. TLS protects transport confidentiality and integrity; it does not decide which caller may access a CDO object.

See Also:

6  Discovering the API and understanding commit behaviorChapter Link

Clients can fetch discovery data from /.well-known/cdo-rest, effective limits from /api/cdo/v1/capabilities, and the canonical OpenAPI 3.1 document from /api/cdo/v1/openapi.json. The OpenAPI specification is served from the REST core bundle and the generated HTML reference is packaged by the CDO documentation bundle.

Graph reads use a captured branch point for repositories with auditing. A reduced read remains HTTP 200 and omits features the caller cannot read; it does not mutate the shared cached CDO revision. Clients can request effective permission metadata with metadata=permission. Non-auditing repositories provide current snapshot reads but cannot guarantee that separately loaded revisions all reflect the same instant during concurrent commits. Historical reads require auditing. REST modification batches use ordinary CDO commit validation, notifications, and optimistic conflict handling. Once the repository commit succeeds, a later HTTP response-stream failure does not roll back that commit.