Collaboration Context
Introduction
The Collaboration Context feature enables domain users to work with records in isolated collaboration namespaces and maintaining data integrity in the OSDU.
This feature allows teams to:
- Consume quality data from the OSDU
- Share data within teams
- Control how and what data is shared back
- Maintain data integrity while enabling collaboration
Key Concepts
- Collaboration Context: A namespace that isolates records from the Source of Record (SOR) namespace
- x-collaboration Header: HTTP header that specifies the collaboration context for API requests
- Message Topics: Separate messaging topics for collaboration and non-collaboration messages
Collaboration behavior
The collaboration feature is available without a dedicated feature flag.
- Requests with
x-collaborationheader are handled in collaboration context - Requests without
x-collaborationheader continue to use the default non-collaboration behavior
Collaboration Header format
x-collaboration: id=<collaboration-uuid>,application=<application-name>
Example:
x-collaboration: id=7d34b896-6b55-40e0-a628-e696f3c00000,application=pws
Architecture
Collaboration filter
The CollaborationFilter can exclude certain paths from collaboration validation:
Default Excluded Paths:
- info
- swagger
- health
- api-docs
Custom Configuration:
collaborationFilter.excludedPaths=info,health,liveness_check,swagger,swagger-ui/swagger-ui.css,swagger-ui/swagger-ui-standalone-preset.js,api-docs,api-docs.yaml,api-docs/swagger-config
Topics
-
recordstopic (V1): Existing topic for non-collaboration messages, SOR namespace only, for backward compatibility
-
recordstopic-v2 (V2): New topic for collaboration messages, includes
x-collaborationattribute when applicable, Collaboration + SOR messages
Indexer-Queue (if applicable)
The Indexer-Queue service subscribes to both V1 and V2 topics, queues messages in a single queue, and sends them to the Indexer service push API.
Indexer
The Indexer service handle collaboration and non-collaboration messages based on
the x-collaboration attribute. It adds a prefix to document IDs and includes a "Collaboration"
property for collaboration records.
Search Service
Search service supports the optional x-collaboration header to search within specified collaboration namespaces.
Data Isolation
Records in collaboration contexts are isolated through:
- Document ID Prefixing: Elasticsearch document IDs include collaboration context
- Example:
osdu:master-data--CollaborationProject:xxx:id=a99cef48-2ed6-4beb-8a43-002373431f21,application=pws - Metadata Field:
x-collaborationfield in Elasticsearch documents - Query Filtering: Search queries automatically filter by collaboration context
Configuration Guide
# Feature flag strategy. appProperty - get value from environment variable, dataPartition - get value from Partition service
featureFlag.strategy=appProperty
# Topic configuration
records-changed-topic-name=${RECORDS_CHANGED_TOPIC_NAME:records-changed}
records-changed-v2-topic-name=${RECORDS_CHANGED_V2_TOPIC_NAME:records-changed-v2}
Infrastructure Setup
recordstopic-v2topic for collaboration messages- Notification service related V2 topics (service, publishing, retry, dead-letter topics)
Collaboration Context adoption
All APIs in storage service can be collaboration context-aware. Please refer to the
Collaboration Integration tutorial for further implementation details.
The x-collaboration header is supported without a dedicated collaboration feature flag.
In order to use storage apis in a collaboration context, the API user needs to add a x-collaboration HTTP header to the requests. The header holds directives instructing the OSDU to handle in context of the provided collaboration instance and not in the context of the promoted or trusted data.
Sample implementation to integrate with records changed messages
Please refer to this MR for the original Azure implementation.
Consumers who want to integrate with record change messages that include changes made within a collaboration context need to register the records to the new topic "recordstopic-v2". Refer the DataNotification.md file for details about the recordstopics-v2.
This topic exists in addition to the current record changed topic and receives collaboration-aware messages.
In summary:
1. A request with x-collaboration header sends a message to recordstopic-v2.
2. A request without x-collaboration header continues to send a message to recordstopic.
The message contains the collaboration context header as an atribute when a change is made in context of a collaboration.
Example of a message when the x-collaboration header is provided -
{
"message": {
"data": [
{
"id": "opendes:wellbore:f213e42d5fa848f592917a8df7fed132",
"version": "1617915304347525",
"modifiedBy": "abc@xyz.com",
"kind": "common:welldb:wellbore:1.0.0",
"op": "create"
}
],
"account-id": "opendes",
"data-partition-id": "opendes",
"correlation-id": "5t3c153e-8f03-4295-8b1a-edaae86dfafa",
"x-collaboration": "id=7d34b896-6b55-40e0-a628-e696f3c00000,application=app"
}
}
Example of a message when the x-collaboration header is not provided -
{
"message": {
"data": [
{
"id": "opendes:inttest:1674654754283",
"kind": "opendes:wks:inttest:1.0.1674654754283",
"op": "create"
}
],
"account-id": "opendes",
"data-partition-id": "opendes",
"correlation-id": "2715a1b8-2ffb-406f-839c-6e6bfed27e5c"
}
}
HTTP header syntax
- Caching directives are case-insensitive but lowercase is recommended
- Multiple directives are comma-separated
Request directives
| Directive | Optionality | Description |
|---|---|---|
| id | Mandatory | ID of the collaboration to handle the request against. |
| application | Mandatory | Name of the application sending the request |
| other directives | Optional | Other directives include but not limited to transaction ID to handle this request against. The transaction must exist and be in an active state on the collaboration |
Example requests
GET the latest version of a record in collaboration context
curl --request GET \
--url '/api/storage/v2/records/{id}'\
--header 'accept: application/json' \
--header 'authorization: Bearer <JWT>' \
--header 'content-type: application/json' \
--header 'Data-Partition-Id: opendes' \
--header 'x-collaboration: id=9e1c4e74-3b9b-4b17-a0d5-67766558ec65,application=Test app'\
CREATE or UPDATE a new record in a collaboration context
curl --request PUT \
--url '/api/storage/v2/records' \
--header 'authorization: Bearer <JWT>' \
--header 'content-type: application/json' \
--header 'Data-Partition-Id: opendes' \
--header 'x-collaboration: id=9e1c4e74-3b9b-4b17-a0d5-67766558ec65,application=Test app' \
--data '[{
"id": "data-partition-id:hello:123456",
"kind": "schema-authority:wks:hello:1.0.0",
"acl": {
"viewers": ["data.default.viewers@data-partition-id.[osdu.opengroup.org]"],
"owners": ["data.default.owners@data-partition-id.[osdu.opengroup.org]"]
},
"legal": {
"legaltags": ["data-partition-id-sample-legaltag"],
"otherRelevantDataCountries": ["FR","US","CA"]
},
"data": {
"msg": "Hello World, Data Ecosystem!"
}
}]'
Excluded Paths
CollaborationFilter, when used with the data partition strategy, makes a call to Partition service. This call requires data-partition-id header, which is not passed/required for certain apis (info, swagger, health, etc)
We can short-circuit the CollaborationFilter class when url contains one of these paths.
Property used (CSP Specific)
- Default paths if not specified : [ info,swagger,health,api-docs ]
- customized using collaborationFilter.excludedPaths=info,swagger,health,api-docs
Additional information
- ADR: Namespacing storage records
- ADR - Project & Workflow Services - ADR Summary
- ADR - Project & Workflow Services - Core Services Integration - Solution Overview
- ADR - Project & Workflow Services - Core Services Integration - Collaboration Service
- ADR - Project & Workflow Services - Core Services Integration - E&O
- ADR - Project & Workflow Services - Core Services Integration - Search Service Support
- ADR - Project & Workflow Services - Core Services Integration - Copy Record references between namespaces
- ADR - Project & Workflow Services - Application Integration
- ADR - Project & Workflow Services - Namespace-per-Kind & Kind-per-Namespace inventory features
- PWS Project