Skip to content

Migrate GOPACS UFTP Participants API from V2 to V3#31

Merged
wborn merged 12 commits into
mainfrom
gopacs-participants-v3
Jun 3, 2026
Merged

Migrate GOPACS UFTP Participants API from V2 to V3#31
wborn merged 12 commits into
mainfrom
gopacs-participants-v3

Conversation

@Miggets7
Copy link
Copy Markdown
Contributor

@Miggets7 Miggets7 commented Apr 29, 2026

Closes #28.

Summary

  • Switch GOPACSHandler participant lookup from the V2 XML address book (/v2/participants/DSO?contractedEan=...) to the V3 JSON endpoint (GET /uftp-participants/v3/participants/{uftpDomainName}), with a Bearer token from the existing OAuth2 client-credentials flow (extracted into a shared fetchBearerToken() helper).
  • Add ParticipantView DTO mirroring the V3 response schema and update GOPACSAddressBookResource to the new endpoint and JSON content type.
  • Repoint DEFAULT_GOPACS_PARTICIPANT_URL to https://api.gopacs-services.eu (V3 host).
  • Introduce GOPACS_BROKER_URL (default https://clc-message-broker.gopacs-services.eu) and synthesise the per-participant outbound endpoint as ${GOPACS_BROKER_URL}/shapeshifter/api/v3/message. V3's ParticipantView no longer carries an endpoint field, so without this fallback UftpSendMessageService.send would NPE on outbound messages.
  • Bump shapeshifterVersion 3.2.2 → 3.5.0.

Per-ContractID / per-role handler registration via GET /participants/contracts/{contractId}/roles/{uftpRole} is intentionally out of scope (see issue #28) and can follow up if we ever need per-Capacity-Steering-Contract handling.

Deployment note

Any deployment that overrides GOPACS_PARTICIPANT_URL must be updated to the new V3 host:

  • Production: GOPACS_PARTICIPANT_URL=https://api.gopacs-services.eu (or unset to use the default).
  • Acceptance: GOPACS_PARTICIPANT_URL=https://api.acc.gopacs-services.eu.

If the broker host differs from the default, also set GOPACS_BROKER_URL accordingly.

Miggets7 added 10 commits April 22, 2026 11:57
Replaces the deprecated v2 list-by-EAN endpoint with the v3 lookup-by-domain
endpoint (GET /uftp-participants/v3/participants/{uftpDomainName}). The
response is now JSON with an Authorization header carrying a Bearer token.
- Default base URL changes from clc-message-broker.gopacs-services.eu to
  api.gopacs-services.eu (override via GOPACS_PARTICIPANT_URL, e.g.
  api.acc.gopacs-services.eu for acceptance).
- getParticipantInformation now calls the v3 by-domain endpoint with a
  Bearer token instead of listing all participants for an EAN. Adds 404
  handling for unknown domains; other non-2xx statuses log at SEVERE.
- Extract fetchBearerToken() so Shapeshifter's getAuthorizationHeader and
  the participant lookup share one OAuth2 flow.
- v3 ParticipantView has no endpoint field so the cached
  UftpParticipantInformation is constructed with endpoint=null.
Verified against shapeshifter-core 3.2.2 and 3.5.0 sources: the outbound
send path does new URI(participantInformation.endpoint()) with no null
guard, so endpoint=null NPEs every FlexOffer / FlexRequestResponse /
FlexOrderResponse. The NPE escapes the send service's try/catch. Also
corrects the library version (3.5.0 exists; it does not fix this).
@Miggets7 Miggets7 requested a review from wborn April 29, 2026 14:36
@Miggets7 Miggets7 added the Enhancement Improvement of an existing feature label Apr 29, 2026
@Miggets7 Miggets7 requested a review from a team May 20, 2026 10:00
@wborn wborn requested a review from Copilot June 3, 2026 08:54
@wborn
Copy link
Copy Markdown
Member

wborn commented Jun 3, 2026

@codex review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the EMS GOPACS UFTP participant lookup from the deprecated V2 XML address book endpoint to the V3 JSON participants API, aligning the integration with the upcoming V2 removal deadline. It also updates outbound routing by synthesizing a broker endpoint (since V3 participant responses no longer include an endpoint) and bumps the Shapeshifter dependency accordingly.

Changes:

  • Switch participant lookup to GET /uftp-participants/v3/participants/{uftpDomainName} (JSON) and add ParticipantView DTO for the V3 schema.
  • Extract OAuth2 client-credentials token acquisition into a shared fetchBearerToken() helper and use it for participant API authorization.
  • Introduce GOPACS_BROKER_URL (with default) and construct outbound send endpoint as ${GOPACS_BROKER_URL}/shapeshifter/api/v3/message; bump shapeshifterVersion to 3.5.0.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
gradle.properties Bumps Shapeshifter dependency version to support/align with the V3 migration.
ems/src/main/java/org/openremote/extension/ems/manager/gopacs/ParticipantView.java Adds a DTO matching the V3 participant response fields used by the handler.
ems/src/main/java/org/openremote/extension/ems/manager/gopacs/GOPACSHandler.java Implements V3 participant lookup with Bearer auth, introduces broker URL fallback, and reuses token acquisition logic.
ems/src/main/java/org/openremote/extension/ems/manager/gopacs/GOPACSAddressBookResource.java Updates the JAX-RS client interface to the V3 by-domain endpoint with JSON + Authorization header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d0da0342fc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@wborn
Copy link
Copy Markdown
Member

wborn commented Jun 3, 2026

It looks good to me but you might want to address the AI findings @Miggets7? Do you want to add test coverage in this PR or another one?

- Re-assert contracted-EAN scoping in processRawMessage: the V3 participant
  lookup resolves any sender domain, so a validly signed flex message from a
  participant outside this handler's contracted EAN could be applied to the
  asset. Drop FlexMessageType messages whose congestion point does not match
  the contracted EAN before any asset mutation or outbound reply.
- Skip the participant API call and return empty when no OAuth2 bearer token
  is available, instead of sending an invalid Authorization header.
- Warn when the outbound authorization header has no bearer token.
- Strip trailing slashes from GOPACS_BROKER_URL so the synthesised endpoint
  never contains a double slash.
@Miggets7
Copy link
Copy Markdown
Contributor Author

Miggets7 commented Jun 3, 2026

Thanks @wborn. Addressed the AI findings in 6479c1b:

  • Codex P1 (EAN scoping): Re-asserted contracted-EAN scoping in processRawMessage. The V3 participant lookup resolves any sender domain, so a validly signed flex message from a participant outside this handler's contracted EAN could otherwise be applied to the asset. FlexMessageType messages whose congestion point doesn't match the contracted EAN are now dropped before any asset mutation or outbound reply. Full per-contract/role scoping via the V3 contracts endpoint stays out of scope (issue [GOPACS] Migrate GOPACS UFTP Participants API from V2 to V3 #28).
  • Copilot (blank token): Participant lookup now short-circuits and returns empty (with a warning) when no OAuth2 bearer token is available, instead of calling the API with an invalid Authorization header. Also added a warning on the outbound signing path for the same case.
  • Copilot (trailing slash): GOPACS_BROKER_URL is now normalised (trailing slashes stripped) so the synthesised endpoint can't contain a double slash.

Test coverage will follow in a separate PR.

@wborn wborn merged commit 8bbb5e3 into main Jun 3, 2026
1 check passed
@wborn wborn deleted the gopacs-participants-v3 branch June 3, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GOPACS] Migrate GOPACS UFTP Participants API from V2 to V3

3 participants