Unified API Developer Manual / Version 2512.0
Table Of ContentsBefore working with the Unified API, a connection to the server must be opened. The connection object implements the interface com.coremedia.cap.common.CapConnection. There are a number of static methods in the class com.coremedia.cap.Cap that allow you to specify various sets of parameters for logging on to Content Server and Workflow Server.
The CoreMedia system supports gRPC and CORBA for internal communication. While servers always offer both protocols for clients to connect, clients can be configured to use either gRPC or CORBA. The protocol can be chosen freely on each start of a component. Currently, CORBA is the default protocol.
Note
With release 2512.0 of the CoreMedia system, the Workflow Server does not yet offer gRPC services to its clients. Activating gRPC on Unified API clients won't do any harm as long as these are of release 2512.0, too. Future clients, though, will fail to connect to that Workflow Server if gRPC is active on them.
Keep this in mind when operating a mixed-release CoreMedia system setup. In such scenarios (e.g., during upgrades), it is recommended to leave clients in their default protocol mode which is CORBA.
Passing Parameters Directly (CORBA only)
A classic way of opening a CORBA connection is provided by a method of the class com.coremedia.cap.Cap with four parameters:
The IOR URL of the Content Server
The name of the user who logs in
The user's domain
The user's password
All parameters are passed as string values. The IOR URL is explained in more detail in the Operations Basics Manual. It is a means for bootstrapping the CORBA protocol.
String url = "http://localhost:40180/ior"; CapConnection connection = Cap.connect(url, "user", "domain", "secret");
The login call will fail with an exception if the Content Server is not reachable. A connection to the Workflow Server is also opened, if the Workflow Server is reachable, but its absence does not abort the login sequence.
Because the IOR URL is cumbersome to write, the Unified API uses some rules for determining this parameter when it is omitted.
CapConnection connection = Cap.connect(null, "user", "domain", "secret");
If the system property coremedia.content.server.url is set, its value is used
as the URL. Else, if the system property coremedia.configpath is set, the
system tries to determine the URL from the file capclient.properties. Because
the latter property is automatically set by the cm start script, there is no
need to configure the URL when the Unified API client is
started by means of a .jpif file.
When you use the built-in user repository of CoreMedia
CMS and not an LDAP server for managing your users, you can set the domain
parameter to null or omit it entirely.
CapConnection connection = Cap.connect(url, "user", "secret");
Passing Parameters as a Map (CORBA and gRPC)
This is the recommended way of configuring and opening a connection. It covers both CORBA and gRPC connections and allows for specification of connection parameters through environment variables which is the preferred approach in Docker or Kubernetes environments.
You can pass a java.util.Map to the login method. The keys are typically chosen from a number of
constants defined in the class Cap. The values in the map are normally strings.
When working purely with environment variables, this map can be left empty but it must not be null.
Map<String,?> params = new HashMap<>(); params.put(Cap.CONTENT_SERVER_URL, "http://localhost:40180/ior"); params.put(Cap.WORKFLOW_SERVER_URL, "http://localhost:40380/ior"); params.put(Cap.USER, "admin"); params.put(Cap.DOMAIN, ""); params.put(Cap.PASSWORD, "admin"); CapConnection connection = Cap.connect(params);
In the previous example for CORBA, you can see that the initial workflow server URL is explicitly passed as a parameter. Normally this is not required, because the Content Server acts as a naming service and provides the necessary information for connecting to other servers. However, in complex setups with multiple firewalls and connection redirection, it may be necessary that different clients connect via different URLs.
An example for connecting via gRPC looks like this:
Map<String,?> params = new HashMap<>();
params.put("spring.grpc.client.channels.cap.address", "localhost:40165");
params.put(Cap.HTTP_BASE_URI, URI.create("http://localhost:40180"));
params.put(Cap.USER, "admin");
params.put(Cap.DOMAIN, "");
params.put(Cap.PASSWORD, "admin");
params.put(Cap.USE_WORKFLOW, "false");
CapConnection connection = Cap.connect(params);
Here, no connection to the Workflow Server is included. For details on using the Workflow Server with gRPC connections, see below.
In the following, you will find summarized the available properties. All names prefixed with
Cap. refer to constants in class com.coremedia.cap.Cap.
Note
To enable gRPC on a Unified API client, either environment variable REPOSITORY_USEGRPC=true must
be specified or Java System Property repository.use-grpc=true be passed to the client
application. This is to clearly separate modes of operation.
| Name | Value | Default | Description |
|---|---|---|---|
|
| URL string | (determined heuristically) | the IOR URL of the Content Server. This property is
only required if CORBA is to be used. As the Workflow Server in release
2512.0 does not yet offer gRPC services, this property is also required when connecting to a
Workflow Server in that release. You may also set it via environment variable
REPOSITORY_URL when starting your client application and leave it from the property map.
|
|
| URL string | (fetched from the Content Server) | the IOR URL of the Workflow Server. This property is
only required if CORBA is to be used. You may also set it via environment variable
REPOSITORY_WORKFLOW_URL when starting your client application and leave it from the property map.
|
|
| gRPC endpoint string | localhost:9090 | the gRPC endpoint of the Content Server. This property is
only required if gRPC is to be used. There is no constant in class Cap for this
property. You may also set it via environment variable SPRING_GRPC_CLIENT_CHANNELS_CAP_ADDRESS
when starting your client application and leave it from the property map.
|
|
| HTTP base URI or URI string | (derived from IOR URL of the Content Server if given, empty otherwise) | the HTTP base URI of the Content Server for
non-CORBA/gRPC services (e.g., Blob Download) . This property is
only required if gRPC is to be used. You may also set it via environment variable
REPOSITORY_HTTPBASEURI when starting your client application and leave it from the property map.
|
|
| gRPC endpoint string | localhost:9090 | the gRPC endpoint of the Workflow Server. This property is
only required if gRPC is to be used. It is not effective in release 2512.0 as the
Workflow Server does not yet offer gRPC services in that release.
There is no constant in class Cap for this
property. You may also set it via environment variable SPRING_GRPC_CLIENT_CHANNELS_WF_ADDRESS
when starting your client application and leave it from the property map.
|
|
| string | N/A | the name of the user to log in. You may also set it via environment variable
REPOSITORY_USER when starting your client application and leave it from the property map.
|
|
| string | "" | the domain of the user to log in. You may also set it via environment variable
REPOSITORY_DOMAIN when starting your client application and leave it from the property map.
|
|
| string | N/A | the password of the user to log in. You may also set it via environment variable
REPOSITORY_PASSWORD when starting your client application and leave it from the property map.
|
|
| "true", "false", "" | "" | whether the Workflow Serverr should be
connected; if "true", the connection is required; if "", the connection is optional;
if "false", no connection attempt is made. You may also set it via environment variable
REPOSITORY_WORKFLOW_CONNECT when starting your client application and leave it from the property map.
|
|
| an | (created automatically) | the ORB for setting up the CORBA connection. This property is only effective if CORBA is to be used. |
|
| string | (built-in factory) | the name of a class implementing the interface CapConnection.ConnectionFactory.
It must be left unset if gRPC is to be used.
|
|
| string | true | if true, the session token for connection to Content Server servlets (for blob up/download and
CPU usage) will be sent as a URL query parameter. Otherwise, it will be sent as a request field.
While sending the token as a query parameter is inherently insecure, it is the default to
keep backward compatibility. Unless connection to an older server (prior to CMCC 13) is required,
it is recommended to set this property to false.
|
Table 4.1. Connection properties
You can also create a connection without opening it immediately. Here you may pass a number of parameters by means of a map, but you can set additional parameters later before opening the connection. Example for CORBA:
Map<String, ?> params = new HashMap<>();
params.put(Cap.CONTENT_SERVER_URL, "http://localhost:40180/ior");
CapConnection connection = Cap.prepare(params);
connection.setUser("admin");
connection.setPassword("admin");
connection.open();
The methods that are available for setting the parameters of a connection are
setUrl(..),setUser(...),setDomain(...), andsetPassword(...).
Passing Parameters for CORBA Connection in Server URL
While flexible, the creation of a map takes some lines of code, so that CoreMedia provides a simple method that works in many cases. The additional parameters beside the Content Server URL are inlined as URL parameters in that URL. This permits the compact configuration via a single string.
String url = "http://localhost:40180/ior"+ "?user=admin&password=admin&useworkflow=false"; CapConnection connection = Cap.connect(url);
Here the workflow component has been disabled entirely by the means of
useworkflow=false. This reduces the resource requirements when the workflow
connection is not needed at all.
Individual parameters are separated by ampersands (&), the entire set of
parameters is separated from the IOR URL by a question mark (?). The constant values in
class com.coremedia.cap.Cap define the possible parameter keys. Among those are, e.g.:
workflowurl,user,domain,password,useworkflow.
Note that the well-known parameters are removed from the URL before it is resolved over the network. In particular, the password is not transmitted in clear text.


