Mercurial > dive4elements > river
annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MetaDataService.java @ 3569:adf9c41610c7
Changed wording for reference curves reference station(s).
flys-artifacts/trunk@5167 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 07 Aug 2012 12:59:30 +0000 |
parents | 5642a83420f2 |
children | b70dedac4c7e |
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 |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 public class MetaDataService |
1633
f84ddc205c8b
Made MetaDataService a subclass of FLYSService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1029
diff
changeset
|
26 extends FLYSService |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 { |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 private static Logger log = Logger.getLogger(MetaDataService.class); |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
30 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
|
31 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
|
32 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
|
33 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
|
34 |
1029
3f3988bb6284
Picky Cosmetics.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
1016
diff
changeset
|
35 /** 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
|
36 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
|
37 "global.artifact.database"; |
969
2c8fc60125b9
Meta data template: Allow '-' in variable names.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
966
diff
changeset
|
38 |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 public MetaDataService() { |
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 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
42 @Override |
1633
f84ddc205c8b
Made MetaDataService a subclass of FLYSService.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
1029
diff
changeset
|
43 protected Document doProcess( |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
44 Document data, |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
45 GlobalContext globalContext, |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
46 CallMeta callMeta |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
47 ) { |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
48 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
|
49 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
50 String artifactId = XMLUtils.xpathString( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
51 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
|
52 |
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
|
53 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
|
54 && (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
|
55 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 } |
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 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
58 String userId = XMLUtils.xpathString( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
59 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
|
60 |
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
|
61 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
|
62 && (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
|
63 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 } |
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 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
66 String outs = XMLUtils.xpathString( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
67 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
|
68 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
69 String parameters = XMLUtils.xpathString( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
70 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
|
71 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
72 return doService( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
73 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
|
74 } |
7c018f466d6d
Datacage: Added river parameter to meta data services.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
372
diff
changeset
|
75 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
76 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
|
77 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
|
78 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
|
79 ) { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
80 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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 continue; |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
86 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
87 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
|
88 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
|
89 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
90 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
91 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
|
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 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
94 protected Document doService( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
95 String artifactId, |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
96 String userId, |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
97 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
|
98 String parameters, |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
99 GlobalContext globalContext |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
100 ) { |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
101 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
|
102 |
974
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
103 FLYSArtifact flysArtifact; |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
104 |
975
a111f0984706
meta data service: Added 'if log.isDebugEnabled() {}'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
974
diff
changeset
|
105 if (log.isDebugEnabled()) { |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
106 log.debug("artifact : " + artifactId); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
107 log.debug("user : " + userId); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
108 log.debug("outs : " + outsString); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
109 log.debug("parameters: " + parameters); |
975
a111f0984706
meta data service: Added 'if log.isDebugEnabled() {}'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
974
diff
changeset
|
110 } |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
111 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
112 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
|
113 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
|
114 return result; |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
115 } |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
116 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
117 if (artifactId != null) { |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
118 if (!StringUtils.checkUUID(artifactId)) { |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
119 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
|
120 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
|
121 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
122 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
123 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
|
124 (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
|
125 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
126 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
|
127 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
|
128 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
|
129 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
130 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
131 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
|
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 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
|
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 try { |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
136 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
|
137 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
138 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
|
139 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
|
140 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
|
141 } |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
142 |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
143 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
|
144 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
|
145 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
|
146 } |
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 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
|
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 else { |
30c85cb33a50
meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
970
diff
changeset
|
151 flysArtifact = null; |
970
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
152 } |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
153 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
154 |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
155 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
|
156 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
|
157 |
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
|
158 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
|
159 ? 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
|
160 : outsString.split("\\s*,\\s*"); |
3076
5642a83420f2
FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
1633
diff
changeset
|
161 |
1015
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
162 Recommendations rec = Recommendations.getInstance(); |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
163 rec.recommend( |
9a1a3080ad98
Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
998
diff
changeset
|
164 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
|
165 |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
166 return result; |
e456aca4eb7b
meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
969
diff
changeset
|
167 } |
372
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
168 } |
fc3cf0ef777e
Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
169 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |