Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java @ 16:f8a5f2c5e2b7
The DESCRIBE document returned by the artifact server is parsed after calling create() of the artifact service and a new Artifact is created with an ArtifactDescription that contains the UUID, HASH, und the current Data.
flys-client/trunk@1329 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 18 Feb 2011 14:23:12 +0000 |
parents | fe2f4d1dd784 |
children | 7f7f6d2c4b2c |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java Fri Feb 18 08:32:38 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java Fri Feb 18 14:23:12 2011 +0000 @@ -2,6 +2,9 @@ import org.w3c.dom.Document; +import de.intevation.artifacts.common.utils.XMLUtils; +import de.intevation.artifacts.common.ArtifactNamespaceContext; + import de.intevation.artifacts.httpclient.utils.ArtifactCreator; import de.intevation.flys.client.shared.model.Artifact; @@ -17,6 +20,13 @@ */ public class FLYSArtifactCreator implements ArtifactCreator { + /** The XPath to the artifact's uuid.*/ + public static final String XPATH_UUID = "/art:result/art:uuid/@art:value"; + + /** The XPath to the artifact's hash value.*/ + public static final String XPATH_HASH = "/art:result/art:hash/@art:value"; + + /** * Creates a new instance of an {@link ArtifactCreator}. */ @@ -34,7 +44,35 @@ * @return an instance if {@link Artifact}. */ public Object create(Document doc) { - return new DefaultArtifact("TODO-UUID", "TODO-HASH"); + Artifact artifact = extractArtifact(doc); + artifact.setArtifactDescription( + ArtifactDescriptionFactory.createArtifactDescription(doc)); + + return artifact; + } + + + /** + * This method extracts the UUID und HASH information of the returned + * artifact document. + * + * @param doc The result of the CREATE operation. + * + * @return an instance of an {@link Artifact}. + */ + protected Artifact extractArtifact(Document doc) { + System.out.println("FLYSArtifactCreator - extractArtifact()"); + + String uuid = XMLUtils.xpathString( + doc, XPATH_UUID, ArtifactNamespaceContext.INSTANCE); + + String hash = XMLUtils.xpathString( + doc, XPATH_HASH, ArtifactNamespaceContext.INSTANCE); + + System.out.println("NEW Artifact UUID: " + uuid); + System.out.println("NEW Artifact HASH: " + hash); + + return new DefaultArtifact(uuid, hash); } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :