Skip to content

Commit

Permalink
Merge branch '2022.06.x' into 2023.06.x
Browse files Browse the repository at this point in the history
* 2022.06.x:
  MCR-3049 prevent unnecessary indexing of mods child documents by checking a property (#2075)
  • Loading branch information
sebhofmann committed Feb 23, 2024
2 parents e3e3e55 + 46839d8 commit 0eff8b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import org.jdom2.Element;
import org.mycore.common.MCRConstants;
import org.mycore.common.config.MCRConfiguration2;
import org.mycore.common.events.MCREvent;
import org.mycore.common.events.MCREventHandlerBase;
import org.mycore.common.events.MCREventManager;
Expand All @@ -42,6 +43,11 @@
*/
public class MCRMODSLinksEventHandler extends MCREventHandlerBase {

public static final String INDEX_ALL_CHILDREN_PROPERTY_NAME = "MCR.MODS.LinksEventHandler.IndexAllChildren";
private static final boolean INDEX_ALL_CHILDREN
= MCRConfiguration2.getBoolean(INDEX_ALL_CHILDREN_PROPERTY_NAME)
.orElseThrow(() -> MCRConfiguration2.createConfigurationException(INDEX_ALL_CHILDREN_PROPERTY_NAME));

/* (non-Javadoc)
* @see org.mycore.common.events.MCREventHandlerBase
* #handleObjectCreated(org.mycore.common.events.MCREvent, org.mycore.datamodel.metadata.MCRObject)
Expand Down Expand Up @@ -87,9 +93,11 @@ protected void handleObjectUpdated(final MCREvent evt, final MCRObject obj) {
}
handleObjectCreated(evt, obj);
//may have to reindex children, if they inherit any information
// TODO: remove this code, it is not part of this classes responsibility. if information is inherited, i.e.
// because of a metadata share agent, that process should, in turn, cause a reindexing of affected objects
for (MCRMetaLinkID childLinkID : obj.getStructure().getChildren()) {
MCRObjectID childID = childLinkID.getXLinkHrefID();
if (MCRMetadataManager.exists(childID)) {
if (MCRMetadataManager.exists(childID) && INDEX_ALL_CHILDREN) {
MCREvent childEvent = new MCREvent(MCREvent.ObjectType.OBJECT, MCREvent.EventType.INDEX);
childEvent.put(MCREvent.OBJECT_KEY, MCRMetadataManager.retrieve(childID));
MCREventManager.instance().handleEvent(childEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,6 @@ MCR.ContentTransformer.migrate-extension-display.Class=org.mycore.common.content
MCR.ContentTransformer.migrate-extension-display.TransformerFactoryClass=net.sf.saxon.TransformerFactoryImpl
MCR.ContentTransformer.migrate-extension-display.Stylesheet=xsl/migrate-extension-display.xsl

# if somebody wants to index all children of a mods object without checking if their metadata is changed,
# then the following property can be set to true
MCR.MODS.LinksEventHandler.IndexAllChildren=false

0 comments on commit 0eff8b8

Please sign in to comment.