Added checks for backwards compat on MediaTypes

This commit is contained in:
Charles Allen 2014-12-08 13:09:48 -08:00
parent 03f7fae3e8
commit 43041ed4ba
2 changed files with 8 additions and 3 deletions

View File

@ -59,6 +59,8 @@ import java.util.concurrent.TimeUnit;
public class AsyncQueryForwardingServlet extends AsyncProxyServlet public class AsyncQueryForwardingServlet extends AsyncProxyServlet
{ {
private static final EmittingLogger log = new EmittingLogger(AsyncQueryForwardingServlet.class); private static final EmittingLogger log = new EmittingLogger(AsyncQueryForwardingServlet.class);
@Deprecated // use SmileMediaTypes.APPLICATION_JACKSON_SMILE
private static final String APPLICATION_SMILE = "application/smile";
private static void handleException(HttpServletResponse response, ObjectMapper objectMapper, Exception exception) private static void handleException(HttpServletResponse response, ObjectMapper objectMapper, Exception exception)
throws IOException throws IOException
@ -103,7 +105,7 @@ public class AsyncQueryForwardingServlet extends AsyncProxyServlet
@Override @Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{ {
final boolean isSmile = SmileMediaTypes.APPLICATION_JACKSON_SMILE.equals(request.getContentType()); final boolean isSmile = SmileMediaTypes.APPLICATION_JACKSON_SMILE.equals(request.getContentType()) || APPLICATION_SMILE.equals(request.getContentType());
final ObjectMapper objectMapper = isSmile ? smileMapper : jsonMapper; final ObjectMapper objectMapper = isSmile ? smileMapper : jsonMapper;
String host = hostFinder.getDefaultHost(); String host = hostFinder.getDefaultHost();

View File

@ -49,6 +49,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.DELETE; import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.Path; import javax.ws.rs.Path;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
@ -69,6 +70,8 @@ import java.util.UUID;
public class QueryResource public class QueryResource
{ {
private static final EmittingLogger log = new EmittingLogger(QueryResource.class); private static final EmittingLogger log = new EmittingLogger(QueryResource.class);
@Deprecated // use SmileMediaTypes.APPLICATION_JACKSON_SMILE
private static final String APPLICATION_SMILE = "application/smile";
private final ServerConfig config; private final ServerConfig config;
private final ObjectMapper jsonMapper; private final ObjectMapper jsonMapper;
@ -104,7 +107,7 @@ public class QueryResource
@DELETE @DELETE
@Path("{id}") @Path("{id}")
@Produces("application/json") @Produces(MediaType.APPLICATION_JSON)
public Response getServer(@PathParam("id") String queryId) public Response getServer(@PathParam("id") String queryId)
{ {
queryManager.cancelQuery(queryId); queryManager.cancelQuery(queryId);
@ -123,7 +126,7 @@ public class QueryResource
byte[] requestQuery = null; byte[] requestQuery = null;
String queryId = null; String queryId = null;
final boolean isSmile = SmileMediaTypes.APPLICATION_JACKSON_SMILE.equals(req.getContentType()); final boolean isSmile = SmileMediaTypes.APPLICATION_JACKSON_SMILE.equals(req.getContentType()) || APPLICATION_SMILE.equals(req.getContentType());
final String contentType = isSmile ? SmileMediaTypes.APPLICATION_JACKSON_SMILE : MediaType.APPLICATION_JSON; final String contentType = isSmile ? SmileMediaTypes.APPLICATION_JACKSON_SMILE : MediaType.APPLICATION_JSON;
ObjectMapper objectMapper = isSmile ? smileMapper : jsonMapper; ObjectMapper objectMapper = isSmile ? smileMapper : jsonMapper;