jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r1851053 - in /jackrabbit/branches/2.8: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/ jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/ jackrabbit-core/src/test/resources/org/apache/jackrabbi...
Date Fri, 11 Jan 2019 14:16:18 GMT
Author: reschke
Date: Fri Jan 11 14:16:18 2019
New Revision: 1851053

URL: http://svn.apache.org/viewvc?rev=1851053&view=rev
Log:
JCR-4093: IndexRule are meant to be applied based on both primaryType and minin type based
inheritance. Currently it appears that only primaryType based inheritance is working (ported
to 2.8)

Added:
    jackrabbit/branches/2.8/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config5.xml
      - copied unchanged from r1780336, jackrabbit/trunk/jackrabbit-core/src/test/resources/org/apache/jackrabbit/core/query/lucene/indexing_config5.xml
Modified:
    jackrabbit/branches/2.8/   (props changed)
    jackrabbit/branches/2.8/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
    jackrabbit/branches/2.8/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
    jackrabbit/branches/2.8/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java

Propchange: jackrabbit/branches/2.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jan 11 14:16:18 2019
@@ -2,4 +2,4 @@
 /jackrabbit/branches/2.14:1813154
 /jackrabbit/branches/JCR-2272:1173165-1176545
 /jackrabbit/sandbox/JCR-2415-lucene-3.0:1060860-1064038
-/jackrabbit/trunk:1592881,1597717,1597799,1597806,1598035,1598058,1603769,1603934,1609712,1615997,1625561,1627529,1634584,1653275,1667787,1667795,1674859,1680757,1709811,1717599,1720093,1729382,1730696,1732436,1740814-1740815,1751279,1752165,1758600,1759607,1759782,1759865,1761679,1761909,1762422,1763558,1766398,1771078,1771741,1771939,1771999,1772049,1772343,1772444,1772457,1772530,1772544,1773579,1773591,1773745,1774443,1775657,1779166,1779460,1780208,1786325,1787043,1787381,1792100,1792105,1792113,1792193,1793315,1793323,1793327,1793332,1796980,1797209,1797917,1798586,1799429,1802977,1807234,1807244,1808752,1808754,1809149,1809329,1810108,1811667,1812994,1814831,1817097-1817098,1817100,1817201,1818586,1819269,1820133,1821597,1822947,1822950,1826230,1826647,1826940,1826964,1833374
+/jackrabbit/trunk:1592881,1597717,1597799,1597806,1598035,1598058,1603769,1603934,1609712,1615997,1625561,1627529,1634584,1653275,1667787,1667795,1674859,1680757,1709811,1717599,1720093,1729382,1730696,1732436,1740814-1740815,1751279,1752165,1758600,1759607,1759782,1759865,1761679,1761909,1762422,1763558,1766398,1771078,1771741,1771939,1771999,1772049,1772343,1772444,1772457,1772530,1772544,1773579,1773591,1773745,1774443,1775657,1776384-1776385,1776407,1776413,1779166,1779460,1780208,1780335-1780336,1786325,1787043,1787381,1792100,1792105,1792113,1792193,1793315,1793323,1793327,1793332,1796980,1797209,1797917,1798586,1799429,1802977,1807234,1807244,1808752,1808754,1809149,1809329,1810108,1811667,1812994,1814831,1817097-1817098,1817100,1817201,1818586,1819269,1820133,1821597,1822947,1822950,1826230,1826647,1826940,1826964,1833374

Modified: jackrabbit/branches/2.8/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.8/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java?rev=1851053&r1=1851052&r2=1851053&view=diff
==============================================================================
--- jackrabbit/branches/2.8/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
(original)
+++ jackrabbit/branches/2.8/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImpl.java
Fri Jan 11 14:16:18 2019
@@ -28,6 +28,7 @@ import java.util.Properties;
 
 import javax.jcr.NamespaceException;
 import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
 
 import org.apache.commons.collections.iterators.AbstractIteratorDecorator;
 import org.apache.jackrabbit.core.HierarchyManager;
@@ -46,6 +47,8 @@ import org.apache.jackrabbit.core.value.
 import org.apache.jackrabbit.spi.Name;
 import org.apache.jackrabbit.spi.Path;
 import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
 import org.apache.jackrabbit.spi.commons.conversion.IllegalNameException;
 import org.apache.jackrabbit.spi.commons.conversion.MalformedPathException;
 import org.apache.jackrabbit.spi.commons.conversion.NameResolver;
