Reviewers: dev-remailer_shindig.apache.org,
Message:
Simple change to remove ApiServlet.checkContentTypes method to use
ContentTypes.checkContentTypes method instead.
Description:
The ApiServlet.checkContentTypes method it is just a simple wrapper to
ContentTypes.checkContentTypes and its not used by external class other
that the subclasses JsonRpcServlet and DataServiceServlet.
Modify the JsonRpcServlet and DataServiceServlet to call
ContentTypes.checkContentTypes instead.
Please review this at http://codereview.appspot.com/1820041/show
Affected files:
java/common/src/main/java/org/apache/shindig/protocol/ApiServlet.java
java/common/src/main/java/org/apache/shindig/protocol/DataServiceServlet.java
java/common/src/main/java/org/apache/shindig/protocol/JsonRpcServlet.java
Index:
java/common/src/main/java/org/apache/shindig/protocol/DataServiceServlet.java
===================================================================
---
java/common/src/main/java/org/apache/shindig/protocol/DataServiceServlet.java
(revision 963534)
+++
java/common/src/main/java/org/apache/shindig/protocol/DataServiceServlet.java
(working copy)
@@ -59,7 +59,7 @@
HttpServletResponse servletResponse)
throws ServletException, IOException {
try {
- checkContentTypes(ALLOWED_CONTENT_TYPES,
servletRequest.getContentType());
+ ContentTypes.checkContentTypes(ALLOWED_CONTENT_TYPES,
servletRequest.getContentType());
executeRequest(servletRequest, servletResponse);
} catch (ContentTypes.InvalidContentTypeException icte) {
sendError(servletResponse,
@@ -79,7 +79,7 @@
HttpServletResponse servletResponse)
throws ServletException, IOException {
try {
- checkContentTypes(ALLOWED_CONTENT_TYPES,
servletRequest.getContentType());
+ ContentTypes.checkContentTypes(ALLOWED_CONTENT_TYPES,
servletRequest.getContentType());
executeRequest(servletRequest, servletResponse);
} catch (ContentTypes.InvalidContentTypeException icte) {
sendError(servletResponse,
Index: java/common/src/main/java/org/apache/shindig/protocol/ApiServlet.java
===================================================================
--- java/common/src/main/java/org/apache/shindig/protocol/ApiServlet.java
(revision 963534)
+++ java/common/src/main/java/org/apache/shindig/protocol/ApiServlet.java
(working copy)
@@ -68,6 +68,7 @@
protected BeanJsonConverter jsonConverter;
protected BeanConverter xmlConverter;
protected BeanConverter atomConverter;
+ protected ContainerConfig containerConfig;
@Override
public void init(ServletConfig config) throws ServletException {
@@ -91,8 +92,6 @@
this.dispatcher = dispatcher;
}
- protected ContainerConfig containerConfig;
-
@Inject
public void setContainerConfig(ContainerConfig containerConfig) {
this.containerConfig = containerConfig;
@@ -154,9 +153,4 @@
}
servletResponse.setCharacterEncoding(DEFAULT_ENCODING);
}
-
- public void checkContentTypes(Set<String> allowedContentTypes,
- String contentType) throws ContentTypes.InvalidContentTypeException {
- ContentTypes.checkContentTypes(allowedContentTypes, contentType);
- }
}
Index:
java/common/src/main/java/org/apache/shindig/protocol/JsonRpcServlet.java
===================================================================
---
java/common/src/main/java/org/apache/shindig/protocol/JsonRpcServlet.java
(revision 963534)
+++
java/common/src/main/java/org/apache/shindig/protocol/JsonRpcServlet.java
(working copy)
@@ -147,7 +147,7 @@
throws ContentTypes.InvalidContentTypeException, IOException {
String content = null;
- checkContentTypes(ALLOWED_CONTENT_TYPES, request.getContentType());
+ ContentTypes.checkContentTypes(ALLOWED_CONTENT_TYPES,
request.getContentType());
if (formParser.isMultipartContent(request)) {
for (FormDataItem item : formParser.parse(request)) {
@@ -157,7 +157,7 @@
// field or file item will not be parsed out, but will be
exposed via getFormItem
// method of RequestItem.
if (!StringUtils.isEmpty(item.getContentType())) {
- checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES,
item.getContentType());
+
ContentTypes.checkContentTypes(ContentTypes.ALLOWED_JSON_CONTENT_TYPES,
item.getContentType());
}
content = item.getAsString();
} else {