annotate artifact-database/src/main/java/de/intevation/artifactdatabase/rest/BaseResource.java @ 336:2c968defd878

Fix debug helper toString(Node). artifacts/trunk@2816 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 23 Sep 2011 08:42:17 +0000
parents 320a81983c8d
children
rev   line source
100
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
1 /*
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
2 * Copyright (c) 2010 by Intevation GmbH
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
3 *
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
4 * This program is free software under the LGPL (>=v2.1)
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
5 * Read the file LGPL.txt coming with the software for details
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
6 * or visit http://www.gnu.org/licenses/ if it does not exist.
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
7 */
933bbc9fc11f Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 94
diff changeset
8
40
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
9 package de.intevation.artifactdatabase.rest;
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
10
93
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 88
diff changeset
11 import de.intevation.artifactdatabase.DefaultCallMeta;
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 88
diff changeset
12 import de.intevation.artifactdatabase.DefaultPreferredLocale;
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 88
diff changeset
13
131
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
14 import de.intevation.artifacts.ArtifactDatabase;
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
15 import de.intevation.artifacts.CallMeta;
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
16 import de.intevation.artifacts.PreferredLocale;
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
17
93
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 88
diff changeset
18 import java.util.List;
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 88
diff changeset
19
40
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 import org.apache.log4j.Logger;
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
21
93
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 88
diff changeset
22 import org.restlet.data.ClientInfo;
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 88
diff changeset
23 import org.restlet.data.Language;
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 88
diff changeset
24 import org.restlet.data.Preference;
40
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
26 import org.restlet.representation.Representation;
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
27
93
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 88
diff changeset
28 import org.restlet.resource.ResourceException;
e27cf9c84eb8 Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 88
diff changeset
29 import org.restlet.resource.ServerResource;
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
30
40
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
31 /**
88
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
32 * Base class for the resources of REST interface of the artifact database.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
33 * Primarily used to unify the logging.
77
48d1a9a082c2 Bring @author javadoc tags in form '@author <a href="john.doe@example.com">John Doe</a>'
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 48
diff changeset
34 * @author <a href="mailto:sascha.teichmann@intevation">Sascha L. Teichmann</a>
40
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 */
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 public class BaseResource
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37 extends ServerResource
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
38 {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
39 private static Logger logger = Logger.getLogger(BaseResource.class);
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40
88
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
41 /**
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
42 * Default constructor.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
43 */
40
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
44 public BaseResource() {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 }
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
46
88
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
47 /**
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
48 * Overrides the post method of ServerResource to handle some
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
49 * exceptions and to the required logging.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
50 * The call bridges to #innerPost(Representation) which
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
51 * should be overwitten by the subclasses to do the real
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
52 * request processing.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
53 * @param requestRepr The incoming represention of the HTTP request.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
54 * @return The representation produced by #innerPost(Representation).
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
55 * @throws ResourceException Thrown if something went wrong during
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
56 * request processing.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
57 */
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
58 @Override
40
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
59 protected Representation post(Representation requestRepr)
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
60 throws ResourceException
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 try {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63 return innerPost(requestRepr);
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
64 }
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
65 catch (ResourceException re) {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
66 throw re;
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
67 }
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
68 catch (RuntimeException re) {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
69 logger.error(re.getLocalizedMessage(), re);
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
70 throw re;
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
71 }
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
72 }
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
73
88
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
74 /**
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
75 * Trivial implementation of innerPost() which is called by
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
76 * #post(Representation) which simply calls super.post(Representation).
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
77 * This should be overwritten by subclasses which need POST support.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
78 * @param requestRepr The incoming representation of the request.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
79 * @return The representation produced by super.post(Representation).
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
80 * @throws ResourceException Thrown if something went wrong during
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
81 * request processing.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
82 */
40
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
83 protected Representation innerPost(Representation requestRepr)
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
84 throws ResourceException
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
85 {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
86 return super.post(requestRepr);
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
87 }
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
88
88
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
89 /**
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
90 * Wrapper around get() of the super class to handle some exceptions
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
91 * and do the corresponing logging. The call is bridged to #innerGet()
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
92 * which should be overwritten by subclasses.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
93 * @return The representation produced by #innerGet()
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
94 * @throws ResourceException Thrown if something went wrong during
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
95 * request processing.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
96 */
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
97 @Override
47
4ae4dc99127d Removed trailing whitespace.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 40
diff changeset
98 protected Representation get()
40
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 throws ResourceException
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
100 {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
101 try {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 return innerGet();
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 }
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104 catch (ResourceException re) {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
105 throw re;
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 }
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107 catch (RuntimeException re) {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 logger.error(re.getLocalizedMessage(), re);
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 throw re;
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
110 }
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
111 }
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
112
88
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
113 /**
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
114 * Trivial implementaion of innerGet() which simply calls
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
115 * super.get() to produce some output representation. This method
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
116 * should be overwritten by subclasses which need GET support.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
117 * @return The representation produced by super.get().
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
118 * @throws ResourceException Thrown if something went wrong during
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
119 * request processing.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
120 */
40
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
121 protected Representation innerGet()
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
122 throws ResourceException
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
123 {
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
124 return super.get();
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
125 }
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
126
88
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
127 /**
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
128 * Returns meta information (preferred languages et. al.)
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
129 * of the current HTTP request.
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
130 * @return the meta information
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
131 */
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
132 protected CallMeta getCallMeta() {
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
133 ClientInfo clientInfo = getClientInfo();
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
134
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
135 List<Preference<Language>> pl = clientInfo.getAcceptedLanguages();
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
136
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
137 PreferredLocale [] languages = new PreferredLocale[pl.size()];
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
138
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
139 int index = 0;
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
140
94
5332d956729c Brought all line lengths of non Javadoc lines below 80.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 93
diff changeset
141 for (Preference<Language> p: pl) {
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
142 String lang = p.getMetadata().getName();
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
143 float quality = p.getQuality();
86
b2e0cb83631c Removed trailing whitespace
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 77
diff changeset
144 languages[index++] = new DefaultPreferredLocale(lang, quality);
48
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
145 }
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
146
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
147 return new DefaultCallMeta(languages);
41c225c8bd41 Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 47
diff changeset
148 }
131
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
149
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
150
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
151 /**
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
152 * Returns the artifact database stored in the context of the REST
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
153 * application.
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
154 *
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
155 * @return the artifact database.
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
156 */
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
157 protected ArtifactDatabase getArtifactDatabase() {
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
158 return (ArtifactDatabase) getContext().getAttributes().get("database");
82809c5992e1 Added a resource '/create-user' to create new users.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 100
diff changeset
159 }
40
af22d4de275c Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
160 }
88
69c84cf7c5d7 Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 86
diff changeset
161 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org