# A Query Validator for the Common Services of the Once-Only Technical System
_The Once-Only Technical System (OOTS) enables Member States of the European
Union (EU) to exchange evidences such as diplomas, birth certificates, and
business permits. Its legal foundation is the Single Digital Gateway (SDG)
Regulation ([Regulation (EU) 2018/1724](eu2018/1724)). At the heart of the OOTS
are the Common Services (CS): three registries that store information about
where evidences can be found, when they are required, and how they relate to
each other._
_In this memo, I present a lightweight validator for query requests to the CS:
the OOTS CS Query Validator (OCQV). The development of the OCQV is intended to
deepen my understanding of the technical design of these registries and to
enable independent testing of query requests without relying on the
availability of the actual CS endpoint. It validates whether requests to the CS
conform to the documented interface and structure, and reports the results in a
structured XML format._
> **Acknowledgement:** At the time of writing this memo, I serve as the
> designated National Coordinator (NC) for the SDG on behalf of the
> Netherlands. However, the work that led to this memo and the associated
> software was carried out in my own time and is not supported or endorsed by
> the Netherlands or the European Commission (EC) in any way.
>
> While I do have access to information beyond what is publicly available due
> to my role as NC SDG, this memo and the software are based solely on public
> sources, which are cited accordingly. For the standing policy, please refer
> to my [vision on the SDG in the Netherlands][vision] (only available in
> Dutch).
## Specification
Before implementing the OCQV, I first need to understand how the CS of the OOTS
are intended to communicate the information they contain. The CS are described
at a technical level in documentation available on the [OOTS Hub][hub]. To make
my own life a bit easier, I've reproduced here the descriptions of the three CS
registries, as presented on the OOTS Hub:
- The **Data Service Directory** (DSD):
> "The Data Service Directory maintains a catalogue of evidence providers
> with the evidence types they are able to provide upon request using their
> Data Services. It is used in the evidence exchange process by the evidence
> requesters to discover the evidence providers that can provide the
> evidences they require, and the required metadata."
- The **Evidence Broker** (EB):
> "The Evidence Broker publishes which types of evidence Member States can
> provide to prove a particular requirement of a procedure. Using the mapping
> from criteria or information requirements to possible evidence types, it
> can find the evidence types that can prove that the User fulfils the
> requirements of the procedure."
- The **Semantic Repository** (SR):
> "The Semantic Repository provides commonly agreed semantic specifications
> for the exchange of evidences. The service provides the following
> functionalities: ability to externally reference data models from other
> components; ability to define and extract subsets of models; provision of
> documentation."
### Queryable Registries
The DSD and EB expose a REST API based on the [OASIS ebXML RegRep V4][oasis]
standard. This standard defines a protocol for querying using HTTP `GET`
requests at each URL following a specific pattern:
```text
/rest/search?queryId=(&=)*
```
This means that each possible query has its own identifier (ID). Before listing
each available ID, it is useful to note that they follow a consistent structure
(where `` is either `dsd` or `eb`):
```text
urn:fdc:oots::ebxml-regrep:queries:
```
Specifying the ID is mandatory, even though this diverges from the OASIS
specification, which states that the ID defaults to
`urn:oasis:names:tc:ebxml-regrep:query:FindObjectById` if omitted. All other
parameters are optional. The [OOTS API documentation][oots] confirms this: the
DSD and EB are only partial implementations of a RegRep server. As such,
several canonical queries and parameters defined by the RegRep standard are not
available and will result in an error. Therefore, I can limit my investigation
to the OOTS-specific documentation alone.
#### Data Service Directory
The DSD exposes a single endpoint for querying data services. Each query has
mandatory and optional parameters (with names that use a mixture of camelCase
and snake-case conventions). In the overview below, optional parameters are
displayed in _italics_.
| Query | Parameter | Description |
|:-----------------------------------------|:-------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| Find Data Services of Evidence Providers | `queryId` | `requirements-by-procedure-and-jurisdiction` |
| | `evidence-type-classification` | The classification code, encoded as a URL according to [RFC 3986][rfc3986]. Retrieved from the EB. |
| | `country-code` | The jurisdiction of the procedure, expressed using the [EEA Country subset of the ISO 3166-1 alpha-2][iso3166-1a2-eea] country code standard. |
| | _`jurisdiction-admin-l2`_ | Second-level administration code, expressed as a [NUTS code][nuts]. |
| | _`jurisdiction-admin-l3`_ | Third-level administration code, expressed as a [LAU code][lau]. |
| | _`jurisdiction-context-id`_ | Only required when responding to a DSD exception, in which case its value is specified. |
| __ | _`specification`_ | The profile used to present the result of the query. Defaults to the OOTS EDM if not specified. |
#### Evidence Broker
The EB exposes two endpoints for queries. It provides the data that is used to
query both evidence types in the EB itself, and data services in the DSD.
The EB queries are listed below in the same manner as for the DSD.
| Query | Parameter | Description |
|:-------------------------|:--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| Get List of Requirements | `queryId` | `requirements-by-procedure-and-jurisdiction` |
| | _`procedure-id`_ | A procedure code, as defined in the [procedures codelist][procedures]. |
| | _`country-code`_ | The jurisdiction of the procedure, expressed using the [EEA Country subset of the ISO 3166-1 alpha-2][iso3166-1a2-eea] country code standard. |
| | _`jurisdiction-admin-l2`_ | Second-level administration code, expressed as a [NUTS code][nuts]. |
| __ | _`jurisdiction-admin-l3`_ | Third-level administration code, expressed as a [LAU code][lau]. |
| Get Evidence Types | `queryId` | `evidence-types-by-requirement-and-jurisdiction` |
| | `requirement-id` | The requirement ID, encoded as a URL according to [RFC 3986][rfc3986]. Either known a priori or retrieved from the EB with a query. |
| __ | _`country-code`_ | The jurisdiction of the procedure, expressed using the [EEA Country subset of the ISO 3166-1 alpha-2][iso3166-1a2-eea] country code standard. |
### Semantic Repository
The SR exposes its semantic assets and associated metadata via HTTP, where each
asset has its own URI, as defined in [RFC 3986][rfc3986]. In practice, this
means that every asset has a path associated with it that is appended to the
domain of the SR. The live version that is hosted by the EC is found at
`sr.oots.tech.ec.europa.eu`. In the following overview I've compiled all
available asset types and their associated routing (i.e. the path used to access
an instance of such an asset).
| Asset | Path |
|-----------------------------|:----------------------------------------|
| Evidence | `/evidencetypeclassification/HR/` |
| Procedure | `/codelist/procedures/` |
| Requirement | `/requirements/` |
| Codelist | `/codelists/