Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/server/AddArtifactServiceImpl.java @ 90:f8c240f28c2a
The title of the parameter tab will change after the module has been selectd.
flys-client/trunk@1603 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 29 Mar 2011 10:11:57 +0000 |
parents | c8cd1b918901 |
children | 5c3d685546a6 |
rev | line source |
---|---|
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.server; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import java.util.List; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import javax.xml.xpath.XPathConstants; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Document; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.Node; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
10 import org.w3c.dom.NodeList; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 import de.intevation.artifacts.common.utils.ClientProtocolUtils; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifacts.common.utils.XMLUtils; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import de.intevation.artifacts.httpclient.exceptions.ConnectionException; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 import de.intevation.artifacts.httpclient.http.HttpClient; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 import de.intevation.artifacts.httpclient.http.HttpClientImpl; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 import de.intevation.artifacts.httpclient.http.response.DocumentResponseHandler; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 import de.intevation.flys.client.shared.model.Artifact; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 import de.intevation.flys.client.shared.model.Collection; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 import de.intevation.flys.client.shared.model.CollectionItem; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 import de.intevation.flys.client.shared.model.DefaultCollection; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 import de.intevation.flys.client.shared.model.DefaultCollectionItem; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 import de.intevation.flys.client.shared.model.DefaultOutputMode; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 import de.intevation.flys.client.shared.model.OutputMode; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 import de.intevation.flys.client.client.services.AddArtifactService; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 /** |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 */ |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 public class AddArtifactServiceImpl |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 extends RemoteServiceServlet |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 implements AddArtifactService |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
40 public Collection add(Collection collection, Artifact artifact, String url) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 System.out.println("AddArtifactServiceImpl - add()"); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 Document add = ClientProtocolUtils.newAddArtifactDocument( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 artifact.getUuid(), null); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 HttpClient client = new HttpClientImpl(url); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 try { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 Document response = (Document) client.doCollectionAction( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 add, collection.identifier(), new DocumentResponseHandler()); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 Collection c = parseCollection(response); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 if (c == null) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 throw new NullPointerException("No collection returned."); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 return c; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
59 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
60 catch (ConnectionException ce) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
61 System.err.println(ce.getLocalizedMessage()); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 return null; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 /** |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 * This method takes the DESCRIBE document of the Collections describe() |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 * operation and extracts the information about the collection itself and |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 * the collection items. |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 * |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 * @param description The DESCRIBE document of the Collections describe() |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 * operation. |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 * |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 * @return a Collection with CollectionItems. |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 */ |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
78 protected Collection parseCollection(Document description) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 System.out.println("AddArtifactServiceImpl.parseCollection"); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
80 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
81 if (description == null) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 System.err.println("The DESCRIBE of the Collection is null!"); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 return null; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 String uuid = XMLUtils.xpathString( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 description, |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 "art:artifact-collection/@art:uuid", |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 ArtifactNamespaceContext.INSTANCE); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 if (uuid == null || uuid.equals("")) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
92 System.err.println("Found an invalid Collection!"); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 return null; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 Collection c = new DefaultCollection(uuid); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 NodeList items = (NodeList) XMLUtils.xpath( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 description, |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 "art:artifact-collection/art:artifacts/art:artifact", |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 XPathConstants.NODESET, |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 ArtifactNamespaceContext.INSTANCE); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 if (items == null || items.getLength() == 0) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
105 System.out.println("No collection item found for this collection."); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
106 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 return c; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 int size = items.getLength(); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 for (int i = 0; i < size; i++) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 CollectionItem item = parseCollectionItem(items.item(i)); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 if (item != null) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 c.addItem(item); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
117 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 System.out.println( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
121 "Found " + c.getItemLength() + " collection items " + |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
122 "for the Collection '" + c.identifier() + "'."); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
123 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
124 return c; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
125 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
126 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
127 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
128 /** |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
129 * This method extracts the CollectionItem from <i>node</i> with its output |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
130 * modes. The output modes are parsed using the parseOutputModes() method. |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 * |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 * @param node A node that contains information about a CollectionItem. |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
133 * |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 * @return a CollectionItem. |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
135 */ |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
136 protected CollectionItem parseCollectionItem(Node node) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
137 System.out.println("AddArtifactServiceImpl.parseCollectionItem"); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 if (node == null) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 System.err.println("The node for parsing CollectionItem is null!"); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 return null; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
143 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
144 String uuid = XMLUtils.xpathString( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
145 node, "@art:uuid", ArtifactNamespaceContext.INSTANCE); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
146 |
87
c8cd1b918901
Bugfix: Step back will remove duplicated output tab and an extended chart image URL bypasses the browser cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
69
diff
changeset
|
147 String hash = XMLUtils.xpathString( |
c8cd1b918901
Bugfix: Step back will remove duplicated output tab and an extended chart image URL bypasses the browser cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
69
diff
changeset
|
148 node, "@art:hash", ArtifactNamespaceContext.INSTANCE); |
c8cd1b918901
Bugfix: Step back will remove duplicated output tab and an extended chart image URL bypasses the browser cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
69
diff
changeset
|
149 |
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 if (uuid == null || uuid.equals("")) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
151 System.err.println("Found an invalid CollectionItem!"); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
152 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
153 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
154 Node outputmodes = (Node) XMLUtils.xpath( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
155 node, |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
156 "art:outputmodes", |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
157 XPathConstants.NODE, |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
158 ArtifactNamespaceContext.INSTANCE); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
159 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
160 List<OutputMode> modes = parseOutputModes(outputmodes); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
161 |
87
c8cd1b918901
Bugfix: Step back will remove duplicated output tab and an extended chart image URL bypasses the browser cache.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
69
diff
changeset
|
162 return new DefaultCollectionItem(uuid, hash, modes); |
69
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
163 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
164 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
165 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
166 /** |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
167 * This method extracts the OutputModes available for a specific |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
168 * CollectionItem and returns them as list. |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
169 * |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
170 * @param node The root node of the outputmodes list. |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
171 * |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
172 * @return a list of OutputModes. |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
173 */ |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
174 protected List<OutputMode> parseOutputModes(Node node) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
175 System.out.println("AddArtifactServiceImpl.parseOutputModes"); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
176 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
177 if (node == null) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
178 System.err.println("The node for parsing OutputModes is null!"); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
179 return null; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
180 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
181 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
182 NodeList list = (NodeList) XMLUtils.xpath( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
183 node, |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
184 "art:output", |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
185 XPathConstants.NODESET, |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
186 ArtifactNamespaceContext.INSTANCE); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
187 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
188 if (list == null || list.getLength() == 0) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
189 System.err.println("No outputmode nodes found!"); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
190 return null; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
191 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
192 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
193 int size = list.getLength(); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
194 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
195 List<OutputMode> modes = new ArrayList<OutputMode>(size); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
196 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
197 for (int i = 0; i < size; i++) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
198 Node tmp = list.item(i); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
199 String name = XMLUtils.xpathString( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
200 tmp, "@art:name", ArtifactNamespaceContext.INSTANCE); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
201 String desc = XMLUtils.xpathString( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
202 tmp, "@art:description", ArtifactNamespaceContext.INSTANCE); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
203 String mime = XMLUtils.xpathString( |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
204 tmp, "@art:mime-type", ArtifactNamespaceContext.INSTANCE); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
205 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
206 if (name == null || name.equals("")) { |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
207 System.err.println("Found an invalid output mode."); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
208 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
209 continue; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
210 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
211 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
212 // TODO Parse Facets |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
213 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
214 modes.add(new DefaultOutputMode(name, desc, mime)); |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
215 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
216 |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
217 return modes; |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
218 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
219 } |
4bdb18e5f484
Added a service to add artifacts to collections.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
220 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |