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