SLING-10087 convert more persistenceexceptions (#11)

within the PostServlet, do not set the response code directly, but throw an PersistenceException instead
diff --git a/src/main/java/org/apache/sling/servlets/post/PostOperation.java b/src/main/java/org/apache/sling/servlets/post/PostOperation.java
index e2b42b3..76a7131 100644
--- a/src/main/java/org/apache/sling/servlets/post/PostOperation.java
+++ b/src/main/java/org/apache/sling/servlets/post/PostOperation.java
@@ -19,6 +19,7 @@
 package org.apache.sling.servlets.post;
 
 import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.PersistenceException;
 import org.apache.sling.servlets.post.exceptions.PreconditionViolatedPersistenceException;
 import org.apache.sling.servlets.post.exceptions.TemporaryPersistenceException;
 
@@ -74,6 +75,7 @@
      * @param processors The {@link SlingPostProcessor} services to be called
      *            after applying the operation. This may be <code>null</code> if
      *            there are none.
+     * @throws PersistenceException 
      * @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 POST servlet
@@ -83,5 +85,5 @@
      *             occurrs running the operation.
      */
     void run(SlingHttpServletRequest request, PostResponse response,
-            SlingPostProcessor[] processors) throws PreconditionViolatedPersistenceException, TemporaryPersistenceException;
+            SlingPostProcessor[] processors) throws PreconditionViolatedPersistenceException, TemporaryPersistenceException, PersistenceException;
 }
diff --git a/src/main/java/org/apache/sling/servlets/post/exceptions/PreconditionViolatedPersistenceException.java b/src/main/java/org/apache/sling/servlets/post/exceptions/PreconditionViolatedPersistenceException.java
index 459c69e..3b6253b 100644
--- a/src/main/java/org/apache/sling/servlets/post/exceptions/PreconditionViolatedPersistenceException.java
+++ b/src/main/java/org/apache/sling/servlets/post/exceptions/PreconditionViolatedPersistenceException.java
@@ -43,6 +43,10 @@
             super(msg,cause,resourcePath,propertyName);
             
             }
+
+public PreconditionViolatedPersistenceException(String msg) {
+    super(msg);
+}
   
 
 }
diff --git a/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java b/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
index 4f378a0..55fffb6 100644
--- a/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
+++ b/src/main/java/org/apache/sling/servlets/post/impl/SlingPostServlet.java
@@ -245,8 +245,8 @@
                 htmlResponse.setStatus(HttpServletResponse.SC_NOT_FOUND,
                     rnfe.getMessage());
             } catch (final PreconditionViolatedPersistenceException e) {
-                log.warn("Exception while handling POST {} with {}",
-                        new Object[] {request.getResource().getPath(),operation.getClass().getName()},e);
+                log.warn("Exception while handling POST on path [{}] with operation [{}]",
+                        request.getResource().getPath(),operation.getClass().getName(),e);
                 if (backwardsCompatibleStatuscode) {
                     htmlResponse.setError(e);
                 } else {
@@ -254,17 +254,17 @@
                 }
             } catch (final PersistenceException e) {
                 // also catches the  RetryableOperationException, as the handling is the same
-                log.warn("Exception while handling POST {} with {}",
-                        new Object[] {request.getResource().getPath(),operation.getClass().getName()},e);
+                log.warn("Exception while handling POST on path [{}] with operation [{}]",
+                        request.getResource().getPath(),operation.getClass().getName(),e);
                 if (backwardsCompatibleStatuscode) {
                     htmlResponse.setError(e);
                 } else {
                     htmlResponse.setStatus(HttpServletResponse.SC_CONFLICT, "repository state conflicting with request");
                 }
-            } catch (final Exception exception) {
-                log.warn("Exception while handling POST {} with {}",
-                        new Object[] {request.getResource().getPath(),operation.getClass().getName()},exception);
-                htmlResponse.setError(exception);
+            } catch (final Exception e) {
+                log.warn("Exception while handling POST on path [{}] with operation [{}]",
+                        request.getResource().getPath(),operation.getClass().getName(),e);
+                htmlResponse.setError(e);
             }
 
         }
diff --git a/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java b/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
index c5c69fb..50abeb8 100644
--- a/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
+++ b/src/main/java/org/apache/sling/servlets/post/impl/helper/SlingPropertyValueHandler.java
@@ -32,6 +32,7 @@
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.servlets.post.Modification;
 import org.apache.sling.servlets.post.SlingPostConstants;
+import org.apache.sling.servlets.post.exceptions.PreconditionViolatedPersistenceException;
 
 /**
  * Sets a property on the given resource, in some cases with a specific type and
@@ -111,7 +112,7 @@
         mod.node = jcrSupport.getNode(parent);
         mod.valueMap = parent.adaptTo(ModifiableValueMap.class);
         if ( mod.valueMap == null ) {
-            throw new PersistenceException("Resource at '" + parent.getPath() + "' is not modifiable.");
+            throw new PreconditionViolatedPersistenceException("Resource at '" + parent.getPath() + "' is not modifiable.");
         }
 
         final String name = prop.getName();
diff --git a/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java b/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java
index 493bf71..0c0bdb4 100644
--- a/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java
+++ b/src/main/java/org/apache/sling/servlets/post/impl/operations/AbstractPostOperation.java
@@ -83,7 +83,7 @@
     @Override
     public void run(final SlingHttpServletRequest request,
                     final PostResponse response,
-                    final SlingPostProcessor[] processors) throws PreconditionViolatedPersistenceException, TemporaryPersistenceException {
+                    final SlingPostProcessor[] processors) throws PreconditionViolatedPersistenceException, TemporaryPersistenceException, PersistenceException {
         final VersioningConfiguration versionableConfiguration = getVersioningConfiguration(request);
 
         try {
@@ -105,10 +105,16 @@
             doRun(request, response, changes);
 
             // invoke processors
-            if (processors != null) {
-                for (SlingPostProcessor processor : processors) {
-                    processor.process(request, changes);
+            try {
+                if (processors != null) {
+                    for (SlingPostProcessor processor : processors) {
+                        processor.process(request, changes);
+                    }
                 }
+            } catch (PreconditionViolatedPersistenceException|TemporaryPersistenceException e) {
+                throw e;
+            } catch (Exception e) {
+                throw new PersistenceException("Exception during response processing",e);
             }
 
             // check modifications for remaining postfix and store the base path
@@ -129,10 +135,8 @@
             if (modificationSourcesContainingPostfix.size() > 0) {
                 for (final Map.Entry<String, String> sourceToCheck : modificationSourcesContainingPostfix.entrySet()) {
                     if (allModificationSources.contains(sourceToCheck.getKey())) {
-                        response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
-                                "Postfix-containing path " + sourceToCheck.getValue() +
+                        throw new PersistenceException("Postfix-containing path " + sourceToCheck.getValue() +
                                 " contained in the modification list. Check configuration.");
-                        return;
                     }
                 }
             }
@@ -179,11 +183,6 @@
                 }
             }
 
-        } catch (Exception e) {
-
-            log.error("Exception during response processing.", e);
-            response.setError(e);
-
         } finally {
             if (isResourceResolverCommitRequired(request)) {
                 request.getResourceResolver().revert();