|
40 | 40 |
|
41 | 41 | import org.apache.logging.log4j.LogManager; |
42 | 42 | import org.apache.logging.log4j.Logger; |
| 43 | +import org.jdom2.Attribute; |
43 | 44 | import org.jdom2.Element; |
| 45 | +import org.jdom2.filter.Filters; |
| 46 | +import org.jdom2.xpath.XPathExpression; |
| 47 | +import org.jdom2.xpath.XPathFactory; |
44 | 48 | import org.mycore.access.MCRAccessManager; |
| 49 | +import org.mycore.common.MCRConstants; |
45 | 50 | import org.mycore.common.MCRException; |
46 | 51 | import org.mycore.common.MCRXlink; |
47 | 52 | import org.mycore.common.content.MCRContent; |
48 | 53 | import org.mycore.common.content.transformer.MCRContentTransformer; |
49 | 54 | import org.mycore.common.content.transformer.MCRParameterizedTransformer; |
50 | 55 | import org.mycore.common.xml.MCRLayoutService; |
| 56 | +import org.mycore.common.xml.MCRURIResolver; |
51 | 57 | import org.mycore.common.xml.MCRXMLFunctions; |
52 | 58 | import org.mycore.common.xsl.MCRParameterCollector; |
53 | 59 | import org.mycore.datamodel.common.MCRISO8601Date; |
@@ -183,14 +189,34 @@ private void sendObject(MCRObjectID id, MCRServletJob job, T container) throws E |
183 | 189 | .getChild(MCRObjectStructure.ELEMENT_DERIVATE_OBJECTS) |
184 | 190 | .getChildren("derobject"); |
185 | 191 |
|
| 192 | + XPathFactory xpathFactory = XPathFactory.instance(); |
| 193 | + XPathExpression<Attribute> derivateTypeXpath = xpathFactory |
| 194 | + .compile("classification[@classid='derivate_types']/@categid", |
| 195 | + Filters.attribute(), null, MCRConstants.XML_NAMESPACE); |
| 196 | + XPathExpression<Boolean> exportedXpath = xpathFactory |
| 197 | + .compile(".//category/label[lang('x-export')]/@text='false'", |
| 198 | + Filters.fboolean(), null, MCRConstants.XML_NAMESPACE); |
| 199 | + |
186 | 200 | for (Element el : li) { |
187 | 201 | if (el.getAttributeValue(MCRXMLConstants.INHERITED).equals("0")) { |
188 | 202 | String ownerID = el.getAttributeValue(MCRXlink.HREF, XLINK_NAMESPACE); |
189 | 203 | MCRObjectID derId = MCRObjectID.getInstance(ownerID); |
190 | 204 | // here the access check is tested only against the derivate |
191 | 205 | if (MCRAccessManager.checkDerivateContentPermission(derId, PERMISSION_READ) |
192 | 206 | && MCRXMLFunctions.isDisplayedEnabledDerivate(ownerID)) { |
193 | | - sendDerivate(derId, null, container); |
| 207 | + |
| 208 | + // export derivate if no derivate type has an 'x-export' property of 'false' |
| 209 | + boolean exported = derivateTypeXpath.evaluate(el).stream().noneMatch(derivateTypeAttribute -> { |
| 210 | + String derivateType = derivateTypeAttribute.getValue(); |
| 211 | + Element derivateTypeElement = MCRURIResolver.obtainInstance() |
| 212 | + .resolve("classification:metadata:0:children:derivate_types:" + derivateType); |
| 213 | + return exportedXpath.evaluate(derivateTypeElement).get(0); |
| 214 | + }); |
| 215 | + |
| 216 | + if (exported) { |
| 217 | + sendDerivate(derId, null, container); |
| 218 | + } |
| 219 | + |
194 | 220 | } |
195 | 221 | } |
196 | 222 | } |
|
0 commit comments