Revision 623763306433 () - Diff

Link to this snippet: https://friendpaste.com/2TWnYXrIvZ9OTX46WtWCUJ
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Index: RestViewJsonService.java
===================================================================
--- RestViewJsonService.java (revision 334)
+++ RestViewJsonService.java (working copy)
@@ -55,18 +55,22 @@
@Override
public void renderService() throws ServiceException {
- if ("GET".equalsIgnoreCase(getHttpRequest().getMethod())) {
+ String method = getHttpRequest().getMethod();
+ if ("GET".equalsIgnoreCase(method)) {
renderServiceJSONGet();
- } else if ("POST".equalsIgnoreCase(getHttpRequest().getMethod())) {
- renderServiceJSONUpdate(0);
- } else if ("PUT".equalsIgnoreCase(getHttpRequest().getMethod())) {
+ } else if ("POST".equalsIgnoreCase(method)) {
+ String override = getHttpRequest().getHeader("X-HTTP-Method-Override");
+ if ("PUT".equalsIgnoreCase(override)) renderServiceJSONUpdate(1);
+ else if ("DELETE".equalsIgnoreCase(override)) renderServiceJSONUpdate(2);
+ else renderServiceJSONUpdate(0);
+ } else if ("PUT".equalsIgnoreCase(method)) {
renderServiceJSONUpdate(1);
- } else if ("DELETE".equalsIgnoreCase(getHttpRequest().getMethod())) {
+ } else if ("DELETE".equalsIgnoreCase(method)) {
renderServiceJSONUpdate(2);
} else {
// Use a different status for an error?
//HttpServletResponse.SC_METHOD_NOT_ALLOWED;
- throw new ServiceException(null,"Method {0} is not allowed with JSON Rest Service",getHttpRequest().getMethod());
+ throw new ServiceException(null,"Method {0} is not allowed with JSON Rest Service",method);
}
}