jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r793613 [8/8] - in /jackrabbit/sandbox/JCR-1456: ./ jackrabbit-core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/cluster/ jackrabbit-core/src/main/java/org/apache/jackra...
Date Mon, 13 Jul 2009 15:56:03 GMT
Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/security/user/NodeResolverTest.java Mon Jul 13 15:55:55 2009
@@ -48,7 +48,7 @@
         nodeResolver = createNodeResolver(superuser);
     }
 
-    private static UserImpl getCurrentUser(Session session) throws NotExecutableException, RepositoryException {
+    protected static UserImpl getCurrentUser(Session session) throws NotExecutableException, RepositoryException {
         if (!(session instanceof JackrabbitSession)) {
             throw new NotExecutableException();
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/AbstractISMLockingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/AbstractISMLockingTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/AbstractISMLockingTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/AbstractISMLockingTest.java Mon Jul 13 15:55:55 2009
@@ -16,18 +16,17 @@
  */
 package org.apache.jackrabbit.core.state;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import junit.framework.TestCase;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.core.ItemId;
+
+import org.apache.jackrabbit.core.id.ItemId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.core.state.ISMLocking.ReadLock;
 import org.apache.jackrabbit.core.state.ISMLocking.WriteLock;
-import org.apache.jackrabbit.uuid.UUID;
 import org.apache.jackrabbit.spi.commons.name.NameConstants;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Iterator;
-
 /**
  * <code>AbstractISMLockingTest</code> contains test cases for the ISMLocking requirements.
  */
@@ -51,15 +50,15 @@
     /**
      * List of change logs, each with a different modification for {@link #state}.
      */
-    protected List logs;
+    protected List<ChangeLog> logs;
 
     protected void setUp() throws Exception {
         super.setUp();
         locking = createISMLocking();
-        NodeId id = new NodeId(UUID.randomUUID());
+        NodeId id = new NodeId();
         state = new NodeState(id, NameConstants.NT_BASE, null, ItemState.STATUS_EXISTING, true);
-        refs = new NodeReferences(new NodeReferencesId(state.getNodeId()));
-        logs = new ArrayList();
+        refs = new NodeReferences(state.getNodeId());
+        logs = new ArrayList<ChangeLog>();
         ChangeLog log = new ChangeLog();
         log.added(state);
         logs.add(log);
@@ -88,8 +87,7 @@
      */
     public void testReadBlocksWrite() throws InterruptedException {
         ReadLock rLock = locking.acquireReadLock(state.getId());
-        for (Iterator it = logs.iterator(); it.hasNext();) {
-            ChangeLog changeLog = (ChangeLog) it.next();
+        for (ChangeLog changeLog : logs) {
             verifyBlocked(startWriterThread(locking, changeLog));
         }
         rLock.release();
@@ -104,8 +102,7 @@
      * @throws InterruptedException on interruption; this will err the test
      */
     public void testWriteBlocksRead() throws InterruptedException {
-        for (Iterator it = logs.iterator(); it.hasNext();) {
-            ChangeLog changeLog = (ChangeLog) it.next();
+        for (ChangeLog changeLog : logs) {
             WriteLock wLock = locking.acquireWriteLock(changeLog);
             verifyBlocked(startReaderThread(locking, state.getId()));
             wLock.release();
@@ -113,10 +110,8 @@
     }
 
     public void testWriteBlocksRead_notIfSameThread() throws InterruptedException {
-        for (Iterator it = logs.iterator(); it.hasNext();) {
-            final ChangeLog changeLog = (ChangeLog) it.next();
+        for (final ChangeLog changeLog : logs) {
             Thread t = new Thread(new Runnable() {
-
                 public void run() {
                     try {
                         WriteLock wLock = locking.acquireWriteLock(changeLog);
@@ -144,8 +139,7 @@
         ChangeLog cl = new ChangeLog();
         cl.added(state);
         WriteLock wLock = locking.acquireWriteLock(cl);
-        for (Iterator it = logs.iterator(); it.hasNext();) {
-            ChangeLog changeLog = (ChangeLog) it.next();
+        for (ChangeLog changeLog : logs) {
             verifyBlocked(startWriterThread(locking, changeLog));
         }
         wLock.release();
@@ -157,8 +151,7 @@
      * @throws InterruptedException on interruption; this will err the test
      */
     public void testDowngrade() throws InterruptedException {
-        for (Iterator it = logs.iterator(); it.hasNext();) {
-            ChangeLog changeLog = (ChangeLog) it.next();
+        for (ChangeLog changeLog : logs) {
             WriteLock wLock = locking.acquireWriteLock(changeLog);
             verifyBlocked(startReaderThread(locking, state.getId()));
             ReadLock rLock = wLock.downgrade();

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/state/ChangeLogTest.java Mon Jul 13 15:55:55 2009
@@ -18,13 +18,10 @@
 
 import org.apache.jackrabbit.test.AbstractJCRTest;
 import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
-import org.apache.jackrabbit.core.PropertyId;
-import org.apache.jackrabbit.core.NodeId;
-import org.apache.jackrabbit.uuid.UUID;
+import org.apache.jackrabbit.core.id.PropertyId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.spi.NameFactory;
 
-import java.util.Iterator;
-
 /**
  * <code>ChangeLogTest</code> contains the test cases for the methods
  * inside {@link org.apache.jackrabbit.core.state.ChangeLog}.
@@ -43,8 +40,7 @@
      * entry in either the added nor the removed states
      */
     public void testAddDelete() throws Exception {
-        PropertyId id = new PropertyId(
-                new NodeId(UUID.randomUUID()), factory.create("", "a"));
+        PropertyId id = new PropertyId(new NodeId(), factory.create("", "a"));
         ItemState state = new PropertyState(id, ItemState.STATUS_NEW, false);
 
         ChangeLog log = new ChangeLog();
@@ -52,10 +48,10 @@
         log.added(state);
         log.deleted(state);
 
-        Iterator iter = log.addedStates();
-        assertFalse("State not in added collection", iter.hasNext());
-        iter = log.deletedStates();
-        assertFalse("State not in deleted collection", iter.hasNext());
+        assertFalse("State not in added collection",
+                log.addedStates().iterator().hasNext());
+        assertFalse("State not in deleted collection",
+                log.deletedStates().iterator().hasNext());
     }
 
     /**
@@ -63,8 +59,7 @@
      * in the added states.
      */
     public void testAddModify() throws Exception {
-        PropertyId id = new PropertyId(
-                new NodeId(UUID.randomUUID()), factory.create("", "a"));
+        PropertyId id = new PropertyId(new NodeId(), factory.create("", "a"));
         ItemState state = new PropertyState(id, ItemState.STATUS_NEW, false);
 
         ChangeLog log = new ChangeLog();
@@ -72,10 +67,10 @@
         log.added(state);
         log.modified(state);
 
-        Iterator iter = log.addedStates();
-        assertTrue("State still in added collection", iter.hasNext());
-        iter = log.modifiedStates();
-        assertFalse("State not in modified collection", iter.hasNext());
+        assertTrue("State still in added collection",
+                log.addedStates().iterator().hasNext());
+        assertFalse("State not in modified collection",
+                log.modifiedStates().iterator().hasNext());
     }
 
     /**
@@ -85,8 +80,7 @@
     public void testPreserveOrder() throws Exception {
         ItemState[] states = new ItemState[10];
         for (int i = 0; i < states.length; i++) {
-            PropertyId id = new PropertyId(
-                    new NodeId(UUID.randomUUID()), factory.create("", "a" + i));
+            PropertyId id = new PropertyId(new NodeId(), factory.create("", "a" + i));
             states[i] = new PropertyState(id, ItemState.STATUS_NEW, false);
         }
 
@@ -96,11 +90,8 @@
             log.added(states[i]);
         }
 
-        Iterator iter = log.addedStates();
         int i = 0;
-
-        while (iter.hasNext()) {
-            ItemState state = (ItemState) iter.next();
+        for (ItemState state : log.addedStates()) {
             assertTrue("Added states preserve order.",
                     state.equals(states[i++]));
         }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/version/VersionIteratorImplTest.java Mon Jul 13 15:55:55 2009
@@ -20,7 +20,7 @@
 
 import junit.framework.TestCase;
 
-import org.apache.jackrabbit.core.NodeId;
+import org.apache.jackrabbit.core.id.NodeId;
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.uuid.UUID;
 
@@ -63,9 +63,9 @@
 
     public void testVersionIterator() throws Exception {
 
-        InternalVersion version = new DummyInternalVersion(new InternalVersion[] {}, new NodeId(UUID.randomUUID()));
+        InternalVersion version = new DummyInternalVersion(new InternalVersion[] {}, new NodeId());
         for (int i = 1; i < VERSION_COUNT; i++) {
-            version = new DummyInternalVersion(new InternalVersion[] {version}, new NodeId(UUID.randomUUID()));
+            version = new DummyInternalVersion(new InternalVersion[] {version}, new NodeId());
         }
 
         try {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/util/Text.java Mon Jul 13 15:55:55 2009
@@ -453,12 +453,12 @@
      * QName EBNF:<br>
      * <xmp>
      * simplename ::= onecharsimplename | twocharsimplename | threeormorecharname
-     * onecharsimplename ::= (* Any Unicode character except: '.', '/', ':', '[', ']', '*', ''', '"', '|' or any whitespace character *)
+     * onecharsimplename ::= (* Any Unicode character except: '.', '/', ':', '[', ']', '*', '|' or any whitespace character *)
      * twocharsimplename ::= '.' onecharsimplename | onecharsimplename '.' | onecharsimplename onecharsimplename
      * threeormorecharname ::= nonspace string nonspace
      * string ::= char | string char
      * char ::= nonspace | ' '
-     * nonspace ::= (* Any Unicode character except: '/', ':', '[', ']', '*', ''', '"', '|' or any whitespace character *)
+     * nonspace ::= (* Any Unicode character except: '/', ':', '[', ']', '*', '|' or any whitespace character *)
      * </xmp>
      *
      * @param name the name to escape
@@ -469,7 +469,7 @@
         for (int i = 0; i < name.length(); i++) {
             char ch = name.charAt(i);
             if (ch == '%' || ch == '/' || ch == ':' || ch == '[' || ch == ']'
-                || ch == '*' || ch == '\'' || ch == '"' || ch == '|'
+                || ch == '*' || ch == '|'
                 || (ch == '.' && name.length() < 3)
                 || (ch == ' ' && (i == 0 || i == name.length() - 1))
                 || ch == '\t' || ch == '\r' || ch == '\n') {
@@ -483,7 +483,8 @@
         return buffer.toString();
     }
 
-    /** Escapes all illegal XPath search characters of a string.
+    /**
+     * Escapes all illegal XPath search characters of a string.
      * <p>Example:<br>
      * A search string like 'test?' will run into a ParseException
      * documented in http://issues.apache.org/jira/browse/JCR-1248

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-commons/src/test/java/org/apache/jackrabbit/util/TextTest.java Mon Jul 13 15:55:55 2009
@@ -182,5 +182,11 @@
             fail("Text.unescape(" + string + "): " + unexpected.getMessage());
         }
     }
+        
+    public void testEscapeIllegalJcrChars() throws Exception {
 
+        // single and double quote are valid since JCR 2.0
+        assertEquals("local'name", Text.escapeIllegalJcrChars("local'name"));
+        assertEquals("local\"name", Text.escapeIllegalJcrChars("local\"name"));       
+    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/NodeReadMethodsTest.java Mon Jul 13 15:55:55 2009
@@ -501,31 +501,6 @@
                 numExpected2,
                 getSize(nodes2));
 
-
-        // test pattern "nodeName|nodeName"
-        String pattern3 = firstNode.getName() + "|" + firstNode.getName();
-        String assertString3 = "node.getNodes(\"" + pattern3 + "\"): ";
-        // test if the names of the found nodes are matching the pattern
-        NodeIterator nodes3 = node.getNodes(pattern3);
-        while (nodes3.hasNext()) {
-            Node n = nodes3.nextNode();
-            assertEquals(assertString2 + "name comparison failed: ",
-                    firstNode.getName(),
-                    n.getName());
-        }
-        // test if the number of found nodes is correct
-        int numExpected3 = 0;
-        for (int i = 0; i < allNodes.size(); i++) {
-            Node n = (Node) allNodes.get(i);
-            if (n.getName().equals(firstNode.getName())) {
-                numExpected3++;
-            }
-        }
-        assertEquals(assertString3 + "number of nodes found: ",
-                numExpected3,
-                getSize(nodes3));
-
-
         // test pattern "nodeName", "nodeName"
         String pattern4 = firstNode.getName() + "," + firstNode.getName();
         String assertString4 = "node.getNodes(\"" + pattern4 + "\"): ";
@@ -801,30 +776,7 @@
                 numExpected2,
                 getSize(properties2));
 
-
         // test: getProperties("propertyName|propertyName")
-        String pattern3 = firstProperty.getName() + "|" + firstProperty.getName();
-        String assertString3 = "node.getProperties(\"" + pattern3 + "\"): ";
-        // test if the names of the found properties are matching the pattern
-        PropertyIterator properties3 = node.getProperties(new String[] { pattern3 });
-        while (properties3.hasNext()) {
-            Property p = properties3.nextProperty();
-            assertEquals(assertString2 + "name comparison failed: ",
-                    firstProperty.getName(),
-                    p.getName());
-        }
-        // test if the number of found properties is correct
-        int numExpected3 = 0;
-        for (int i = 0; i < allProperties.size(); i++) {
-            Property p = (Property) allProperties.get(i);
-            if (p.getName().equals(firstProperty.getName())) {
-                numExpected3++;
-            }
-        }
-        assertEquals(assertString3 + "number of properties found: ",
-                numExpected3,
-                getSize(properties3));
-
         // test: getProperties("propertyName", "propertyName")
         String pattern4 = firstProperty.getName() + "," + firstProperty.getName();
         String assertString4 = "node.getProperties(\"" + pattern4 + "\"): ";

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java Mon Jul 13 15:55:55 2009
@@ -40,6 +40,7 @@
 public class NodeTypeCreationTest extends AbstractJCRTest {
 
     private static String ns = "http://example.org/jcr-tck/";
+    private static String propname = "{" + ns + "}" + "boolean";
     
     private NodeTypeManager ntm;
     
@@ -59,7 +60,7 @@
         super.tearDown();
     }
 
-    public void testNodeTypeTemplate() throws Exception {
+    public void testNewNodeTypeTemplate() throws Exception {
         
         String ntname = "{" + ns + "}" + "littlemixin";
         
@@ -71,6 +72,7 @@
         ntt.setMixin(true);
         ntt.setOrderableChildNodes(false);
         ntt.setQueryable(false);
+        ntt.setPrimaryItemName(null);
         
         List pdefs = ntt.getPropertyDefinitionTemplates();
         pdefs.add(createBooleanPropTemplate());
@@ -79,9 +81,7 @@
     public void testPropertyDefinitionTemplate() throws Exception {
         PropertyDefinitionTemplate pdt = createBooleanPropTemplate();
         
-        String pref = superuser.getNamespacePrefix(ns);
-        
-        assertEquals(pref + ":" + "boolean", pdt.getName());
+        assertEquals(propname, pdt.getName());
         assertEquals(false, pdt.isAutoCreated());
         assertEquals(false, pdt.isMandatory());
         assertEquals(OnParentVersionAction.IGNORE, pdt.getOnParentVersion());
@@ -99,8 +99,6 @@
     
     
     private PropertyDefinitionTemplate createBooleanPropTemplate() throws RepositoryException {
-        String propname = "{" + ns + "}" + "boolean";
-        
         PropertyDefinitionTemplate pdt = ntm.createPropertyDefinitionTemplate();
         pdt.setName(propname);
         pdt.setAutoCreated(false);

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/AbstractQueryTest.java Mon Jul 13 15:55:55 2009
@@ -30,6 +30,8 @@
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
 import javax.jcr.Session;
+import javax.jcr.ValueFactory;
+
 import java.util.Set;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -81,6 +83,11 @@
     protected QueryObjectModelFactory qf;
 
     /**
+     * The value factory for creating literals for the query object model.
+     */
+    protected ValueFactory vf;
+
+    /**
      * The query manager for {@link #superuser}
      */
     protected QueryManager qm;
@@ -100,11 +107,13 @@
         xpathRoot = "/" + jcrRoot + ISO9075.encodePath(testRoot);
         qm = superuser.getWorkspace().getQueryManager();
         qf = qm.getQOMFactory();
+        vf = superuser.getValueFactory();
     }
 
     protected void tearDown() throws Exception {
         qm = null;
         qf = null;
+        vf = null;
         super.tearDown();
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/BindVariableValueTest.java Mon Jul 13 15:55:55 2009
@@ -71,6 +71,13 @@
         super.tearDown();
     }
 
+    public void testBindVariableNames() throws RepositoryException {
+        String[] names = qomQuery.getBindVariableNames();
+        assertNotNull(names);
+        assertEquals(1, names.length);
+        assertEquals("v", names[0]);
+    }
+
     public void testIllegalArgumentException() throws RepositoryException {
         try {
             bindVariableValue(qomQuery, "x", vf.createValue(STRING_VALUE));

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/FullTextSearchScoreTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/FullTextSearchScoreTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/FullTextSearchScoreTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/FullTextSearchScoreTest.java Mon Jul 13 15:55:55 2009
@@ -45,7 +45,7 @@
         QueryObjectModel qom = qf.createQuery(
                 qf.selector(testNodeType, "s"),
                 qf.and(
-                        qf.fullTextSearch("s", null, "fox"),
+                        qf.fullTextSearch("s", null, qf.literal(vf.createValue("fox"))),
                         qf.descendantNode("s", testRootNode.getPath())
                 ),
                 new Ordering[]{qf.ascending(qf.fullTextSearchScore("s"))},
@@ -72,7 +72,7 @@
                 qf.selector(testNodeType, "s"),
                 qf.and(
                         qf.and(
-                                qf.fullTextSearch("s", null, "fox"),
+                                qf.fullTextSearch("s", null, qf.literal(vf.createValue("fox"))),
                                 qf.comparison(
                                         qf.fullTextSearchScore("s"),
                                         QueryObjectModelFactory.JCR_OPERATOR_GREATER_THAN,

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/QueryObjectModelFactoryTest.java Mon Jul 13 15:55:55 2009
@@ -370,27 +370,48 @@
     }
 
     /**
-     * Test case for {@link QueryObjectModelFactory#fullTextSearch(String, String, String)}
+     * Test case for {@link QueryObjectModelFactory#fullTextSearch(String, String, StaticOperand)}
      */
     public void testFullTextSearch() throws RepositoryException {
-        FullTextSearch ftSearch = qf.fullTextSearch(SELECTOR_NAME1, propertyName1, FULLTEXT_SEARCH_EXPR);
+        FullTextSearch ftSearch = qf.fullTextSearch(
+                SELECTOR_NAME1, propertyName1,
+                qf.literal(vf.createValue(FULLTEXT_SEARCH_EXPR)));
         assertEquals("Wrong selector name", SELECTOR_NAME1, ftSearch.getSelectorName());
         assertEquals("Wrong propertyName", propertyName1, ftSearch.getPropertyName());
-        // TODO is there some way to check the contents of a StaticOperand?
-        
-        // minimal test of getFullTextSearchExpression()
+
         StaticOperand op = ftSearch.getFullTextSearchExpression();
         assertNotNull(op);
+        assertTrue("not a Literal", op instanceof Literal);
+        Literal literal = (Literal) op;
+        assertEquals(FULLTEXT_SEARCH_EXPR, literal.getLiteralValue().getString());
     }
 
     /**
-     * Test case for {@link QueryObjectModelFactory#fullTextSearch(String, String, String)}
+     * Test case for {@link QueryObjectModelFactory#fullTextSearch(String, String, StaticOperand)}
      */
     public void testFullTextSearchAllProperties() throws RepositoryException {
-        FullTextSearch ftSearch = qf.fullTextSearch(SELECTOR_NAME1, null, FULLTEXT_SEARCH_EXPR);
+        FullTextSearch ftSearch = qf.fullTextSearch(
+                SELECTOR_NAME1, null,
+                qf.literal(vf.createValue(FULLTEXT_SEARCH_EXPR)));
         assertEquals("Wrong selector name", SELECTOR_NAME1, ftSearch.getSelectorName());
         assertNull("Property name must be null", ftSearch.getPropertyName());
-        // TODO is there some way to check the contents of a StaticOperand?
+    }
+
+    /**
+     * Test case for {@link QueryObjectModelFactory#fullTextSearch(String, String, StaticOperand)}
+     */
+    public void testFullTextSearchWithBindVariableValue() throws RepositoryException {
+        FullTextSearch ftSearch = qf.fullTextSearch(
+                SELECTOR_NAME1, propertyName1,
+                qf.bindVariable(VARIABLE_NAME));
+        assertEquals("Wrong selector name", SELECTOR_NAME1, ftSearch.getSelectorName());
+        assertEquals("Wrong propertyName", propertyName1, ftSearch.getPropertyName());
+
+        StaticOperand op = ftSearch.getFullTextSearchExpression();
+        assertNotNull(op);
+        assertTrue("not a BindVariableValue", op instanceof BindVariableValue);
+        BindVariableValue value = (BindVariableValue) op;
+        assertEquals(VARIABLE_NAME, value.getBindVariableName());
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/SelectorTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/SelectorTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/SelectorTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/query/qom/SelectorTest.java Mon Jul 13 15:55:55 2009
@@ -22,6 +22,7 @@
 import javax.jcr.nodetype.NodeTypeManager;
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.Query;
+import javax.jcr.query.QueryResult;
 import javax.jcr.query.qom.QueryObjectModelConstants;
 import javax.jcr.query.qom.QueryObjectModel;
 
@@ -38,7 +39,12 @@
                 qf.selector(testNodeType, "s"), null, null, null);
         forQOMandSQL2(qom, new Callable() {
             public Object call(Query query) throws RepositoryException {
-                NodeIterator it = query.execute().getNodes();
+                QueryResult result = query.execute();
+                String[] names = result.getSelectorNames();
+                assertNotNull(names);
+                assertEquals(1, names.length);
+                assertEquals("s", names[0]);
+                NodeIterator it = result.getNodes();
                 while (it.hasNext()) {
                     assertTrue("Wrong node type", it.nextNode().isNodeType(testNodeType));
                 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/NodeImpl.java Mon Jul 13 15:55:55 2009
@@ -519,7 +519,7 @@
         checkStatus();
         List properties = new ArrayList();
         // traverse child properties using a filtering item visitor
-        accept(new ChildrenCollectorFilter(nameGlobs, properties, true, false, 1));
+        accept(new ChildrenCollectorFilter(nameGlobs, properties, false, true, 1));
         return new PropertyIteratorAdapter(properties);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryImpl.java Mon Jul 13 15:55:55 2009
@@ -221,6 +221,13 @@
     }
 
     /**
+     * @see Query#getBindVariableNames()
+     */
+    public String[] getBindVariableNames() throws RepositoryException {
+        return varNames.toArray(new String[varNames.size()]);
+    }
+
+    /**
      * @see Query#bindValue(String, Value)
      */
     public void bindValue(String varName, Value value) throws RepositoryException {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryManagerImpl.java Mon Jul 13 15:55:55 2009
@@ -116,8 +116,7 @@
         String language = node.getProperty(resolver.getJCRName(NameConstants.JCR_LANGUAGE)).getString();
 
         if (Query.JCR_JQOM.equals(language)) {
-            QueryObjectModelFactory qomFactory = new QOMFactory(
-                    node, resolver, valueFactory);
+            QueryObjectModelFactory qomFactory = new QOMFactory(node, resolver);
             QueryObjectModelBuilder builder = QueryObjectModelBuilderRegistry.getQueryObjectModelBuilder(language);
             return builder.createQueryObjectModel(statement, qomFactory, valueFactory);
         } else {
@@ -137,7 +136,7 @@
      * @see QueryManager#getQOMFactory()
      */
     public QueryObjectModelFactory getQOMFactory() {
-        return new QOMFactory(null, mgrProvider.getNamePathResolver(), valueFactory);
+        return new QOMFactory(null, mgrProvider.getNamePathResolver());
     }
 
     //------------------------------------------------------------< private >---
@@ -158,10 +157,8 @@
 
         private final Node node;
 
-        public QOMFactory(Node node,
-                          NamePathResolver resolver,
-                          ValueFactory factory) {
-            super(resolver, factory);
+        public QOMFactory(Node node, NamePathResolver resolver) {
+            super(resolver);
             this.node = node;
         }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryObjectModelImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryObjectModelImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryObjectModelImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryObjectModelImpl.java Mon Jul 13 15:55:55 2009
@@ -180,5 +180,10 @@
                 throws IllegalArgumentException, RepositoryException {
             throw new UnsupportedOperationException();
         }
+
+        public String[] getBindVariableNames() throws RepositoryException {
+            throw new UnsupportedOperationException();
+        }
+
     }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryResultImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryResultImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryResultImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-jcr2spi/src/main/java/org/apache/jackrabbit/jcr2spi/query/QueryResultImpl.java Mon Jul 13 15:55:55 2009
@@ -19,6 +19,8 @@
 import org.apache.jackrabbit.jcr2spi.ItemManager;
 import org.apache.jackrabbit.jcr2spi.ManagerProvider;
 import org.apache.jackrabbit.spi.QueryInfo;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
 
 import javax.jcr.NodeIterator;
 import javax.jcr.RepositoryException;
@@ -63,6 +65,19 @@
     /**
      * {@inheritDoc}
      */
+    public String[] getSelectorNames() throws RepositoryException {
+        Name[] names = queryInfo.getSelectorNames();
+        String[] sn = new String[names.length];
+        NameResolver resolver = mgrProvider.getNameResolver();
+        for (int i = 0; i < sn.length; i++) {
+            sn[i] = resolver.getJCRName(names[i]);
+        }
+        return sn;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public String[] getColumnNames() throws RepositoryException {
         return queryInfo.getColumnNames();
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-parent/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-parent/pom.xml?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-parent/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-parent/pom.xml Mon Jul 13 15:55:55 2009
@@ -147,7 +147,7 @@
       <dependency>
         <groupId>javax.jcr</groupId>
         <artifactId>jcr</artifactId>
-        <version>2.0-b18</version>
+        <version>2.0-b19</version>
         <scope>provided</scope>
       </dependency>
       <dependency>

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/RelationQueryNode.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/RelationQueryNode.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/RelationQueryNode.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/RelationQueryNode.java Mon Jul 13 15:55:55 2009
@@ -175,7 +175,11 @@
      */
     public void addPathElement(Path.Element element) {
         LocationStepQueryNode step = factory.createLocationStepQueryNode(relPath);
-        step.setNameTest(element.getName());
+        if (element.getName().equals(STAR_NAME_TEST)) {
+            step.setNameTest(null);
+        } else {
+            step.setNameTest(element.getName());
+        }
         relPath.addPathStep(step);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/qom/QueryObjectModelFactoryImpl.java Mon Jul 13 15:55:55 2009
@@ -58,7 +58,6 @@
 import javax.jcr.query.qom.UpperCase;
 import javax.jcr.RepositoryException;
 import javax.jcr.Value;
-import javax.jcr.ValueFactory;
 
 /**
  * <code>QueryObjectModelFactoryImpl</code> implements the query object model
@@ -71,15 +70,8 @@
      */
     private final NamePathResolver resolver;
 
-    /**
-     * Value factory of the current session.
-     */
-    private final ValueFactory factory;
-
-    public QueryObjectModelFactoryImpl(
-            NamePathResolver resolver, ValueFactory factory) {
+    public QueryObjectModelFactoryImpl(NamePathResolver resolver) {
         this.resolver = resolver;
-        this.factory = factory;
     }
 
     /**
@@ -529,7 +521,7 @@
      */
     public FullTextSearch fullTextSearch(String selectorName,
                                          String propertyName,
-                                         String fullTextSearchExpression)
+                                         StaticOperand fullTextSearchExpression)
             throws InvalidQueryException, RepositoryException {
         if (fullTextSearchExpression == null) {
             throw new IllegalArgumentException(
@@ -539,11 +531,9 @@
         if (propertyName != null) {
             propName = checkPropertyName(propertyName);
         }
-        Literal literal =
-            literal(factory.createValue(fullTextSearchExpression));
         return new FullTextSearchImpl(resolver,
                 checkSelectorName(selectorName), propName,
-                checkFullTextSearchExpression(literal));
+                checkFullTextSearchExpression(fullTextSearchExpression));
     }
 
     /**

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/sql2/Parser.java Mon Jul 13 15:55:55 2009
@@ -139,9 +139,9 @@
     private String readName() throws RepositoryException {
         if (readIf("[")) {
             if (currentTokenType == VALUE) {
-                String s = readString();
+                Value value = readString();
                 read("]");
-                return s;
+                return value.getString();
             } else {
                 int level = 1;
                 StringBuilder buff = new StringBuilder();
@@ -330,16 +330,20 @@
             if (readIf(".")) {
                 if (readIf("*")) {
                     read(",");
-                    c = factory.fullTextSearch(name, null, readString());
+                    c = factory.fullTextSearch(
+                            name, null, factory.literal(readString()));
                 } else {
                     String selector = name;
                     name = readName();
                     read(",");
-                    c = factory.fullTextSearch(selector, name, readString());
+                    c = factory.fullTextSearch(
+                            selector, name, factory.literal(readString()));
                 }
             } else {
                 read(",");
-                c = factory.fullTextSearch(getOnlySelectorName(), name, readString());
+                c = factory.fullTextSearch(
+                        getOnlySelectorName(), name,
+                        factory.literal(readString()));
             }
         } else if ("ISSAMENODE".equalsIgnoreCase(functionName)) {
             String name = readName();
@@ -635,13 +639,13 @@
         return s;
     }
 
-    private String readString() throws RepositoryException {
+    private Value readString() throws RepositoryException {
         if (currentTokenType != VALUE) {
             throw getSyntaxError("string value");
         }
-        String s = currentValue.getString();
+        Value value = currentValue;
         read();
-        return s;
+        return value;
     }
 
     private void addExpected(String token) {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/main/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormat.java Mon Jul 13 15:55:55 2009
@@ -351,7 +351,17 @@
             } else if (relPath.getNumOperands() > 0 && relPath.getPathSteps()[0].getNameTest().equals(XPathQueryBuilder.FN_POSITION_FULL)) {
                 propPath.append(resolver.getJCRName(XPathQueryBuilder.FN_POSITION_FULL));
             } else {
-                visit(relPath, data);
+                LocationStepQueryNode[] steps = relPath.getPathSteps();
+                String slash = "";
+                for (int i = 0; i < steps.length; i++) {
+                    propPath.append(slash);
+                    slash = "/";
+                    if (i == steps.length - 1 && node.getOperation() != OPERATION_SIMILAR) {
+                        // last step
+                        propPath.append("@");
+                    }
+                    visit(steps[i], propPath);
+                }
             }
 
             // surround name with property function
@@ -407,6 +417,7 @@
                 sb.append(resolver.getJCRName(XPathQueryBuilder.REP_SIMILAR));
                 sb.append("(").append(propPath).append(", ");
                 appendValue(node, sb);
+                sb.append(")");
             } else if (node.getOperation() == OPERATION_SPELLCHECK) {
                 sb.append(resolver.getJCRName(XPathQueryBuilder.REP_SPELLCHECK));
                 sb.append("(");

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/sql2/ParserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/sql2/ParserTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/sql2/ParserTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/sql2/ParserTest.java Mon Jul 13 15:55:55 2009
@@ -46,8 +46,8 @@
 
     static class QOMF extends QueryObjectModelFactoryImpl  {
 
-        public QOMF(NamePathResolver resolver, ValueFactory factory) {
-            super(resolver, factory);
+        public QOMF(NamePathResolver resolver) {
+            super(resolver);
         }
 
         protected QueryObjectModel createQuery(QueryObjectModelTree qomTree) throws InvalidQueryException,
@@ -60,8 +60,8 @@
     protected void setUp() throws Exception {
         super.setUp();
         NamePathResolver resolver = new DefaultNamePathResolver(new DummyNamespaceResolver());
+        QueryObjectModelFactoryImpl factory = new QOMF(resolver);
         ValueFactory vf = new ValueFactoryQImpl(QValueFactoryImpl.getInstance(), resolver);
-        QueryObjectModelFactoryImpl factory = new QOMF(resolver, vf);
         parser = new Parser(factory, vf);
     }
 

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi-commons/src/test/java/org/apache/jackrabbit/spi/commons/query/xpath/QueryFormatTest.java Mon Jul 13 15:55:55 2009
@@ -20,6 +20,7 @@
 
 import javax.jcr.query.Query;
 import javax.jcr.query.InvalidQueryException;
+import javax.jcr.NamespaceException;
 
 import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
 import org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver;
@@ -28,6 +29,7 @@
 import org.apache.jackrabbit.spi.commons.query.DefaultQueryNodeFactory;
 import org.apache.jackrabbit.spi.commons.query.QueryRootNode;
 import org.apache.jackrabbit.spi.commons.query.QueryParser;
+import org.apache.jackrabbit.spi.Name;
 
 import junit.framework.TestCase;
 
@@ -37,12 +39,39 @@
 public class QueryFormatTest extends TestCase {
 
     private static final NameResolver RESOLVER = new DefaultNamePathResolver(
-            new DummyNamespaceResolver());
+            new DummyNamespaceResolver() {
+                public String getURI(String prefix) throws NamespaceException {
+                    if (Name.NS_REP_PREFIX.equals(prefix)) {
+                        return Name.NS_REP_URI;
+                    } else {
+                        return super.getURI(prefix);
+                    }
+                }
+
+                public String getPrefix(String uri) {
+                    if (Name.NS_REP_URI.equals(uri)) {
+                        return Name.NS_REP_PREFIX;
+                    } else {
+                        return super.getPrefix(uri);
+                    }
+                }
+            });
 
-    private static final QueryNodeFactory FACTORY = new DefaultQueryNodeFactory(Collections.EMPTY_LIST);
+    private static final QueryNodeFactory FACTORY = new DefaultQueryNodeFactory(Collections.<Name>emptyList());
 
     public void testSelectWithOrderBy() throws InvalidQueryException {
-        String stmt = "//element(*, foo)/(@a|@b) order by @bar";
+        checkStatement("//element(*, foo)/(@a|@b) order by @bar");
+    }
+
+    public void testStarNameTest() throws Exception {
+        checkStatement("//element(*, foo)[foo/*/@bar = 'bla']");
+    }
+
+    public void testRepSimilar() throws Exception {
+        checkStatement("//element(*, foo)[rep:similar(foo, '/some/path')]");
+    }
+
+    protected void checkStatement(String stmt) throws InvalidQueryException {
         QueryRootNode root = QueryParser.parse(stmt, Query.XPATH, RESOLVER, FACTORY);
         assertEquals(stmt, QueryFormat.toString(root, RESOLVER));
     }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QueryInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QueryInfo.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QueryInfo.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi/src/main/java/org/apache/jackrabbit/spi/QueryInfo.java Mon Jul 13 15:55:55 2009
@@ -39,9 +39,16 @@
     public RangeIterator getRows();
 
     /**
-     * @return an array of <code>Name</code>s representing the column names of
-     * the query result.
+     * @return an array of <code>String</code>s representing the column names of
+     *         the query result.
      * @see javax.jcr.query.QueryResult#getColumnNames()
      */
     public String[] getColumnNames();
+
+    /**
+     * @return an array of <code>Name</code>s representing the selector names of
+     *         the query result.
+     * @see javax.jcr.query.QueryResult#getSelectorNames()
+     */
+    public Name[] getSelectorNames();
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryInfoImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryInfoImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryInfoImpl.java Mon Jul 13 15:55:55 2009
@@ -18,6 +18,8 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
 
 import javax.jcr.RepositoryException;
 import javax.jcr.ValueFactory;
@@ -27,6 +29,7 @@
 import org.apache.jackrabbit.spi.QValueFactory;
 import org.apache.jackrabbit.spi.QueryResultRow;
 import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.util.ISO9075;
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.MultiStatusResponse;
@@ -86,4 +89,23 @@
         System.arraycopy(columnNames, 0, names, 0, columnNames.length);
         return names;
     }
+
+    /**
+     * @see QueryInfo#getSelectorNames()
+     */
+    public Name[] getSelectorNames() {
+        if (results.isEmpty()) {
+            // TODO: this is not correct
+            return new Name[0];
+        } else {
+            Set<Name> uniqueNames = new HashSet<Name>();
+            QueryResultRowImpl row = (QueryResultRowImpl) results.get(0);
+            for (Name n : row.getSelectorNames()) {
+                if (n != null) {
+                    uniqueNames.add(n);
+                }
+            }
+            return uniqueNames.toArray(new Name[uniqueNames.size()]);
+        }
+    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryResultRowImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryResultRowImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryResultRowImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi2dav/src/main/java/org/apache/jackrabbit/spi2dav/QueryResultRowImpl.java Mon Jul 13 15:55:55 2009
@@ -56,6 +56,8 @@
 
     private final String[] columnNames;
 
+    private final Name[] selectorNames;
+
     public QueryResultRowImpl(MultiStatusResponse response,
                               String[] columnNames,
                               NamePathResolver resolver,
@@ -73,22 +75,23 @@
         Value[] values = resultProp.getValues();
         String[] names = resultProp.getColumnNames();
         String[] selectorNames = resultProp.getSelectorNames();
+        this.selectorNames = new Name[selectorNames.length];
         for (int i = 0; i < values.length; i++) {
             try {
                 QValue v = (values[i] == null) ? null : ValueFormat.getQValue(values[i], resolver, qValueFactory);
-                Name s = (selectorNames[i] == null) ? null : resolver.getQName(selectorNames[i]);
+                this.selectorNames[i] = (selectorNames[i] == null) ? null : resolver.getQName(selectorNames[i]);
                 if (jcrScore.equals(names[i])) {
                     Double score = 0.0;
                     if (v != null) {
                         score = v.getDouble();
                     }
-                    scores.put(s, score);
+                    scores.put(this.selectorNames[i], score);
                 } else if (jcrPath.equals(names[i])) {
                     NodeId id = null;
                     if (v != null) {
                         id = idFactory.createNodeId((String) null, v.getPath());
                     }
-                    nodeIds.put(s, id);
+                    nodeIds.put(this.selectorNames[i], id);
                 }
                 qValues.put(names[i], v);
             } catch (RepositoryException e) {
@@ -129,4 +132,8 @@
         }
         return values;
     }
+
+    Name[] getSelectorNames() {
+        return selectorNames;
+    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/pom.xml?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/pom.xml (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/pom.xml Mon Jul 13 15:55:55 2009
@@ -71,9 +71,7 @@
                 org.apache.jackrabbit.jcr2spi.name.NamespaceRegistryTest#testRegisteredNamespaceVisibility
                 org.apache.jackrabbit.test.api.ShareableNodeTest
                 org.apache.jackrabbit.test.api.version.simple
-                org.apache.jackrabbit.test.api.NodeReadMethodsTest#testGetPropertiesNamePatternArray
                 org.apache.jackrabbit.test.api.version.ActivitiesTest
-                org.apache.jackrabbit.test.api.nodetype.NodeTypeCreationTest#testPropertyDefinitionTemplate
               </value>
             </property>
           </systemProperties>

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/QueryInfoImpl.java Mon Jul 13 15:55:55 2009
@@ -27,16 +27,11 @@
 
 import javax.jcr.query.QueryResult;
 import javax.jcr.query.Row;
-import javax.jcr.query.Query;
-import javax.jcr.query.qom.QueryObjectModel;
-import javax.jcr.query.qom.Source;
-import javax.jcr.query.qom.Join;
-import javax.jcr.query.qom.Selector;
 import javax.jcr.RepositoryException;
 import javax.jcr.RangeIterator;
 import java.util.NoSuchElementException;
 import java.util.List;
-import java.util.ArrayList;
+import java.util.Arrays;
 
 /**
  * <code>QueryInfoImpl</code> implements a <code>QueryInfo</code> based on a
@@ -82,7 +77,6 @@
     /**
      * Creates a new query info based on a given <code>result</code>.
      *
-     * @param query         the JCR query.
      * @param result        the JCR query result.
      * @param idFactory     the id factory.
      * @param resolver      the name path resolver.
@@ -90,8 +84,7 @@
      * @throws RepositoryException if an error occurs while reading from
      *                             <code>result</code>.
      */
-    public QueryInfoImpl(Query query,
-                         QueryResult result,
+    public QueryInfoImpl(QueryResult result,
                          IdFactoryImpl idFactory,
                          NamePathResolver resolver,
                          QValueFactory qValueFactory)
@@ -101,7 +94,7 @@
         this.resolver = resolver;
         this.qValueFactory = qValueFactory;
         this.columnNames = result.getColumnNames();
-        this.selectorNames = getSelectorNames(query, result, resolver);
+        this.selectorNames = getSelectorNames(result, resolver);
     }
 
     /**
@@ -136,39 +129,23 @@
         return names;
     }
 
-    private static Name[] getSelectorNames(Query query,
-                                           QueryResult result,
+    /**
+     * {@inheritDoc}
+     */
+    public Name[] getSelectorNames() {
+        Name[] names = new Name[selectorNames.length];
+        System.arraycopy(selectorNames, 0, names, 0, selectorNames.length);
+        return names;
+    }
+
+    private static Name[] getSelectorNames(QueryResult result,
                                            NamePathResolver resolver)
             throws RepositoryException {
-        List<String> sn = new ArrayList<String>();
-        if (query instanceof QueryObjectModel) {
-            QueryObjectModel qom = (QueryObjectModel) query;
-            collectSelectorNames(qom.getSource(), sn);
-        } else {
-            // TODO
-            // sn.addAll(Arrays.asList(result.getSelectorNames()));
-        }
+        List<String> sn = Arrays.asList(result.getSelectorNames());
         Name[] selectorNames = new Name[sn.size()];
         for (int i = 0; i < sn.size(); i++) {
             selectorNames[i] = resolver.getQName(sn.get(i));
         }
         return selectorNames;
     }
-
-    private static void collectSelectorNames(Source source, List<String> sn) {
-        if (source instanceof Join) {
-            collectSelectorNames((Join) source, sn);
-        } else {
-            collectSelectorNames((Selector) source, sn);
-        }
-    }
-
-    private static void collectSelectorNames(Join join, List<String> sn) {
-        collectSelectorNames(join.getLeft(), sn);
-        collectSelectorNames(join.getRight(), sn);
-    }
-
-    private static void collectSelectorNames(Selector s, List<String> sn) {
-        sn.add(s.getSelectorName());
-    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-spi2jcr/src/main/java/org/apache/jackrabbit/spi2jcr/RepositoryServiceImpl.java Mon Jul 13 15:55:55 2009
@@ -89,13 +89,6 @@
 import javax.jcr.query.InvalidQueryException;
 import javax.jcr.query.QueryManager;
 import javax.jcr.query.Query;
-import javax.jcr.query.qom.Constraint;
-import javax.jcr.query.qom.And;
-import javax.jcr.query.qom.Or;
-import javax.jcr.query.qom.Not;
-import javax.jcr.query.qom.Comparison;
-import javax.jcr.query.qom.BindVariableValue;
-import javax.jcr.query.qom.QueryObjectModel;
 import javax.jcr.lock.LockException;
 import javax.jcr.lock.Lock;
 import javax.jcr.version.VersionException;
@@ -1034,7 +1027,7 @@
             throws InvalidQueryException, RepositoryException {
         Query q = createQuery(getSessionInfoImpl(sessionInfo).getSession(),
                 statement, language, namespaces);
-        return getBindVariableNames(q);
+        return q.getBindVariableNames();
     }
 
     /**
@@ -1056,7 +1049,7 @@
                 query.bindValue(entry.getKey(), value);
             }
         }
-        return new QueryInfoImpl(query, query.execute(), idFactory,
+        return new QueryInfoImpl(query.execute(), idFactory,
                 sInfo.getNamePathResolver(), getQValueFactory());
     }
 
@@ -1831,36 +1824,4 @@
         // if we get here simply run as is
         return call.run();
     }
-
-    private String[] getBindVariableNames(Query query) {
-        List<String> names = new ArrayList<String>();
-        if (query instanceof QueryObjectModel) {
-            QueryObjectModel qom = (QueryObjectModel) query;
-            collectBindVariableNames(qom.getConstraint(), names);
-        } else {
-            // TODO: use when available
-            // names.addAll(Arrays.asList(q.getBindVariableNames()));
-        }
-        return names.toArray(new String[names.size()]);
-    }
-
-    private void collectBindVariableNames(Constraint c, List<String> names) {
-        if (c instanceof And) {
-            collectBindVariableNames(((And) c).getConstraint1(), names);
-            collectBindVariableNames(((And) c).getConstraint2(), names);
-        } else if (c instanceof Or) {
-            collectBindVariableNames(((Or) c).getConstraint1(), names);
-            collectBindVariableNames(((Or) c).getConstraint2(), names);
-        } else if (c instanceof Not) {
-            collectBindVariableNames(((Not) c).getConstraint(), names);
-        } else if (c instanceof Comparison) {
-            collectBindVariableNames((Comparison) c, names);
-        }
-    }
-
-    private void collectBindVariableNames(Comparison c, List<String> names) {
-        if (c.getOperand2() instanceof BindVariableValue) {
-            names.add(((BindVariableValue) c.getOperand2()).getBindVariableName());
-        }
-    }
 }

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryAccessServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryAccessServlet.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryAccessServlet.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryAccessServlet.java Mon Jul 13 15:55:55 2009
@@ -103,7 +103,7 @@
      * @param ctx the servlet context
      * @return this servlet
      */
-    private static RepositoryAccessServlet getInstance(ServletContext ctx) {
+    public static RepositoryAccessServlet getInstance(ServletContext ctx) {
         final RepositoryAccessServlet instance = (RepositoryAccessServlet) ctx.getAttribute(CTX_PARAM_THIS);
         if(instance==null) {
             throw new IllegalStateException(
@@ -322,6 +322,14 @@
     }
 
     /**
+     * Returns the config that was used to bootstrap this servlet.
+     * @return the bootstrap config or <code>null</code>.
+     */
+    public BootstrapConfig getBootstrapConfig() {
+        return config;
+    }
+
+    /**
      * optional class for RMI, will only be used, if RMI client is present
      */
     protected static abstract class ClientFactoryDelegater {

Modified: jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java?rev=793613&r1=793612&r2=793613&view=diff
==============================================================================
--- jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java (original)
+++ jackrabbit/sandbox/JCR-1456/jackrabbit-webapp/src/main/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java Mon Jul 13 15:55:55 2009
@@ -592,6 +592,14 @@
     }
 
     /**
+     * Returns the config that was used to bootstrap this servlet.
+     * @return the bootstrap config or <code>null</code>.
+     */
+    public BootstrapConfig getBootstrapConfig() {
+        return config;
+    }
+
+    /**
      * Return the fully qualified name of the class providing the remote
      * repository. The class whose name is returned must implement the
      * {@link RemoteFactoryDelegater} interface.



Mime
View raw message