changeset 525:0fdd239f4f39 facet-metadata

Merged default into branch facet-metadata.
author Tom Gottfried <tom@intevation.de>
date Tue, 08 Jul 2014 18:33:15 +0200
parents ab13ab6acc5c (current diff) 52c11c3a1f79 (diff)
children e149751b9c6d 41feef58781b
files
diffstat 3 files changed, 29 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Wed Jul 02 12:29:21 2014 +0200
+++ b/.hgtags	Tue Jul 08 18:33:15 2014 +0200
@@ -58,3 +58,10 @@
 0aff3300a490ec47263237cc3b34ce181f9d5b51 3.1.0
 da92d120932800e805820d0c88610234aa28b38f 3.1.1
 08c82b4e8b58ea48e6d6aa061279f646a73b034a 3.1.2
+863f1fa669814fd73053e733ada79f62a3a924b5 3.1.3
+d364086a01bcadddeabdc8533a4f271b9dfe6747 3.1.13
+d364086a01bcadddeabdc8533a4f271b9dfe6747 3.1.13
+0000000000000000000000000000000000000000 3.1.13
+863f1fa669814fd73053e733ada79f62a3a924b5 3.1.3
+0a2a2d097013cec1ddba1b3f1c08df92b1903203 3.1.3
+992ccb9ad4dea8824a75803bd4d44dbea60a89c2 3.1.4
--- a/artifact-database/src/main/java/org/dive4elements/artifactdatabase/DefaultArtifactFactory.java	Wed Jul 02 12:29:21 2014 +0200
+++ b/artifact-database/src/main/java/org/dive4elements/artifactdatabase/DefaultArtifactFactory.java	Tue Jul 08 18:33:15 2014 +0200
@@ -27,6 +27,7 @@
 import org.apache.log4j.Logger;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -141,9 +142,9 @@
         try {
             Artifact artifact =
                 (Artifact)artifactClass.newInstance();
+            String oldName = artifact.getName();
 
-            if (artifact.getName() == null ||
-                artifact.getName().length() == 0) {
+            if (oldName == null || oldName.length() == 0) {
                 artifact.setName(artifactName);
             }
             artifact.setup(
@@ -170,6 +171,8 @@
     }
 
     public void setup(Document document, Node factoryNode) {
+        boolean debug = logger.isDebugEnabled();
+
         String ttlString = Config.getStringXPath(factoryNode, XPATH_TTL);
         if (ttlString != null) {
             try {
@@ -185,14 +188,20 @@
 
         name = Config.getStringXPath(
             factoryNode, XPATH_NAME, toString());
-        logger.debug("setting up " + name);
+
+        if (debug) {
+            logger.debug("setting up " + name);
+        }
 
         String artifact = Config.getStringXPath(
             factoryNode, XPATH_ARTIFACT, DEFAULT_ARTIFACT);
 
         artifactName = Config.getStringXPath(
             document, XPATH_ARTIFACT_NAME, "default");
-        logger.debug(artifactName);
+
+        if (debug) {
+            logger.debug("artifact name: " + artifactName);
+        }
         Map<String, String> variables = new HashMap<String, String>();
         variables.put("name", name);
         NodeList facets = (NodeList) XMLUtils.xpath(
@@ -202,10 +211,14 @@
             null,
             variables);
 
-        for (int i = 0; i < facets.getLength(); i++) {
-            logger.debug(facets.item(i).getAttributes().getNamedItem("class").getNodeValue());
-            String className =
-                facets.item(i).getAttributes().getNamedItem("class").getNodeValue();
+        for (int i = 0, F = facets.getLength(); i < F; i++) {
+            Element element = (Element)facets.item(i);
+            String className = element.getAttribute("class");
+
+            if (debug) {
+                logger.debug("load facet class: " + className);
+            }
+
             try {
                 facetClasses.add(Class.forName(className));
             }
@@ -213,6 +226,7 @@
                 logger.error(cnfe.getLocalizedMessage(), cnfe);
             }
         }
+
         try {
             artifactClass = Class.forName(artifact);
         }
--- a/artifact-database/src/main/java/org/dive4elements/artifactdatabase/state/StaticFacet.java	Wed Jul 02 12:29:21 2014 +0200
+++ b/artifact-database/src/main/java/org/dive4elements/artifactdatabase/state/StaticFacet.java	Tue Jul 08 18:33:15 2014 +0200
@@ -8,8 +8,6 @@
 
 package org.dive4elements.artifactdatabase.state;
 
-import java.io.Serializable;
-
 import org.dive4elements.artifacts.Artifact;
 import org.dive4elements.artifacts.CallMeta;
 import org.w3c.dom.Document;

http://dive4elements.wald.intevation.org