jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r929516 - in /jackrabbit/trunk: jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/ jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/
Date Wed, 31 Mar 2010 12:54:42 GMT
Author: angela
Date: Wed Mar 31 12:54:41 2010
New Revision: 929516

URL: http://svn.apache.org/viewvc?rev=929516&view=rev
Log:
JCR-2585:  spi2davex: unspecific BadRequest error instead of error code matching the RepositoryException

Added:
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AddNodeTest.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/DiffException.java
    jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandler.java
    jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/DiffException.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/DiffException.java?rev=929516&r1=929515&r2=929516&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/DiffException.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/DiffException.java
Wed Mar 31 12:54:41 2010
@@ -16,16 +16,26 @@
  */
 package org.apache.jackrabbit.server.remoting.davex;
 
+import java.io.IOException;
+
 /**
  * <code>DiffException</code>...
  */
-class DiffException extends Exception {
+class DiffException extends IOException {
+
+    private Throwable cause;
 
     public DiffException(String message) {
         super(message);
     }
 
     public DiffException(String message, Throwable cause) {
-        super(message, cause);
+        super(message);
+        this.cause = cause;
+    }
+
+    @Override
+    public Throwable getCause() {
+        return cause;
     }
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandler.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandler.java?rev=929516&r1=929515&r2=929516&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandler.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/remoting/davex/JsonDiffHandler.java
Wed Mar 31 12:54:41 2010
@@ -145,7 +145,11 @@ class JsonDiffHandler implements DiffHan
         } catch (RepositoryException e) {
             throw new DiffException(e.getMessage(), e);
         } catch (IOException e) {
-            throw new DiffException(e.getMessage(), e);
+            if (e instanceof DiffException) {
+                throw (DiffException) e;
+            } else {
+                throw new DiffException(e.getMessage(), e);
+            }
         }
     }
 
@@ -264,7 +268,11 @@ class JsonDiffHandler implements DiffHan
             NodeHandler hndlr = new NodeHandler(parent, nodeName);            
             new JsonParser(hndlr).parse(diffValue);
         } catch (IOException e) {
-            throw new DiffException(e.getMessage());
+            if (e instanceof DiffException) {
+                throw (DiffException) e;
+            } else {
+                throw new DiffException(e.getMessage(), e);
+            }
         }
     }
 
@@ -552,7 +560,7 @@ class JsonDiffHandler implements DiffHan
                 if (obj instanceof ImportNode) {
                     ((ImportNode) obj).addNode(n);
                 } else {
-                    throw new IOException("Invalid DIFF format: The JSONArray may only contain
simple values.");
+                    throw new DiffException("Invalid DIFF format: The JSONArray may only
contain simple values.");
                 }
             }
             st.push(n);
@@ -563,7 +571,7 @@ class JsonDiffHandler implements DiffHan
             // contain simple values, no arrays/objects are allowed.
             ImportItem obj = st.pop();
             if (!((obj instanceof ImportNode))) {
-                throw new IOException("Invalid DIFF format.");
+                throw new DiffException("Invalid DIFF format.");
             }
             if (st.isEmpty()) {
                 // everything parsed -> start adding all nodes and properties
@@ -571,7 +579,7 @@ class JsonDiffHandler implements DiffHan
                     obj.createItem(parent);                    
                 } catch (RepositoryException e) {
                     log.error(e.getMessage());
-                    throw new IOException("Invalid DIFF format");
+                    throw new DiffException(e.getMessage(), e);
                 }
             }
         }
@@ -582,7 +590,7 @@ class JsonDiffHandler implements DiffHan
             if (obj instanceof ImportNode) {
                 ((ImportNode)obj).addProp(prop);
             } else {
-                throw new IOException("Invalid DIFF format: The JSONArray may only contain
simple values.");
+                throw new DiffException("Invalid DIFF format: The JSONArray may only contain
simple values.");
             }
             st.push(prop);
         }
@@ -592,7 +600,7 @@ class JsonDiffHandler implements DiffHan
             // contain simple values, no arrays/objects are allowed.
             ImportItem obj = st.pop();
             if (!((obj instanceof ImportMvProp))) {
-                throw new IOException("Invalid DIFF format: The JSONArray may only contain
simple values.");                
+                throw new DiffException("Invalid DIFF format: The JSONArray may only contain
simple values.");
             }
         }
 
@@ -632,7 +640,7 @@ class JsonDiffHandler implements DiffHan
         final String name;
         private ImportItem(String name) throws IOException {
             if (name == null) {
-                throw new IOException("Invalid DIFF format: NULL key.");
+                throw new DiffException("Invalid DIFF format: NULL key.");
             }
             this.name = name;
         }

Added: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AddNodeTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AddNodeTest.java?rev=929516&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AddNodeTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AddNodeTest.java
Wed Mar 31 12:54:41 2010
@@ -0,0 +1,61 @@
+/*
+ * 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.jackrabbit.jcr2spi;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.lock.LockException;
+
+/**
+ * <code>AddNodeTest</code>...
+ */
+public class AddNodeTest extends AbstractJCRTest {
+
+    /**
+     * logger instance
+     */
+    private static final Logger log = LoggerFactory.getLogger(AddNodeTest.class);
+
+    /**
+     * Writing to a locked node must throw LockException even if the lock
+     * isn't detected withing Jcr2Spi.
+     *
+     * @throws Exception
+     * @see <a href="https://issues.apache.org/jira/browse/JCR-2585">JCR-2585</a>
+     */
+    public void testAddNodeOnLocked() throws Exception {
+        Session s = getHelper().getSuperuserSession();
+        try {
+            Node node = s.getNode(testRootNode.getPath());
+            Node n = node.addNode(nodeName1);
+            n.setProperty(propertyName1, "value");
+            
+            testRootNode.lock(true, true);
+
+            s.save();
+        } catch (LockException e) {
+            // success
+        } finally {
+            s.logout();
+        }
+    }
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AddNodeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/AddNodeTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java?rev=929516&r1=929515&r2=929516&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/TestAll.java
Wed Mar 31 12:54:41 2010
@@ -19,18 +19,13 @@ package org.apache.jackrabbit.jcr2spi;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-
 import org.apache.jackrabbit.jcr2spi.observation.ObservationTest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * <code>TestAll</code>...
  */
 public class TestAll extends TestCase {
 
-    private static Logger log = LoggerFactory.getLogger(TestAll.class);
-
     public static Test suite() {
 
         TestSuite suite = new TestSuite("jcr2spi tests");
@@ -42,6 +37,9 @@ public class TestAll extends TestCase {
         suite.addTestSuite(SNSIndexTest.class);
         suite.addTestSuite(NodeOrderTest.class);
 
+        // add nodes
+        suite.addTestSuite(AddNodeTest.class);
+        
         // set/add property
         suite.addTestSuite(GetPropertyTest.class);
         suite.addTestSuite(AddPropertyTest.class);



Mime
View raw message