Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MetaDataService.java @ 4981:0e6e44e6725f
flys-client: (first draft) In GaugeInfo show link to show main values.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 14 Feb 2013 09:32:29 +0100 |
parents | 9bddb6f5baa0 |
children |
rev | line source |
---|---|
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.artifacts.services; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import org.w3c.dom.Document; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 |
415
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
7 import java.util.Map; |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
8 import java.util.HashMap; |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
9 |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
10 import de.intevation.artifacts.Artifact; |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 import de.intevation.artifacts.CallMeta; |
966
a63d79107289
Adjusted services to implement changed signature.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
950
diff
changeset
|
12 import de.intevation.artifacts.GlobalContext; |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
13 import de.intevation.artifacts.ArtifactDatabase; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
14 import de.intevation.artifacts.ArtifactDatabaseException; |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import de.intevation.artifacts.common.utils.XMLUtils; |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
17 import de.intevation.artifacts.common.utils.StringUtils; |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
421
24b53f9aa9dc
MetaDataService: Make incoming XML symmetric to DistanceInfoService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
415
diff
changeset
|
19 import de.intevation.artifacts.common.ArtifactNamespaceContext; |
24b53f9aa9dc
MetaDataService: Make incoming XML symmetric to DistanceInfoService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
415
diff
changeset
|
20 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
21 import de.intevation.flys.artifacts.datacage.Recommendations; |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
23 import de.intevation.flys.artifacts.FLYSArtifact; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
24 |
4529
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
25 |
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
26 /** |
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
27 * Following XPaths are evaluated on the incoming document. |
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
28 * |
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
29 * "/art:meta/art:artifact-id/@value" The UUID of the artifact. Optional. |
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
30 * Used to fill the template enviroment. |
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
31 * "/art:meta/art:user-id/@value" The UUID of the user. Optional. |
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
32 * If given the user specific template is filled. |
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
33 * "/art:meta/art:outs/@value" The list of outs used to recommend for the |
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
34 * various outputs. |
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
35 * "/art:meta/art:parameters/@value" A list of key/value pairs to inject more |
4868
9bddb6f5baa0
MetaDataService: Document parameters string.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4589
diff
changeset
|
36 * filters to the templating, as "key:value;key2:value2" |
4529
b70dedac4c7e
MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
3076
diff
changeset
|
37 */ |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 public class MetaDataService |
1633
f84ddc205c8b
Made MetaDataService a subclass of FLYSService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1029
diff
changeset
|
39 extends FLYSService |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 private static Logger log = Logger.getLogger(MetaDataService.class); |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
43 public static final String XPATH_ARTIFACT_ID = "/art:meta/art:artifact-id/@value"; |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
44 public static final String XPATH_USER_ID = "/art:meta/art:user-id/@value"; |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
45 public static final String XPATH_OUTS = "/art:meta/art:outs/@value"; |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
46 public static final String XPATH_PARAMETERS = "/art:meta/art:parameters/@value"; |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
47 |
1029
3f3988bb6284
Picky Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1016
diff
changeset
|
48 /** The global context key of the artifact database. */ |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
49 public static final String ARTIFACT_DATA_BASE_KEY = |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
50 "global.artifact.database"; |
969
2c8fc60125b9
Meta data template: Allow '-' in variable names.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
966
diff
changeset
|
51 |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 public MetaDataService() { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 } |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
55 @Override |
1633
f84ddc205c8b
Made MetaDataService a subclass of FLYSService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1029
diff
changeset
|
56 protected Document doProcess( |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
57 Document data, |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
58 GlobalContext globalContext, |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
59 CallMeta callMeta |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
60 ) { |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
61 log.debug("MetaDataService.process"); |
415
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
62 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
63 String artifactId = XMLUtils.xpathString( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
64 data, XPATH_ARTIFACT_ID, ArtifactNamespaceContext.INSTANCE); |
415
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
65 |
1016
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
66 if (artifactId != null |
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
67 && (artifactId = artifactId.trim()).length() == 0) { |
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
68 artifactId = null; |
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
69 } |
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
70 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
71 String userId = XMLUtils.xpathString( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
72 data, XPATH_USER_ID, ArtifactNamespaceContext.INSTANCE); |
415
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
73 |
1016
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
74 if (userId != null |
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
75 && (userId = userId.trim()).length() == 0) { |
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
76 userId = null; |
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
77 } |
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
78 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
79 String outs = XMLUtils.xpathString( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
80 data, XPATH_OUTS, ArtifactNamespaceContext.INSTANCE); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
81 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
82 String parameters = XMLUtils.xpathString( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
83 data, XPATH_PARAMETERS, ArtifactNamespaceContext.INSTANCE); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
84 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
85 return doService( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
86 artifactId, userId, outs, parameters, globalContext); |
415
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
87 } |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
88 |
4868
9bddb6f5baa0
MetaDataService: Document parameters string.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4589
diff
changeset
|
89 |
9bddb6f5baa0
MetaDataService: Document parameters string.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4589
diff
changeset
|
90 /** |
9bddb6f5baa0
MetaDataService: Document parameters string.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4589
diff
changeset
|
91 * Split parameterstring in the form of key1:value1;key2:value2 |
9bddb6f5baa0
MetaDataService: Document parameters string.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4589
diff
changeset
|
92 * into hash (key1->value1, key2->value2). |
9bddb6f5baa0
MetaDataService: Document parameters string.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4589
diff
changeset
|
93 * @param parameters "key1:value1;key2:value2" |
9bddb6f5baa0
MetaDataService: Document parameters string.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4589
diff
changeset
|
94 * @param data Map into wich to put parameter hash and return. |
9bddb6f5baa0
MetaDataService: Document parameters string.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4589
diff
changeset
|
95 * @return parameter data |
9bddb6f5baa0
MetaDataService: Document parameters string.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4589
diff
changeset
|
96 */ |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
97 protected static Map<String, Object> splitParameters( |
974
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
98 String parameters, |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
99 Map<String, Object> data |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
100 ) { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
101 if (parameters != null) { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
102 String [] parts = parameters.split("\\s*;\\s*"); |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
103 for (String part: parts) { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
104 String [] kv = part.split("\\s*:\\s*"); |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
105 if (kv.length < 2 || (kv[0] = kv[0].trim()).length() == 0) { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
106 continue; |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
107 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
108 String [] values = kv[1].split("\\s*,\\s*"); |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
109 data.put(kv[0], values.length == 1 ? values[0] : values); |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
110 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
111 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
112 return data; |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
113 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
114 |
4589
afd817b006b7
Documentation added.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4529
diff
changeset
|
115 /** Return the document containing matched stuff from meta-data.xml. */ |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
116 protected Document doService( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
117 String artifactId, |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
118 String userId, |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
119 String outsString, |
974
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
120 String parameters, |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
121 GlobalContext globalContext |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
122 ) { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
123 Document result = XMLUtils.newDocument(); |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
124 |
974
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
125 FLYSArtifact flysArtifact; |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
126 |
975
a111f0984706
meta data service: Added 'if log.isDebugEnabled() {}'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
974
diff
changeset
|
127 if (log.isDebugEnabled()) { |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
128 log.debug("artifact : " + artifactId); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
129 log.debug("user : " + userId); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
130 log.debug("outs : " + outsString); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
131 log.debug("parameters: " + parameters); |
975
a111f0984706
meta data service: Added 'if log.isDebugEnabled() {}'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
974
diff
changeset
|
132 } |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
133 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
134 if (userId != null && !StringUtils.checkUUID(userId)) { |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
135 log.warn("'" + userId + "' is not a UUID"); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
136 return result; |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
137 } |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
138 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
139 if (artifactId != null) { |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
140 if (!StringUtils.checkUUID(artifactId)) { |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
141 log.warn("'" + artifactId + "' is not a UUID"); |
974
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
142 return result; |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
143 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
144 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
145 Object dbObject = |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
146 (ArtifactDatabase)globalContext.get(ARTIFACT_DATA_BASE_KEY); |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
147 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
148 if (!(dbObject instanceof ArtifactDatabase)) { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
149 log.error("Cannot find artifact database"); |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
150 return result; |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
151 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
152 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
153 ArtifactDatabase db = (ArtifactDatabase)dbObject; |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
154 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
155 Artifact artifact; |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
156 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
157 try { |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
158 artifact = db.getRawArtifact(artifactId); |
974
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
159 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
160 catch (ArtifactDatabaseException adbe) { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
161 log.warn("fetching artifact failed", adbe); |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
162 return result; |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
163 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
164 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
165 if (!(artifact instanceof FLYSArtifact)) { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
166 log.warn("artifact is not a FLYS artifact."); |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
167 return result; |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
168 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
169 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
170 flysArtifact = (FLYSArtifact)artifact; |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
171 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
172 else { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
173 flysArtifact = null; |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
174 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
175 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
176 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
177 Map<String, Object> data = splitParameters( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
178 parameters, new HashMap<String, Object>()); |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
179 |
1016
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
180 String [] outs = outsString == null |
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
181 ? new String [0] |
ff7b81cf9999
Meta data service: Be a bit more tolerant about empty strings for UUIDs of artifact and user.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1015
diff
changeset
|
182 : outsString.split("\\s*,\\s*"); |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1633
diff
changeset
|
183 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
184 Recommendations rec = Recommendations.getInstance(); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
185 rec.recommend( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
186 flysArtifact, userId, outs, data, result); |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
187 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
188 return result; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
189 } |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
190 } |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
191 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |