Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ArtifactOutResource.java @ 193:949d69ad3756
Fixed issue with outdating an artifact if it is removed from a collection.
artifacts/trunk@1423 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 08 Mar 2011 10:13:45 +0000 |
parents | 7e20702a90ed |
children | d9a99b28a847 |
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 |
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
|
49 /** |
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
|
50 * 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
|
51 */ |
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
|
52 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
|
53 String identifier, |
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
|
54 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
|
55 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
|
56 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
|
57 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
|
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 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
|
60 |
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
|
61 return db.out(identifier, 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
|
62 } |
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
88
69c84cf7c5d7
Added javadoc to the REST package of the artifact database (complete).
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
77
diff
changeset
|
64 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |