Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/org/dive4elements/artifactdatabase/rest/CollectionOutResource.java @ 533:3d9d6d61d0c6 3.1.7
Use the real artifact name.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 25 Sep 2014 11:04:34 +0200 |
parents | 415df0fc4fa1 |
children | 584591f8203c |
rev | line source |
---|---|
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 /* |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 * Copyright (c) 2011 by Intevation GmbH |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
3 * |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 * This program is free software under the LGPL (>=v2.1) |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 * Read the file LGPL.txt coming with the software for details |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 * or visit http://www.gnu.org/licenses/ if it does not exist. |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
7 */ |
475
415df0fc4fa1
Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
8 package org.dive4elements.artifactdatabase.rest; |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
9 |
475
415df0fc4fa1
Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
10 import org.dive4elements.artifacts.ArtifactDatabase; |
415df0fc4fa1
Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
11 import org.dive4elements.artifacts.ArtifactDatabaseException; |
415df0fc4fa1
Fixed maven group ids
Sascha L. Teichmann <teichmann@intevation.de>
parents:
473
diff
changeset
|
12 import org.dive4elements.artifacts.CallMeta; |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 import org.apache.log4j.Logger; |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 import org.restlet.Request; |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
17 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
18 import org.w3c.dom.Document; |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
21 /** |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
22 * Resource to serve the out()-outputs of collections. |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
23 * |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 * @author <a href="mailto:ingo.weinzierl@intevation">Ingo Weinzierl</a> |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 */ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
26 public class CollectionOutResource |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
27 extends BaseOutResource |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
28 { |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
29 /** The logger used in this class.*/ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 private static Logger logger = Logger.getLogger(CollectionOutResource.class); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 /** server URL where to find the resource.*/ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 public static final String PATH = "/collection/{uuid}/{type}"; |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
34 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
35 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 /** |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 * 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:
diff
changeset
|
38 * |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
39 * @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:
diff
changeset
|
40 */ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 protected String getIdentifier() { |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 Request request = getRequest(); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 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:
diff
changeset
|
45 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
269
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
48 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
|
49 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
|
50 |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
51 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
|
52 } |
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 |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
55 /** |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 * Call the ArtifactDatabase.outCollection method. |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 */ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 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:
diff
changeset
|
59 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
|
60 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:
diff
changeset
|
61 Document input, |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
62 ArtifactDatabase db, |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
63 CallMeta meta) |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
64 throws ArtifactDatabaseException |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
65 { |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
66 logger.debug("CollectionOutResource.doOut"); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
67 |
269
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
143
diff
changeset
|
68 return db.outCollection(identifier, type, input, meta); |
143
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
69 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
70 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
71 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |