Exclude templates from isValid and isApproved publication checks#9422
Exclude templates from isValid and isApproved publication checks#9422tylerjmchugh wants to merge 5 commits into
Conversation
|
Yes this totally makes sense as a bug! templates are by nature incomplete - let me review the PR. |
| The following settings control what metadata can be published when the metadata workflow is active. They are found under `Administration` --> `Settings` --> `Metadata Workflow`. | ||
|
|
||
| - **Allow publication of invalid metadata** When disabled, only metadata that passes all required XSD and schematron validation rules can be published. When enabled, metadata can be published regardless of its validation status. Templates are always exempt from this check, as they are typically incomplete by design. | ||
| - **Allow publication of non-approved metadata** When disabled, only metadata with an `Approved` workflow status can be published. When enabled, metadata can be published regardless of its workflow status. Templates are always exempt from this check, as they are not expected to go through the approval workflow. |
There was a problem hiding this comment.
It is unclear to me if tempaltes may be subject to an approval workflow? I could very much imagine a team wishing to approve a new workflow before sharing it for wider use?
There was a problem hiding this comment.
If it is agreed that templates should respect the Allow publication of non-approved metadata setting, maybe the Allow submission/approval of invalid metadata setting needs to also exclude templates instead. With that setting disabled, currently an invalid template could never be approved so again it would be unpublishable.
Updated the PR description accordingly
There was a problem hiding this comment.
Updated the code so the "must be approved to publish" check is still respected. Instead I modified the "must be valid to approve" check to exclude templates.
So now an invalid template can be approved and then published.
| MetadataType metadataType = metadata.getDataInfo().getType(); | ||
| if (metadataType == MetadataType.TEMPLATE | ||
| || metadataType == MetadataType.SUB_TEMPLATE | ||
| || metadataType == MetadataType.TEMPLATE_OF_SUB_TEMPLATE) { |
There was a problem hiding this comment.
This is starting to be a little silly, perhaps MetadataType should have a .isRequiresValidation() property :)
There was a problem hiding this comment.
Fixed in latest push
| */ | ||
| @Test | ||
| public void publishInvalidTemplateSucceedsWhenPublishInvalidMdDisabled() throws Exception { | ||
| // Disable publishing of invalid metadata – the strict mode that triggered the bug. |
There was a problem hiding this comment.
After the bug is addressed this comment will not make sense :P
There was a problem hiding this comment.
Fixed in latest push
jodygarnett
left a comment
There was a problem hiding this comment.
I have provided some small comments, but this change is fine as written.
Thanks for including test case which allows for prompt / efficient review.
8595900 to
acab98c
Compare
Thank you for the review. I believe I have addressed all your comments |
99dd750 to
94c8b15
Compare
94c8b15 to
b15d7f5
Compare
When Allow publication of invalid metadata and Allow submission/approval of invalid metadata are both disabled, template records cannot be published or approved.

Templates are usually intentionally incomplete and are not expected to pass validation. However, the approval and publication checks currently apply the same validation requirements to templates as regular metadata records, causing the approval and publication to fail.
This PR aims to fix this issue by updating to skip the validation checks for templates.
Checklist
mainbranch, backports managed with labelREADME.mdfilespom.xmldependency management. Update build documentation with intended library use and library tutorials or documentation