com.github.phillipkruger.apiee.providers.NotAuthorizedExceptionMapper Maven / Gradle / Ivy
package com.github.phillipkruger.apiee.providers;
import javax.ejb.AccessLocalException;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
/**
* Translate Java entity not found exceptions to HTTP response
* @author Phillip Kruger ([email protected])
*/
@Provider
public class NotAuthorizedExceptionMapper implements ExceptionMapper {
@Override
@Produces(MediaType.APPLICATION_JSON)
public Response toResponse(AccessLocalException accessLocalException) {
return Response.status(Response.Status.UNAUTHORIZED).header(REASON,accessLocalException.getMessage()).build();
}
private static final String REASON = "reason";
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy