You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by ju...@apache.org on 2012/01/25 14:30:25 UTC

svn commit: r1235737 [3/7] - in /jackrabbit/branches/2.4: ./ examples/jackrabbit-firsthops/src/main/java/org/apache/jackrabbit/firsthops/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/ jackrabbit-api/src/main/java/org/apache/jackrabbit/api/jmx...

Modified: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/VersioningTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/VersioningTest.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/VersioningTest.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/VersioningTest.java Wed Jan 25 13:30:17 2012
@@ -1,215 +1,215 @@
-/*
- * 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.core.integration;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.jcr.Node;
-import javax.jcr.Session;
-import javax.jcr.version.Version;
-
-import org.apache.jackrabbit.test.AbstractJCRTest;
-
-/**
- * Versioning tests.
- */
-public class VersioningTest extends AbstractJCRTest {
-
-    private Node n1;
-    private Node n2;
-
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        Session s1 = getHelper().getSuperuserSession();
-        n1 = s1.getRootNode().addNode("VersioningTest");
-        n1.addMixin(mixVersionable);
-        n1.getSession().save();
-
-        Session s2 = getHelper().getSuperuserSession(workspaceName);
-        s2.getWorkspace().clone(
-                s1.getWorkspace().getName(), n1.getPath(),
-                "/VersioningTest", true);
-        n2 = s2.getRootNode().getNode("VersioningTest");
-    }
-
-    protected void tearDown() throws Exception {
-        super.tearDown();
-
-        Session s1 = n1.getSession();
-        n1.remove();
-        s1.save();
-        s1.logout();
-
-        Session s2 = n2.getSession();
-        n2.remove();
-        s2.save();
-        s2.logout();
-    }
-
-    /**
-     * Tests that the version tree documented in
-     * AbstractVersionManager.calculateCheckinVersionName() can be
-     * constructed and has the expected version names.
-     * <p>
-     * Note that this test case needs to be modified if the version naming
-     * algorithm ever gets changed.
-     */
-    public void testVersionGraph() throws Exception {
-        Version vR = n1.getBaseVersion();
-
-        Version v10 = n1.checkin();
-        n1.checkout();
-        Version v11 = n1.checkin();
-        n1.checkout();
-        Version v12 = n1.checkin();
-        n1.checkout();
-        Version v13 = n1.checkin();
-        n1.checkout();
-        Version v14 = n1.checkin();
-        n1.checkout();
-        Version v15 = n1.checkin();
-        n1.checkout();
-        Version v16 = n1.checkin();
-
-        n1.restore(v12, true);
-        n1.checkout();
-        Version v120 = n1.checkin();
-        n1.checkout();
-        Version v121 = n1.checkin();
-        n1.checkout();
-        Version v122 = n1.checkin();
-
-        n1.restore(v12, true);
-        n1.checkout();
-        Version v1200 = n1.checkin();
-
-        n1.restore(v121, true);
-        n1.checkout();
-        Version v1210 = n1.checkin();
-        n1.checkout();
-        Version v1211 = n1.checkin();
-
-        // x.0 versions can be created if the newly created versionable
-        // node is cloned to another workspace before the first checkin
-        Version v20 = n2.checkin();
-
-        // Multiple branches can be merged using multiple workspaces
-        n2.restore(v122, true);
-        n1.restore(v16, true);
-        n1.checkout();
-        n1.merge(n2.getSession().getWorkspace().getName(), true);
-        n1.doneMerge(v122);
-        Version v17 = n1.checkin();
-
-        assertEquals("jcr:rootVersion", vR.getName());
-        assertPredecessors("", vR);
-        assertSuccessors("1.0 2.0", vR);
-        assertEquals("1.0", v10.getName());
-        assertPredecessors("jcr:rootVersion", v10);
-        assertSuccessors("1.1", v10);
-        assertEquals("1.1", v11.getName());
-        assertPredecessors("1.0", v11);
-        assertSuccessors("1.2", v11);
-        assertEquals("1.2", v12.getName());
-        assertPredecessors("1.1", v12);
-        assertSuccessors("1.3 1.2.0 1.2.0.0", v12);
-        assertEquals("1.3", v13.getName());
-        assertPredecessors("1.2", v13);
-        assertSuccessors("1.4", v13);
-        assertEquals("1.4", v14.getName());
-        assertPredecessors("1.3", v14);
-        assertSuccessors("1.5", v14);
-        assertEquals("1.5", v15.getName());
-        assertPredecessors("1.4", v15);
-        assertSuccessors("1.6", v15);
-        assertEquals("1.6", v16.getName());
-        assertPredecessors("1.5", v16);
-        assertSuccessors("1.7", v16);
-        assertEquals("1.7", v17.getName());
-        assertPredecessors("1.6 1.2.2", v17);
-        assertSuccessors("", v17);
-
-        assertEquals("1.2.0", v120.getName());
-        assertPredecessors("1.2", v120);
-        assertSuccessors("1.2.1", v120);
-        assertEquals("1.2.1", v121.getName());
-        assertPredecessors("1.2.0", v121);
-        assertSuccessors("1.2.2 1.2.1.0", v121);
-        assertEquals("1.2.2", v122.getName());
-        assertPredecessors("1.2.1", v122);
-        assertSuccessors("1.7", v122);
-
-        assertEquals("1.2.0.0", v1200.getName());
-        assertPredecessors("1.2", v1200);
-        assertSuccessors("", v1200);
-
-        assertEquals("1.2.1.0", v1210.getName());
-        assertPredecessors("1.2.1", v1210);
-        assertSuccessors("1.2.1.1", v1210);
-        assertEquals("1.2.1.1", v1211.getName());
-        assertPredecessors("1.2.1.0", v1211);
-        assertSuccessors("", v1211);
-
-        assertEquals("2.0", v20.getName());
-        assertPredecessors("jcr:rootVersion", v20);
-        assertSuccessors("", v20);
-    }
-
-    private void assertPredecessors(String expected, Version version)
-            throws Exception {
-        Set predecessors = new HashSet();
-        if (expected.length() > 0) {
-            predecessors.addAll(Arrays.asList(expected.split(" ")));
-        }
-        Version[] versions = version.getPredecessors();
-        for (int i = 0; i < versions.length; i++) {
-            if (!predecessors.remove(versions[i].getName())) {
-                fail("Version " + version.getName()
-                        + " has an unexpected predessor "
-                        + versions[i].getName());
-            }
-        }
-        if (!predecessors.isEmpty()) {
-            fail("Version " + version.getName()
-                    + " does not have all expected predecessors");
-        }
-    }
-
-    private void assertSuccessors(String expected, Version version)
-            throws Exception {
-        Set successors = new HashSet();
-        if (expected.length() > 0) {
-            successors.addAll(Arrays.asList(expected.split(" ")));
-        }
-        Version[] versions = version.getSuccessors();
-        for (int i = 0; i < versions.length; i++) {
-            if (!successors.remove(versions[i].getName())) {
-                fail("Version " + version.getName()
-                        + " has an unexpected successor "
-                        + versions[i].getName());
-            }
-        }
-        if (!successors.isEmpty()) {
-            fail("Version " + version.getName()
-                    + " does not have all expected successors");
-        }
-    }
-
-}
+/*
+ * 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.core.integration;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+import javax.jcr.version.Version;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+/**
+ * Versioning tests.
+ */
+public class VersioningTest extends AbstractJCRTest {
+
+    private Node n1;
+    private Node n2;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        Session s1 = getHelper().getSuperuserSession();
+        n1 = s1.getRootNode().addNode("VersioningTest");
+        n1.addMixin(mixVersionable);
+        n1.getSession().save();
+
+        Session s2 = getHelper().getSuperuserSession(workspaceName);
+        s2.getWorkspace().clone(
+                s1.getWorkspace().getName(), n1.getPath(),
+                "/VersioningTest", true);
+        n2 = s2.getRootNode().getNode("VersioningTest");
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+
+        Session s1 = n1.getSession();
+        n1.remove();
+        s1.save();
+        s1.logout();
+
+        Session s2 = n2.getSession();
+        n2.remove();
+        s2.save();
+        s2.logout();
+    }
+
+    /**
+     * Tests that the version tree documented in
+     * AbstractVersionManager.calculateCheckinVersionName() can be
+     * constructed and has the expected version names.
+     * <p>
+     * Note that this test case needs to be modified if the version naming
+     * algorithm ever gets changed.
+     */
+    public void testVersionGraph() throws Exception {
+        Version vR = n1.getBaseVersion();
+
+        Version v10 = n1.checkin();
+        n1.checkout();
+        Version v11 = n1.checkin();
+        n1.checkout();
+        Version v12 = n1.checkin();
+        n1.checkout();
+        Version v13 = n1.checkin();
+        n1.checkout();
+        Version v14 = n1.checkin();
+        n1.checkout();
+        Version v15 = n1.checkin();
+        n1.checkout();
+        Version v16 = n1.checkin();
+
+        n1.restore(v12, true);
+        n1.checkout();
+        Version v120 = n1.checkin();
+        n1.checkout();
+        Version v121 = n1.checkin();
+        n1.checkout();
+        Version v122 = n1.checkin();
+
+        n1.restore(v12, true);
+        n1.checkout();
+        Version v1200 = n1.checkin();
+
+        n1.restore(v121, true);
+        n1.checkout();
+        Version v1210 = n1.checkin();
+        n1.checkout();
+        Version v1211 = n1.checkin();
+
+        // x.0 versions can be created if the newly created versionable
+        // node is cloned to another workspace before the first checkin
+        Version v20 = n2.checkin();
+
+        // Multiple branches can be merged using multiple workspaces
+        n2.restore(v122, true);
+        n1.restore(v16, true);
+        n1.checkout();
+        n1.merge(n2.getSession().getWorkspace().getName(), true);
+        n1.doneMerge(v122);
+        Version v17 = n1.checkin();
+
+        assertEquals("jcr:rootVersion", vR.getName());
+        assertPredecessors("", vR);
+        assertSuccessors("1.0 2.0", vR);
+        assertEquals("1.0", v10.getName());
+        assertPredecessors("jcr:rootVersion", v10);
+        assertSuccessors("1.1", v10);
+        assertEquals("1.1", v11.getName());
+        assertPredecessors("1.0", v11);
+        assertSuccessors("1.2", v11);
+        assertEquals("1.2", v12.getName());
+        assertPredecessors("1.1", v12);
+        assertSuccessors("1.3 1.2.0 1.2.0.0", v12);
+        assertEquals("1.3", v13.getName());
+        assertPredecessors("1.2", v13);
+        assertSuccessors("1.4", v13);
+        assertEquals("1.4", v14.getName());
+        assertPredecessors("1.3", v14);
+        assertSuccessors("1.5", v14);
+        assertEquals("1.5", v15.getName());
+        assertPredecessors("1.4", v15);
+        assertSuccessors("1.6", v15);
+        assertEquals("1.6", v16.getName());
+        assertPredecessors("1.5", v16);
+        assertSuccessors("1.7", v16);
+        assertEquals("1.7", v17.getName());
+        assertPredecessors("1.6 1.2.2", v17);
+        assertSuccessors("", v17);
+
+        assertEquals("1.2.0", v120.getName());
+        assertPredecessors("1.2", v120);
+        assertSuccessors("1.2.1", v120);
+        assertEquals("1.2.1", v121.getName());
+        assertPredecessors("1.2.0", v121);
+        assertSuccessors("1.2.2 1.2.1.0", v121);
+        assertEquals("1.2.2", v122.getName());
+        assertPredecessors("1.2.1", v122);
+        assertSuccessors("1.7", v122);
+
+        assertEquals("1.2.0.0", v1200.getName());
+        assertPredecessors("1.2", v1200);
+        assertSuccessors("", v1200);
+
+        assertEquals("1.2.1.0", v1210.getName());
+        assertPredecessors("1.2.1", v1210);
+        assertSuccessors("1.2.1.1", v1210);
+        assertEquals("1.2.1.1", v1211.getName());
+        assertPredecessors("1.2.1.0", v1211);
+        assertSuccessors("", v1211);
+
+        assertEquals("2.0", v20.getName());
+        assertPredecessors("jcr:rootVersion", v20);
+        assertSuccessors("", v20);
+    }
+
+    private void assertPredecessors(String expected, Version version)
+            throws Exception {
+        Set predecessors = new HashSet();
+        if (expected.length() > 0) {
+            predecessors.addAll(Arrays.asList(expected.split(" ")));
+        }
+        Version[] versions = version.getPredecessors();
+        for (int i = 0; i < versions.length; i++) {
+            if (!predecessors.remove(versions[i].getName())) {
+                fail("Version " + version.getName()
+                        + " has an unexpected predessor "
+                        + versions[i].getName());
+            }
+        }
+        if (!predecessors.isEmpty()) {
+            fail("Version " + version.getName()
+                    + " does not have all expected predecessors");
+        }
+    }
+
+    private void assertSuccessors(String expected, Version version)
+            throws Exception {
+        Set successors = new HashSet();
+        if (expected.length() > 0) {
+            successors.addAll(Arrays.asList(expected.split(" ")));
+        }
+        Version[] versions = version.getSuccessors();
+        for (int i = 0; i < versions.length; i++) {
+            if (!successors.remove(versions[i].getName())) {
+                fail("Version " + version.getName()
+                        + " has an unexpected successor "
+                        + versions[i].getName());
+            }
+        }
+        if (!successors.isEmpty()) {
+            fail("Version " + version.getName()
+                    + " does not have all expected successors");
+        }
+    }
+
+}

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/VersioningTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/integration/benchmark/SimpleBench.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/lock/LockTimeoutTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/AutoFixCorruptNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/persistence/TestAll.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/LimitedAccessQueryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SQL2NodeLocalNameTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SQL2OffsetLimitTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SQL2OrderByTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SQL2OuterJoinTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/SQL2TooManyClausesTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/BlockingParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ComparableArrayTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/DecimalConvertTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SQL2IndexingAggregateTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/SQL2IndexingAggregateTest2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/authentication/CryptedSimpleCredentialsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/AuthorizableActionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeCreationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/UserImporterTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/DefaultISMLockingDeadlockTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/stats/TimeSeriesRecorderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/util/CooperativeFileLockTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/InternalValueTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/PathTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/value/TestAll.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RestoreNodeWithSNSTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RestoreNodeWithSNSTest.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RestoreNodeWithSNSTest.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RestoreNodeWithSNSTest.java Wed Jan 25 13:30:17 2012
@@ -1,67 +1,67 @@
-/*
- * 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.core.version;
-
-import javax.jcr.Node;
-import javax.jcr.version.Version;
-import javax.jcr.version.VersionManager;
-
-import org.apache.jackrabbit.test.AbstractJCRTest;
-
-/**
- * Test case for JCR-2930
- */
-public class RestoreNodeWithSNSTest extends AbstractJCRTest {
-
-    public void testRestoreWithSNS() throws Exception {
-        
-        int childCount = 5;
-        
-        // create a test node with /childCount/ children with the same name
-        Node n = testRootNode.addNode(nodeName1);
-        n.addMixin(mixVersionable);
-        for (int i = 0; i < childCount; i++) {
-            Node child = n.addNode(nodeName2);
-            child.setProperty("name", nodeName2 + i);
-        }
-        testRootNode.getSession().save();
-
-        // check the number of children
-        assertEquals(childCount, n.getNodes().getSize());
-
-        VersionManager vm = testRootNode.getSession().getWorkspace()
-                .getVersionManager();
-        vm.checkin(n.getPath());
-
-        // modify one child
-        vm.checkout(n.getPath());
-        n.getNode(nodeName2).setProperty("name", "modified");
-        testRootNode.getSession().save();
-
-        // check the number of children again
-        assertEquals(childCount, n.getNodes().getSize());
-
-        // restore base versiob
-        Version baseVersion = vm.getBaseVersion(n.getPath());
-        vm.restore(baseVersion, true);
-
-        n.getSession().refresh(false);
-
-        // check the number of children again
-        assertEquals(childCount, n.getNodes().getSize());
-    }
-}
+/*
+ * 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.core.version;
+
+import javax.jcr.Node;
+import javax.jcr.version.Version;
+import javax.jcr.version.VersionManager;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+/**
+ * Test case for JCR-2930
+ */
+public class RestoreNodeWithSNSTest extends AbstractJCRTest {
+
+    public void testRestoreWithSNS() throws Exception {
+        
+        int childCount = 5;
+        
+        // create a test node with /childCount/ children with the same name
+        Node n = testRootNode.addNode(nodeName1);
+        n.addMixin(mixVersionable);
+        for (int i = 0; i < childCount; i++) {
+            Node child = n.addNode(nodeName2);
+            child.setProperty("name", nodeName2 + i);
+        }
+        testRootNode.getSession().save();
+
+        // check the number of children
+        assertEquals(childCount, n.getNodes().getSize());
+
+        VersionManager vm = testRootNode.getSession().getWorkspace()
+                .getVersionManager();
+        vm.checkin(n.getPath());
+
+        // modify one child
+        vm.checkout(n.getPath());
+        n.getNode(nodeName2).setProperty("name", "modified");
+        testRootNode.getSession().save();
+
+        // check the number of children again
+        assertEquals(childCount, n.getNodes().getSize());
+
+        // restore base versiob
+        Version baseVersion = vm.getBaseVersion(n.getPath());
+        vm.restore(baseVersion, true);
+
+        n.getSession().refresh(false);
+
+        // check the number of children again
+        assertEquals(childCount, n.getNodes().getSize());
+    }
+}

