Skip to content

Allow modifiying the id of a hosted annotation id#1209

Merged
JackLewis-digirati merged 6 commits into
developfrom
feature/hostedAdjunctId
Jun 2, 2026
Merged

Allow modifiying the id of a hosted annotation id#1209
JackLewis-digirati merged 6 commits into
developfrom
feature/hostedAdjunctId

Conversation

@JackLewis-digirati
Copy link
Copy Markdown
Collaborator

@JackLewis-digirati JackLewis-digirati commented Jun 2, 2026

What does this change?

Resolves #1194

This PR makes it so that hosted annotations (whether ambient or not) have their id values rewritten to match the id coming from protagonist. An example of this would be the following json:

{
  "@context": "http://iiif.io/api/annotation/3/context.json",
  "id": "random id",
  "type": "AnnotationPage",
  "items": []
}

being rewritten to:

{
  "@context": "http://iiif.io/api/annotation/3/context.json",
  "id": "<orchestrator base url>/adjuncts/26/1/asset-id/adjunct-id",
  "type": "AnnotationPage",
  "items": []
}

based on the asset being asset-id and the adjunct being adjunct-id. This will also work for rewritten paths. For example, changing the default of adjuncts to supplementing would see the id rewritten to "<orchestrator base url>/supplementing/26/1/asset-id/adjunct-id"

This works by streaming the object in and then rewriting the top level id to avoid additional processing time of fully deserializing the object

Note

The code from this PR closely resembles the work written to do similar in iiif-presentation

Note

If the id property is not present, it will be added

Settings

new setting added:

orchestratorSetting
"MaxAdjunctSizeBytes"

This controls that if an adjunct is larger than the MaxAdjunctSizeBytes (defaults to 5MB), then a 500 will be returned from orchestrator

@JackLewis-digirati JackLewis-digirati changed the title Initial commit for modifiying a hosted anootation id Initial commit for modifiying a hosted anotation id Jun 2, 2026
@JackLewis-digirati JackLewis-digirati changed the title Initial commit for modifiying a hosted anotation id Allow modifiying the id of a hosted annotation id Jun 2, 2026
@JackLewis-digirati JackLewis-digirati marked this pull request as ready for review June 2, 2026 11:06
@JackLewis-digirati JackLewis-digirati requested a review from a team as a code owner June 2, 2026 11:06
@JackLewis-digirati
Copy link
Copy Markdown
Collaborator Author

JackLewis-digirati commented Jun 2, 2026

What this PR does

Implements #1194 — sets the correct "id" value on hosted annotation adjuncts served by the Orchestrator.

Approach

A reusable token-by-token streaming JSON pipeline is introduced in Orchestrator/Infrastructure/IdRewriter/:

  • IJsonProcessor / StreamingProcessorBase<T> — dispatch each JSON token to virtual overrides
  • StreamingJsonProcessor — drives the read/write loop (synchronous due to ref struct + async limitations in C# < 13)
  • TopLevelIdRewriteProcessor — rewrites (or injects) the top-level "id" property to a supplied value

AdjunctRequestHandler detects when a request targets an Annotations adjunct, builds the correct id path (query params excluded), and returns an IdRewriteProxyActionResult. AdjunctRouteHandlers.RewriteAndStreamAdjunct then fetches the object from S3, runs it through the processor, and streams the result to the HTTP response. Any failure (missing S3 object or malformed JSON) returns a 500.

Comment thread src/protagonist/Orchestrator/Infrastructure/ReverseProxy/ProxyActionResult.cs Outdated
Comment thread src/protagonist/Orchestrator/Features/Adjuncts/AdjunctRouteHandlers.cs Outdated
Comment thread src/protagonist/Orchestrator/Features/Adjuncts/AdjunctRequestHandler.cs Outdated
Comment thread src/protagonist/Orchestrator.Tests/Integration/AdjunctHandlingTests.cs Outdated
- remove InlineAnnotation
- add setting for guard
- return 404 for missing adjunct instead of 500
- extract helper function for setting the new id
@JackLewis-digirati JackLewis-digirati merged commit cab2006 into develop Jun 2, 2026
8 checks passed
@JackLewis-digirati JackLewis-digirati deleted the feature/hostedAdjunctId branch June 2, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set "id" on hosted annotation adjunct

2 participants