Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/server/FLYSArtifactCreator.java @ 227:7f7f6d2c4b2c
We can now distinuish between different artifact types based on its name in the DESCRIBE. The ArtifactCreator returns concrete instances of Artifacts now.
flys-client/trunk@1673 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 12 Apr 2011 13:46:33 +0000 |
parents | f8a5f2c5e2b7 |
children | c9549074ecd1 |
comparison
equal
deleted
inserted
replaced
226:a13382876e5d | 227:7f7f6d2c4b2c |
---|---|
7 | 7 |
8 import de.intevation.artifacts.httpclient.utils.ArtifactCreator; | 8 import de.intevation.artifacts.httpclient.utils.ArtifactCreator; |
9 | 9 |
10 import de.intevation.flys.client.shared.model.Artifact; | 10 import de.intevation.flys.client.shared.model.Artifact; |
11 import de.intevation.flys.client.shared.model.DefaultArtifact; | 11 import de.intevation.flys.client.shared.model.DefaultArtifact; |
12 import de.intevation.flys.client.shared.model.WINFOArtifact; | |
12 | 13 |
13 | 14 |
14 /** | 15 /** |
15 * An implementation of an {@link ArtifactCreator}. This class uses the document | 16 * An implementation of an {@link ArtifactCreator}. This class uses the document |
16 * that is returned by the artifact server to parse important information (like | 17 * that is returned by the artifact server to parse important information (like |
23 /** The XPath to the artifact's uuid.*/ | 24 /** The XPath to the artifact's uuid.*/ |
24 public static final String XPATH_UUID = "/art:result/art:uuid/@art:value"; | 25 public static final String XPATH_UUID = "/art:result/art:uuid/@art:value"; |
25 | 26 |
26 /** The XPath to the artifact's hash value.*/ | 27 /** The XPath to the artifact's hash value.*/ |
27 public static final String XPATH_HASH = "/art:result/art:hash/@art:value"; | 28 public static final String XPATH_HASH = "/art:result/art:hash/@art:value"; |
29 | |
30 /** The XPath to the artifact's name value.*/ | |
31 public static final String XPATH_NAME = "/art:result/art:name/@art:value"; | |
28 | 32 |
29 | 33 |
30 /** | 34 /** |
31 * Creates a new instance of an {@link ArtifactCreator}. | 35 * Creates a new instance of an {@link ArtifactCreator}. |
32 */ | 36 */ |
67 doc, XPATH_UUID, ArtifactNamespaceContext.INSTANCE); | 71 doc, XPATH_UUID, ArtifactNamespaceContext.INSTANCE); |
68 | 72 |
69 String hash = XMLUtils.xpathString( | 73 String hash = XMLUtils.xpathString( |
70 doc, XPATH_HASH, ArtifactNamespaceContext.INSTANCE); | 74 doc, XPATH_HASH, ArtifactNamespaceContext.INSTANCE); |
71 | 75 |
76 String name = XMLUtils.xpathString( | |
77 doc, XPATH_NAME, ArtifactNamespaceContext.INSTANCE); | |
78 | |
72 System.out.println("NEW Artifact UUID: " + uuid); | 79 System.out.println("NEW Artifact UUID: " + uuid); |
73 System.out.println("NEW Artifact HASH: " + hash); | 80 System.out.println("NEW Artifact HASH: " + hash); |
81 System.out.println("NEW Artifact NAME: " + name); | |
82 | |
83 if (name == null) { | |
84 return new DefaultArtifact(uuid, hash); | |
85 } | |
86 | |
87 name = name.trim(); | |
88 | |
89 if (name.length() > 0 && name.equals("winfo")) { | |
90 System.out.println("+++++ NEW WINFO ARTIFACT."); | |
91 return new WINFOArtifact(uuid, hash); | |
92 } | |
74 | 93 |
75 return new DefaultArtifact(uuid, hash); | 94 return new DefaultArtifact(uuid, hash); |
76 } | 95 } |
77 } | 96 } |
78 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 97 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |