Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ArtifactResource.java @ 43:b8516aa3d8a1
Time delta calculation in SQL statement to figure out outdated artifacts
in H2 database was broken.
artifacts/trunk@122 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 24 Sep 2009 09:15:56 +0000 |
parents | af22d4de275c |
children | 41c225c8bd41 |
rev | line source |
---|---|
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.artifactdatabase.rest; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
40
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
3 import org.restlet.resource.ResourceException; |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
5 import org.restlet.representation.Representation; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 import org.restlet.representation.EmptyRepresentation; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
8 import org.restlet.ext.xml.DomRepresentation; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.artifacts.ArtifactDatabase; |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
11 import de.intevation.artifacts.ArtifactDatabaseException; |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 import de.intevation.artifacts.Artifact; |
29
22b03d5c84c5
Added REST out handler for artifacts reachable via HTTP GET '/artifact/{uuid}/{type}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
28
diff
changeset
|
13 import de.intevation.artifacts.ArtifactNamespaceContext; |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 import org.restlet.data.Request; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 import org.restlet.data.Response; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 import org.restlet.data.Status; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 import org.restlet.data.MediaType; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 import org.apache.log4j.Logger; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 import org.w3c.dom.Document; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 |
28
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
24 import java.io.IOException; |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
25 |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
26 import de.intevation.artifactdatabase.XMLUtils; |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
27 |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 /** |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 * @author Sascha L. Teichmann (sascha.teichmann@intevation) |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 */ |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 public class ArtifactResource |
40
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
32 extends BaseResource |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 { |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 private static Logger logger = Logger.getLogger(ArtifactResource.class); |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 |
28
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
36 public static final String XPATH_ACTION = "/action/type/@name"; |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
37 |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 public static final String PATH = "/artifact/{uuid}"; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
28
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
40 public static final String NO_ACTION_MESSAGE = "no action given"; |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
41 public static final String NO_SUCH_ACTION_MESSAGE = "no such action"; |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
42 |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 public static final String NO_ARTIFACT_FOUND = "Artifact not found"; |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 |
28
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
45 public static final String ADVANCE = "advance"; |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
46 public static final String FEED = "feed"; |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
47 |
40
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
48 protected Representation innerGet() |
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
49 throws ResourceException |
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
50 { |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 Request request = getRequest(); |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 String identifier = (String)request.getAttributes().get("uuid"); |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 if (logger.isDebugEnabled()) { |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 logger.debug("looking for artifact id '" + identifier + "'"); |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 } |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 ArtifactDatabase db = (ArtifactDatabase)getContext() |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 .getAttributes().get("database"); |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
62 try { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
63 return new DomRepresentation( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
64 MediaType.APPLICATION_XML, |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
65 db.describe(identifier)); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
66 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
67 catch (ArtifactDatabaseException adbe) { |
35
7a01a464a83b
More warning log output in POST case in REST interface of artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
34
diff
changeset
|
68 logger.warn(adbe.getLocalizedMessage(), adbe); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
69 Response response = getResponse(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
70 response.setStatus( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
71 Status.CLIENT_ERROR_NOT_FOUND, adbe.getMessage()); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
72 return new EmptyRepresentation(); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
73 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
74 } |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
76 protected Representation dispatch( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
77 String identifier, |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
78 String action, |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
79 Document source, |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
80 ArtifactDatabase db |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
81 ) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
82 Document out = null; |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
83 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
84 try { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
85 if (action.equals(FEED)) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
86 out = db.feed(identifier, source); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
87 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
88 else if (action.equals(ADVANCE)) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
89 out = db.advance(identifier, source); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
90 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
91 else { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
92 throw new ArtifactDatabaseException(NO_SUCH_ACTION_MESSAGE); |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
93 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
94 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
95 catch (ArtifactDatabaseException adbe) { |
35
7a01a464a83b
More warning log output in POST case in REST interface of artifact.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
34
diff
changeset
|
96 logger.warn(adbe.getLocalizedMessage(), adbe); |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 Response response = getResponse(); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
98 response.setStatus( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
99 Status.CLIENT_ERROR_BAD_REQUEST, adbe.getMessage()); |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 return new EmptyRepresentation(); |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 } |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
103 return new DomRepresentation(MediaType.APPLICATION_XML, out); |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 } |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 |
40
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
106 protected Representation innerPost(Representation requestRepr) { |
28
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
107 |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
108 Document inputDocument = null; |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
109 try { |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
110 DomRepresentation input = new DomRepresentation(requestRepr); |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
111 inputDocument = input.getDocument(); |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
112 } |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
113 catch (IOException ioe) { |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
114 logger.error(ioe.getMessage()); |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
115 Response response = getResponse(); |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
116 response.setStatus(Status.CLIENT_ERROR_BAD_REQUEST, ioe); |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
117 return new EmptyRepresentation(); |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
118 } |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
119 |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
120 String action = XMLUtils.xpathString( |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
121 inputDocument, |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
122 XPATH_ACTION, |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
123 ArtifactNamespaceContext.INSTANCE); |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
124 |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
125 if (action == null || action.length() == 0) { |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
126 Response response = getResponse(); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
127 response.setStatus( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
128 Status.CLIENT_ERROR_BAD_REQUEST, NO_ACTION_MESSAGE); |
28
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
129 return new EmptyRepresentation(); |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
130 } |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
131 |
40
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
132 Request request = getRequest(); |
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
133 |
28
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
134 String identifier = (String)request.getAttributes().get("uuid"); |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
135 |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
136 ArtifactDatabase db = (ArtifactDatabase)getContext() |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
137 .getAttributes().get("database"); |
019b9f02d523
Added REST handler for 'advance' and 'feed' to be called by HTTP POST '/artifact/{uuid}'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
27
diff
changeset
|
138 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
139 return dispatch(identifier, action, inputDocument, db); |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
140 } |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
141 } |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
142 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |