# HG changeset patch # User Sascha L. Teichmann # Date 1383130624 -3600 # Node ID f16dce7a24075fdaca5d4dacdec85620a46bf66b # Parent 52c364813cb155205475fd8acbcedecfe94f8b68 Simplified recommendattion monitor code a bit. diff -r 52c364813cb1 -r f16dce7a2407 artifacts/src/main/java/org/dive4elements/river/artifacts/CollectionMonitor.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/CollectionMonitor.java Wed Oct 30 11:56:13 2013 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/CollectionMonitor.java Wed Oct 30 11:57:04 2013 +0100 @@ -12,18 +12,16 @@ import java.util.List; import java.util.Map; -import javax.xml.xpath.XPathConstants; - import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.ArtifactNamespaceContext; import org.dive4elements.artifacts.CallContext; import org.dive4elements.artifacts.Hook; -import org.dive4elements.artifacts.common.utils.XMLUtils; import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; import org.dive4elements.artifactdatabase.state.Output; @@ -33,9 +31,6 @@ /** Monitors collection changes. */ public class CollectionMonitor implements Hook { - public static final String XPATH_RESULT = "/art:result"; - - @Override public void setup(Node cfg) { } @@ -51,11 +46,14 @@ return; } - Element result = (Element) XMLUtils.xpath( - doc, - XPATH_RESULT, - XPathConstants.NODE, - ArtifactNamespaceContext.INSTANCE); + NodeList results = doc.getElementsByTagNameNS( + ArtifactNamespaceContext.NAMESPACE_URI, "result"); + + if (results.getLength() < 1) { + return; + } + + Element result = (Element)results.item(0); ElementCreator creator = new ElementCreator( doc, @@ -63,7 +61,6 @@ ArtifactNamespaceContext.NAMESPACE_PREFIX); Element recommended = creator.create("recommended-artifacts"); - result.appendChild(recommended); String[] outs = extractOutputNames(flys, context); Map params = getNoneUserSpecificParameters(flys, context); @@ -73,6 +70,8 @@ // TODO For newer official-lines recommendations we actually // need user-id (null here). rec.recommend(flys, null, outs, params, recommended); + + result.appendChild(recommended); }