001/*
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 */
006package org.fcrepo.http.commons.exceptionhandlers;
007
008import org.fcrepo.kernel.api.exception.ResourceTypeException;
009
010import org.slf4j.Logger;
011
012import javax.ws.rs.core.Response;
013import javax.ws.rs.ext.ExceptionMapper;
014import javax.ws.rs.ext.Provider;
015
016import static javax.ws.rs.core.Response.Status.BAD_REQUEST;
017import static org.slf4j.LoggerFactory.getLogger;
018import static javax.ws.rs.core.Response.status;
019
020/**
021 * @author cabeer
022 * @since 9/15/14
023 */
024@Provider
025public class ResourceTypeExceptionMapper implements
026        ExceptionMapper<ResourceTypeException>, ExceptionDebugLogging {
027
028    private static final Logger LOGGER =
029            getLogger(ResourceTypeExceptionMapper.class);
030
031    @Override
032    public Response toResponse(final ResourceTypeException e) {
033        debugException(this, e, LOGGER);
034        return status(BAD_REQUEST).entity(null).build();
035    }
036}