Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jdom2.Attribute;
import org.jdom2.Element;
import org.jdom2.filter.Filters;
import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory;
import org.mycore.access.MCRAccessManager;
import org.mycore.common.MCRConstants;
import org.mycore.common.MCRException;
import org.mycore.common.MCRXlink;
import org.mycore.common.content.MCRContent;
import org.mycore.common.content.transformer.MCRContentTransformer;
import org.mycore.common.content.transformer.MCRParameterizedTransformer;
import org.mycore.common.xml.MCRLayoutService;
import org.mycore.common.xml.MCRURIResolver;
import org.mycore.common.xsl.MCRParameterCollector;
import org.mycore.datamodel.common.MCRISO8601Date;
import org.mycore.datamodel.common.MCRXMLMetadataManager;
Expand Down Expand Up @@ -182,13 +188,32 @@ private void sendObject(MCRObjectID id, MCRServletJob job, T container) throws E
.getChild(MCRObjectStructure.ELEMENT_DERIVATE_OBJECTS)
.getChildren("derobject");

XPathFactory xpathFactory = XPathFactory.instance();
XPathExpression<Attribute> derivateTypeXpath = xpathFactory
.compile("classification[@classid='derivate_types']/@categid",
Filters.attribute(), null, MCRConstants.XML_NAMESPACE);
XPathExpression<Boolean> exportedXpath = xpathFactory
.compile(".//category/label[lang('x-export')]/@text='false'",
Filters.fboolean(), null, MCRConstants.XML_NAMESPACE);

for (Element el : li) {
if (el.getAttributeValue(MCRXMLConstants.INHERITED).equals("0")) {
String ownerID = el.getAttributeValue(MCRXlink.HREF, XLINK_NAMESPACE);
MCRObjectID derId = MCRObjectID.getInstance(ownerID);
// here the access check is tested only against the derivate
if (MCRAccessManager.checkDerivateContentPermission(derId, PERMISSION_READ)) {
sendDerivate(derId, null, container);

// export derivate if no derivate type has an 'x-export' property of 'false'
boolean exported = derivateTypeXpath.evaluate(el).stream().noneMatch(derivateTypeAttribute -> {
String derivateType = derivateTypeAttribute.getValue();
Element derivateTypeElement = MCRURIResolver.obtainInstance()
.resolve("classification:metadata:0:children:derivate_types:" + derivateType);
return exportedXpath.evaluate(derivateTypeElement).get(0);
});

if (exported) {
sendDerivate(derId, null, container);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ MCR.LayoutTransformerFactory.Default.Ignore=%MCR.LayoutTransformerFactory.Defaul

MCR.Module-solr.linkQuery=category.top:{0}

MCR.classeditor.additionalLanguages=x-disable,x-display,x-group,x-logo,x-uri
MCR.classeditor.additionalLanguages=x-disable,x-display,x-export,x-group,x-logo,x-uri

MCR.JSON.Manager.TypeAdapters.categoryType.Class=org.mycore.frontend.classeditor.MCRCategoryTypeAdapter
MCR.JSON.Manager.TypeAdapters.categoryIdType.Class=org.mycore.frontend.classeditor.MCRCategoryIDTypeAdapter
Expand Down
10 changes: 7 additions & 3 deletions mycore-mods/src/main/resources/xsl/mods-enhancer.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@

<xsl:variable name="ifsTemp">
<xsl:for-each select="mycoreobject/structure/derobjects/derobject[acl:checkDerivateContentPermission(@xlink:href, 'read')]">
<der id="{@xlink:href}">
<xsl:copy-of select="document(concat('xslStyle:mcr_directory-recursive:ifs:',@xlink:href,'/'))" />
</der>
<xsl:variable name="derivateType" select="classification[@classid='derivate_types']/@categid" />
<xsl:variable name="derivateExported" select="not(document(concat('classification:metadata:0:children:derivate_types:',$derivateType))//category/label[lang('x-export')]/@text='false')" />
<xsl:if test="$derivateExported">
<der id="{@xlink:href}">
<xsl:copy-of select="document(concat('xslStyle:mcr_directory-recursive:ifs:',@xlink:href,'/'))" />
</der>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="ifs" select="xalan:nodeset($ifsTemp)" />
Expand Down
10 changes: 7 additions & 3 deletions mycore-mods/src/main/resources/xslt/utils/mods-enhancer.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@

<xsl:variable name="ifs">
<xsl:for-each select="mycoreobject/structure/derobjects/derobject[mcracl:check-permission(@xlink:href,'read')]">
<der id="{@xlink:href}">
<xsl:copy-of select="document(concat('xslStyle:mcr_directory-recursive:ifs:',@xlink:href,'/'))" />
</der>
<xsl:variable name="derivateType" select="classification[@classid='derivate_types']/@categid" />
<xsl:variable name="derivateExported" select="not(document(concat('classification:metadata:0:children:derivate_types:',$derivateType))//category/label[lang('x-export')]/@text='false')" />
<xsl:if test="$derivateExported">
<der id="{@xlink:href}">
<xsl:copy-of select="document(concat('xslStyle:mcr_directory-recursive:ifs:',@xlink:href,'/'))" />
</der>
</xsl:if>
</xsl:for-each>
</xsl:variable>

Expand Down