Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/rest/BaseOutResource.java @ 434:403a6793077c
Added tag flys-2.9.2 for changeset bd012f4720ae
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 03 Oct 2012 16:32:33 +0200 |
parents | d9a99b28a847 |
children |
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 */ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
8 package de.intevation.artifactdatabase.rest; |
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 |
207
b2115f484edb
Move Config and XMLUtils totally to commons package.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
143
diff
changeset
|
10 import de.intevation.artifacts.common.utils.XMLUtils; |
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
|
11 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.ArtifactDatabase; |
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 import de.intevation.artifacts.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
|
14 import de.intevation.artifacts.ArtifactNamespaceContext; |
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 import de.intevation.artifacts.CallMeta; |
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 |
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 import java.io.IOException; |
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 |
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 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
|
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 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
|
22 import org.restlet.Response; |
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 import org.restlet.data.MediaType; |
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 import org.restlet.data.Status; |
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 |
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 import org.restlet.ext.xml.DomRepresentation; |
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 import org.restlet.representation.EmptyRepresentation; |
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 import org.restlet.representation.Representation; |
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 import org.restlet.resource.ResourceException; |
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 |
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 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
|
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 /** |
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 * Base Resource to serve the out()-outputs of collections and artifacts. |
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 * |
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 * @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
|
41 */ |
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 public abstract class 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
|
43 extends BaseResource |
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 { |
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 /** 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
|
46 private static Logger logger = Logger.getLogger(BaseOutResource.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
|
47 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 /** XPath to figure out the MIME type of the requested result.*/ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 public static final String XPATH_MIME_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
|
50 "/art:action/art:out/art:mime-type/@value"; |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
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:
diff
changeset
|
52 /** Default result MIME type: octet stream.*/ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 public static final MediaType DEFAULT_MIME_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
|
54 MediaType.APPLICATION_OCTET_STREAM; |
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 |
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 @Override |
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 Representation innerPost(Representation requestRepr) |
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 throws ResourceException |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
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:
diff
changeset
|
61 Document inputDocument = null; |
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 |
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 try { |
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 DomRepresentation input = new DomRepresentation(requestRepr); |
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 input.setNamespaceAware(true); |
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 inputDocument = input.getDocument(); |
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 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
68 catch (IOException ioe) { |
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 logger.error(ioe.getMessage()); |
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 Response response = getResponse(); |
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 response.setStatus(Status.CLIENT_ERROR_BAD_REQUEST, ioe); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
72 return new EmptyRepresentation(); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
73 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
74 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
75 ArtifactDatabase db = getArtifactDatabase(); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
76 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
77 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
|
78 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
79 String identifier = getIdentifier(); |
269
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
80 String outType = getType(); |
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
|
81 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
82 if (logger.isDebugEnabled()) { |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
83 logger.debug("looking for artifact id '" + identifier + "'"); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
84 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
85 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 String mimeTypeString = XMLUtils.xpathString( |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 inputDocument, |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 XPATH_MIME_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
|
89 ArtifactNamespaceContext.INSTANCE); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
91 MediaType mimeType = DEFAULT_MIME_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
|
92 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
93 if (mimeTypeString != null && mimeTypeString.length() != 0) { |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
94 try { |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
95 mimeType = MediaType.valueOf(mimeTypeString); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
96 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
97 catch (Exception e) { |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
98 logger.error(e.getLocalizedMessage()); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
99 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
100 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
101 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
102 try { |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
103 return new OutRepresentation( |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
104 mimeType, |
269
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
105 doOut(identifier, outType, inputDocument, db, getCallMeta())); |
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
|
106 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
107 catch (ArtifactDatabaseException adbe) { |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
108 Response response = getResponse(); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
109 response.setStatus( |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
110 Status.CLIENT_ERROR_NOT_FOUND, adbe.getMessage()); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
111 return new EmptyRepresentation(); |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
112 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
113 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
114 |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
115 /** |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
116 * Returns the identifier of the artifact or 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
|
117 * |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
118 * @return the identifier. |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
119 */ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
120 protected abstract 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
|
121 |
269
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
122 |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
123 /** |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
124 * Returns the concrete output type of the artifact or collection. |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
125 * |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
126 * @return the output type. |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
127 */ |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
128 protected abstract String getType(); |
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
129 |
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
|
130 /** |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
131 * This method is called to process the operation on artifacts or |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
132 * 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
|
133 * |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
134 * @param identifier The identifier of the artifact or collection. |
269
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
135 * @param type The output 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
|
136 * @param input The input document of the 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
|
137 * @param db The artifact database. |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
138 * @param meta The CallMeta object. |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
139 * |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
140 * @return the result of the operation. |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
141 */ |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
142 protected abstract 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
|
143 String identifier, |
269
d9a99b28a847
Added support for the 'type' parameter of artifacts and collections out() call.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
207
diff
changeset
|
144 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
|
145 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
|
146 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
|
147 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
|
148 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
|
149 } |
7e20702a90ed
Implemented an abstract class for the output of artifacts and collections. Added a CollectionOutResource.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
150 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |