├── .gitignore
├── README.md
├── example
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── com
│ │ └── stormpath
│ │ └── blog
│ │ └── spring
│ │ ├── http
│ │ └── converter
│ │ │ └── json
│ │ │ └── DefaultJacksonHttpMessageConverter.java
│ │ └── mvc
│ │ └── rest
│ │ └── exhandler
│ │ ├── DefaultController.java
│ │ ├── UnknownResourceException.java
│ │ ├── User.java
│ │ └── UserController.java
│ └── webapp
│ └── WEB-INF
│ ├── rest-servlet.xml
│ └── web.xml
├── main
├── pom.xml
└── src
│ └── main
│ └── java
│ └── com
│ └── stormpath
│ └── spring
│ └── web
│ └── servlet
│ └── handler
│ ├── DefaultRestErrorResolver.java
│ ├── MapRestErrorConverter.java
│ ├── RestError.java
│ ├── RestErrorConverter.java
│ ├── RestErrorResolver.java
│ └── RestExceptionHandler.java
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | *.ipr
3 | *.iws
4 | target
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #Stormpath is Joining Okta
2 | We are incredibly excited to announce that [Stormpath is joining forces with Okta](https://stormpath.com/blog/stormpaths-new-path?utm_source=github&utm_medium=readme&utm-campaign=okta-announcement). Please visit [the Migration FAQs](https://stormpath.com/oktaplusstormpath?utm_source=github&utm_medium=readme&utm-campaign=okta-announcement) for a detailed look at what this means for Stormpath users.
3 |
4 | We're available to answer all questions at [support@stormpath.com](mailto:support@stormpath.com).
5 |
6 | spring-mvc-rest-exhandler
7 | =========================
8 |
9 | Spring MVC ReST Exception Handler
10 |
11 | Check out the two-part blog post that this example backs: [Part 1](https://stormpath.com/blog/spring-mvc-rest-exception-handling-best-practices-part-1/), [Part 2](https://stormpath.com/blog/spring-mvc-rest-exception-handling-best-practices-part-2/)
12 |
--------------------------------------------------------------------------------
/example/pom.xml:
--------------------------------------------------------------------------------
1 |
16 |
18 |
19 | 4.0.0
20 |
21 |
22 | com.stormpath.blog
23 | spring-mvc-rest-exhandler-root
24 | 1.0.0-SNAPSHOT
25 |
26 |
27 | com.stormpath.blog
28 | spring-mvc-rest-exhandler-example
29 | 1.0.0-SNAPSHOT
30 | war
31 |
32 | Spring MVC Rest Exception Handler : Example Webapp
33 |
34 |
35 |
36 | com.stormpath.blog
37 | spring-mvc-rest-exhandler
38 |
39 |
40 | org.codehaus.jackson
41 | jackson-mapper-asl
42 |
43 |
44 | org.slf4j
45 | slf4j-api
46 |
47 |
48 | org.springframework
49 | spring-web
50 |
51 |
52 | org.springframework
53 | spring-webmvc
54 |
55 |
56 | javax.servlet
57 | servlet-api
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.mortbay.jetty
65 | maven-jetty-plugin
66 | ${jetty.version}
67 |
68 | /
69 |
70 |
71 | 8080
72 | 60000
73 |
74 |
75 |
76 | ./target/yyyy_mm_dd.request.log
77 | 90
78 | true
79 | false
80 | GMT
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/example/src/main/java/com/stormpath/blog/spring/http/converter/json/DefaultJacksonHttpMessageConverter.java:
--------------------------------------------------------------------------------
1 | package com.stormpath.blog.spring.http.converter.json;
2 |
3 | import org.codehaus.jackson.JsonEncoding;
4 | import org.codehaus.jackson.JsonGenerationException;
5 | import org.codehaus.jackson.JsonGenerator;
6 | import org.codehaus.jackson.JsonParseException;
7 | import org.codehaus.jackson.map.ObjectMapper;
8 | import org.codehaus.jackson.map.type.TypeFactory;
9 | import org.codehaus.jackson.type.JavaType;
10 | import org.springframework.http.HttpInputMessage;
11 | import org.springframework.http.HttpOutputMessage;
12 | import org.springframework.http.MediaType;
13 | import org.springframework.http.converter.AbstractHttpMessageConverter;
14 | import org.springframework.http.converter.HttpMessageNotReadableException;
15 | import org.springframework.http.converter.HttpMessageNotWritableException;
16 | import org.springframework.util.Assert;
17 |
18 | import java.io.IOException;
19 | import java.nio.charset.Charset;
20 |
21 | /**
22 | * Replaces Spring's {@link org.springframework.http.converter.json.MappingJacksonHttpMessageConverter}, which is
23 | * difficult to configure for pretty-printing. This implementation enables pretty-printing easily via a setter/getter.
24 | *