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.RepositoryVersionRuntimeException; 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.NOT_FOUND; 017import static javax.ws.rs.core.Response.status; 018import static org.fcrepo.http.commons.domain.RDFMediaType.TEXT_PLAIN_WITH_CHARSET; 019import static org.slf4j.LoggerFactory.getLogger; 020 021/** 022 * @author cabeer 023 * @since 9/15/14 024 */ 025@Provider 026public class RepositoryVersionRuntimeExceptionMapper implements 027 ExceptionMapper<RepositoryVersionRuntimeException>, ExceptionDebugLogging { 028 029 private static final Logger LOGGER = 030 getLogger(RepositoryVersionRuntimeExceptionMapper.class); 031 032 @Override 033 public Response toResponse(final RepositoryVersionRuntimeException e) { 034 debugException(this, e, LOGGER); 035 return status(NOT_FOUND).entity("This resource is not versioned").type(TEXT_PLAIN_WITH_CHARSET).build(); 036 } 037}