view 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
line wrap: on
line source
package de.intevation.artifactdatabase.rest;

import org.apache.log4j.Logger;

import org.restlet.resource.ServerResource;
import org.restlet.resource.ResourceException;

import org.restlet.representation.Representation;

/**
 * @author Sascha L. Teichmann (sascha.teichmann@intevation)
 */
public class BaseResource
extends      ServerResource
{
    private static Logger logger = Logger.getLogger(BaseResource.class);

    public BaseResource() {
    }

    protected Representation post(Representation requestRepr)
    throws    ResourceException
    {
        try {
            return innerPost(requestRepr);
        }
        catch (ResourceException re) {
            throw re;
        }
        catch (RuntimeException re) {
            logger.error(re.getLocalizedMessage(), re);
            throw re;
        }
    }

    protected Representation innerPost(Representation requestRepr)
    throws    ResourceException
    {
        return super.post(requestRepr);
    }

    protected Representation get() 
    throws    ResourceException
    {
        try {
            return innerGet();
        }
        catch (ResourceException re) {
            throw re;
        }
        catch (RuntimeException re) {
            logger.error(re.getLocalizedMessage(), re);
            throw re;
        }
    }

    protected Representation innerGet()
    throws    ResourceException
    {
        return super.get();
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

http://dive4elements.wald.intevation.org