comparison artifact-database/src/main/java/de/intevation/artifactdatabase/rest/ArtifactOutResource.java @ 40:af22d4de275c

Log RuntimeExceptions in REST calls to log4j. artifacts/trunk@112 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 23 Sep 2009 08:27:35 +0000
parents 3f03aee55c2f
children 41c225c8bd41
comparison
equal deleted inserted replaced
39:075cb3778d71 40:af22d4de275c
1 package de.intevation.artifactdatabase.rest; 1 package de.intevation.artifactdatabase.rest;
2 2
3 import org.apache.log4j.Logger; 3 import org.apache.log4j.Logger;
4 4
5 import org.restlet.resource.Get; 5 import org.restlet.resource.ResourceException;
6 import org.restlet.resource.Post;
7 import org.restlet.resource.ServerResource;
8 6
9 import org.restlet.data.Request; 7 import org.restlet.data.Request;
10 import org.restlet.data.Response; 8 import org.restlet.data.Response;
11 import org.restlet.data.Status; 9 import org.restlet.data.Status;
12 import org.restlet.data.MediaType; 10 import org.restlet.data.MediaType;
28 26
29 /** 27 /**
30 * @author Sascha L. Teichmann (sascha.teichmann@intevation) 28 * @author Sascha L. Teichmann (sascha.teichmann@intevation)
31 */ 29 */
32 public class ArtifactOutResource 30 public class ArtifactOutResource
33 extends ServerResource 31 extends BaseResource
34 { 32 {
35 public static final String PATH = "/artifact/{uuid}/{type}"; 33 public static final String PATH = "/artifact/{uuid}/{type}";
36 34
37 public static final String XPATH_MIME_TYPE = "/action/out/mime-type/@value"; 35 public static final String XPATH_MIME_TYPE = "/action/out/mime-type/@value";
38 36
39 public static final MediaType DEFAULT_MIME_TYPE = 37 public static final MediaType DEFAULT_MIME_TYPE =
40 MediaType.APPLICATION_OCTET_STREAM; 38 MediaType.APPLICATION_OCTET_STREAM;
41 39
42 private static Logger logger = Logger.getLogger(ArtifactOutResource.class); 40 private static Logger logger = Logger.getLogger(ArtifactOutResource.class);
43 41
44 @Post 42 protected Representation innerPost(Representation requestRepr)
45 public Representation represent() { 43 throws ResourceException
46 44 {
47 Request request = getRequest();
48
49 Representation requestRepr = request.getEntity();
50
51 Document inputDocument = null; 45 Document inputDocument = null;
52 try { 46 try {
53 DomRepresentation input = new DomRepresentation(requestRepr); 47 DomRepresentation input = new DomRepresentation(requestRepr);
54 inputDocument = input.getDocument(); 48 inputDocument = input.getDocument();
55 } 49 }
60 return new EmptyRepresentation(); 54 return new EmptyRepresentation();
61 } 55 }
62 56
63 ArtifactDatabase db = (ArtifactDatabase)getContext() 57 ArtifactDatabase db = (ArtifactDatabase)getContext()
64 .getAttributes().get("database"); 58 .getAttributes().get("database");
59
60 Request request = getRequest();
65 61
66 String identifier = (String)request.getAttributes().get("uuid"); 62 String identifier = (String)request.getAttributes().get("uuid");
67 63
68 if (logger.isDebugEnabled()) { 64 if (logger.isDebugEnabled()) {
69 logger.debug("looking for artifact id '" + identifier + "'"); 65 logger.debug("looking for artifact id '" + identifier + "'");

http://dive4elements.wald.intevation.org