annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/services/MetaDataService.java @ 4560:661102336f16

Add css for the project list changes
author Björn Ricks <bjoern.ricks@intevation.de>
date Fri, 16 Nov 2012 14:26:25 +0100
parents b70dedac4c7e
children afd817b006b7
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
b70dedac4c7e MetaDataService: Added comment from ChangeLog.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents: 3076
diff changeset
36 * filters to the templating.
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
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
89 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
90 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
91 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
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 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
94 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
95 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
96 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
97 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
98 continue;
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
99 }
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 [] 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
101 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
102 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
103 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
104 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
105 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
106
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
107 protected Document doService(
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
108 String artifactId,
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
109 String userId,
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
110 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
111 String parameters,
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
112 GlobalContext globalContext
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
113 ) {
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
114 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
115
974
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
116 FLYSArtifact flysArtifact;
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
117
975
a111f0984706 meta data service: Added 'if log.isDebugEnabled() {}'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 974
diff changeset
118 if (log.isDebugEnabled()) {
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
119 log.debug("artifact : " + artifactId);
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
120 log.debug("user : " + userId);
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
121 log.debug("outs : " + outsString);
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
122 log.debug("parameters: " + parameters);
975
a111f0984706 meta data service: Added 'if log.isDebugEnabled() {}'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 974
diff changeset
123 }
970
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
124
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
125 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
126 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
127 return result;
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
128 }
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
129
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
130 if (artifactId != null) {
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
131 if (!StringUtils.checkUUID(artifactId)) {
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
132 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
133 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
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
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
136 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
137 (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
138
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
139 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
140 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
141 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
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
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
144 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
145
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
146 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
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 try {
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
149 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
150 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
151 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
152 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
153 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
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
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
156 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
157 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
158 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
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
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
161 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
162 }
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
163 else {
30c85cb33a50 meta data service: made artifact optional and allow passing extra parameters.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 970
diff changeset
164 flysArtifact = null;
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
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
167
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
168 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
169 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
170
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
171 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
172 ? 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
173 : outsString.split("\\s*,\\s*");
3076
5642a83420f2 FLYS artifacts: Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 1633
diff changeset
174
1015
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
175 Recommendations rec = Recommendations.getInstance();
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
176 rec.recommend(
9a1a3080ad98 Bring user specific meta data service to life.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 998
diff changeset
177 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
178
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
179 return result;
e456aca4eb7b meta data service: Adjusted to use the DataCage recommendations.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 969
diff changeset
180 }
372
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
181 }
fc3cf0ef777e Added meta data service.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
182 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org