comparison artifact-database/src/main/java/de/intevation/artifactdatabase/rest/BaseResource.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
children 4ae4dc99127d
comparison
equal deleted inserted replaced
39:075cb3778d71 40:af22d4de275c
1 package de.intevation.artifactdatabase.rest;
2
3 import org.apache.log4j.Logger;
4
5 import org.restlet.resource.ServerResource;
6 import org.restlet.resource.ResourceException;
7
8 import org.restlet.representation.Representation;
9
10 /**
11 * @author Sascha L. Teichmann (sascha.teichmann@intevation)
12 */
13 public class BaseResource
14 extends ServerResource
15 {
16 private static Logger logger = Logger.getLogger(BaseResource.class);
17
18 public BaseResource() {
19 }
20
21 protected Representation post(Representation requestRepr)
22 throws ResourceException
23 {
24 try {
25 return innerPost(requestRepr);
26 }
27 catch (ResourceException re) {
28 throw re;
29 }
30 catch (RuntimeException re) {
31 logger.error(re.getLocalizedMessage(), re);
32 throw re;
33 }
34 }
35
36 protected Representation innerPost(Representation requestRepr)
37 throws ResourceException
38 {
39 return super.post(requestRepr);
40 }
41
42 protected Representation get()
43 throws ResourceException
44 {
45 try {
46 return innerGet();
47 }
48 catch (ResourceException re) {
49 throw re;
50 }
51 catch (RuntimeException re) {
52 logger.error(re.getLocalizedMessage(), re);
53 throw re;
54 }
55 }
56
57 protected Representation innerGet()
58 throws ResourceException
59 {
60 return super.get();
61 }
62 }
63 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org