Mercurial > dive4elements > framework
annotate artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ArtifactResource.java @ 62:76abf0c64d3b
Added XML utils method to load XML file from file.
artifacts/trunk@438 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 16 Dec 2009 08:08:56 +0000 |
parents | 9a29899b31e5 |
children | 8b72676698b5 |
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 |
55
9a29899b31e5
describe() in REST interface is also handled as POST to pass
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
48
diff
changeset
|
45 public static final String ADVANCE = "advance"; |
9a29899b31e5
describe() in REST interface is also handled as POST to pass
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
48
diff
changeset
|
46 public static final String FEED = "feed"; |
9a29899b31e5
describe() in REST interface is also handled as POST to pass
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
48
diff
changeset
|
47 public static final String DESCRIBE = "describe"; |
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
|
48 |
40
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
49 protected Representation innerGet() |
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
50 throws ResourceException |
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
51 { |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 Request request = getRequest(); |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 String identifier = (String)request.getAttributes().get("uuid"); |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 if (logger.isDebugEnabled()) { |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 logger.debug("looking for artifact id '" + identifier + "'"); |
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 |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 ArtifactDatabase db = (ArtifactDatabase)getContext() |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 .getAttributes().get("database"); |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
63 try { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
64 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
|
65 MediaType.APPLICATION_XML, |
55
9a29899b31e5
describe() in REST interface is also handled as POST to pass
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
48
diff
changeset
|
66 db.describe(identifier, null, getCallMeta())); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
67 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
68 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
|
69 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
|
70 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
|
71 response.setStatus( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
72 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
|
73 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
|
74 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
75 } |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
77 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
|
78 String identifier, |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
79 String action, |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
80 Document source, |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
81 ArtifactDatabase db |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
82 ) { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
83 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
|
84 |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
85 try { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
86 if (action.equals(FEED)) { |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
40
diff
changeset
|
87 out = db.feed(identifier, source, getCallMeta()); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
88 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
89 else if (action.equals(ADVANCE)) { |
48
41c225c8bd41
Add i18n support via "Accept-Language" HTTP headers.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
40
diff
changeset
|
90 out = db.advance(identifier, source, getCallMeta()); |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
91 } |
55
9a29899b31e5
describe() in REST interface is also handled as POST to pass
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
48
diff
changeset
|
92 else if (action.equals(DESCRIBE)) { |
9a29899b31e5
describe() in REST interface is also handled as POST to pass
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
48
diff
changeset
|
93 out = db.describe(identifier, source, getCallMeta()); |
9a29899b31e5
describe() in REST interface is also handled as POST to pass
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
48
diff
changeset
|
94 } |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
95 else { |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
96 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
|
97 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
98 } |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
99 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
|
100 logger.warn(adbe.getLocalizedMessage(), adbe); |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 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
|
102 response.setStatus( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
103 Status.CLIENT_ERROR_BAD_REQUEST, adbe.getMessage()); |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
104 return new EmptyRepresentation(); |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
105 } |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
106 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
107 return new DomRepresentation(MediaType.APPLICATION_XML, out); |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 } |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 |
40
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
110 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
|
111 |
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 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
|
113 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
|
114 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
|
115 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
|
116 } |
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 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 } |
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 |
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 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
|
125 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
|
126 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
|
127 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
|
128 |
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 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
|
130 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
|
131 response.setStatus( |
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
132 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
|
133 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
|
134 } |
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 |
40
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
136 Request request = getRequest(); |
af22d4de275c
Log RuntimeExceptions in REST calls to log4j.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
35
diff
changeset
|
137 |
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
|
138 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
|
139 |
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
|
140 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
|
141 .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
|
142 |
32
c2d53bd30ab8
Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
29
diff
changeset
|
143 return dispatch(identifier, action, inputDocument, db); |
27
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
144 } |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
145 } |
75bdaf900473
Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
146 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |