8dffc69e by Adam Heath

Issue #4170: Refactor use of pathInfo/contentType/getPathInfo()/getContentType().

1 parent ba0e1190
...@@ -97,11 +97,12 @@ public class DirectControlServlet extends HttpServlet { ...@@ -97,11 +97,12 @@ public class DirectControlServlet extends HttpServlet {
97 } 97 }
98 98
99 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 99 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
100 String pathInfo = request.getPathInfo();
101 String contentType = request.getContentType();
100 try { 102 try {
101 Debug.logInfo("getPathInfo: " + request.getPathInfo() + 103 Debug.logInfo("getPathInfo: " + pathInfo +
102 " request.getContentType: " + request.getContentType(), module); 104 " request.getContentType: " + contentType, module);
103 105
104 String pathInfo = request.getPathInfo();
105 if (pathInfo == null || pathInfo.length() == 0) { 106 if (pathInfo == null || pathInfo.length() == 0) {
106 return; 107 return;
107 } 108 }
...@@ -109,7 +110,6 @@ public class DirectControlServlet extends HttpServlet { ...@@ -109,7 +110,6 @@ public class DirectControlServlet extends HttpServlet {
109 110
110 // Determine type of request and load the context from JSON content or 111 // Determine type of request and load the context from JSON content or
111 // parameter values accordingly 112 // parameter values accordingly
112 String contentType = request.getContentType();
113 113
114 // Determine the request method for service lookup and parameter filters 114 // Determine the request method for service lookup and parameter filters
115 String method = ""; 115 String method = "";
...@@ -129,8 +129,8 @@ public class DirectControlServlet extends HttpServlet { ...@@ -129,8 +129,8 @@ public class DirectControlServlet extends HttpServlet {
129 } 129 }
130 } else { 130 } else {
131 // Check if the request is a backbone style "emulateJSON" request 131 // Check if the request is a backbone style "emulateJSON" request
132 if (request.getContentType() != null && 132 if (contentType != null &&
133 request.getContentType().indexOf("x-www-form-urlencoded") != -1 && 133 contentType.indexOf("x-www-form-urlencoded") != -1 &&
134 request.getParameter("model") != null) { 134 request.getParameter("model") != null) {
135 Debug.logInfo("MODEL: " + request.getParameter("model"), module); 135 Debug.logInfo("MODEL: " + request.getParameter("model"), module);
136 JSON json = new JSON(new StringReader(request.getParameter("model"))); 136 JSON json = new JSON(new StringReader(request.getParameter("model")));
......