@@ -212,7 +215,7 @@ public class IndexingConfigurationImpl
      *         <code>false</code> otherwise.
      */
     public boolean isIndexed(NodeState state, Name propertyName) {
-        IndexingRule rule = getApplicableIndexingRule(state);
+        IndexingRule rule = getApplicableIndexingRule(state, propertyName);
         if (rule != null) {
             return rule.isIndexed(propertyName);
         }
@@ -230,7 +233,7 @@ public class IndexingConfigurationImpl
      * @return the boost value for the property.
      */
     public float getPropertyBoost(NodeState state, Name propertyName) {
-        IndexingRule rule = getApplicableIndexingRule(state);
+        IndexingRule rule = getApplicableIndexingRule(state, propertyName);
         if (rule != null) {
             return rule.getBoost(propertyName);
         }
@@ -244,7 +247,7 @@ public class IndexingConfigurationImpl
      * @return the boost for the node scope fulltext index field.
      */
     public float getNodeBoost(NodeState state) {
-        IndexingRule rule = getApplicableIndexingRule(state);
+        IndexingRule rule = getApplicableIndexingRule(state, null);
         if (rule != null) {
             return rule.getNodeBoost();
         }
@@ -263,7 +266,7 @@ public class IndexingConfigurationImpl
      */
     public boolean isIncludedInNodeScopeIndex(NodeState state,
                                               Name propertyName) {
-        IndexingRule rule = getApplicableIndexingRule(state);
+        IndexingRule rule = getApplicableIndexingRule(state, propertyName);
         if (rule != null) {
             return rule.isIncludedInNodeScopeIndex(propertyName);
         }
@@ -282,7 +285,7 @@ public class IndexingConfigurationImpl
      *         included in an excerpt; <code>false</code> otherwise.
      */
     public boolean useInExcerpt(NodeState state, Name propertyName) {
-        IndexingRule rule = getApplicableIndexingRule(state);
+        IndexingRule rule = getApplicableIndexingRule(state, propertyName);
         if (rule != null) {
             return rule.useInExcerpt(propertyName);
         }
@@ -353,7 +356,7 @@ public class IndexingConfigurationImpl
                             nt2rules.put(ntName, perNtConfig);
                         }
                         log.debug("Registering it for name '{}'", ntName);
-                        perNtConfig.add(new IndexingRule(element, ntName));
+                        perNtConfig.add(new IndexingRule(element, ntReg.getNodeTypeDef(ntName)));
                     }
                 }
             }
@@ -367,9 +370,10 @@ public class IndexingConfigurationImpl
      * <code>state</code>.
      *
      * @param state a node state.
+     * @param propertyName the property name to check.
      * @return the indexing rule or <code>null</code> if none applies.
      */
-    private IndexingRule getApplicableIndexingRule(NodeState state) {
+    private IndexingRule getApplicableIndexingRule(NodeState state, Name propertyName) {
         List<IndexingRule> rules = null;
         List<IndexingRule> r = configElements.get(state.getNodeTypeName());
         if (r != null) {
@@ -389,7 +393,7 @@ public class IndexingConfigurationImpl
 
         if (rules != null) {
             for (IndexingRule rule : rules) {
-                if (rule.appliesTo(state)) {
+                if (rule.appliesTo(state, propertyName)) {
                     return rule;
                 }
             }
@@ -654,9 +658,9 @@ public class IndexingConfigurationImpl
     private class IndexingRule {
 
         /**
-         * The node type of this fulltext indexing rule.
+         * The NodeTypeDefinition of this fulltext indexing rule.
          */
-        private final Name nodeTypeName;
+        private final QNodeTypeDefinition nodeTypeDefinition;
 
         /**
          * Map of {@link PropertyConfig}. Key=Name of property.
@@ -683,10 +687,10 @@ public class IndexingConfigurationImpl
          * different node type name.
          *
          * @param original the existing rule.
-         * @param nodeTypeName the node type name for the rule.
+         * @param qNodeTypeDefinition the node type for the rule.
          */
-        IndexingRule(IndexingRule original, Name nodeTypeName) {
-            this.nodeTypeName = nodeTypeName;
+        IndexingRule(IndexingRule original, QNodeTypeDefinition qNodeTypeDefinition) {
+            this.nodeTypeDefinition = qNodeTypeDefinition;
             this.propConfigs = original.propConfigs;
             this.namePatterns = original.namePatterns;
             this.condition = original.condition;
@@ -699,10 +703,11 @@ public class IndexingConfigurationImpl
          * @throws MalformedPathException if the condition expression is malformed.
          * @throws IllegalNameException   if a name contains illegal characters.
          * @throws NamespaceException if a name contains an unknown prefix.
+         * @throws NoSuchNodeTypeException if the nodeType could not be evaluated
          */
         IndexingRule(Node config)
-                throws MalformedPathException, IllegalNameException, NamespaceException {
-            this.nodeTypeName = getNodeTypeName(config);
+                throws MalformedPathException, IllegalNameException, NamespaceException,
NoSuchNodeTypeException {
+            this.nodeTypeDefinition = getNodeTypeDefinition(config);
             this.condition = getCondition(config);
             this.boost = getNodeBoost(config);
             this.propConfigs = new HashMap<Name, PropertyConfig>();
@@ -716,7 +721,7 @@ public class IndexingConfigurationImpl
          * @return name of the node type.
          */
         public Name getNodeTypeName() {
-            return nodeTypeName;
+            return nodeTypeDefinition.getName();
         }
 
         /**
@@ -788,10 +793,19 @@ public class IndexingConfigurationImpl
          * <code>state</code>.
          *
          * @param state the state to check.
+         * @param propertyName the property name to check.
          * @return <code>true</code> the rule applies to the given node;
          *         <code>false</code> otherwise.
          */
-        public boolean appliesTo(NodeState state) {
+        public boolean appliesTo(NodeState state, Name propertyName) {
+        	Name nodeTypeName = getNodeTypeName();
+        	if (propertyName != null) {
+	        	for (QPropertyDefinition propertyDefinition : nodeTypeDefinition.getPropertyDefs())
{
+	        		if (propertyDefinition.getName().equals(propertyName)) {
+	        			return true;
+	        		}
+	        	}
+        	}
             if (!nodeTypeName.equals(state.getNodeTypeName())) {
                 return false;
             }
@@ -831,11 +845,12 @@ public class IndexingConfigurationImpl
          *                                characters.
          * @throws NamespaceException if the node type contains an unknown
          *                                prefix.
+         * @throws NoSuchNodeTypeException if the node type could not be evaluated
          */
-        private Name getNodeTypeName(Node config)
-                throws IllegalNameException, NamespaceException {
+        private QNodeTypeDefinition getNodeTypeDefinition(Node config)
+                throws IllegalNameException, NamespaceException, NoSuchNodeTypeException
{
             String ntString = config.getAttributes().getNamedItem("nodeType").getNodeValue();
-            return resolver.getQName(ntString);
+            return ntReg.getNodeTypeDef(resolver.getQName(ntString));
         }
 
         /**

Modified: jackrabbit/branches/2.8/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.8/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java?rev=1851053&r1=1851052&r2=1851053&view=diff
==============================================================================
--- jackrabbit/branches/2.8/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
(original)
+++ jackrabbit/branches/2.8/jackrabbit-core/src/test/java/org/apache/jackrabbit/core/query/lucene/IndexingConfigurationImplTest.java
Fri Jan 11 14:16:18 2019
@@ -43,12 +43,14 @@ public class IndexingConfigurationImplTe
     private static final Name FOO = NameFactoryImpl.getInstance().create("", "foo");
 
     private NodeState nState;
+    private Node n;
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        Node n = testRootNode.addNode(nodeName1, ntUnstructured);
+        n = testRootNode.addNode(nodeName1, ntUnstructured);
         n.addMixin(mixReferenceable);
+        n.addMixin(mixTitle);
         session.save();
         nState = (NodeState) getSearchIndex().getContext().getItemStateManager().getItemState(
                 new NodeId(n.getIdentifier()));
@@ -97,8 +99,14 @@ public class IndexingConfigurationImplTe
         assertFalse(config.isIncludedInNodeScopeIndex(state, FOO));
     }
 
-    //----------------------------< internal >----------------------------------
+    public void testIndexRuleMixin() throws Exception{
+        IndexingConfiguration config = createConfig("config5");
+        assertTrue(config.isIndexed(nState, NameConstants.JCR_TITLE));
+        assertFalse(config.isIndexed(nState, NameConstants.JCR_DESCRIPTION));
+        assertTrue(config.isIndexed(nState, NameConstants.JCR_UUID)); // from mixReferenceable
... should be indexed
+    }
 
+    //----------------------------< internal >----------------------------------
     protected IndexingConfiguration createConfig(String name) throws Exception {
         IndexingConfiguration config = new IndexingConfigurationImpl();
         config.init(loadConfig(name), getSearchIndex().getContext(),

Modified: jackrabbit/branches/2.8/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/2.8/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java?rev=1851053&r1=1851052&r2=1851053&view=diff
==============================================================================
--- jackrabbit/branches/2.8/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
(original)
+++ jackrabbit/branches/2.8/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/AbstractJCRTest.java
Fri Jan 11 14:16:18 2019
@@ -213,6 +213,11 @@ public abstract class AbstractJCRTest ex
     protected String mixLockable;
 
     /**
+     * JCR Name mix:title using the namespace resolver of the current session.
+     */
+    protected String mixTitle;
+
+    /**
      * JCR Name mix:shareable using the namespace resolver of the current session.
      */
     protected String mixShareable;
@@ -379,6 +384,7 @@ public abstract class AbstractJCRTest ex
         mixSimpleVersionable = superuser.getNamespacePrefix(NS_MIX_URI) + ":simpleVersionable";
         mixLockable = superuser.getNamespacePrefix(NS_MIX_URI) + ":lockable";
         mixShareable = superuser.getNamespacePrefix(NS_MIX_URI) + ":shareable";
+        mixTitle = superuser.getNamespacePrefix(NS_MIX_URI) + ":title";
         ntQuery = superuser.getNamespacePrefix(NS_NT_URI) + ":query";
 
         // setup custom namespaces



Mime
View raw message