incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1076637 [2/2] - in /sling/trunk/bundles/servlets/post: ./ src/main/java/org/apache/sling/servlets/post/ src/main/java/org/apache/sling/servlets/post/impl/ src/main/java/org/apache/sling/servlets/post/impl/helper/ src/main/java/org/apache/s...
Date Thu, 03 Mar 2011 14:25:57 GMT
Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostOperation.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/SlingPostOperation.java Thu Mar  3 14:25:56 2011
@@ -30,29 +30,31 @@ import org.apache.sling.api.servlets.Htm
  * The <code>SlingPostOperation</code> service must be registered with a
  * {@link #PROP_OPERATION_NAME} registration property giving the name(s) of the
  * operations supported by the service. The names will be used to find the
- * actual operation from the
- * {@link SlingPostConstants#RP_OPERATION <code>:operation</code>} request
- * parameter.
+ * actual operation from the {@link SlingPostConstants#RP_OPERATION
+ * <code>:operation</code>} request parameter.
  * <p>
  * The Sling default POST servlet defines the <code>copy</code>,
- * <code>move</code> and <code>delete</code> operation names. These names
- * should not be used by <code>SlingPostOperation</code> service providers.
+ * <code>move</code> and <code>delete</code> operation names. These names should
+ * not be used by <code>SlingPostOperation</code> service providers.
+ *
+ * @deprecated as of 2.0.8 (Bundle version 2.2.0) and replaced by
+ *             {@link PostOperation}.
  */
+@Deprecated
 public interface SlingPostOperation {
 
     /**
-     * The name of the Sling POST operation service (value is
-     * "org.apache.sling.servlets.post.SlingPostOperation").
+     * The name of the Sling POST operation service.
      */
-    public static final String SERVICE_NAME = SlingPostOperation.class.getName();
+    public static final String SERVICE_NAME = "org.apache.sling.servlets.post.SlingPostOperation";
 
     /**
      * The name of the service registration property indicating the name(s) of
      * the operation provided by the operation implementation (value is
      * "sling.post.operation"). The value of this service property must be a
-     * single String or an array or <code>java.util.Collection</code> of Strings.
-     * If multiple strings are defined, the service is registered for all
-     * operation names.
+     * single String or an array or <code>java.util.Collection</code> of
+     * Strings. If multiple strings are defined, the service is registered for
+     * all operation names.
      */
     public static final String PROP_OPERATION_NAME = "sling.post.operation";
 
@@ -60,10 +62,13 @@ public interface SlingPostOperation {
      * Executes the operation provided by this service implementation. This
      * method is called by the Sling default POST servlet.
      *
-     * @param request The <code>SlingHttpServletRequest</code> object
-     *            providing the request input for the operation.
+     * @param request The <code>SlingHttpServletRequest</code> object providing
+     *            the request input for the operation.
      * @param response The <code>HtmlResponse</code> into which the operation
      *            steps should be recorded.
+     * @param processors The {@link SlingPostProcessor} services to be called
+     *            after applying the operation. This may be <code>null</code> if
+     *            there are none.
      * @throws org.apache.sling.api.resource.ResourceNotFoundException May be
      *             thrown if the operation requires an existing request
      *             resource. If this exception is thrown the Sling default POST
@@ -72,5 +77,6 @@ public interface SlingPostOperation {
      * @throws org.apache.sling.api.SlingException May be thrown if an error
      *             occurrs running the operation.
      */
-    void run(SlingHttpServletRequest request, HtmlResponse response, SlingPostProcessor[] processors);
+    void run(SlingHttpServletRequest request, HtmlResponse response,
+            SlingPostProcessor[] processors);
 }

Added: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/PostOperationProxyProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/PostOperationProxyProvider.java?rev=1076637&view=auto
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/PostOperationProxyProvider.java (added)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/PostOperationProxyProvider.java Thu Mar  3 14:25:56 2011
@@ -0,0 +1,239 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.servlets.post.impl;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.IdentityHashMap;
+import java.util.Map;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.servlets.post.PostOperation;
+import org.apache.sling.servlets.post.PostResponse;
+import org.apache.sling.servlets.post.SlingPostOperation;
+import org.apache.sling.servlets.post.SlingPostProcessor;
+import org.apache.sling.servlets.post.impl.helper.HtmlResponseProxy;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * The <code>PostOperationProxyProvider</code> listens for legacy
+ * {@link SlingPostOperation} services being registered and wraps them with a
+ * proxy for the new {@link PostOperation} API and registers the procies.
+ */
+@Component(specVersion = "1.1", metatype = false)
+public class PostOperationProxyProvider implements ServiceListener {
+
+    /**
+     * The service listener filter to listen for SlingPostOperation services
+     */
+    private static final String REFERENCE_FILTER = "(" + Constants.OBJECTCLASS
+        + "=" + SlingPostOperation.SERVICE_NAME + ")";
+
+    // maps references to the SlingPostOperation services to the registrations
+    // of the PostOperation proxies for unregistration purposes
+    private final Map<ServiceReference, ServiceRegistration> proxies = new IdentityHashMap<ServiceReference, ServiceRegistration>();
+
+    // The DS component context to access the services to proxy
+    private BundleContext bundleContext;
+
+    // DS activation/deactivation
+
+    /**
+     * Activates the proxy provider component:
+     * <ol>
+     * <li>Keep BundleContext reference</li>
+     * <li>Start listening for SlingPostOperation services</li>
+     * <li>Register proxies for all existing SlingPostOperation services</li>
+     * </ol>
+     */
+    @SuppressWarnings("unused")
+    @Activate
+    private void activate(final BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+
+        try {
+            bundleContext.addServiceListener(this, REFERENCE_FILTER);
+            final ServiceReference[] serviceReferences = bundleContext.getServiceReferences(
+                SlingPostOperation.SERVICE_NAME, null);
+            if (serviceReferences != null) {
+                for (ServiceReference serviceReference : serviceReferences) {
+                    register(serviceReference);
+                }
+            }
+        } catch (InvalidSyntaxException ise) {
+            // not expected for tested static filter
+            // TODO:log !!
+        }
+    }
+
+    /**
+     * Deactivates the proxy provide component:
+     * <ol>
+     * <li>Unregister as a service listener</li>
+     * <li>Unregister all proxies</li>
+     * <li>Drop BundleContext reference</li>
+     * </ol>
+     */
+    @SuppressWarnings("unused")
+    @Deactivate
+    private void deactivate() {
+
+        this.bundleContext.removeServiceListener(this);
+
+        final ServiceReference[] serviceReferences;
+        synchronized (this.proxies) {
+            serviceReferences = this.proxies.keySet().toArray(
+                new ServiceReference[this.proxies.size()]);
+        }
+
+        for (ServiceReference serviceReference : serviceReferences) {
+            unregister(serviceReference);
+        }
+
+        this.bundleContext = null;
+    }
+
+    // ServiceEvent handling
+
+    public void serviceChanged(ServiceEvent event) {
+
+        /*
+         * There is a slight chance for a race condition on deactivation where
+         * the component may be deactivating and the bundle context reference
+         * has been removed but the framework is still sending service events.
+         * In this situation we don't want to handle the event any way and so we
+         * can safely ignore it
+         */
+        if (this.bundleContext == null) {
+            return;
+        }
+
+        switch (event.getType()) {
+            case ServiceEvent.REGISTERED:
+                register(event.getServiceReference());
+                break;
+            case ServiceEvent.MODIFIED:
+                update(event.getServiceReference());
+                break;
+            case ServiceEvent.UNREGISTERING:
+                unregister(event.getServiceReference());
+                break;
+        }
+    }
+
+    /**
+     * Access SlingPostOperation service and register proxy.
+     * <p>
+     * Called by serviceChanged
+     */
+    private void register(final ServiceReference serviceReference) {
+        final SlingPostOperation service = (SlingPostOperation) this.bundleContext.getService(serviceReference);
+        final PostOperationProxy proxy = new PostOperationProxy(service);
+
+        final BundleContext bundleContext = serviceReference.getBundle().getBundleContext();
+        final Dictionary<String, Object> props = copyServiceProperties(serviceReference);
+        final ServiceRegistration reg = bundleContext.registerService(
+            PostOperation.SERVICE_NAME, proxy, props);
+
+        synchronized (this.proxies) {
+            this.proxies.put(serviceReference, reg);
+        }
+    }
+
+    /**
+     * Update proxy service registration properties
+     * <p>
+     * Called by serviceChanged
+     */
+    private void update(final ServiceReference serviceReference) {
+        final ServiceRegistration proxyRegistration;
+        synchronized (this.proxies) {
+            proxyRegistration = this.proxies.get(serviceReference);
+        }
+
+        if (proxyRegistration != null) {
+            proxyRegistration.setProperties(copyServiceProperties(serviceReference));
+        }
+    }
+
+    /**
+     * Unregister proxy and unget SlingPostOperation service
+     * <p>
+     * Called by serviceChanged
+     */
+    private void unregister(final ServiceReference serviceReference) {
+        final ServiceRegistration proxyRegistration;
+        synchronized (this.proxies) {
+            proxyRegistration = this.proxies.remove(serviceReference);
+        }
+
+        if (proxyRegistration != null) {
+            this.bundleContext.ungetService(serviceReference);
+            proxyRegistration.unregister();
+        }
+    }
+
+    // Helpers
+
+    /**
+     * Creates a Dictionary for use as the service registration properties of
+     * the PostOperation proxy.
+     */
+    private Dictionary<String, Object> copyServiceProperties(
+            final ServiceReference serviceReference) {
+        final Dictionary<String, Object> props = new Hashtable<String, Object>();
+        for (String key : serviceReference.getPropertyKeys()) {
+            props.put(key, serviceReference.getProperty(key));
+        }
+        props.put(PostOperation.PROP_OPERATION_NAME,
+            serviceReference.getProperty(SlingPostOperation.SERVICE_NAME));
+        props.put(Constants.SERVICE_DESCRIPTION, "Proxy for "
+            + serviceReference);
+        return props;
+    }
+
+    /**
+     * The <code>PostOperationProxy</code> is the proxy implementing the
+     * {@link PostOperation} service interface by calling the
+     * {@link SlingPostOperation} service.
+     */
+    private class PostOperationProxy implements PostOperation {
+
+        private final SlingPostOperation delegatee;
+
+        PostOperationProxy(final SlingPostOperation delegatee) {
+            this.delegatee = delegatee;
+        }
+
+        public void run(SlingHttpServletRequest request, PostResponse response,
+                SlingPostProcessor[] processors) {
+            HtmlResponse apiResponse = new HtmlResponseProxy(response);
+            delegatee.run(request, apiResponse, processors);
+        }
+    }
+}

Propchange: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/PostOperationProxyProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/PostOperationProxyProvider.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java Thu Mar  3 14:25:56 2011
@@ -22,26 +22,38 @@ import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.References;
+import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.SlingHttpServletResponse;
 import org.apache.sling.api.resource.ResourceNotFoundException;
 import org.apache.sling.api.resource.ResourceUtil;
-import org.apache.sling.api.servlets.HtmlResponse;
 import org.apache.sling.api.servlets.SlingAllMethodsServlet;
 import org.apache.sling.commons.osgi.OsgiUtil;
 import org.apache.sling.jcr.contentloader.ContentImporter;
+import org.apache.sling.servlets.post.HtmlResponse;
+import org.apache.sling.servlets.post.JSONResponse;
 import org.apache.sling.servlets.post.NodeNameGenerator;
+import org.apache.sling.servlets.post.PostOperation;
+import org.apache.sling.servlets.post.PostResponse;
 import org.apache.sling.servlets.post.SlingPostConstants;
 import org.apache.sling.servlets.post.SlingPostOperation;
 import org.apache.sling.servlets.post.SlingPostProcessor;
 import org.apache.sling.servlets.post.VersioningConfiguration;
 import org.apache.sling.servlets.post.impl.helper.DateParser;
 import org.apache.sling.servlets.post.impl.helper.DefaultNodeNameGenerator;
-import org.apache.sling.servlets.post.impl.helper.JSONResponse;
 import org.apache.sling.servlets.post.impl.helper.MediaRangeList;
 import org.apache.sling.servlets.post.impl.operations.CheckinOperation;
 import org.apache.sling.servlets.post.impl.operations.CheckoutOperation;
@@ -51,46 +63,29 @@ import org.apache.sling.servlets.post.im
 import org.apache.sling.servlets.post.impl.operations.ModifyOperation;
 import org.apache.sling.servlets.post.impl.operations.MoveOperation;
 import org.apache.sling.servlets.post.impl.operations.NopOperation;
+import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.component.ComponentContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * POST servlet that implements the sling client library "protocol"
- *
- * @scr.component immediate="true" label="%servlet.post.name"
- *                description="%servlet.post.description"
- * @scr.service interface="javax.servlet.Servlet"
- * @scr.property name="service.description" value="Sling Post Servlet"
- * @scr.property name="service.vendor" value="The Apache Software Foundation"
- *
- * Use this as the default servlet for POST requests for Sling
- * @scr.property name="sling.servlet.prefix" value="-1" type="Integer" private="true"
- *
- *
- * @scr.property name="sling.servlet.paths"
- *          values.0="sling/servlet/default/POST"
- *          private="true"
- *
- * Get all SlingPostProcessors
- * @scr.reference name="postProcessor"
- *                interface="org.apache.sling.servlets.post.SlingPostProcessor"
- *                cardinality="0..n" policy="dynamic"
- * @scr.reference name="postOperation"
- * 					interface="org.apache.sling.servlets.post.SlingPostOperation"
- * 					cardinality="0..n"
- * 					policy="dynamic"
- * @scr.reference name="nodeNameGenerator"
- *                  interface="org.apache.sling.servlets.post.NodeNameGenerator"
- *                  cardinality="0..n"
- *                  policy="dynamic"
- * @scr.reference name="contentImporter"
- *                  interface="org.apache.sling.jcr.contentloader.ContentImporter"
- *                  cardinality="0..1"
- *                  policy="dynamic"
  */
+@Component(immediate = true, metatype = true, label = "%servlet.post.name", description = "%servlet.post.description")
+@Service(value = Servlet.class)
+@org.apache.felix.scr.annotations.Properties({
+    @Property(name = "service.description", value = "Sling Post Servlet"),
+    @Property(name = "service.vendor", value = "The Apache Software Foundation"),
+    @Property(name = "sling.servlet.prefix", intValue = -1, propertyPrivate = true),
+    @Property(name = "sling.servlet.paths", value = "sling/servlet/default/POST", propertyPrivate = true) })
+@References({
+    @Reference(name = "postProcessor", referenceInterface = SlingPostProcessor.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+    @Reference(name = "postOperation", referenceInterface = PostOperation.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+    @Reference(name = "nodeNameGenerator", referenceInterface = NodeNameGenerator.class, cardinality = ReferenceCardinality.OPTIONAL_MULTIPLE, policy = ReferencePolicy.DYNAMIC),
+    @Reference(name = "contentImporter", referenceInterface = ContentImporter.class, cardinality = ReferenceCardinality.OPTIONAL_UNARY, policy = ReferencePolicy.DYNAMIC) })
 public class SlingPostServlet extends SlingAllMethodsServlet {
 
     private static final long serialVersionUID = 1837674988291697074L;
@@ -100,46 +95,33 @@ public class SlingPostServlet extends Sl
      */
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    /**
-     * @scr.property values.0="EEE MMM dd yyyy HH:mm:ss 'GMT'Z"
-     *               values.1="ISO8601"
-     *               values.2="yyyy-MM-dd'T'HH:mm:ss.SSSZ"
-     *               values.3="yyyy-MM-dd'T'HH:mm:ss" values.4="yyyy-MM-dd"
-     *               values.5="dd.MM.yyyy HH:mm:ss" values.6="dd.MM.yyyy"
-     */
+    @Property({ "EEE MMM dd yyyy HH:mm:ss 'GMT'Z", "ISO8601",
+        "yyyy-MM-dd'T'HH:mm:ss.SSSZ", "yyyy-MM-dd'T'HH:mm:ss", "yyyy-MM-dd",
+        "dd.MM.yyyy HH:mm:ss", "dd.MM.yyyy" })
     private static final String PROP_DATE_FORMAT = "servlet.post.dateFormats";
 
-    /**
-     * @scr.property values.0="title" values.1="jcr:title" values.2="name"
-     *               values.3="description" values.4="jcr:description"
-     *               values.5="abstract" values.6="text" values.7="jcr:text"
-     */
+    @Property({ "title", "jcr:title", "name", "description",
+        "jcr:description", "abstract", "text", "jcr:text" })
     private static final String PROP_NODE_NAME_HINT_PROPERTIES = "servlet.post.nodeNameHints";
 
-    /**
-     * @scr.property value="20" type="Integer"
-     */
+    @Property(intValue = 20)
     private static final String PROP_NODE_NAME_MAX_LENGTH = "servlet.post.nodeNameMaxLength";
 
-    /**
-     * @scr.property valueRef="DEFAULT_CHECKIN_ON_CREATE" type="Boolean"
-     */
+    private static final boolean DEFAULT_CHECKIN_ON_CREATE = false;
+
+    @Property(boolValue = DEFAULT_CHECKIN_ON_CREATE)
     private static final String PROP_CHECKIN_ON_CREATE = "servlet.post.checkinNewVersionableNodes";
 
-    /**
-     * @scr.property valueRef="DEFAULT_AUTO_CHECKOUT" type="Boolean"
-     */
+    private static final boolean DEFAULT_AUTO_CHECKOUT = false;
+
+    @Property(boolValue = DEFAULT_AUTO_CHECKOUT)
     private static final String PROP_AUTO_CHECKOUT = "servlet.post.autoCheckout";
-    /**
-     * @scr.property valueRef="DEFAULT_AUTO_CHECKIN" type="Boolean"
-     */
-    private static final String PROP_AUTO_CHECKIN = "servlet.post.autoCheckin";
 
-    private static final boolean DEFAULT_CHECKIN_ON_CREATE = false;
+    private static final boolean DEFAULT_AUTO_CHECKIN = true;
 
-    private static final boolean DEFAULT_AUTO_CHECKOUT = false;
+    @Property(boolValue = DEFAULT_AUTO_CHECKIN)
+    private static final String PROP_AUTO_CHECKIN = "servlet.post.autoCheckin";
 
-    private static final boolean DEFAULT_AUTO_CHECKIN = true;
 
     private static final String PARAM_CHECKIN_ON_CREATE = ":checkinNewVersionableNodes";
 
@@ -154,9 +136,11 @@ public class SlingPostServlet extends Sl
 
     private ModifyOperation modifyOperation;
 
+    private ServiceRegistration[] internalOperations;
+
     private final List<ServiceReference> delayedPostOperations = new ArrayList<ServiceReference>();
 
-    private final Map<String, SlingPostOperation> postOperations = new HashMap<String, SlingPostOperation>();
+    private final Map<String, PostOperation> postOperations = new HashMap<String, PostOperation>();
 
     private final List<ServiceReference> delayedPostProcessors = new ArrayList<ServiceReference>();
 
@@ -184,37 +168,6 @@ public class SlingPostServlet extends Sl
     private VersioningConfiguration baseVersioningConfiguration;
 
     @Override
-    public void init() {
-        // default operation: create/modify
-        modifyOperation = new ModifyOperation(defaultNodeNameGenerator, dateParser,
-            getServletContext());
-        modifyOperation.setExtraNodeNameGenerators(cachedNodeNameGenerators);
-
-        // other predefined operations
-        postOperations.put(SlingPostConstants.OPERATION_COPY,
-            new CopyOperation());
-        postOperations.put(SlingPostConstants.OPERATION_MOVE,
-            new MoveOperation());
-        postOperations.put(SlingPostConstants.OPERATION_DELETE,
-            new DeleteOperation());
-        postOperations.put(SlingPostConstants.OPERATION_NOP, new NopOperation());
-        postOperations.put(SlingPostConstants.OPERATION_CHECKIN, new CheckinOperation());
-        postOperations.put(SlingPostConstants.OPERATION_CHECKOUT, new CheckoutOperation());
-
-        importOperation = new ImportOperation(defaultNodeNameGenerator,
-            contentImporter);
-        importOperation.setExtraNodeNameGenerators(cachedNodeNameGenerators);
-        postOperations.put(SlingPostConstants.OPERATION_IMPORT,
-            importOperation);
-    }
-
-    @Override
-    public void destroy() {
-        modifyOperation = null;
-        postOperations.clear();
-    }
-
-    @Override
     protected void doPost(SlingHttpServletRequest request,
             SlingHttpServletResponse response) throws IOException {
         VersioningConfiguration localVersioningConfig = createRequestVersioningConfiguration(request);
@@ -222,10 +175,10 @@ public class SlingPostServlet extends Sl
         request.setAttribute(VersioningConfiguration.class.getName(), localVersioningConfig);
 
         // prepare the response
-        HtmlResponse htmlResponse = createHtmlResponse(request);
+        PostResponse htmlResponse = createHtmlResponse(request);
         htmlResponse.setReferer(request.getHeader("referer"));
 
-        SlingPostOperation operation = getSlingPostOperation(request);
+        PostOperation operation = getSlingPostOperation(request);
         if (operation == null) {
 
             htmlResponse.setStatus(
@@ -276,7 +229,7 @@ public class SlingPostServlet extends Sl
      * </ul>
      * or a {@link org.apache.sling.api.servlets.HtmlResponse} otherwise
      */
-     HtmlResponse createHtmlResponse(SlingHttpServletRequest req) {
+     PostResponse createHtmlResponse(SlingHttpServletRequest req) {
         @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
         MediaRangeList mediaRangeList = new MediaRangeList(req);
         if (JSONResponse.RESPONSE_CONTENT_TYPE.equals(mediaRangeList.prefer("text/html", JSONResponse.RESPONSE_CONTENT_TYPE))) {
@@ -286,7 +239,7 @@ public class SlingPostServlet extends Sl
         }
     }
 
-    private SlingPostOperation getSlingPostOperation(
+    private PostOperation getSlingPostOperation(
             SlingHttpServletRequest request) {
         String operation = request.getParameter(SlingPostConstants.RP_OPERATION);
         if (operation == null || operation.length() == 0) {
@@ -304,7 +257,7 @@ public class SlingPostServlet extends Sl
      * @param ctx the post processor
      * @return the redirect location or <code>null</code>
      */
-    protected String getRedirectUrl(HttpServletRequest request, HtmlResponse ctx) {
+    protected String getRedirectUrl(HttpServletRequest request, PostResponse ctx) {
         // redirect param has priority (but see below, magic star)
         String result = request.getParameter(SlingPostConstants.RP_REDIRECT_TO);
         if (result != null && ctx.getPath() != null) {
@@ -415,9 +368,58 @@ public class SlingPostServlet extends Sl
         }
 
         this.baseVersioningConfiguration = createBaseVersioningConfiguration(props);
+
+        // default operation: create/modify
+        modifyOperation = new ModifyOperation(defaultNodeNameGenerator,
+            dateParser);
+        modifyOperation.setExtraNodeNameGenerators(cachedNodeNameGenerators);
+
+        importOperation = new ImportOperation(defaultNodeNameGenerator,
+            contentImporter);
+        importOperation.setExtraNodeNameGenerators(cachedNodeNameGenerators);
+
+        // other predefined operations
+        final ArrayList<ServiceRegistration> providedServices = new ArrayList<ServiceRegistration>();
+        final BundleContext bundleContext = componentContext.getBundleContext();
+        providedServices.add(registerOperation(bundleContext,
+            SlingPostConstants.OPERATION_MODIFY, modifyOperation));
+        providedServices.add(registerOperation(bundleContext,
+            SlingPostConstants.OPERATION_COPY, new CopyOperation()));
+        providedServices.add(registerOperation(bundleContext,
+            SlingPostConstants.OPERATION_MOVE, new MoveOperation()));
+        providedServices.add(registerOperation(bundleContext,
+            SlingPostConstants.OPERATION_DELETE, new DeleteOperation()));
+        providedServices.add(registerOperation(bundleContext,
+            SlingPostConstants.OPERATION_NOP, new NopOperation()));
+        providedServices.add(registerOperation(bundleContext,
+            SlingPostConstants.OPERATION_CHECKIN, new CheckinOperation()));
+        providedServices.add(registerOperation(bundleContext,
+            SlingPostConstants.OPERATION_CHECKOUT, new CheckoutOperation()));
+        providedServices.add(registerOperation(bundleContext,
+            SlingPostConstants.OPERATION_IMPORT, importOperation));
+
+        internalOperations = providedServices.toArray(new ServiceRegistration[providedServices.size()]);
+    }
+
+    @Override
+    public void init() throws ServletException {
+        modifyOperation.setServletContext(getServletContext());
+    }
+
+    @Override
+    public void destroy() {
+        modifyOperation.setServletContext(null);
     }
 
     protected void deactivate(ComponentContext context) {
+        if (internalOperations != null) {
+            for (ServiceRegistration registration : internalOperations) {
+                registration.unregister();
+            }
+            internalOperations = null;
+        }
+        modifyOperation = null;
+        defaultNodeNameGenerator = null;
         dateParser = null;
         this.componentContext = null;
     }
@@ -434,7 +436,7 @@ public class SlingPostServlet extends Sl
 
     protected void registerPostOperation(ServiceReference ref) {
     	String operationName = (String) ref.getProperty(SlingPostOperation.PROP_OPERATION_NAME);
-		SlingPostOperation operation = (SlingPostOperation) this.componentContext.locateService("postOperation", ref);
+		PostOperation operation = (PostOperation) this.componentContext.locateService("postOperation", ref);
 		if ( operation != null ) {
 	        synchronized (this.postOperations) {
 	            this.postOperations.put(operationName, operation);
@@ -498,6 +500,18 @@ public class SlingPostServlet extends Sl
         }
     }
 
+    private ServiceRegistration registerOperation(final BundleContext context,
+            final String opCode, final PostOperation operation) {
+        Properties properties = new Properties();
+        properties.put(PostOperation.PROP_OPERATION_NAME, opCode);
+        properties.put(Constants.SERVICE_DESCRIPTION,
+            "Sling POST Servlet Operation " + opCode);
+        properties.put(Constants.SERVICE_VENDOR,
+            context.getBundle().getHeaders().get(Constants.BUNDLE_VENDOR));
+        return context.registerService(PostOperation.SERVICE_NAME, operation,
+            properties);
+    }
+
     protected void bindNodeNameGenerator(ServiceReference ref) {
         synchronized ( this.delayedNodeNameGenerators ) {
             if ( this.componentContext == null ) {

Added: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlPostResponseProxy.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlPostResponseProxy.java?rev=1076637&view=auto
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlPostResponseProxy.java (added)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlPostResponseProxy.java Thu Mar  3 14:25:56 2011
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.servlets.post.impl.helper;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.servlets.post.PostResponse;
+
+/**
+ * The <code>HtmlPostResponseProxy</code> class implements the
+ * {@link PostResponse} interface using a Sling API <code>HtmlResponse</code>.
+ * <p>
+ * This class is mainly used by the deprecated
+ * {@link org.apache.sling.servlets.post.AbstractSlingPostOperation} for
+ * bridging into the new
+ * {@link org.apache.sling.servlets.post.AbstractPostOperation}.
+ */
+public class HtmlPostResponseProxy implements PostResponse {
+
+    private final HtmlResponse apiHtmlResponse;
+
+    public HtmlPostResponseProxy(final HtmlResponse apiHtmlResponse) {
+        this.apiHtmlResponse = apiHtmlResponse;
+    }
+
+    public HtmlResponse getHtmlResponse() {
+        return apiHtmlResponse;
+    }
+
+    public Throwable getError() {
+        return apiHtmlResponse.getError();
+    }
+
+    public String getLocation() {
+        return apiHtmlResponse.getLocation();
+    }
+
+    public String getParentLocation() {
+        return apiHtmlResponse.getParentLocation();
+    }
+
+    public String getPath() {
+        return apiHtmlResponse.getPath();
+    }
+
+    public <Type> Type getProperty(String name, Class<Type> type) {
+        return apiHtmlResponse.getProperty(name, type);
+    }
+
+    public Object getProperty(String name) {
+        return apiHtmlResponse.getProperty(name);
+    }
+
+    public String getReferer() {
+        return apiHtmlResponse.getReferer();
+    }
+
+    public int getStatusCode() {
+        return apiHtmlResponse.getStatusCode();
+    }
+
+    public String getStatusMessage() {
+        return apiHtmlResponse.getStatusMessage();
+    }
+
+    public boolean isCreateRequest() {
+        return apiHtmlResponse.isCreateRequest();
+    }
+
+    public boolean isSuccessful() {
+        return apiHtmlResponse.isSuccessful();
+    }
+
+    public void onChange(String type, String... arguments) {
+        apiHtmlResponse.onChange(type, arguments);
+    }
+
+    public void onCopied(String srcPath, String dstPath) {
+        apiHtmlResponse.onCopied(srcPath, dstPath);
+    }
+
+    public void onCreated(String path) {
+        apiHtmlResponse.onCreated(path);
+    }
+
+    public void onDeleted(String path) {
+        apiHtmlResponse.onDeleted(path);
+    }
+
+    public void onModified(String path) {
+        apiHtmlResponse.onModified(path);
+    }
+
+    public void onMoved(String srcPath, String dstPath) {
+        apiHtmlResponse.onMoved(srcPath, dstPath);
+    }
+
+    public void send(HttpServletResponse response, boolean setStatus)
+            throws IOException {
+        apiHtmlResponse.send(response, setStatus);
+    }
+
+    public void setCreateRequest(boolean isCreateRequest) {
+        apiHtmlResponse.setCreateRequest(isCreateRequest);
+    }
+
+    public void setError(Throwable error) {
+        apiHtmlResponse.setError(error);
+    }
+
+    public void setLocation(String location) {
+        apiHtmlResponse.setLocation(location);
+    }
+
+    public void setParentLocation(String parentLocation) {
+        apiHtmlResponse.setParentLocation(parentLocation);
+    }
+
+    public void setPath(String path) {
+        apiHtmlResponse.setPath(path);
+    }
+
+    public void setProperty(String name, Object value) {
+        apiHtmlResponse.setProperty(name, value);
+    }
+
+    public void setReferer(String referer) {
+        apiHtmlResponse.setReferer(referer);
+    }
+
+    public void setStatus(int code, String message) {
+        apiHtmlResponse.setStatus(code, message);
+    }
+
+    public void setTitle(String title) {
+        apiHtmlResponse.setTitle(title);
+    }
+}

Propchange: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlPostResponseProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlPostResponseProxy.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Added: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlResponseProxy.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlResponseProxy.java?rev=1076637&view=auto
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlResponseProxy.java (added)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlResponseProxy.java Thu Mar  3 14:25:56 2011
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.servlets.post.impl.helper;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.servlets.post.PostResponse;
+
+/**
+ * The <code>HtmlResponseProxy</code> extends the Sling API
+ * <code>HtmlResponse</code> overwriting all public methods and redirecting to a
+ * proxied {@link PostResponse}. As a consequence the underlying (extended)
+ * Sling API <code>HtmlResponse</code> will not be fed with data and thus will
+ * remain "empty".
+ * <p>
+ * This class is mainly used by the deprecated
+ * {@link org.apache.sling.servlets.post.AbstractSlingPostOperation} for
+ * bridging into the new
+ * {@link org.apache.sling.servlets.post.AbstractPostOperation}.
+ */
+public class HtmlResponseProxy extends HtmlResponse {
+
+    private final PostResponse postResponse;
+
+    public HtmlResponseProxy(final PostResponse postResponse) {
+        this.postResponse = postResponse;
+    }
+
+    public PostResponse getPostResponse() {
+        return postResponse;
+    }
+
+    public <Type> Type getProperty(String name, Class<Type> type) {
+        // return postResponse.getProperty(name, type);
+        return null;
+    }
+
+    public Object getProperty(String name) {
+        // return postResponse.getProperty(name);
+        return null;
+    }
+
+    public void setProperty(String name, Object value) {
+        // postResponse.setProperty(name, value);
+    }
+
+    public Throwable getError() {
+        return postResponse.getError();
+    }
+
+    public String getLocation() {
+        return postResponse.getLocation();
+    }
+
+    public String getParentLocation() {
+        return postResponse.getParentLocation();
+    }
+
+    public String getPath() {
+        return postResponse.getPath();
+    }
+
+    public String getReferer() {
+        return postResponse.getReferer();
+    }
+
+    public int getStatusCode() {
+        return postResponse.getStatusCode();
+    }
+
+    public String getStatusMessage() {
+        return postResponse.getStatusMessage();
+    }
+
+    public boolean isCreateRequest() {
+        return postResponse.isCreateRequest();
+    }
+
+    public boolean isSuccessful() {
+        return postResponse.isSuccessful();
+    }
+
+    public void onChange(String type, String... arguments) {
+        postResponse.onChange(type, arguments);
+    }
+
+    public void onCopied(String srcPath, String dstPath) {
+        postResponse.onCopied(srcPath, dstPath);
+    }
+
+    public void onCreated(String path) {
+        postResponse.onCreated(path);
+    }
+
+    public void onDeleted(String path) {
+        postResponse.onDeleted(path);
+    }
+
+    public void onModified(String path) {
+        postResponse.onModified(path);
+    }
+
+    public void onMoved(String srcPath, String dstPath) {
+        postResponse.onMoved(srcPath, dstPath);
+    }
+
+    public void send(HttpServletResponse response, boolean setStatus)
+            throws IOException {
+        postResponse.send(response, setStatus);
+    }
+
+    public void setCreateRequest(boolean isCreateRequest) {
+        postResponse.setCreateRequest(isCreateRequest);
+    }
+
+    public void setError(Throwable error) {
+        postResponse.setError(error);
+    }
+
+    public void setLocation(String location) {
+        postResponse.setLocation(location);
+    }
+
+    public void setParentLocation(String parentLocation) {
+        postResponse.setParentLocation(parentLocation);
+    }
+
+    public void setPath(String path) {
+        postResponse.setPath(path);
+    }
+
+    public void setReferer(String referer) {
+        postResponse.setReferer(referer);
+    }
+
+    public void setStatus(int code, String message) {
+        postResponse.setStatus(code, message);
+    }
+
+    public void setTitle(String title) {
+        postResponse.setTitle(title);
+    }
+}

Propchange: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlResponseProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/HtmlResponseProxy.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev Url

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingFileUploadHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingFileUploadHandler.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingFileUploadHandler.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingFileUploadHandler.java Thu Mar  3 14:25:56 2011
@@ -86,14 +86,10 @@ public class SlingFileUploadHandler {
     /**
      * The servlet context.
      */
-    private final ServletContext servletContext;
+    private ServletContext servletContext;
 
-    /**
-     * Constructs file upload handler
-     * @param servletCtx the post processor
-     */
-    public SlingFileUploadHandler(ServletContext servletCtx) {
-        this.servletContext = servletCtx;
+    public void setServletContext(ServletContext servletContext) {
+        this.servletContext = servletContext;
     }
 
     /**
@@ -179,7 +175,10 @@ public class SlingFileUploadHandler {
             }
             if (contentType == null || contentType.equals("application/octet-stream")) {
                 // try to find a better content type
-                contentType = this.servletContext.getMimeType(value.getFileName());
+                ServletContext ctx = this.servletContext;
+                if (ctx != null) {
+                    contentType = ctx.getMimeType(value.getFileName());
+                }
                 if (contentType == null || contentType.equals("application/octet-stream")) {
                     contentType = "application/octet-stream";
                 }
@@ -219,7 +218,7 @@ public class SlingFileUploadHandler {
         return result;
     }
 
-    private Node createWithChanges(Node parent, String name, String typeHint, 
+    private Node createWithChanges(Node parent, String name, String typeHint,
             List<Modification> changes) throws RepositoryException {
         Node result = parent.addNode(name, typeHint);
         changes.add(Modification.onCreated(result.getPath()));

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCopyMoveOperation.java Thu Mar  3 14:25:56 2011
@@ -28,9 +28,9 @@ import javax.servlet.http.HttpServletRes
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceUtil;
-import org.apache.sling.api.servlets.HtmlResponse;
-import org.apache.sling.servlets.post.AbstractSlingPostOperation;
+import org.apache.sling.servlets.post.AbstractPostOperation;
 import org.apache.sling.servlets.post.Modification;
+import org.apache.sling.servlets.post.PostResponse;
 import org.apache.sling.servlets.post.SlingPostConstants;
 import org.apache.sling.servlets.post.VersioningConfiguration;
 
@@ -39,15 +39,15 @@ import org.apache.sling.servlets.post.Ve
  * the {@link CopyOperation} and {@link MoveOperation} classes implementing
  * commong behaviour.
  */
-abstract class AbstractCopyMoveOperation extends AbstractSlingPostOperation {
+abstract class AbstractCopyMoveOperation extends AbstractPostOperation {
 
     @Override
     protected final void doRun(SlingHttpServletRequest request,
-            HtmlResponse response,
+            PostResponse response,
             List<Modification> changes)
     throws RepositoryException {
         Session session = request.getResourceResolver().adaptTo(Session.class);
-        
+
         VersioningConfiguration versioningConfiguration = getVersioningConfiguration(request);
 
         Resource resource = request.getResource();

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractCreateOperation.java Thu Mar  3 14:25:56 2011
@@ -34,21 +34,20 @@ import javax.jcr.nodetype.ConstraintViol
 import javax.jcr.nodetype.NoSuchNodeTypeException;
 import javax.jcr.nodetype.NodeType;
 import javax.jcr.version.VersionException;
-import javax.servlet.ServletException;
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.request.RequestParameter;
 import org.apache.sling.api.request.RequestParameterMap;
 import org.apache.sling.api.resource.ResourceUtil;
-import org.apache.sling.api.servlets.HtmlResponse;
-import org.apache.sling.servlets.post.AbstractSlingPostOperation;
+import org.apache.sling.servlets.post.AbstractPostOperation;
 import org.apache.sling.servlets.post.Modification;
 import org.apache.sling.servlets.post.NodeNameGenerator;
+import org.apache.sling.servlets.post.PostResponse;
 import org.apache.sling.servlets.post.SlingPostConstants;
 import org.apache.sling.servlets.post.VersioningConfiguration;
 import org.apache.sling.servlets.post.impl.helper.RequestProperty;
 
-abstract class AbstractCreateOperation extends AbstractSlingPostOperation {
+abstract class AbstractCreateOperation extends AbstractPostOperation {
     /**
      * The default node name generator
      */
@@ -73,7 +72,7 @@ abstract class AbstractCreateOperation e
      * @throws RepositoryException if a repository error occurs
      */
     protected void processCreate(Session session,
-            Map<String, RequestProperty> reqProperties, HtmlResponse response, List<Modification> changes,
+            Map<String, RequestProperty> reqProperties, PostResponse response, List<Modification> changes,
             VersioningConfiguration versioningConfiguration)
             throws RepositoryException {
 
@@ -126,7 +125,7 @@ abstract class AbstractCreateOperation e
             }
         }
     }
-    
+
     /**
      * Collects the properties that form the content to be written back to the
      * repository.
@@ -135,7 +134,7 @@ abstract class AbstractCreateOperation e
      * @throws ServletException if an internal error occurs
      */
     protected Map<String, RequestProperty> collectContent(
-            SlingHttpServletRequest request, HtmlResponse response) {
+            SlingHttpServletRequest request, PostResponse response) {
 
         boolean requireItemPrefix = requireItemPathPrefix(request);
 
@@ -308,7 +307,7 @@ abstract class AbstractCreateOperation e
      * property path by prepending the response path (<code>response.getPath</code>)
      * to the parameter name if not already absolute.
      */
-    private String toPropertyPath(String paramName, HtmlResponse response) {
+    private String toPropertyPath(String paramName, PostResponse response) {
         if (!paramName.startsWith("/")) {
             paramName = ResourceUtil.normalize(response.getPath() + '/' + paramName);
         }
@@ -465,10 +464,10 @@ abstract class AbstractCreateOperation e
     protected String generateName(SlingHttpServletRequest request, String basePath)
     	throws RepositoryException {
 
-		// SLING-1091: If a :name parameter is supplied, the (first) value of this parameter is used unmodified as the name 
-		//    for the new node. If the name is illegally formed with respect to JCR name requirements, an exception will be 
-		//    thrown when trying to create the node. The assumption with the :name parameter is, that the caller knows what 
-		//    he (or she) is supplying and should get the exact result if possible.        
+		// SLING-1091: If a :name parameter is supplied, the (first) value of this parameter is used unmodified as the name
+		//    for the new node. If the name is illegally formed with respect to JCR name requirements, an exception will be
+		//    thrown when trying to create the node. The assumption with the :name parameter is, that the caller knows what
+		//    he (or she) is supplying and should get the exact result if possible.
 		RequestParameterMap parameters = request.getRequestParameterMap();
 		RequestParameter specialParam = parameters.getValue(SlingPostConstants.RP_NODE_NAME);
 		if ( specialParam != null ) {
@@ -476,7 +475,7 @@ abstract class AbstractCreateOperation e
 		        // If the path ends with a *, create a node under its parent, with
 		        // a generated node name
 		        basePath = basePath += "/" + specialParam.getString();
-		
+
 		        // if the resulting path already exists then report an error
 		        Session session = request.getResourceResolver().adaptTo(Session.class);
 	            String jcrPath = removeAndValidateWorkspace(basePath, session);
@@ -484,14 +483,14 @@ abstract class AbstractCreateOperation e
 	    		    throw new RepositoryException(
 	    			        "Collision in node names for path=" + basePath);
 	            }
-		
+
 		        return basePath;
 		    }
 		}
 
 		// no :name value was supplied, so generate a name
 		boolean requirePrefix = requireItemPathPrefix(request);
-		
+
 		String generatedName = null;
 		if (extraNodeNameGenerators != null) {
 		    for (NodeNameGenerator generator : extraNodeNameGenerators) {
@@ -504,13 +503,13 @@ abstract class AbstractCreateOperation e
 		if (generatedName == null) {
 		    generatedName = defaultNodeNameGenerator.getNodeName(request, basePath, requirePrefix, defaultNodeNameGenerator);
 		}
-		
+
 		// If the path ends with a *, create a node under its parent, with
 		// a generated node name
 		basePath += "/" + generatedName;
-		
+
 		basePath = ensureUniquePath(request, basePath);
-		
+
 		return basePath;
     }
 
@@ -518,9 +517,9 @@ abstract class AbstractCreateOperation e
 		// if resulting path exists, add a suffix until it's not the case
 		// anymore
 		Session session = request.getResourceResolver().adaptTo(Session.class);
-		
+
 		String jcrPath = removeAndValidateWorkspace(basePath, session);
-		
+
 		// if resulting path exists, add a suffix until it's not the case
 		// anymore
 		if (session.itemExists(jcrPath)) {
@@ -533,14 +532,14 @@ abstract class AbstractCreateOperation e
 		        }
 		    }
 		}
-		
+
 		// if it still exists there are more than 1000 nodes ?
 		if (session.itemExists(jcrPath)) {
 		    throw new RepositoryException(
 		        "Collision in generated node names for path=" + basePath);
 		}
-		
+
 		return basePath;
     }
-    
+
 }

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckinOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckinOperation.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckinOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckinOperation.java Thu Mar  3 14:25:56 2011
@@ -25,19 +25,19 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.servlets.HtmlResponse;
-import org.apache.sling.servlets.post.AbstractSlingPostOperation;
+import org.apache.sling.servlets.post.AbstractPostOperation;
 import org.apache.sling.servlets.post.Modification;
+import org.apache.sling.servlets.post.PostResponse;
 
 /**
  * The <code>CheckinOperation</code> class implements the
  * {@link org.apache.sling.servlets.post.SlingPostConstants#OPERATION_CHECKIN checkin}
  * operation for the Sling default POST servlet.
  */
-public class CheckinOperation extends AbstractSlingPostOperation {
+public class CheckinOperation extends AbstractPostOperation {
 
     @Override
-    protected void doRun(SlingHttpServletRequest request, HtmlResponse response, List<Modification> changes)
+    protected void doRun(SlingHttpServletRequest request, PostResponse response, List<Modification> changes)
             throws RepositoryException {
         Iterator<Resource> res = getApplyToResources(request);
         if (res == null) {

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckoutOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckoutOperation.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckoutOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/CheckoutOperation.java Thu Mar  3 14:25:56 2011
@@ -25,18 +25,18 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.servlets.HtmlResponse;
-import org.apache.sling.servlets.post.AbstractSlingPostOperation;
+import org.apache.sling.servlets.post.AbstractPostOperation;
 import org.apache.sling.servlets.post.Modification;
+import org.apache.sling.servlets.post.PostResponse;
 
 /**
  * The <code>CheckoutOperation</code> class implements the
  * {@link org.apache.sling.servlets.post.SlingPostConstants#OPERATION_CHECKOUT checkout}
  * operation for the Sling default POST servlet.
  */
-public class CheckoutOperation extends AbstractSlingPostOperation {
+public class CheckoutOperation extends AbstractPostOperation {
     @Override
-    protected void doRun(SlingHttpServletRequest request, HtmlResponse response, List<Modification> changes)
+    protected void doRun(SlingHttpServletRequest request, PostResponse response, List<Modification> changes)
             throws RepositoryException {
         Iterator<Resource> res = getApplyToResources(request);
         if (res == null) {

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/DeleteOperation.java Thu Mar  3 14:25:56 2011
@@ -25,9 +25,9 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.Resource;
-import org.apache.sling.api.servlets.HtmlResponse;
-import org.apache.sling.servlets.post.AbstractSlingPostOperation;
+import org.apache.sling.servlets.post.AbstractPostOperation;
 import org.apache.sling.servlets.post.Modification;
+import org.apache.sling.servlets.post.PostResponse;
 import org.apache.sling.servlets.post.VersioningConfiguration;
 
 /**
@@ -35,10 +35,10 @@ import org.apache.sling.servlets.post.Ve
  * {@link org.apache.sling.servlets.post.SlingPostConstants#OPERATION_DELETE delete}
  * operation for the Sling default POST servlet.
  */
-public class DeleteOperation extends AbstractSlingPostOperation {
+public class DeleteOperation extends AbstractPostOperation {
 
     @Override
-    protected void doRun(SlingHttpServletRequest request, HtmlResponse response, List<Modification> changes)
+    protected void doRun(SlingHttpServletRequest request, PostResponse response, List<Modification> changes)
     throws RepositoryException {
         VersioningConfiguration versioningConfiguration = getVersioningConfiguration(request);
 

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ImportOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ImportOperation.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ImportOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ImportOperation.java Thu Mar  3 14:25:56 2011
@@ -29,13 +29,13 @@ import javax.servlet.http.HttpServletRes
 
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.request.RequestParameter;
-import org.apache.sling.api.servlets.HtmlResponse;
 import org.apache.sling.jcr.contentloader.ContentImportListener;
 import org.apache.sling.jcr.contentloader.ContentImporter;
 import org.apache.sling.jcr.contentloader.ImportOptions;
 import org.apache.sling.servlets.post.Modification;
 import org.apache.sling.servlets.post.ModificationType;
 import org.apache.sling.servlets.post.NodeNameGenerator;
+import org.apache.sling.servlets.post.PostResponse;
 import org.apache.sling.servlets.post.SlingPostConstants;
 import org.apache.sling.servlets.post.VersioningConfiguration;
 import org.apache.sling.servlets.post.impl.helper.RequestProperty;
@@ -61,9 +61,9 @@ public class ImportOperation extends Abs
     public void setContentImporter(ContentImporter importer) {
 		this.contentImporter = importer;
 	}
-    
+
     @Override
-    protected void doRun(SlingHttpServletRequest request, HtmlResponse response, final List<Modification> changes)
+    protected void doRun(SlingHttpServletRequest request, PostResponse response, final List<Modification> changes)
     		throws RepositoryException {
     	ContentImporter importer = contentImporter;
     	if (importer == null) {
@@ -73,7 +73,7 @@ public class ImportOperation extends Abs
     	}
     	Map<String, RequestProperty> reqProperties = collectContent(request,
              response);
-     
+
         VersioningConfiguration versioningConfiguration = getVersioningConfiguration(request);
 
         // do not change order unless you have a very good reason.
@@ -92,7 +92,7 @@ public class ImportOperation extends Abs
             // it was not a node
         }
         if (node == null) {
-            
+
             response.setStatus(HttpServletResponse.SC_NOT_FOUND,
                     "Missing target node " + path + " for import");
             return;
@@ -109,17 +109,17 @@ public class ImportOperation extends Abs
         final boolean replace = "true".equalsIgnoreCase(request.getParameter(SlingPostConstants.RP_REPLACE));
         final boolean replaceProperties = "true".equalsIgnoreCase(request.getParameter(SlingPostConstants.RP_REPLACE_PROPERTIES));
         final boolean checkin = "true".equalsIgnoreCase(request.getParameter(SlingPostConstants.RP_CHECKIN));
-        
+
         String basePath = getItemPath(request);
         basePath = removeAndValidateWorkspace(basePath, request.getResourceResolver().adaptTo(Session.class));
         if (basePath.endsWith("/")) {
         	//remove the trailing slash
         	basePath = basePath.substring(0, basePath.length() - 1);
         }
-        
+
         String contentRootName;
         //check if a name was posted to use as the name of the imported root node
-        if (request.getParameter(SlingPostConstants.RP_NODE_NAME) != null || 
+        if (request.getParameter(SlingPostConstants.RP_NODE_NAME) != null ||
         		request.getParameter(SlingPostConstants.RP_NODE_NAME_HINT) != null) {
    			String nodePath = generateName(request, basePath);
    			String name = nodePath.substring(nodePath.lastIndexOf('/') + 1);
@@ -129,7 +129,7 @@ public class ImportOperation extends Abs
    	        contentRootName = "." + contentType;
         }
         response.setCreateRequest(true);
-        
+
         try {
             InputStream contentStream = null;
             String content = request.getParameter(SlingPostConstants.RP_CONTENT);
@@ -176,27 +176,27 @@ public class ImportOperation extends Abs
 							}
     					},
     					new ContentImportListener() {
-							
+
 							public void onReorder(String orderedPath, String beforeSibbling) {
 								changes.add(Modification.onOrder(orderedPath, beforeSibbling));
 							}
-							
+
 							public void onMove(String srcPath, String destPath) {
 								changes.add(Modification.onMoved(srcPath, destPath));
 							}
-							
+
 							public void onModify(String srcPath) {
 								changes.add(Modification.onModified(srcPath));
 							}
-							
+
 							public void onDelete(String srcPath) {
 								changes.add(Modification.onDeleted(srcPath));
 							}
-							
+
 							public void onCreate(String srcPath) {
 								changes.add(Modification.onCreated(srcPath));
 							}
-							
+
 							public void onCopy(String srcPath, String destPath) {
 								changes.add(Modification.onMoved(srcPath, destPath));
 							}

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/ModifyOperation.java Thu Mar  3 14:25:56 2011
@@ -28,16 +28,14 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.nodetype.NodeType;
 import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-
 import org.apache.sling.api.SlingException;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.resource.NonExistingResource;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceUtil;
-import org.apache.sling.api.servlets.HtmlResponse;
 import org.apache.sling.servlets.post.Modification;
 import org.apache.sling.servlets.post.NodeNameGenerator;
+import org.apache.sling.servlets.post.PostResponse;
 import org.apache.sling.servlets.post.SlingPostConstants;
 import org.apache.sling.servlets.post.VersioningConfiguration;
 import org.apache.sling.servlets.post.impl.helper.DateParser;
@@ -61,19 +59,23 @@ public class ModifyOperation extends Abs
     private final SlingFileUploadHandler uploadHandler;
 
     public ModifyOperation(NodeNameGenerator defaultNodeNameGenerator,
-            DateParser dateParser, ServletContext servletContext) {
-    	super(defaultNodeNameGenerator);
+            DateParser dateParser) {
+        super(defaultNodeNameGenerator);
         this.dateParser = dateParser;
-        this.uploadHandler = new SlingFileUploadHandler(servletContext);
+        this.uploadHandler = new SlingFileUploadHandler();
+    }
+
+    public void setServletContext(final ServletContext servletContext) {
+        this.uploadHandler.setServletContext(servletContext);
     }
 
     @Override
-    protected void doRun(SlingHttpServletRequest request, HtmlResponse response, List<Modification> changes)
+    protected void doRun(SlingHttpServletRequest request, PostResponse response, List<Modification> changes)
             throws RepositoryException {
 
         Map<String, RequestProperty> reqProperties = collectContent(request,
                 response);
-        
+
         VersioningConfiguration versioningConfiguration = getVersioningConfiguration(request);
 
         // do not change order unless you have a very good reason.
@@ -236,7 +238,7 @@ public class ModifyOperation extends Abs
             if (session.itemExists(propPath)) {
                 Node parent = session.getItem(propPath).getParent();
                 checkoutIfNecessary(parent, changes, versioningConfiguration);
-                
+
                 session.getItem(propPath).remove();
                 changes.add(Modification.onDeleted(propPath));
             } else {
@@ -354,8 +356,8 @@ public class ModifyOperation extends Abs
                 Node parent = deepGetOrCreateNode(session,
                     prop.getParentPath(), reqProperties, changes, versioningConfiguration);
 
-                checkoutIfNecessary(parent, changes, versioningConfiguration); 
-                
+                checkoutIfNecessary(parent, changes, versioningConfiguration);
+
                 // skip jcr special properties
                 if (prop.getName().equals("jcr:primaryType")
                     || prop.getName().equals("jcr:mixinTypes")) {

Modified: sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/NopOperation.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/NopOperation.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/NopOperation.java (original)
+++ sling/trunk/bundles/servlets/post/src/main/java/org/apache/sling/servlets/post/impl/operations/NopOperation.java Thu Mar  3 14:25:56 2011
@@ -19,9 +19,9 @@
 package org.apache.sling.servlets.post.impl.operations;
 
 import org.apache.sling.api.SlingHttpServletRequest;
-import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.servlets.post.PostResponse;
 import org.apache.sling.servlets.post.SlingPostConstants;
-import org.apache.sling.servlets.post.SlingPostOperation;
+import org.apache.sling.servlets.post.PostOperation;
 import org.apache.sling.servlets.post.SlingPostProcessor;
 
 /**
@@ -29,9 +29,9 @@ import org.apache.sling.servlets.post.Sl
  * sets the response status accroding to the <i>:nopstatus</i> parameter if
  * availables. Otherwise the status is set as 200/OK.
  */
-public class NopOperation implements SlingPostOperation {
+public class NopOperation implements PostOperation {
 
-    public void run(SlingHttpServletRequest request, HtmlResponse response,
+    public void run(SlingHttpServletRequest request, PostResponse response,
             SlingPostProcessor[] processors) {
 
         // get the :nopstatus parameter for a specific code

Copied: sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/JsonResponseTest.java (from r991959, sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/JsonResponseTest.java)
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/JsonResponseTest.java?p2=sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/JsonResponseTest.java&p1=sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/JsonResponseTest.java&r1=991959&r2=1076637&rev=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/helper/JsonResponseTest.java (original)
+++ sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/JsonResponseTest.java Thu Mar  3 14:25:56 2011
@@ -15,13 +15,13 @@
  * limitations under the License.
  */
 
-package org.apache.sling.servlets.post.impl.helper;
+package org.apache.sling.servlets.post;
 
 import junit.framework.TestCase;
-import org.apache.sling.api.servlets.HtmlResponse;
 import org.apache.sling.commons.json.JSONArray;
 import org.apache.sling.commons.json.JSONException;
 import org.apache.sling.commons.json.JSONObject;
+import org.apache.sling.servlets.post.JSONResponse;
 
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.Cookie;
@@ -105,6 +105,7 @@ public class JsonResponseTest extends Te
         private StringBuffer output = new StringBuffer();
         private String contentType;
         private String encoding;
+        private int status = SC_OK;
 
         public StringBuffer getOutput() {
             return output;
@@ -171,9 +172,11 @@ public class JsonResponseTest extends Te
         }
 
         public void setStatus(int i) {
+            this.status = i;
         }
 
         public void setStatus(int i, String s) {
+            this.status = i;
         }
 
         public String getCharacterEncoding() {

Modified: sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/RequestPropertyTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/RequestPropertyTest.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/RequestPropertyTest.java (original)
+++ sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/RequestPropertyTest.java Thu Mar  3 14:25:56 2011
@@ -16,7 +16,10 @@
  */
 package org.apache.sling.servlets.post.impl;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -29,7 +32,8 @@ import junitx.util.PrivateAccessor;
 import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.api.request.RequestParameter;
 import org.apache.sling.api.request.RequestParameterMap;
-import org.apache.sling.api.servlets.HtmlResponse;
+import org.apache.sling.servlets.post.HtmlResponse;
+import org.apache.sling.servlets.post.PostResponse;
 import org.apache.sling.servlets.post.impl.helper.RequestProperty;
 import org.apache.sling.servlets.post.impl.operations.ModifyOperation;
 import org.jmock.Expectations;
@@ -199,7 +203,7 @@ public class RequestPropertyTest {
         assertFalse(prop.hasValues());
     }
 
-    private static final Class[] COLLECT_CLASSES = new Class[] { SlingHttpServletRequest.class, HtmlResponse.class };
+    private static final Class[] COLLECT_CLASSES = new Class[] { SlingHttpServletRequest.class, PostResponse.class };
 
     private class Param {
         String key;
@@ -276,8 +280,9 @@ public class RequestPropertyTest {
         final HtmlResponse response = new HtmlResponse();
         response.setPath("/test/path");
 
-        Map<String, RequestProperty> props = (Map<String, RequestProperty>) PrivateAccessor.invoke(new ModifyOperation(
-                null, null, null), "collectContent", COLLECT_CLASSES, new Object[] { request, response });
+        Map<String, RequestProperty> props = (Map<String, RequestProperty>) PrivateAccessor.invoke(
+            new ModifyOperation(null, null), "collectContent", COLLECT_CLASSES,
+            new Object[] { request, response });
         return props;
     }
 }

Modified: sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/SlingPostServletTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/SlingPostServletTest.java?rev=1076637&r1=1076636&r2=1076637&view=diff
==============================================================================
--- sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/SlingPostServletTest.java (original)
+++ sling/trunk/bundles/servlets/post/src/test/java/org/apache/sling/servlets/post/impl/SlingPostServletTest.java Thu Mar  3 14:25:56 2011
@@ -20,10 +20,10 @@ package org.apache.sling.servlets.post.i
 
 import junit.framework.TestCase;
 
-import org.apache.sling.api.servlets.HtmlResponse;
 import org.apache.sling.commons.testing.sling.MockSlingHttpServletRequest;
+import org.apache.sling.servlets.post.JSONResponse;
+import org.apache.sling.servlets.post.PostResponse;
 import org.apache.sling.servlets.post.SlingPostConstants;
-import org.apache.sling.servlets.post.impl.helper.JSONResponse;
 import org.apache.sling.servlets.post.impl.helper.MediaRangeList;
 
 public class SlingPostServletTest extends TestCase {
@@ -68,7 +68,7 @@ public class SlingPostServletTest extend
             }
         };
         SlingPostServlet servlet = new SlingPostServlet();
-        HtmlResponse result = servlet.createHtmlResponse(req);
+        PostResponse result = servlet.createHtmlResponse(req);
         assertTrue(result instanceof JSONResponse);
     }
 



Mime
View raw message