Remove redundant expression true:false
[controller.git] / opendaylight / northbound / commons / src / main / java / org / opendaylight / controller / northbound / commons / JacksonJsonProcessingExceptionMapper.java
1 /**
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.northbound.commons;
10
11 import javax.ws.rs.Consumes;
12 import javax.ws.rs.core.GenericEntity;
13 import javax.ws.rs.core.MediaType;
14 import javax.ws.rs.core.Response;
15 import javax.ws.rs.ext.ExceptionMapper;
16 import javax.ws.rs.ext.Provider;
17
18 import org.codehaus.jackson.JsonProcessingException;
19
20 /**
21  * A custom exception mapper for handling Jackson JsonProcessingException types
22  */
23 @Provider
24 @Consumes({MediaType.APPLICATION_JSON})
25 public class JacksonJsonProcessingExceptionMapper
26     implements ExceptionMapper<JsonProcessingException>
27 {
28
29     @Override
30     public Response toResponse(JsonProcessingException exception) {
31         GenericEntity<String> entity =
32                 new GenericEntity<String>(exception.getMessage()) {};
33         return Response.status(Response.Status.BAD_REQUEST).entity(entity).build();
34     }
35 }
36