Propchange: jackrabbit/branches/2.4/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/RestoreNodeWithSNSTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jca/src/main/java/org/apache/jackrabbit/jca/AnonymousConnection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/RepositoryFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java Wed Jan 25 13:30:17 2012
@@ -1,240 +1,240 @@
-/*
- * 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.commons;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.jcr.NamespaceException;
-import javax.jcr.NamespaceRegistry;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.jackrabbit.util.XMLChar;
-
-/**
- * Helper class for working with JCR namespaces.
- *
- * @since Jackrabbit JCR Commons 1.5
- */
-public class NamespaceHelper {
-
-    /**
-     * The <code>jcr</code> namespace URI.
-     */
-    public static final String JCR = "http://www.jcp.org/jcr/1.0";
-
-    /**
-     * The <code>nt</code> namespace URI.
-     */
-    public static final String NT = "http://www.jcp.org/jcr/nt/1.0";
-
-    /**
-     * The <code>mix</code> namespace URI.
-     */
-    public static final String MIX = "http://www.jcp.org/jcr/mix/1.0";
-
-    /**
-     * Current session.
-     */
-    private final Session session;
-
-    /**
-     * Creates a namespace helper for the given session.
-     *
-     * @param session current session
-     */
-    public NamespaceHelper(Session session) {
-        this.session = session;
-    }
-
-    /**
-     * Returns a map containing all prefix to namespace URI mappings of
-     * the current session. The returned map is newly allocated and can
-     * can be freely modified by the caller.
-     *
-     * @see Session#getNamespacePrefixes()
-     * @return namespace mappings
-     * @throws RepositoryException if the namespaces could not be retrieved
-     */
-    public Map<String, String> getNamespaces() throws RepositoryException {
-        Map<String, String> namespaces = new HashMap<String, String>();
-        String[] prefixes = session.getNamespacePrefixes();
-        for (String prefixe : prefixes) {
-            namespaces.put(prefixe, session.getNamespaceURI(prefixe));
-        }
-        return namespaces;
-    }
-
-    /**
-     * Returns the prefix mapped to the given namespace URI in the current
-     * session, or <code>null</code> if the namespace does not exist.
-     *
-     * @see Session#getNamespacePrefix(String)
-     * @param uri namespace URI
-     * @return namespace prefix, or <code>null</code>
-     * @throws RepositoryException if the namespace could not be retrieved
-     */
-    public String getPrefix(String uri) throws RepositoryException {
-        try {
-            return session.getNamespacePrefix(uri);
-        } catch (NamespaceException e) {
-            return null;
-        }
-    }
-
-    /**
-     * Returns the namespace URI mapped to the given prefix in the current
-     * session, or <code>null</code> if the namespace does not exist.
-     *
-     * @see Session#getNamespaceURI(String)
-     * @param prefix namespace prefix
-     * @return namespace prefix, or <code>null</code>
-     * @throws RepositoryException if the namespace could not be retrieved
-     */
-    public String getURI(String prefix) throws RepositoryException {
-        try {
-            return session.getNamespaceURI(prefix);
-        } catch (NamespaceException e) {
-            return null;
-        }
-    }
-
-    /**
-     * Returns the prefixed JCR name for the given namespace URI and local
-     * name in the current session.
-     *
-     * @param uri namespace URI
-     * @param name local name
-     * @return prefixed JCR name
-     * @throws NamespaceException if the namespace does not exist
-     * @throws RepositoryException if the namespace could not be retrieved
-     */
-    public String getJcrName(String uri, String name)
-            throws NamespaceException, RepositoryException {
-        if (uri != null && uri.length() > 0) {
-            return session.getNamespacePrefix(uri) + ":" + name;
-        } else {
-            return name;
-        }
-    }
-
-    /**
-     * Replaces the standard <code>jcr</code>, <code>nt</code>, or
-     * <code>mix</code> prefix in the given name with the prefix
-     * mapped to that namespace in the current session.
-     * <p>
-     * The purpose of this method is to make it easier to write
-     * namespace-aware code that uses names in the standard JCR namespaces.
-     * For example:
-     * <pre>
-     *     node.getProperty(helper.getName("jcr:data"));
-     * </pre>
-     *
-     * @param name prefixed name using the standard JCR prefixes
-     * @return prefixed name using the current session namespace mappings
-     * @throws IllegalArgumentException if the prefix is unknown
-     * @throws RepositoryException if the namespace could not be retrieved
-     */
-    public String getJcrName(String name)
-            throws IllegalArgumentException, RepositoryException {
-        String standardPrefix;
-        String currentPrefix;
-
-        if (name.startsWith("jcr:")) {
-            standardPrefix = "jcr";
-            currentPrefix = session.getNamespacePrefix(JCR);
-        } else if (name.startsWith("nt:")) {
-            standardPrefix = "nt";
-            currentPrefix = session.getNamespacePrefix(NT);
-        } else if (name.startsWith("mix:")) {
-            standardPrefix = "mix";
-            currentPrefix = session.getNamespacePrefix(MIX);
-        } else {
-            throw new IllegalArgumentException("Unknown prefix: " + name);
-        }
-
-        if (currentPrefix.equals(standardPrefix)) {
-            return name;
-        } else {
-            return currentPrefix + name.substring(standardPrefix.length());
-        }
-    }
-
-    /**
-     * Safely registers the given namespace. If the namespace already exists,
-     * then the prefix mapped to the namespace in the current session is
-     * returned. Otherwise the namespace is registered to the namespace
-     * registry. If the given prefix is already registered for some other
-     * namespace or otherwise invalid, then another prefix is automatically
-     * generated. After the namespace has been registered, the prefix mapped
-     * to it in the current session is returned.
-     *
-     * @see NamespaceRegistry#registerNamespace(String, String)
-     * @param prefix namespace prefix
-     * @param uri namespace URI
-     * @return namespace prefix in the current session
-     * @throws RepositoryException if the namespace could not be registered
-     */
-    public String registerNamespace(String prefix, String uri)
-            throws RepositoryException {
-        NamespaceRegistry registry =
-            session.getWorkspace().getNamespaceRegistry();
-        try {
-            // Check if the namespace is registered
-            registry.getPrefix(uri);
-        } catch (NamespaceException e1) {
-             // Replace troublesome prefix hints
-            if (prefix == null || prefix.length() == 0
-                    || prefix.toLowerCase().startsWith("xml")
-                    || !XMLChar.isValidNCName(prefix)) {
-                prefix = "ns"; // ns, ns2, ns3, ns4, ...
-            }
-
-            // Loop until an unused prefix is found
-            try {
-                String base = prefix;
-                for (int i = 2; true; i++) {
-                    registry.getURI(prefix);
-                    prefix = base + i;
-                }
-            } catch (NamespaceException e2) {
-                // Exit the loop
-            } 
-
-            // Register the namespace
-            registry.registerNamespace(prefix, uri);
-        }
-
-        return session.getNamespacePrefix(uri);
-    }
-
-    /**
-     * Safely registers all namespaces in the given map from
-     * prefixes to namespace URIs.
-     *
-     * @param namespaces namespace mappings
-     * @throws RepositoryException if the namespaces could not be registered
-     */
-    public void registerNamespaces(Map<String,String> namespaces) throws RepositoryException {
-        for (Map.Entry<String, String> stringStringEntry : namespaces.entrySet()) {
-            Map.Entry<String, String> entry = stringStringEntry;
-            registerNamespace(entry.getKey(), entry.getValue());
-        }
-    }
-
-}
+/*
+ * 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.commons;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.NamespaceRegistry;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.util.XMLChar;
+
+/**
+ * Helper class for working with JCR namespaces.
+ *
+ * @since Jackrabbit JCR Commons 1.5
+ */
+public class NamespaceHelper {
+
+    /**
+     * The <code>jcr</code> namespace URI.
+     */
+    public static final String JCR = "http://www.jcp.org/jcr/1.0";
+
+    /**
+     * The <code>nt</code> namespace URI.
+     */
+    public static final String NT = "http://www.jcp.org/jcr/nt/1.0";
+
+    /**
+     * The <code>mix</code> namespace URI.
+     */
+    public static final String MIX = "http://www.jcp.org/jcr/mix/1.0";
+
+    /**
+     * Current session.
+     */
+    private final Session session;
+
+    /**
+     * Creates a namespace helper for the given session.
+     *
+     * @param session current session
+     */
+    public NamespaceHelper(Session session) {
+        this.session = session;
+    }
+
+    /**
+     * Returns a map containing all prefix to namespace URI mappings of
+     * the current session. The returned map is newly allocated and can
+     * can be freely modified by the caller.
+     *
+     * @see Session#getNamespacePrefixes()
+     * @return namespace mappings
+     * @throws RepositoryException if the namespaces could not be retrieved
+     */
+    public Map<String, String> getNamespaces() throws RepositoryException {
+        Map<String, String> namespaces = new HashMap<String, String>();
+        String[] prefixes = session.getNamespacePrefixes();
+        for (String prefixe : prefixes) {
+            namespaces.put(prefixe, session.getNamespaceURI(prefixe));
+        }
+        return namespaces;
+    }
+
+    /**
+     * Returns the prefix mapped to the given namespace URI in the current
+     * session, or <code>null</code> if the namespace does not exist.
+     *
+     * @see Session#getNamespacePrefix(String)
+     * @param uri namespace URI
+     * @return namespace prefix, or <code>null</code>
+     * @throws RepositoryException if the namespace could not be retrieved
+     */
+    public String getPrefix(String uri) throws RepositoryException {
+        try {
+            return session.getNamespacePrefix(uri);
+        } catch (NamespaceException e) {
+            return null;
+        }
+    }
+
+    /**
+     * Returns the namespace URI mapped to the given prefix in the current
+     * session, or <code>null</code> if the namespace does not exist.
+     *
+     * @see Session#getNamespaceURI(String)
+     * @param prefix namespace prefix
+     * @return namespace prefix, or <code>null</code>
+     * @throws RepositoryException if the namespace could not be retrieved
+     */
+    public String getURI(String prefix) throws RepositoryException {
+        try {
+            return session.getNamespaceURI(prefix);
+        } catch (NamespaceException e) {
+            return null;
+        }
+    }
+
+    /**
+     * Returns the prefixed JCR name for the given namespace URI and local
+     * name in the current session.
+     *
+     * @param uri namespace URI
+     * @param name local name
+     * @return prefixed JCR name
+     * @throws NamespaceException if the namespace does not exist
+     * @throws RepositoryException if the namespace could not be retrieved
+     */
+    public String getJcrName(String uri, String name)
+            throws NamespaceException, RepositoryException {
+        if (uri != null && uri.length() > 0) {
+            return session.getNamespacePrefix(uri) + ":" + name;
+        } else {
+            return name;
+        }
+    }
+
+    /**
+     * Replaces the standard <code>jcr</code>, <code>nt</code>, or
+     * <code>mix</code> prefix in the given name with the prefix
+     * mapped to that namespace in the current session.
+     * <p>
+     * The purpose of this method is to make it easier to write
+     * namespace-aware code that uses names in the standard JCR namespaces.
+     * For example:
+     * <pre>
+     *     node.getProperty(helper.getName("jcr:data"));
+     * </pre>
+     *
+     * @param name prefixed name using the standard JCR prefixes
+     * @return prefixed name using the current session namespace mappings
+     * @throws IllegalArgumentException if the prefix is unknown
+     * @throws RepositoryException if the namespace could not be retrieved
+     */
+    public String getJcrName(String name)
+            throws IllegalArgumentException, RepositoryException {
+        String standardPrefix;
+        String currentPrefix;
+
+        if (name.startsWith("jcr:")) {
+            standardPrefix = "jcr";
+            currentPrefix = session.getNamespacePrefix(JCR);
+        } else if (name.startsWith("nt:")) {
+            standardPrefix = "nt";
+            currentPrefix = session.getNamespacePrefix(NT);
+        } else if (name.startsWith("mix:")) {
+            standardPrefix = "mix";
+            currentPrefix = session.getNamespacePrefix(MIX);
+        } else {
+            throw new IllegalArgumentException("Unknown prefix: " + name);
+        }
+
+        if (currentPrefix.equals(standardPrefix)) {
+            return name;
+        } else {
+            return currentPrefix + name.substring(standardPrefix.length());
+        }
+    }
+
+    /**
+     * Safely registers the given namespace. If the namespace already exists,
+     * then the prefix mapped to the namespace in the current session is
+     * returned. Otherwise the namespace is registered to the namespace
+     * registry. If the given prefix is already registered for some other
+     * namespace or otherwise invalid, then another prefix is automatically
+     * generated. After the namespace has been registered, the prefix mapped
+     * to it in the current session is returned.
+     *
+     * @see NamespaceRegistry#registerNamespace(String, String)
+     * @param prefix namespace prefix
+     * @param uri namespace URI
+     * @return namespace prefix in the current session
+     * @throws RepositoryException if the namespace could not be registered
+     */
+    public String registerNamespace(String prefix, String uri)
+            throws RepositoryException {
+        NamespaceRegistry registry =
+            session.getWorkspace().getNamespaceRegistry();
+        try {
+            // Check if the namespace is registered
+            registry.getPrefix(uri);
+        } catch (NamespaceException e1) {
+             // Replace troublesome prefix hints
+            if (prefix == null || prefix.length() == 0
+                    || prefix.toLowerCase().startsWith("xml")
+                    || !XMLChar.isValidNCName(prefix)) {
+                prefix = "ns"; // ns, ns2, ns3, ns4, ...
+            }
+
+            // Loop until an unused prefix is found
+            try {
+                String base = prefix;
+                for (int i = 2; true; i++) {
+                    registry.getURI(prefix);
+                    prefix = base + i;
+                }
+            } catch (NamespaceException e2) {
+                // Exit the loop
+            } 
+
+            // Register the namespace
+            registry.registerNamespace(prefix, uri);
+        }
+
+        return session.getNamespacePrefix(uri);
+    }
+
+    /**
+     * Safely registers all namespaces in the given map from
+     * prefixes to namespace URIs.
+     *
+     * @param namespaces namespace mappings
+     * @throws RepositoryException if the namespaces could not be registered
+     */
+    public void registerNamespaces(Map<String,String> namespaces) throws RepositoryException {
+        for (Map.Entry<String, String> stringStringEntry : namespaces.entrySet()) {
+            Map.Entry<String, String> entry = stringStringEntry;
+            registerNamespace(entry.getKey(), entry.getValue());
+        }
+    }
+
+}

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/NamespaceHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/SimpleValueFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/cnd/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/BTreeManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/ItemSequence.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/NodeSequence.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/PropertySequence.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/Rank.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/Sequence.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/SizedIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/TreeManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/TreeTraverser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/flat/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/LazyIteratorChain.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/SizedIterator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/iterator/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/jackrabbit/user/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/json/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackage.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackage.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackage.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackage.java Wed Jan 25 13:30:17 2012
@@ -1,27 +1,27 @@
-/*
- * 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.commons.packaging;
-
-import java.util.Iterator;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-public interface ContentPackage {
-
-    Iterator getItems(Session session) throws RepositoryException;
-}
+/*
+ * 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.commons.packaging;
+
+import java.util.Iterator;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+public interface ContentPackage {
+
+    Iterator getItems(Session session) throws RepositoryException;
+}

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackageExporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackageExporter.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackageExporter.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackageExporter.java Wed Jan 25 13:30:17 2012
@@ -1,27 +1,27 @@
-/*
- * 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.commons.packaging;
-
-import java.io.OutputStream;
-
-import javax.jcr.RepositoryException;
-
-public interface ContentPackageExporter {
-
-    void export(ContentPackage description, OutputStream out)
-    throws RepositoryException;
-}
+/*
+ * 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.commons.packaging;
+
+import java.io.OutputStream;
+
+import javax.jcr.RepositoryException;
+
+public interface ContentPackageExporter {
+
+    void export(ContentPackage description, OutputStream out)
+    throws RepositoryException;
+}

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/ContentPackageExporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java Wed Jan 25 13:30:17 2012
@@ -1,205 +1,205 @@
-/*
- * 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.commons.packaging;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import javax.jcr.Item;
-import javax.jcr.Node;
-import javax.jcr.NodeIterator;
-import javax.jcr.PropertyIterator;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.jackrabbit.commons.predicate.Predicate;
-
-public class FilterContentPackage implements ContentPackage {
-
-    protected final List<Content> content = new ArrayList<Content>();
-
-    protected boolean includeProperties = false;
-
-    public void addContent(String path, Predicate filterList) {
-        this.content.add(new Content(new String[] {path}, filterList));
-    }
-
-    public void addContent(String[] paths, Predicate filterList) {
-        this.content.add(new Content(paths, filterList));
-    }
-
-    /**
-     * @see org.apache.jackrabbit.commons.packaging.ContentPackage#getItems(javax.jcr.Session)
-     */
-    public Iterator<Item> getItems(Session session)
-    throws RepositoryException {
-        return new FilteringIterator(session, new ArrayList<Content>(this.content), this.includeProperties);
-    }
-
-    protected static class Content {
-        protected final String[] paths;
-        protected final Predicate filterList;
-
-        public Content(String[] paths, Predicate filterList) {
-            this.paths = paths;
-            this.filterList = filterList;
-        }
-    }
-
-    public static class FilteringIterator implements Iterator {
-
-        /** The content we will iterate over. */
-        protected final List<Content> content;
-
-        /**
-         * Filter that defines which items are included
-         */
-        protected Predicate includeFilter;
-
-        protected int contentIndex, pathIndex;
-
-        protected Item nextItem;
-
-        protected Node lastNode;
-
-        protected final Session session;
-
-        protected final List<NodeIterator> nodeIteratorStack = new ArrayList<NodeIterator>();
-
-        protected final boolean includeProperties;
-
-        protected PropertyIterator propertyIterator;
-
-        /**
-         * Creates a new tree walker that uses the given filter as include and
-         * traversal filter.
-         *
-         * @param session The session.
-         * @param contentList The list of content objects.
-         * @param includeProperties Should properties be included.
-         */
-        public FilteringIterator(final Session session,
-                                 final List<Content> contentList,
-                                 final boolean includeProperties) {
-            this.content = contentList;
-            this.session = session;
-            this.includeProperties = includeProperties;
-        }
-
-        /**
-         * @see java.util.Iterator#hasNext()
-         */
-        public boolean hasNext() {
-            if ( this.nextItem != null ) {
-                return true;
-            }
-            try {
-                return this.checkForNextNode();
-            } catch (RepositoryException e) {
-                // if any error occurs, we stop iterating
-                return false;
-            }
-        }
-
-        protected boolean checkForNextNode() throws RepositoryException {
-            if ( this.propertyIterator != null ) {
-                if ( this.propertyIterator.hasNext() ) {
-                    this.nextItem = this.propertyIterator.nextProperty();
-                    return true;
-                }
-                this.propertyIterator = null;
-            } else if ( this.includeProperties && this.lastNode != null ) {
-                if ( this.lastNode.hasProperties() ) {
-                    this.propertyIterator = this.lastNode.getProperties();
-                    this.propertyIterator.hasNext();
-                    this.nextItem = this.propertyIterator.nextProperty();
-                    return true;
-                }
-            }
-            if ( this.lastNode != null ) {
-
-                if ( this.lastNode.hasNodes() ) {
-                    final NodeIterator iter = this.lastNode.getNodes();
-                    this.nodeIteratorStack.add(iter);
-                }
-                while ( this.nodeIteratorStack.size() > 0 ) {
-                    final NodeIterator iter = (NodeIterator)this.nodeIteratorStack.get(this.nodeIteratorStack.size() - 1);
-                    if ( iter.hasNext() ) {
-                        do {
-                            final Node contextNode = iter.nextNode();
-                            if ( this.includeFilter.evaluate(contextNode) ) {
-                                this.lastNode = contextNode;
-                                this.nextItem = contextNode;
-                                return true;
-                            }
-                        } while ( iter.hasNext() );
-                    }
-                    this.nodeIteratorStack.remove(iter);
-                }
-                this.pathIndex++;
-                this.lastNode = null;
-            }
-            while ( this.contentIndex < this.content.size() ) {
-                final Content content = (Content)this.content.get(this.contentIndex);
-                this.includeFilter = content.filterList;
-                while ( this.pathIndex < content.paths.length ) {
-                    final String path = content.paths[this.pathIndex];
-                    this.pathIndex++;
-                    final Node contextNode = (Node)this.session.getItem(path);
-                    if ( this.includeFilter.evaluate(contextNode) ) {
-                        this.lastNode = contextNode;
-                        this.nextItem = contextNode;
-                        return true;
-                    }
-                }
-                this.contentIndex++;
-                this.pathIndex = 0;
-            }
-
-            return false;
-        }
-
-        /**
-         * @see java.util.Iterator#next()
-         */
-        public Object next() {
-            if ( this.hasNext() ) {
-                final Item result = nextItem;
-                this.nextItem = null;
-                return result;
-            }
-            throw new NoSuchElementException("No more elements available");
-        }
-
-        /**
-         * @see java.util.Iterator#remove()
-         */
-        public void remove() {
-            throw new UnsupportedOperationException("Remove is not supported.");
-        }
-    }
-
-    public boolean isIncludeProperties() {
-        return includeProperties;
-    }
-
-    public void setIncludeProperties(boolean includeProperties) {
-        this.includeProperties = includeProperties;
-    }
-}
+/*
+ * 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.commons.packaging;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.commons.predicate.Predicate;
+
+public class FilterContentPackage implements ContentPackage {
+
+    protected final List<Content> content = new ArrayList<Content>();
+
+    protected boolean includeProperties = false;
+
+    public void addContent(String path, Predicate filterList) {
+        this.content.add(new Content(new String[] {path}, filterList));
+    }
+
+    public void addContent(String[] paths, Predicate filterList) {
+        this.content.add(new Content(paths, filterList));
+    }
+
+    /**
+     * @see org.apache.jackrabbit.commons.packaging.ContentPackage#getItems(javax.jcr.Session)
+     */
+    public Iterator<Item> getItems(Session session)
+    throws RepositoryException {
+        return new FilteringIterator(session, new ArrayList<Content>(this.content), this.includeProperties);
+    }
+
+    protected static class Content {
+        protected final String[] paths;
+        protected final Predicate filterList;
+
+        public Content(String[] paths, Predicate filterList) {
+            this.paths = paths;
+            this.filterList = filterList;
+        }
+    }
+
+    public static class FilteringIterator implements Iterator {
+
+        /** The content we will iterate over. */
+        protected final List<Content> content;
+
+        /**
+         * Filter that defines which items are included
+         */
+        protected Predicate includeFilter;
+
+        protected int contentIndex, pathIndex;
+
+        protected Item nextItem;
+
+        protected Node lastNode;
+
+        protected final Session session;
+
+        protected final List<NodeIterator> nodeIteratorStack = new ArrayList<NodeIterator>();
+
+        protected final boolean includeProperties;
+
+        protected PropertyIterator propertyIterator;
+
+        /**
+         * Creates a new tree walker that uses the given filter as include and
+         * traversal filter.
+         *
+         * @param session The session.
+         * @param contentList The list of content objects.
+         * @param includeProperties Should properties be included.
+         */
+        public FilteringIterator(final Session session,
+                                 final List<Content> contentList,
+                                 final boolean includeProperties) {
+            this.content = contentList;
+            this.session = session;
+            this.includeProperties = includeProperties;
+        }
+
+        /**
+         * @see java.util.Iterator#hasNext()
+         */
+        public boolean hasNext() {
+            if ( this.nextItem != null ) {
+                return true;
+            }
+            try {
+                return this.checkForNextNode();
+            } catch (RepositoryException e) {
+                // if any error occurs, we stop iterating
+                return false;
+            }
+        }
+
+        protected boolean checkForNextNode() throws RepositoryException {
+            if ( this.propertyIterator != null ) {
+                if ( this.propertyIterator.hasNext() ) {
+                    this.nextItem = this.propertyIterator.nextProperty();
+                    return true;
+                }
+                this.propertyIterator = null;
+            } else if ( this.includeProperties && this.lastNode != null ) {
+                if ( this.lastNode.hasProperties() ) {
+                    this.propertyIterator = this.lastNode.getProperties();
+                    this.propertyIterator.hasNext();
+                    this.nextItem = this.propertyIterator.nextProperty();
+                    return true;
+                }
+            }
+            if ( this.lastNode != null ) {
+
+                if ( this.lastNode.hasNodes() ) {
+                    final NodeIterator iter = this.lastNode.getNodes();
+                    this.nodeIteratorStack.add(iter);
+                }
+                while ( this.nodeIteratorStack.size() > 0 ) {
+                    final NodeIterator iter = (NodeIterator)this.nodeIteratorStack.get(this.nodeIteratorStack.size() - 1);
+                    if ( iter.hasNext() ) {
+                        do {
+                            final Node contextNode = iter.nextNode();
+                            if ( this.includeFilter.evaluate(contextNode) ) {
+                                this.lastNode = contextNode;
+                                this.nextItem = contextNode;
+                                return true;
+                            }
+                        } while ( iter.hasNext() );
+                    }
+                    this.nodeIteratorStack.remove(iter);
+                }
+                this.pathIndex++;
+                this.lastNode = null;
+            }
+            while ( this.contentIndex < this.content.size() ) {
+                final Content content = (Content)this.content.get(this.contentIndex);
+                this.includeFilter = content.filterList;
+                while ( this.pathIndex < content.paths.length ) {
+                    final String path = content.paths[this.pathIndex];
+                    this.pathIndex++;
+                    final Node contextNode = (Node)this.session.getItem(path);
+                    if ( this.includeFilter.evaluate(contextNode) ) {
+                        this.lastNode = contextNode;
+                        this.nextItem = contextNode;
+                        return true;
+                    }
+                }
+                this.contentIndex++;
+                this.pathIndex = 0;
+            }
+
+            return false;
+        }
+
+        /**
+         * @see java.util.Iterator#next()
+         */
+        public Object next() {
+            if ( this.hasNext() ) {
+                final Item result = nextItem;
+                this.nextItem = null;
+                return result;
+            }
+            throw new NoSuchElementException("No more elements available");
+        }
+
+        /**
+         * @see java.util.Iterator#remove()
+         */
+        public void remove() {
+            throw new UnsupportedOperationException("Remove is not supported.");
+        }
+    }
+
+    public boolean isIncludeProperties() {
+        return includeProperties;
+    }
+
+    public void setIncludeProperties(boolean includeProperties) {
+        this.includeProperties = includeProperties;
+    }
+}

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/FilterContentPackage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/packaging/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/predicate/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/Operator.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/Operator.java?rev=1235737&r1=1235736&r2=1235737&view=diff
==============================================================================
--- jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/Operator.java (original)
+++ jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/Operator.java Wed Jan 25 13:30:17 2012
@@ -1,161 +1,161 @@
-/*
- * 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.commons.query.qom;
-
-import javax.jcr.RepositoryException;
-import javax.jcr.query.qom.Comparison;
-import javax.jcr.query.qom.DynamicOperand;
-import javax.jcr.query.qom.QueryObjectModelConstants;
-import javax.jcr.query.qom.QueryObjectModelFactory;
-import javax.jcr.query.qom.StaticOperand;
-
-/**
- * Enumeration of the JCR 2.0 query operators.
- *
- * @since Apache Jackrabbit 2.0
- */
-public enum Operator {
-
-    EQ(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, "="),
-
-    NE(QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO, "!=", "<>"),
-
-    GT(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN, ">"),
-
-    GE(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO, ">="),
-
-    LT(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN, "<"),
-
-    LE(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO, "<="),
-
-    LIKE(QueryObjectModelConstants.JCR_OPERATOR_LIKE, null, "like");
-
-    /**
-     * JCR name of this operator.
-     */
-    private final String name;
-
-    /**
-     * This operator in XPath syntax.
-     */
-    private final String xpath;
-
-    /**
-     * This operator in SQL syntax.
-     */
-    private final String sql;
-
-    private Operator(String name, String op) {
-        this(name, op, op);
-    }
-
-    private Operator(String name, String xpath, String sql) {
-        this.name = name;
-        this.xpath = xpath;
-        this.sql = sql;
-    }
-
-    /**
-     * Returns a comparison between the given operands using this operator.
-     *
-     * @param factory factory for creating the comparison
-     * @param left operand on the left hand side
-     * @param right operand on the right hand side
-     * @return comparison
-     * @throws RepositoryException if the comparison can not be created
-     */
-    public Comparison comparison(
-            QueryObjectModelFactory factory,
-            DynamicOperand left, StaticOperand right)
-            throws RepositoryException {
-        return factory.comparison(left, name, right);
-    }
-
-    /**
-     * Formats an XPath constraint with this operator and the given operands.
-     * The operands are simply used as-is, without any quoting or escaping.
-     *
-     * @param a first operand
-     * @param b second operand
-     * @return XPath constraint, <code>a op b</code> or
-     *         <code>jcr:like(a, b)</code> for {@link #LIKE}
-     */
-    public String formatXpath(String a, String b) {
-        if (this == LIKE) {
-            return "jcr:like(" + a + ", " + b + ")";
-        } else {
-            return a + " " + xpath + " " + b;
-        }
-    }
-
-    /**
-     * Formats an SQL constraint with this operator and the given operands.
-     * The operands are simply used as-is, without any quoting or escaping.
-     *
-     * @param a first operand
-     * @param b second operand
-     * @return SQL constraint, <code>a op b</code>
-     */
-    public String formatSql(String a, String b) {
-        return a + " " + sql + " " + b;
-    }
-
-    /**
-     * Returns the JCR 2.0 name of this query operator.
-     *
-     * @see QueryObjectModelConstants
-     * @return JCR name of this operator
-     */
-    public String toString() {
-        return name;
-    }
-
-    /**
-     * Returns an array of the names of all the JCR 2.0 query operators.
-     *
-     * @return names of all query operators
-     */
-    public static String[] getAllQueryOperators() {
-        return new String[] {
-                EQ.toString(),
-                NE.toString(),
-                GT.toString(),
-                GE.toString(),
-                LT.toString(),
-                LE.toString(),
-                LIKE.toString()
-        };
-    }
-
-    /**
-     * Returns the operator with the given JCR name.
-     *
-     * @param name JCR name of an operator
-     * @return operator with the given name
-     * @throws RepositoryException if the given name is unknown
-     */
-    public static Operator getOperatorByName(String name)
-            throws RepositoryException {
-        for (Operator operator : Operator.values()) {
-            if (operator.name.equals(name)) {
-                return operator;
-            }
-        }
-        throw new RepositoryException("Unknown operator name: " + name);
-    }
-
-}
+/*
+ * 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.commons.query.qom;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.query.qom.Comparison;
+import javax.jcr.query.qom.DynamicOperand;
+import javax.jcr.query.qom.QueryObjectModelConstants;
+import javax.jcr.query.qom.QueryObjectModelFactory;
+import javax.jcr.query.qom.StaticOperand;
+
+/**
+ * Enumeration of the JCR 2.0 query operators.
+ *
+ * @since Apache Jackrabbit 2.0
+ */
+public enum Operator {
+
+    EQ(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, "="),
+
+    NE(QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO, "!=", "<>"),
+
+    GT(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN, ">"),
+
+    GE(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO, ">="),
+
+    LT(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN, "<"),
+
+    LE(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO, "<="),
+
+    LIKE(QueryObjectModelConstants.JCR_OPERATOR_LIKE, null, "like");
+
+    /**
+     * JCR name of this operator.
+     */
+    private final String name;
+
+    /**
+     * This operator in XPath syntax.
+     */
+    private final String xpath;
+
+    /**
+     * This operator in SQL syntax.
+     */
+    private final String sql;
+
+    private Operator(String name, String op) {
+        this(name, op, op);
+    }
+
+    private Operator(String name, String xpath, String sql) {
+        this.name = name;
+        this.xpath = xpath;
+        this.sql = sql;
+    }
+
+    /**
+     * Returns a comparison between the given operands using this operator.
+     *
+     * @param factory factory for creating the comparison
+     * @param left operand on the left hand side
+     * @param right operand on the right hand side
+     * @return comparison
+     * @throws RepositoryException if the comparison can not be created
+     */
+    public Comparison comparison(
+            QueryObjectModelFactory factory,
+            DynamicOperand left, StaticOperand right)
+            throws RepositoryException {
+        return factory.comparison(left, name, right);
+    }
+
+    /**
+     * Formats an XPath constraint with this operator and the given operands.
+     * The operands are simply used as-is, without any quoting or escaping.
+     *
+     * @param a first operand
+     * @param b second operand
+     * @return XPath constraint, <code>a op b</code> or
+     *         <code>jcr:like(a, b)</code> for {@link #LIKE}
+     */
+    public String formatXpath(String a, String b) {
+        if (this == LIKE) {
+            return "jcr:like(" + a + ", " + b + ")";
+        } else {
+            return a + " " + xpath + " " + b;
+        }
+    }
+
+    /**
+     * Formats an SQL constraint with this operator and the given operands.
+     * The operands are simply used as-is, without any quoting or escaping.
+     *
+     * @param a first operand
+     * @param b second operand
+     * @return SQL constraint, <code>a op b</code>
+     */
+    public String formatSql(String a, String b) {
+        return a + " " + sql + " " + b;
+    }
+
+    /**
+     * Returns the JCR 2.0 name of this query operator.
+     *
+     * @see QueryObjectModelConstants
+     * @return JCR name of this operator
+     */
+    public String toString() {
+        return name;
+    }
+
+    /**
+     * Returns an array of the names of all the JCR 2.0 query operators.
+     *
+     * @return names of all query operators
+     */
+    public static String[] getAllQueryOperators() {
+        return new String[] {
+                EQ.toString(),
+                NE.toString(),
+                GT.toString(),
+                GE.toString(),
+                LT.toString(),
+                LE.toString(),
+                LIKE.toString()
+        };
+    }
+
+    /**
+     * Returns the operator with the given JCR name.
+     *
+     * @param name JCR name of an operator
+     * @return operator with the given name
+     * @throws RepositoryException if the given name is unknown
+     */
+    public static Operator getOperatorByName(String name)
+            throws RepositoryException {
+        for (Operator operator : Operator.values()) {
+            if (operator.name.equals(name)) {
+                return operator;
+            }
+        }
+        throw new RepositoryException("Unknown operator name: " + name);
+    }
+
+}

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/Operator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/qom/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/branches/2.4/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/query/sql2/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native