diff gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java @ 626:61f688a69a55

Split up export modes from output modes. gnv-artifacts/trunk@700 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 23 Feb 2010 11:47:08 +0000
parents 93978859fa9e
children f4331a0df032
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java	Mon Feb 22 11:29:34 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/state/OutputStateBase.java	Tue Feb 23 11:47:08 2010 +0000
@@ -8,8 +8,11 @@
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
 
+import javax.xml.xpath.XPathConstants;
+
 import org.apache.log4j.Logger;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -17,6 +20,7 @@
 import org.w3c.dom.NodeList;
 
 import de.intevation.artifactdatabase.Config;
+import de.intevation.artifactdatabase.XMLUtils; 
 import de.intevation.artifacts.CallContext;
 import de.intevation.artifacts.CallMeta;
 import de.intevation.gnv.artifacts.cache.CacheFactory;
@@ -43,6 +47,9 @@
     public static final String XPATH_MIME_TYPE   =
         "/art:action/art:out/art:mime-type/@value";
 
+    public static final String XPATH_EXPORTS =
+        "exportModes/export";
+
     /**
      * The UID of this Class
      */
@@ -115,8 +122,28 @@
                     }
                 }
 
+                // parse export modes
+                List<ExportMode> exportList = null;
+                NodeList exports = (NodeList) XMLUtils.xpath(
+                    currentNode, XPATH_EXPORTS, XPathConstants.NODESET);
+
+                if (exports != null) {
+                    int exportSize   = exports.getLength();
+
+                    exportList = new ArrayList<ExportMode>(exportSize);
+                    for (int k = 0; k < exportSize; k++) {
+                        Element exp    = (Element) exports.item(k);
+                        String expName = exp.getAttribute("name");
+                        String expDesc = exp.getAttribute("description");
+                        String expMime = exp.getAttribute("mime-type");
+
+                        exportList.add(
+                            new DefaultExportMode(expName, expDesc, expMime));
+                    }
+                }
+
                 OutputMode outputMode = new DefaultOutputMode(name,
-                        description, mimeType, inputParameters);
+                        description, mimeType, inputParameters, exportList);
                 log.debug(outputMode.toString());
                 this.outputModes.add(outputMode);
 
@@ -385,3 +412,4 @@
         );
     }
 }
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org