Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
15:eb425ab34fd8 | 16:f8a5f2c5e2b7 |
---|---|
1 package de.intevation.flys.client.server; | 1 package de.intevation.flys.client.server; |
2 | 2 |
3 import org.w3c.dom.Document; | 3 import org.w3c.dom.Document; |
4 | |
5 import de.intevation.artifacts.common.utils.XMLUtils; | |
6 import de.intevation.artifacts.common.ArtifactNamespaceContext; | |
4 | 7 |
5 import de.intevation.artifacts.httpclient.utils.ArtifactCreator; | 8 import de.intevation.artifacts.httpclient.utils.ArtifactCreator; |
6 | 9 |
7 import de.intevation.flys.client.shared.model.Artifact; | 10 import de.intevation.flys.client.shared.model.Artifact; |
8 import de.intevation.flys.client.shared.model.DefaultArtifact; | 11 import de.intevation.flys.client.shared.model.DefaultArtifact; |
14 * uuid, hash) and returns a new {@link Artifact} instance. | 17 * uuid, hash) and returns a new {@link Artifact} instance. |
15 * | 18 * |
16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 19 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
17 */ | 20 */ |
18 public class FLYSArtifactCreator implements ArtifactCreator { | 21 public class FLYSArtifactCreator implements ArtifactCreator { |
22 | |
23 /** The XPath to the artifact's uuid.*/ | |
24 public static final String XPATH_UUID = "/art:result/art:uuid/@art:value"; | |
25 | |
26 /** The XPath to the artifact's hash value.*/ | |
27 public static final String XPATH_HASH = "/art:result/art:hash/@art:value"; | |
28 | |
19 | 29 |
20 /** | 30 /** |
21 * Creates a new instance of an {@link ArtifactCreator}. | 31 * Creates a new instance of an {@link ArtifactCreator}. |
22 */ | 32 */ |
23 public FLYSArtifactCreator() { | 33 public FLYSArtifactCreator() { |
32 * in the artifact server. | 42 * in the artifact server. |
33 * | 43 * |
34 * @return an instance if {@link Artifact}. | 44 * @return an instance if {@link Artifact}. |
35 */ | 45 */ |
36 public Object create(Document doc) { | 46 public Object create(Document doc) { |
37 return new DefaultArtifact("TODO-UUID", "TODO-HASH"); | 47 Artifact artifact = extractArtifact(doc); |
48 artifact.setArtifactDescription( | |
49 ArtifactDescriptionFactory.createArtifactDescription(doc)); | |
50 | |
51 return artifact; | |
52 } | |
53 | |
54 | |
55 /** | |
56 * This method extracts the UUID und HASH information of the returned | |
57 * artifact document. | |
58 * | |
59 * @param doc The result of the CREATE operation. | |
60 * | |
61 * @return an instance of an {@link Artifact}. | |
62 */ | |
63 protected Artifact extractArtifact(Document doc) { | |
64 System.out.println("FLYSArtifactCreator - extractArtifact()"); | |
65 | |
66 String uuid = XMLUtils.xpathString( | |
67 doc, XPATH_UUID, ArtifactNamespaceContext.INSTANCE); | |
68 | |
69 String hash = XMLUtils.xpathString( | |
70 doc, XPATH_HASH, ArtifactNamespaceContext.INSTANCE); | |
71 | |
72 System.out.println("NEW Artifact UUID: " + uuid); | |
73 System.out.println("NEW Artifact HASH: " + hash); | |
74 | |
75 return new DefaultArtifact(uuid, hash); | |
38 } | 76 } |
39 } | 77 } |
40 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 78 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |