Mercurial > dive4elements > river
changeset 65:8f719fa1a691
The output modes of an artifact are extracted from DESCRIBE document and put into the ArtifactDescription.
flys-client/trunk@1547 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 23 Mar 2011 11:19:18 +0000 |
parents | 3d646d3e8e27 |
children | a361ce81abcf |
files | flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java |
diffstat | 2 files changed, 57 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-client/ChangeLog Wed Mar 23 11:06:31 2011 +0000 +++ b/flys-client/ChangeLog Wed Mar 23 11:19:18 2011 +0000 @@ -1,3 +1,9 @@ +2011-03-23 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java: + Extract the output modes from DESCRIBE document and fill the + ArtifactDescription with those objects. + 2011-03-23 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/client/shared/model/ArtifactDescription.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java Wed Mar 23 11:06:31 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/ArtifactDescriptionFactory.java Wed Mar 23 11:19:18 2011 +0000 @@ -19,6 +19,8 @@ import de.intevation.flys.client.shared.model.DefaultArtifactDescription; import de.intevation.flys.client.shared.model.DefaultData; import de.intevation.flys.client.shared.model.DefaultDataItem; +import de.intevation.flys.client.shared.model.DefaultOutputMode; +import de.intevation.flys.client.shared.model.OutputMode; /** @@ -58,6 +60,7 @@ Node staticNode = ClientProtocolUtils.getStaticUI(doc); Node dynamicNode = ClientProtocolUtils.getDynamicUI(doc); Node reachable = ClientProtocolUtils.getReachableStates(doc); + NodeList outputs = ClientProtocolUtils.getOutputModes(doc); String state = (String) XMLUtils.xpath( currentState, @@ -69,8 +72,14 @@ DataList currentData = extractCurrentData(dynamicNode, state); DataList[] old = extractOldData(staticNode); String[] states = extractReachableStates(reachable); + OutputMode[] outs = extractOutputModes(outputs); - return new DefaultArtifactDescription(old, currentData, state, states); + return new DefaultArtifactDescription( + old, + currentData, + state, + states, + outs); } @@ -305,5 +314,46 @@ return states; } + + + /** + * This method extract available output modes of the the current artifact. + * + * @param outputs A list of nodes that contain information about output + * modes. + * + * @return an array of Output modes. + */ + protected static OutputMode[] extractOutputModes(NodeList outputs) { + System.out.println("ArtifactDescriptionFactory - extractOutputModes()"); + + if (outputs == null || outputs.getLength() == 0) { + return null; + } + + int size = outputs.getLength(); + + List<OutputMode> outs = new ArrayList<OutputMode>(size); + + for (int i = 0; i < size; i++) { + Node out = outputs.item(i); + + String name = XMLUtils.xpathString( + out, "@art:name", ArtifactNamespaceContext.INSTANCE); + String desc = XMLUtils.xpathString( + out, "@art:description", ArtifactNamespaceContext.INSTANCE); + String mimeType = XMLUtils.xpathString( + out, "@art:mime-type", ArtifactNamespaceContext.INSTANCE); + + if (name != null) { + outs.add(new DefaultOutputMode(name, desc, mimeType)); + } + else { + System.err.println("Found an invalid output mode."); + } + } + + return (OutputMode[]) outs.toArray(new OutputMode[size]); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :