-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MIR-1329 Reenable support for validation of PDF/A documents #998
Open
yagee-de
wants to merge
4
commits into
2023.06.x
Choose a base branch
from
revert-995-issues/MIR-1304-remove_validation_until_validation_frequency_improved
base: 2023.06.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8ff6dc9
Revert "MIR-1304 Revert "MIR-1198 Support validation of PDF/A documen…
yagee-de a11ce4e
MIR-1198 use mode parameter to seperate templates from other includes
yagee-de 13d024e
MIR-1329 Add Property to enable PDF/A Validation in Workflow
Antoniafriedrich 7f1be80
Some changes
Antoniafriedrich File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
169 changes: 169 additions & 0 deletions
169
mir-module/src/main/resources/xsl/metadata/mir-pdf-errorbox.xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:i18n="xalan://org.mycore.services.i18n.MCRTranslation" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
xmlns:mcrxsl="xalan://org.mycore.common.xml.MCRXMLFunctions" | ||
xmlns:xalan="http://xml.apache.org/xalan" | ||
version="1.0" exclude-result-prefixes="i18n mcrxsl"> | ||
|
||
<xsl:param name="ServletsBaseURL"/> | ||
|
||
|
||
<xsl:template match="mycoreobject" mode="displayPdfError"> | ||
<xsl:variable name="errorMessages"> | ||
<xsl:apply-templates select="structure/derobjects/derobject" mode="displayPdfError"/> | ||
</xsl:variable> | ||
|
||
<xsl:choose> | ||
<xsl:when test="contains($errorMessages,i18n:translate('pdf.errorbox.clause'))"> | ||
<div class="container pdf-validation mb-3 px-0" id="accordion"> | ||
<div class="card-header bg-danger text-white"> | ||
<div class="list-group list-group-root well p-3"> | ||
<p class="h5"> | ||
<xsl:value-of select="i18n:translate('pdf.errorbox.warning.heading')"/> | ||
</p> | ||
<p> | ||
<xsl:value-of select="i18n:translate('pdf.errorbox.warning.message')"/> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="card-body border-left border-right border-bottom"> | ||
<xsl:copy-of select="$errorMessages"/> | ||
</div> | ||
</div> | ||
</xsl:when> | ||
<xsl:when | ||
test="string-length(normalize-space($errorMessages)) > 0"> | ||
<div class="card-header bg-success text-white mb-3"> | ||
<div class="list-group list-group-root well p-3"> | ||
<p class="h5"> | ||
<xsl:value-of select="i18n:translate('pdf.errorbox.success.heading')"/> | ||
</p> | ||
<p> | ||
<xsl:value-of select="i18n:translate('pdf.errorbox.success.message')"/> | ||
</p> | ||
</div> | ||
</div> | ||
</xsl:when> | ||
</xsl:choose> | ||
</xsl:template> | ||
|
||
<xsl:template match="structure/derobjects/derobject" mode="displayPdfError"> | ||
<xsl:variable name="derivateID" select="@xlink:href"/> | ||
<xsl:variable name="result" select="document(concat('pdfAValidator:', $derivateID))"/> | ||
<xsl:if test="not(normalize-space($result))"> | ||
<xsl:apply-templates select="$result/derivate/file" mode="displayPdfError"/> | ||
</xsl:if> | ||
</xsl:template> | ||
|
||
<xsl:template match="file" mode="displayPdfError"> | ||
<xsl:variable name="derivate" select="../@id"/> | ||
<xsl:variable name="name"> | ||
<xsl:call-template name="pdfError.getFilename"> | ||
<xsl:with-param name="filePath" select="@name"/> | ||
</xsl:call-template> | ||
</xsl:variable> | ||
<xsl:variable name="badgecolor"> | ||
<xsl:choose> | ||
<xsl:when test="failed">danger</xsl:when> | ||
<xsl:otherwise>success</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:variable> | ||
<xsl:variable name="uniqueFileId" select="generate-id(.)"/> | ||
<div id="{$derivate}{$uniqueFileId}" class="font-weight-bold d-flex list-group list-group-root"> | ||
<a onclick="$('#{$derivate}{$uniqueFileId}cbButton').toggleClass('fa-chevron-right fa-chevron-down');" | ||
data-toggle="collapse" href="#collapse{$derivate}{$uniqueFileId}" | ||
class="text-left d-flex flex-md-row flex-grow-1 list-group-item align-items-center"> | ||
<i id="{$derivate}{$uniqueFileId}cbButton" class="fa fa-chevron-right ml-auto mr-1"/> | ||
<span class="flex-grow-1 font-weight-bold text-break"> | ||
<xsl:value-of select="$name"/> | ||
</span> | ||
<span class="badge badge-{$badgecolor} badge-pill align-self-center"> | ||
<xsl:value-of select="count(failed)"/> | ||
</span> | ||
</a> | ||
</div> | ||
<ul class="list-group collapse" id="collapse{$derivate}{$uniqueFileId}"> | ||
<li class="list-group-item d-flex flex-column flex-xl-row flex-grow-2 text-break"> | ||
<p class="flex-grow-1 col-lg-8 align-items-center"> | ||
<span class="text-muted pdf-term"> | ||
<xsl:value-of select="concat(i18n:translate('pdf.errorbox.conformity.level'),': ')"/> | ||
</span> | ||
<span class="pdf-value"> | ||
<xsl:value-of select="concat('PDF/A-',@flavour)"/> | ||
</span> | ||
</p> | ||
<xsl:variable name="downloadLink"> | ||
<xsl:value-of | ||
select="concat($ServletsBaseURL,'MCRFileNodeServlet/',$derivate,'/',mcrxsl:encodeURIPath(@name))"/> | ||
</xsl:variable> | ||
|
||
|
||
<a class="btn btn-primary col" href="{$downloadLink}" target="_blank"> | ||
<xsl:value-of select="concat(i18n:translate('pdf.errorbox.button.download'),' ')"/> | ||
<i class="fas fa-download"/> | ||
</a> | ||
</li> | ||
<xsl:apply-templates select="failed" mode="displayPdfError"/> | ||
</ul> | ||
</xsl:template> | ||
|
||
<xsl:template match="failed" mode="displayPdfError"> | ||
<li class="list-group-item d-flex flex-column flex-xl-row flex-grow-1 text-break"> | ||
<p class="flex-grow col-lg-8 col-md-9 align-self-center"> | ||
<span class="text-muted pdf-term"> | ||
<xsl:value-of select="concat(i18n:translate('pdf.errorbox.specification'),': ')"/> | ||
</span> | ||
<span class="pdf-value"> | ||
<xsl:value-of select="concat(' ', @specification, ' ')"/> | ||
</span> | ||
<span class="text-muted pdf-term"> | ||
<xsl:value-of select="concat(i18n:translate('pdf.errorbox.clause'),': ')"/> | ||
</span> | ||
<span class="pdf-value"> | ||
<xsl:value-of select="concat(' ', @clause, ' ')"/> | ||
</span> | ||
<span class="text-muted pdf-term"> | ||
<xsl:value-of select="concat(i18n:translate('pdf.errorbox.test'),': ')"/> | ||
</span> | ||
<span class="pdf-value"> | ||
<xsl:value-of select="concat(' ', @testNumber, ' ')"/> | ||
</span> | ||
</p> | ||
<xsl:choose> | ||
<xsl:when test="not(@link)"> | ||
<a class="btn btn-info col" role="button" href="{@Link}" target="_blank"> | ||
<xsl:value-of select="concat(i18n:translate('pdf.errorbox.button.info'),' ')"/> | ||
<i class="fas fa-external-link-alt"/> | ||
</a> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<div class="text-center alert alert-danger col" role="alert"> | ||
<xsl:value-of select="i18n:translate('pdf.errorbox.unknown.error')"/> | ||
</div> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</li> | ||
</xsl:template> | ||
|
||
<xsl:template name="pdfError.getFilename"> | ||
<xsl:param name="filePath"/> | ||
<xsl:variable name="rest-of" select="substring-after($filePath, '/')"/> | ||
<xsl:choose> | ||
<xsl:when test="contains($rest-of, '/')"> | ||
<xsl:call-template name="pdfError.getFilename"> | ||
<xsl:with-param name="filePath" select="$rest-of"/> | ||
</xsl:call-template> | ||
</xsl:when> | ||
<xsl:otherwise> | ||
<xsl:if test="normalize-space($rest-of)"> | ||
<xsl:value-of select="$rest-of"/> | ||
</xsl:if> | ||
<xsl:if test="not(normalize-space($rest-of))"> | ||
<xsl:value-of select="$filePath"/> | ||
</xsl:if> | ||
</xsl:otherwise> | ||
</xsl:choose> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a notNull or exception uri resolver chained in, to prevent the resolver from crashing the whole metadata page like in MIR-1303
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am working on that ticket seperately and will be merging it into this branch in a seperate pull request.