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 static org.fcrepo.http.commons.domain.RDFMediaType.TEXT_PLAIN_WITH_CHARSET; 009import static org.slf4j.LoggerFactory.getLogger; 010 011import static javax.ws.rs.core.Response.Status.UNSUPPORTED_MEDIA_TYPE; 012import static javax.ws.rs.core.Response.status; 013 014import javax.ws.rs.core.Response; 015import javax.ws.rs.ext.ExceptionMapper; 016import javax.ws.rs.ext.Provider; 017 018import org.fcrepo.kernel.api.exception.UnsupportedMediaTypeException; 019import org.slf4j.Logger; 020 021/** 022 * UnsupportedMediaType mapper 023 * @author whikloj 024 * @since 6.0.0 025 */ 026@Provider 027public class UnsupportedMediaTypeExceptionMapper implements 028 ExceptionMapper<UnsupportedMediaTypeException>, ExceptionDebugLogging { 029 030 private static final Logger LOGGER = 031 getLogger(UnsupportedMediaTypeExceptionMapper.class); 032 033 @Override 034 public Response toResponse(final UnsupportedMediaTypeException e) { 035 debugException(this, e, LOGGER); 036 037 return status(UNSUPPORTED_MEDIA_TYPE).entity(e.getMessage()).type(TEXT_PLAIN_WITH_CHARSET).build(); 038 } 039 040}