annotate artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ArtifactResource.java @ 36:f7d2cd59a0d5

Bugfix done. Now the feed Method works fine artifacts/trunk@93 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Wed, 16 Sep 2009 07:53:26 +0000
parents 7a01a464a83b
children af22d4de275c
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
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
3 import org.restlet.resource.Get;
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
4 import org.restlet.resource.Post;
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
5 import org.restlet.resource.ServerResource;
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
6
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
7 import org.restlet.representation.Representation;
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
8 import org.restlet.representation.EmptyRepresentation;
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 org.restlet.ext.xml.DomRepresentation;
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
11
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
12 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
13 import de.intevation.artifacts.ArtifactDatabaseException;
27
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
14 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
15 import de.intevation.artifacts.ArtifactNamespaceContext;
27
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
16
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
17 import org.restlet.data.Request;
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
18 import org.restlet.data.Response;
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
19 import org.restlet.data.Status;
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
20 import org.restlet.data.MediaType;
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.apache.log4j.Logger;
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
23
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
24 import org.w3c.dom.Document;
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
25
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
26 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
27
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
28 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
29
27
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 * @author Sascha L. Teichmann (sascha.teichmann@intevation)
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
32 */
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
33 public class ArtifactResource
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
34 extends ServerResource
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
35 {
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
36 private static Logger logger = Logger.getLogger(ArtifactResource.class);
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
37
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
38 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
39
27
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
40 public static final String PATH = "/artifact/{uuid}";
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
41
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
42 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
43 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
44
27
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
45 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
46
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
47 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
48 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
49
27
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
50 @Get
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
51 public Representation represent() {
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 Request request = getRequest();
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 String identifier = (String)request.getAttributes().get("uuid");
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
56
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
57 if (logger.isDebugEnabled()) {
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
58 logger.debug("looking for artifact id '" + identifier + "'");
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
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
61 ArtifactDatabase db = (ArtifactDatabase)getContext()
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
62 .getAttributes().get("database");
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
63
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
64 try {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
65 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
66 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
67 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
68 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
69 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
70 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
71 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
72 response.setStatus(
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
73 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
74 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
75 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
76 }
27
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
77
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
78 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
79 String identifier,
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
80 String action,
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
81 Document source,
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
82 ArtifactDatabase db
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 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
85
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
86 try {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
87 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
88 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
89 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
90 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
91 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
92 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
93 else {
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
94 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
95 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
96 }
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
97 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
98 logger.warn(adbe.getLocalizedMessage(), adbe);
27
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
99 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
100 response.setStatus(
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
101 Status.CLIENT_ERROR_BAD_REQUEST, adbe.getMessage());
27
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
102 return new EmptyRepresentation();
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
103 }
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
104
32
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
105 return new DomRepresentation(MediaType.APPLICATION_XML, out);
27
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
106 }
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
107
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
108 @Post
75bdaf900473 Added REST handler for 'describe'.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff changeset
109 public Representation representPost() {
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
110 Request request = getRequest();
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 Representation requestRepr = request.getEntity();
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
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 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
115 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
116 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
117 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
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 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
120 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
121 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
122 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
123 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
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
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 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
127 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
128 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
129 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
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 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
132 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
133 response.setStatus(
c2d53bd30ab8 Re-factored artifact API for better integration of background processing.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 29
diff changeset
134 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
135 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
136 }
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
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:

http://dive4elements.wald.intevation.org