// Path: src/java/tmf/org/dsmapi/tt/service/JsonFault.java
// @XmlRootElement
// @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
// public class JsonFault {
// 
//     private ExceptionBean error;
//     private String detail;
// 
//     public JsonFault(ExceptionBean error) {
//         this.error = error;
//     }
// 
//     public JsonFault(ExceptionBean error, String detail) {
//         this.error = error;
//         this.detail = detail;
//     }   
// 
//     /**
//      * @return the type
//      */
//     public ExceptionBean getError() {
//         return error;
//     }
// 
//     /**
//      * @param type the type to set
//      */
//     public void setError(ExceptionBean error) {
//         this.error = error;
//     }
// 
//     /**
//      * @return the detail
//      */
//     public String getDetail() {
//         return detail;
//     }
// 
//     /**
//      * @param detail the detail to set
//      */
//     public void setDetail(String detail) {
//         this.detail = detail;
//     }
// 
// }
// 
// Path: src/java/tmf/org/dsmapi/commons/exceptions/ExceptionType.java
// public enum ExceptionType {
// 
//     BAD_USAGE_GENERIC(new ExceptionBean("4000", "Bad Usage")),
//     BAD_USAGE_SEARCH_QUERY(new ExceptionBean("4001", "Search query is not valid")),
//     BAD_USAGE_STATUS_TRANSITION(new ExceptionBean("4002", "The status transition is not allowed")),
//     BAD_USAGE_MANDATORY_FIELDS(new ExceptionBean("4003", "Missing mandatory field")),
//     BAD_USAGE_UNKNOWN_VALUE(new ExceptionBean("4004", "Unknown value")),    
//     UNKNOWN_RESOURCE(new ExceptionBean("4041", "Unknown resource"));
//     private ExceptionBean info;
// 
//     ExceptionType(ExceptionBean info) {
//         this.info = info;
//     }
// 
//     @Override
//     public String toString() {
//         String out = String.format("%1$ - %2$ - %3$", this.getInfo().getCode(), this.name(), this.getInfo().getTitle());
//         return out;
//     }
// 
//     public ExceptionBean getInfo() {
//         return info;
//     }    
// }


import tmf.org.dsmapi.tt.service.JsonFault;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.codehaus.jackson.map.JsonMappingException;
import tmf.org.dsmapi.commons.exceptions.ExceptionType;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tmf.org.dsmapi.tt.service.mapper;


@Provider
public class JsonMappingExceptionMapper implements ExceptionMapper<JsonMappingException> {
    @Override
    public Response toResponse(JsonMappingException ex) {
// Path: src/java/tmf/org/dsmapi/tt/service/JsonFault.java
// @XmlRootElement
// @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
// public class JsonFault {
// 
//     private ExceptionBean error;
//     private String detail;
// 
//     public JsonFault(ExceptionBean error) {
//         this.error = error;
//     }
// 
//     public JsonFault(ExceptionBean error, String detail) {
//         this.error = error;
//         this.detail = detail;
//     }   
// 
//     /**
//      * @return the type
//      */
//     public ExceptionBean getError() {
//         return error;
//     }
// 
//     /**
//      * @param type the type to set
//      */
//     public void setError(ExceptionBean error) {
//         this.error = error;
//     }
// 
//     /**
//      * @return the detail
//      */
//     public String getDetail() {
//         return detail;
//     }
// 
//     /**
//      * @param detail the detail to set
//      */
//     public void setDetail(String detail) {
//         this.detail = detail;
//     }
// 
// }
// 
// Path: src/java/tmf/org/dsmapi/commons/exceptions/ExceptionType.java
// public enum ExceptionType {
// 
//     BAD_USAGE_GENERIC(new ExceptionBean("4000", "Bad Usage")),
//     BAD_USAGE_SEARCH_QUERY(new ExceptionBean("4001", "Search query is not valid")),
//     BAD_USAGE_STATUS_TRANSITION(new ExceptionBean("4002", "The status transition is not allowed")),
//     BAD_USAGE_MANDATORY_FIELDS(new ExceptionBean("4003", "Missing mandatory field")),
//     BAD_USAGE_UNKNOWN_VALUE(new ExceptionBean("4004", "Unknown value")),    
//     UNKNOWN_RESOURCE(new ExceptionBean("4041", "Unknown resource"));
//     private ExceptionBean info;
// 
//     ExceptionType(ExceptionBean info) {
//         this.info = info;
//     }
// 
//     @Override
//     public String toString() {
//         String out = String.format("%1$ - %2$ - %3$", this.getInfo().getCode(), this.name(), this.getInfo().getTitle());
//         return out;
//     }
// 
//     public ExceptionBean getInfo() {
//         return info;
//     }    
// }


// Path: src/java/tmf/org/dsmapi/tt/service/mapper/JsonMappingExceptionMapper.java
import tmf.org.dsmapi.tt.service.JsonFault;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.codehaus.jackson.map.JsonMappingException;
import tmf.org.dsmapi.commons.exceptions.ExceptionType;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tmf.org.dsmapi.tt.service.mapper;


@Provider
public class JsonMappingExceptionMapper implements ExceptionMapper<JsonMappingException> {
    @Override
    public Response toResponse(JsonMappingException ex) {
        JsonFault error = new JsonFault(ExceptionType.BAD_USAGE_UNKNOWN_VALUE.getInfo(), ex.getMessage());