Skip to content

Conversation

runeflobakk
Copy link
Member

Using XML Schema choice to either allow for the old singular document syntax with all textual information in the document (title, non-sensitive title, description), or to specify the textual info for the entire job, and allow multiple documents each with its own title.

This allows us to transition to new structure in the API for multiple documents, while also supporting the old syntax, and be able to validate this structure as well on the API-level.

As Java does not have support for such "sum typing", the generated JAXB-code can not be a perfectly tight fit, so we employ some tricks to have unmarshalled legacy messages to "magically" be viewed as the new structure. Since the new structure is conceptually a generalization of the old (from one document only to multiple documents), the legacy singular document messages does fit as the new multiple documents structure. This is implemented using a bit of Java-fu with internal interfaces to "inject" code into the generated XMLManifest-representations for direct- and portal-jobs.

The method XMLManifest.getDocument() is appropriately marked as
@deprecated, and can be replaced with the unified API for multiple
documents. (XMLManifest.getDocumentsToSign() and XMLManifest.getJobInformation())

Either a manifest has one document containing the title, nonsensitive title and description,
_or_ the manifest itself specifies title, nonsensitive title and
description, and has one or more documents with just a document title.

Using some tricks with JAXB and private interfaces to "inject"
code to be able to treat a strictly single document manifest (p.t. direct-job manifest)
as a multiple documents, even though the generated JAXB-classes does not
support this yet. (Reverting the cardinality of the direct-document from
"unbounded" to 1)

The method XMLManifest.getDocument() is appropriately marked as
@deprecated, and can be replaced with the unified API for multiple
documents.
Copy link
Contributor

@simenstoa simenstoa left a comment

Choose a reason for hiding this comment

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

Dette ble jo veldig bra 💯 Godt jobba!

@simenstoa simenstoa merged commit 44c883d into oppdragstittel Jan 13, 2021
@simenstoa simenstoa deleted the multiple-documents-with-legacy-single-document-support branch January 13, 2021 07:43
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.

2 participants