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;
009
010import static javax.ws.rs.core.Response.Status.CONFLICT;
011import static javax.ws.rs.core.Response.status;
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.GhostNodeException;
018
019/**
020 * Map an GhostNodeException to a response.
021 * @author whikloj
022 */
023@Provider
024public class GhostNodeExceptionMapper implements ExceptionMapper<GhostNodeException> {
025
026    @Override
027    public Response toResponse(final GhostNodeException e) {
028        final String msg = e.getMessage();
029        return status(CONFLICT).entity(msg).type(TEXT_PLAIN_WITH_CHARSET).build();
030    }
031}