Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MetaDataService.java @ 1078:048517d67215
Changed state spawning mechanism of MainValuesArtifact.
flys-artifacts/trunk@2575 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 25 Aug 2011 10:38:45 +0000 |
parents | 3f3988bb6284 |
children | f84ddc205c8b |
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.artifactdatabase.DefaultService; |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 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
|
19 import de.intevation.artifacts.common.utils.StringUtils; |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
421
24b53f9aa9dc
MetaDataService: Make incoming XML symmetric to DistanceInfoService.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
415
diff
changeset
|
21 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
|
22 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
23 import de.intevation.flys.artifacts.datacage.Recommendations; |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
25 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
|
26 |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 public class MetaDataService |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 extends DefaultService |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 private static Logger log = Logger.getLogger(MetaDataService.class); |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
32 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
|
33 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
|
34 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
|
35 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
|
36 |
1029
3f3988bb6284
Picky Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1016
diff
changeset
|
37 /** 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
|
38 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
|
39 "global.artifact.database"; |
969
2c8fc60125b9
Meta data template: Allow '-' in variable names.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
966
diff
changeset
|
40 |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 public MetaDataService() { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 } |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
44 @Override |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
45 public Document process( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
46 Document data, |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
47 GlobalContext globalContext, |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
48 CallMeta callMeta |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
49 ) { |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
50 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
|
51 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
52 String artifactId = XMLUtils.xpathString( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
53 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
|
54 |
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
|
55 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
|
56 && (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
|
57 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
|
58 } |
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
|
59 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
60 String userId = XMLUtils.xpathString( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
61 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
|
62 |
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
|
63 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
|
64 && (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
|
65 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
|
66 } |
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 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
68 String outs = XMLUtils.xpathString( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
69 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
|
70 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
71 String parameters = 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_PARAMETERS, ArtifactNamespaceContext.INSTANCE); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
73 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
74 return doService( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
75 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
|
76 } |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
77 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
78 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
|
79 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
|
80 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
|
81 ) { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
82 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
|
83 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
|
84 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
|
85 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
|
86 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
|
87 continue; |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
88 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
89 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
|
90 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
|
91 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
92 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
93 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
|
94 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
95 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
96 protected Document doService( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
97 String artifactId, |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
98 String userId, |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
99 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
|
100 String parameters, |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
101 GlobalContext globalContext |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
102 ) { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
103 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
|
104 |
974
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
105 FLYSArtifact flysArtifact; |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
106 |
975
a111f0984706
meta data service: Added 'if log.isDebugEnabled() {}'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
974
diff
changeset
|
107 if (log.isDebugEnabled()) { |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
108 log.debug("artifact : " + artifactId); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
109 log.debug("user : " + userId); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
110 log.debug("outs : " + outsString); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
111 log.debug("parameters: " + parameters); |
975
a111f0984706
meta data service: Added 'if log.isDebugEnabled() {}'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
974
diff
changeset
|
112 } |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
113 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
114 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
|
115 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
|
116 return result; |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
117 } |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
118 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
119 if (artifactId != null) { |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
120 if (!StringUtils.checkUUID(artifactId)) { |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
121 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
|
122 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
|
123 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
124 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
125 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
|
126 (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
|
127 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
128 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
|
129 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
|
130 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
|
131 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
132 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
133 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
|
134 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
135 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
|
136 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
137 try { |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
138 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
|
139 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
140 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
|
141 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
|
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 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
|
146 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
|
147 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
|
148 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
149 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
150 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
|
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 else { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
153 flysArtifact = null; |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
154 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
155 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
156 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
157 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
|
158 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
|
159 |
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
|
160 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
|
161 ? 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
|
162 : outsString.split("\\s*,\\s*"); |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
163 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
164 Recommendations rec = Recommendations.getInstance(); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
165 rec.recommend( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
166 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
|
167 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
168 return result; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
169 } |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
170 } |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
171 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |