Add discard quietly for node session
[lgpl/argeo-commons.git] / server / runtime / org.argeo.server.jcr / src / main / java / org / argeo / jcr / JcrUtils.java
index ebcb4ee9f5efd7da10c800bf077bbc320a0fbb61..f530f170b7fe4a0637d2eb72b75b4470dba07199 100644 (file)
@@ -652,6 +652,21 @@ public class JcrUtils implements ArgeoJcrConstants {
                }
        }
 
+       /**
+        * Discards the current changes in the session attached to this node. To be
+        * used typically in a catch block.
+        * 
+        * @see #discardQuietly(Session)
+        */
+       public static void discardUnderlyingSessionQuietly(Node node) {
+               try {
+                       discardQuietly(node.getSession());
+               } catch (RepositoryException e) {
+                       log.warn("Cannot quietly discard session of node " + node + ": "
+                                       + e.getMessage());
+               }
+       }
+
        /**
         * Discards the current changes in a session by calling
         * {@link Session#refresh(boolean)} with <code>false</code>, only logging