2TWnYXrIvZ9OTX46WtWCUJ changeset

Changeset623763306433 (b)
ParentNone (a)
ab
0+Index: RestViewJsonService.java
0+===================================================================
0+--- RestViewJsonService.java    (revision 334)
0++++ RestViewJsonService.java    (working copy)
0+@@ -55,18 +55,22 @@
0+       
0+        @Override
0+        public void renderService() throws ServiceException {
0+-               if ("GET".equalsIgnoreCase(getHttpRequest().getMethod())) {
0++               String method = getHttpRequest().getMethod();
0++               if ("GET".equalsIgnoreCase(method)) {
0+                        renderServiceJSONGet();
0+-               } else if ("POST".equalsIgnoreCase(getHttpRequest().getMethod())) {
0+-                       renderServiceJSONUpdate(0);
0+-               } else if ("PUT".equalsIgnoreCase(getHttpRequest().getMethod())) {
0++               } else if ("POST".equalsIgnoreCase(method)) {
0++                       String override = getHttpRequest().getHeader("X-HTTP-Method-Override");
0++                       if ("PUT".equalsIgnoreCase(override)) renderServiceJSONUpdate(1);
0++                       else if ("DELETE".equalsIgnoreCase(override)) renderServiceJSONUpdate(2);
0++                       else renderServiceJSONUpdate(0);
0++               } else if ("PUT".equalsIgnoreCase(method)) {
0+                        renderServiceJSONUpdate(1);
0+-               } else if ("DELETE".equalsIgnoreCase(getHttpRequest().getMethod())) {
0++               } else if ("DELETE".equalsIgnoreCase(method)) {
0+                        renderServiceJSONUpdate(2);
0+                } else {
0+                        // Use a different status for an error?
0+                        //HttpServletResponse.SC_METHOD_NOT_ALLOWED;
0+-                       throw new ServiceException(null,"Method {0} is not allowed with JSON Rest Service",getHttpRequest().getMethod());
0++                       throw new ServiceException(null,"Method {0} is not allowed with JSON Rest Service",method);
0+                }
0+        }
0+ 
...
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
34
35
36
--- Revision None
+++ Revision 623763306433
@@ -0,0 +1,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);
+ }
+ }
+