package com.airlenet.integration.jersey;

import com.airlenet.repo.domain.Result;
import com.airlenet.security.shiro.PlayAuthenticationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.NotFoundException;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import java.util.HashMap;
import java.util.Map;

/**
 * @author airlenet
 * @version 2017-10-05
 */
@Provider
public class ExceptionMapperSupport implements ExceptionMapper<Exception> {
   private static final Logger LOG = LoggerFactory.getLogger(ExceptionMapperSupport.class);

    @Override
    public Response toResponse(Exception e) {
        if (e instanceof PlayAuthenticationException) {
            return Response.status(Response.Status.UNAUTHORIZED).entity(Result.accessDenide()).build();
        }
        if(e instanceof NotFoundException){
            return Response.status(Response.Status.NOT_FOUND).entity(Result.notFound()).build();
        }
        LOG.error("ExceptionMapperSupport", e);
        return Response.status(Response.Status.BAD_REQUEST).entity(Result.exception()).build();
    }
}
@@ -31,24 +31,68 @@
 on.jersey;%0A%0A
+import com.airlenet.repo.domain.PlayResult;%0A
 import com.a
@@ -857,28 +857,35 @@
 ity(
+Play
 Result.
-accessDenide(
+error(%22401%22,null
 )).b
@@ -1019,24 +1019,35 @@
 ity(
+Play
 Result.
-notFound(
+error(%22404%22,null
 )).b
@@ -1179,24 +1179,28 @@
 .entity(
+Play
 Result.e
 xception
@@ -1195,17 +1195,32 @@
 lt.e
-xception(
+rror(e.getMessage(),null
 )).b

update add jersey support