This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.jcr.jackrabbit.usermanager-2.1.0 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-jackrabbit-usermanager.git
commit aadce9e6c6d45a23ef72dca93ec55f6fe2ffe95d Author: Eric Norman <enor...@apache.org> AuthorDate: Tue Aug 24 04:36:06 2010 +0000 SLING-1676 Let UserManager POST servlets return JSON git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/jackrabbit-usermanager@988381 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 20 ++++++++++++++++-- .../impl/post/AbstractAuthorizablePostServlet.java | 24 +++++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 6768e00..b05aed4 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,8 @@ </Private-Package> <Embed-Dependency> org.apache.sling.servlets.post;inline="org/apache/sling/servlets/post/impl/helper/RequestProperty* - |org/apache/sling/servlets/post/impl/helper/DateParser*" + |org/apache/sling/servlets/post/impl/helper/DateParser* + |org/apache/sling/servlets/post/impl/helper/JSONResponse*" </Embed-Dependency> </instructions> </configuration> @@ -89,7 +90,7 @@ <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.servlets.post</artifactId> - <version>2.0.4-incubator</version> + <version>2.0.5-SNAPSHOT</version> </dependency> <dependency> <groupId>org.apache.jackrabbit</groupId> @@ -109,5 +110,20 @@ <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.jcr.resource</artifactId> + <version>2.0.6</version> + </dependency> + <dependency> + <groupId>org.apache.sling</groupId> + <artifactId>org.apache.sling.commons.osgi</artifactId> + <version>2.0.6</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> </dependencies> </project> \ No newline at end of file diff --git a/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractAuthorizablePostServlet.java b/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractAuthorizablePostServlet.java index 315f636..9b7e0e7 100644 --- a/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractAuthorizablePostServlet.java +++ b/src/main/java/org/apache/sling/jackrabbit/usermanager/impl/post/AbstractAuthorizablePostServlet.java @@ -44,11 +44,12 @@ import org.apache.sling.api.servlets.HtmlResponse; import org.apache.sling.api.servlets.SlingAllMethodsServlet; import org.apache.sling.api.wrappers.SlingRequestPaths; import org.apache.sling.commons.osgi.OsgiUtil; -import org.apache.sling.servlets.post.impl.helper.DateParser; -import org.apache.sling.servlets.post.impl.helper.RequestProperty; import org.apache.sling.jackrabbit.usermanager.impl.resource.AuthorizableResourceProvider; import org.apache.sling.servlets.post.Modification; import org.apache.sling.servlets.post.SlingPostConstants; +import org.apache.sling.servlets.post.impl.helper.DateParser; +import org.apache.sling.servlets.post.impl.helper.JSONResponse; +import org.apache.sling.servlets.post.impl.helper.RequestProperty; import org.osgi.service.component.ComponentContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -103,7 +104,7 @@ public abstract class AbstractAuthorizablePostServlet extends SlingHttpServletResponse httpResponse) throws ServletException, IOException { // prepare the response - HtmlResponse htmlResponse = new HtmlResponse(); + HtmlResponse htmlResponse = createHtmlResponse(request); htmlResponse.setReferer(request.getHeader("referer")); // calculate the paths @@ -191,6 +192,23 @@ public abstract class AbstractAuthorizablePostServlet extends } /** + * Creates an instance of a HtmlResponse. + * @param req The request being serviced + * @return a {@link org.apache.sling.servlets.post.impl.helper.JSONResponse} if any of these conditions are true: + * <ul> + * <li>the response content type is application/json + * </ul> + * or a {@link org.apache.sling.api.servlets.HtmlResponse} otherwise + */ + protected HtmlResponse createHtmlResponse(SlingHttpServletRequest req) { + if (JSONResponse.RESPONSE_CONTENT_TYPE.equals(req.getResponseContentType())) { + return new JSONResponse(); + } else { + return new HtmlResponse(); + } + } + + /** * Extending Servlet should implement this operation to do the work * * @param request the sling http request to process -- To stop receiving notification emails like this one, please contact "commits@sling.apache.org" <commits@sling.apache.org>.