Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ArtifactOutResource.java @ 403:bd76529d612b
FacetActivity: Added interface and registry to decide if a facet should initially active or not.
artifacts/trunk@5150 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 29 Jul 2012 09:37:55 +0000 |
parents | d9a99b28a847 |
children |
rev | line source |
---|---|
100
933bbc9fc11f
Added license file and license headers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
94
diff
changeset
|
1 /* |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
2 * Copyright (c) 2010, 2011 by Intevation GmbH |
100
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 |
29
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 package de.intevation.artifactdatabase.rest; |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
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.artifacts.ArtifactDatabase; |
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
88
diff
changeset
|
12 import de.intevation.artifacts.ArtifactDatabaseException; |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
13 import de.intevation.artifacts.CallMeta; |
93
e27cf9c84eb8
Unified imports.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
88
diff
changeset
|
14 |
29
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import org.apache.log4j.Logger; |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 |
101
7fc0650f194c
Upgraded the Restlet version to 2.0.4 (current stable).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
100
diff
changeset
|
17 import org.restlet.Request; |
29
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 import org.w3c.dom.Document; |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 /** |
88
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
22 * Resource to serve the out()-outputs of artifacts. |
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:
65
diff
changeset
|
23 * @author <a href="mailto:sascha.teichmann@intevation">Sascha L. Teichmann</a> |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
24 * @author <a href="mailto:ingo.weinzierl@intevation">Ingo Weinzierl</a> |
29
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 */ |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 public class ArtifactOutResource |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
27 extends BaseOutResource |
29
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 { |
88
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
29 /** |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
30 * server URL where to find the resource. |
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
31 */ |
29
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 public static final String PATH = "/artifact/{uuid}/{type}"; |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 private static Logger logger = Logger.getLogger(ArtifactOutResource.class); |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
37 /** |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
38 * Returns the identifier of the collection. |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
39 * |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
40 * @return the identifier of the collection. |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
41 */ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
42 protected String getIdentifier() { |
40
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
37
diff
changeset
|
43 Request request = getRequest(); |
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
37
diff
changeset
|
44 |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
45 return (String) request.getAttributes().get("uuid"); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
46 } |
29
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 |
269
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
49 protected String getType() { |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
50 Request request = getRequest(); |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
51 |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
52 return (String) request.getAttributes().get("type"); |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
53 } |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
54 |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
55 |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
56 /** |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
57 * Call the ArtifactDatabase.out method. |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
58 */ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
59 protected ArtifactDatabase.DeferredOutput doOut( |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
60 String identifier, |
269
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
61 String type, |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
62 Document input, |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
63 ArtifactDatabase db, |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
64 CallMeta meta) |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
65 throws ArtifactDatabaseException |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
66 { |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
67 logger.debug("ArtifactOutResource.doOut"); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
101
diff
changeset
|
68 |
269
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
69 return db.out(identifier, type, input, meta); |
29
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 } |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 } |
88
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
72 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |