BUG-2218: Keep existing link augmentations during discovery process
[controller.git] / opendaylight / adsal / 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 com.fasterxml.jackson.core.JsonProcessingException;
19
20
21 /**
22  * A custom exception mapper for handling Jackson JsonProcessingException types
23  */
24 @Provider
25 @Consumes({MediaType.APPLICATION_JSON})
26 public class JacksonJsonProcessingExceptionMapper
27     implements ExceptionMapper<JsonProcessingException>
28 {
29
30     @Override
31     public Response toResponse(JsonProcessingException exception) {
32         GenericEntity<String> entity =
33                 new GenericEntity<String>(exception.getMessage()) {};
34         return Response.status(Response.Status.BAD_REQUEST).entity(entity).build();
35     }
36 }
37