# HG changeset patch # User Ingo Weinzierl # Date 1300877268 0 # Node ID 435631e07da238b0306b60bb59d907f0e318bafd # Parent b75fca1ac21526d2b70a8c1af5d60661fb21de47 Enhanced the ProtocolUtils and ClientProtocolUtils to append and retrieve output modes. artifacts/trunk@1543 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r b75fca1ac215 -r 435631e07da2 ChangeLog --- a/ChangeLog Wed Mar 23 10:45:36 2011 +0000 +++ b/ChangeLog Wed Mar 23 10:47:48 2011 +0000 @@ -1,3 +1,13 @@ +2011-03-23 Ingo Weinzierl + + * artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java: + Added a method to append an section to a document that + describes the output modes of a state. + + * artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java: + Added a method to retrieve a list of output modes from DESCRIBE + document. + 2011-03-23 Ingo Weinzierl * artifact-database/src/main/java/de/intevation/artifactdatabase/state/State.java: diff -r b75fca1ac215 -r 435631e07da2 artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java --- a/artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java Wed Mar 23 10:45:36 2011 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/ProtocolUtils.java Wed Mar 23 10:47:48 2011 +0000 @@ -13,6 +13,7 @@ import de.intevation.artifacts.common.utils.XMLUtils; +import de.intevation.artifactdatabase.state.Output; import de.intevation.artifactdatabase.state.State; @@ -144,5 +145,20 @@ root.appendChild(reachable); } + + + public static void appendOutputModes( + XMLUtils.ElementCreator creator, + Element out, + List outputs) + { + for (Output o: outputs) { + out.appendChild(createArtNode( + creator, + "output", + new String[] {"name", "description", "mime-type"}, + new String[] {o.getName(),o.getDescription(),o.getMimeType()})); + } + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: diff -r b75fca1ac215 -r 435631e07da2 artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java --- a/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java Wed Mar 23 10:45:36 2011 +0000 +++ b/artifacts-common/src/main/java/de/intevation/artifacts/common/utils/ClientProtocolUtils.java Wed Mar 23 10:47:48 2011 +0000 @@ -38,6 +38,11 @@ public static final String XPATH_STATES = "/art:result/art:reachable-states"; + /** The XPath to the output modes in the DESCRIBE document.*/ + public static final String XPATH_OUTPUT_MODES = + "/art:result/art:outputmodes/art:output"; + + /** The XPath to the select node relative to the dynamic UI node in the * DESCRIBE document.*/ public static final String XPATH_DATA_SELECT = "art:select"; @@ -326,6 +331,23 @@ /** + * This method returns the output mode nodes of the DESCRIBE document. + * + * @param description The document returned by the artifact server's + * DESCRIBE operation. + * + * @return the node that contains the output modes. + */ + public static NodeList getOutputModes(Document description) { + return (NodeList) XMLUtils.xpath( + description, + XPATH_OUTPUT_MODES, + XPathConstants.NODESET, + ArtifactNamespaceContext.INSTANCE); + } + + + /** * Returns the node found by {@link XPATH_DATA_SELECT}. * * @param dynamicNode The dynamic UI node of the DESCRIBE document.