jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1463524 [1/2] - in /jackrabbit/oak/trunk: oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/ oak-solr-core/src/main/resources/solr/ oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/serv...
Date Tue, 02 Apr 2013 13:24:19 GMT
Author: tommaso
Date: Tue Apr  2 13:24:19 2013
New Revision: 1463524

URL: http://svn.apache.org/r1463524
Log:
OAK-735 - move DefaultOakSolrProvider and OakSolrNodeStateConfiguration to oak-solr-embedded

Added:
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/DefaultOakSolrProvider.java
  (with props)
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/FixedNodeStateConfiguration.java
  (with props)
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java
  (with props)
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfiguration.java
  (with props)
    jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/
    jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/
    jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/
    jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/
    jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/
    jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/
    jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/
    jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/
    jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/DefaultOakSolrProviderTest.java
  (with props)
    jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfigurationTest.java
  (with props)
Removed:
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/
    jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/server/
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/resources/solr/oak/conf/protwords.txt
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/resources/solr/oak/conf/stopwords.txt
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/resources/solr/oak/conf/synonyms.txt
Modified:
    jackrabbit/oak/trunk/oak-solr-embedded/pom.xml
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrServerProvider.java
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/resources/solr/oak/conf/schema.xml
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/resources/solr/oak/conf/solrconfig.xml

Modified: jackrabbit/oak/trunk/oak-solr-embedded/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/pom.xml?rev=1463524&r1=1463523&r2=1463524&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-solr-embedded/pom.xml Tue Apr  2 13:24:19 2013
@@ -145,12 +145,6 @@
       <artifactId>lucene-core</artifactId>
       <version>${solr.version}</version>
     </dependency>
-    <dependency>
-      <groupId>org.apache.lucene</groupId>
-      <artifactId>lucene-codecs</artifactId>
-      <version>${solr.version}</version>
-    </dependency>
-
 
     <dependency>
       <groupId>org.apache.felix</groupId>
@@ -309,6 +303,12 @@
       <scope>runtime</scope>
     </dependency>
 
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
   </dependencies>
 
 </project>

Added: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/DefaultOakSolrProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/DefaultOakSolrProvider.java?rev=1463524&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/DefaultOakSolrProvider.java
(added)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/DefaultOakSolrProvider.java
Tue Apr  2 13:24:19 2013
@@ -0,0 +1,164 @@
+/*
+ * 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.oak.plugins.index.solr.embedded;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+
+import org.apache.jackrabbit.mk.util.IOUtils;
+import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration;
+import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfigurationProvider;
+import org.apache.jackrabbit.oak.plugins.index.solr.SolrServerProvider;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+import org.apache.solr.client.solrj.SolrServer;
+import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer;
+import org.apache.solr.core.CoreContainer;
+
+/**
+ * Default implementation of {@link SolrServerProvider} and {@link OakSolrConfigurationProvider}
+ * which hides an {@link EmbeddedSolrServer} configured as per passed {@link NodeState}
+ * properties.
+ */
+public class DefaultOakSolrProvider implements SolrServerProvider, OakSolrConfigurationProvider
{
+
+    private final OakSolrNodeStateConfiguration oakSolrConfiguration;
+
+    public DefaultOakSolrProvider(NodeState configurationNodeState) {
+        this.oakSolrConfiguration = new FixedNodeStateConfiguration(configurationNodeState);
+    }
+
+    public DefaultOakSolrProvider(NodeStore store, String path) {
+        this.oakSolrConfiguration = new UpToDateNodeStateConfiguration(store, path);
+    }
+
+    private SolrServer solrServer;
+
+    private SolrServer createSolrServer() throws Exception {
+
+        String solrHomePath = oakSolrConfiguration.getSolrHomePath();
+        String coreName = oakSolrConfiguration.getCoreName();
+        String solrConfigPath = oakSolrConfiguration.getSolrConfigPath();
+
+        if (solrConfigPath != null && solrHomePath != null && coreName !=
null) {
+
+            checkSolrConfiguration(solrHomePath, solrConfigPath, coreName);
+
+            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+            Thread.currentThread().setContextClassLoader(CoreContainer.class.getClassLoader());
+
+            CoreContainer coreContainer = new CoreContainer(solrHomePath);
+            try {
+                coreContainer.load(solrHomePath, new File(solrConfigPath));
+            } finally {
+                Thread.currentThread().setContextClassLoader(classLoader);
+            }
+
+            return new EmbeddedSolrServer(coreContainer, coreName);
+        } else {
+            throw new Exception("SolrServer configuration proprties not set");
+        }
+    }
+
+    private void checkSolrConfiguration(String solrHomePath, String solrConfigPath, String
coreName) throws IOException {
+
+        // check if solrHomePath exists
+        File solrHomePathFile = new File(solrHomePath);
+        if (!solrHomePathFile.exists()) {
+            if (!solrHomePathFile.mkdirs()) {
+                throw new IOException("could not create solrHomePath directory");
+            } else {
+                // copy all the needed files to the just created directory
+                copy("/solr/solr.xml", solrHomePath);
+                copy("/solr/zoo.cfg", solrHomePath);
+                if (!new File(solrHomePath + "/oak/conf").mkdirs()) {
+                    throw new IOException("could not create nested core directory in solrHomePath");
+                }
+                String coreDir = solrHomePath + "/oak/conf/";
+                copy("/solr/oak/conf/currency.xml", coreDir);
+                copy("/solr/oak/conf/schema.xml", coreDir);
+                copy("/solr/oak/conf/solrconfig.xml", coreDir);
+            }
+        } else if (!solrHomePathFile.isDirectory()) {
+            throw new IOException("a non directory file with the specified name already exists
for the given solrHomePath");
+        }
+
+        File solrConfigPathFile = new File(solrConfigPath);
+        // check if solrConfigPath exists
+        if (!solrConfigPathFile.exists()) {
+            if (solrConfigPathFile.createNewFile()) {
+                copy("/solr/solr.xml", solrConfigPathFile.getAbsolutePath());
+            }
+        }
+
+        // check if the a core with the given coreName exists
+        // TODO : improve this check
+        String[] files = new File(solrHomePath).list();
+        Arrays.sort(files);
+        if (Arrays.binarySearch(files, coreName) < 0) {
+            throw new IOException("could not find a directory with the given coreName in
the solrHomePath");
+        }
+
+
+    }
+
+    private void copy(String resource, String dir) throws IOException {
+        String fileName = dir + resource.substring(resource.lastIndexOf("/"));
+        File outputFile = new File(fileName);
+        if (outputFile.createNewFile()) {
+            InputStream inputStream = null;
+            FileOutputStream outputStream = null;
+            try {
+                inputStream = getClass().getResourceAsStream(resource);
+                outputStream = new FileOutputStream(outputFile);
+                IOUtils.copy(inputStream, outputStream);
+            } finally {
+                if (inputStream != null) {
+                    try {
+                        inputStream.close();
+                    } catch (Exception e) {
+                        // do nothing
+                    }
+                }
+                if (outputStream != null) {
+                    try {
+                        outputStream.close();
+                    } catch (Exception e) {
+                        // do nothing
+                    }
+                }
+            }
+        }
+
+    }
+
+    @Override
+    public SolrServer getSolrServer() throws Exception {
+        if (solrServer == null) {
+            solrServer = createSolrServer();
+        }
+        return solrServer;
+    }
+
+    @Override
+    public OakSolrConfiguration getConfiguration() {
+        return oakSolrConfiguration;
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/DefaultOakSolrProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrServerProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrServerProvider.java?rev=1463524&r1=1463523&r2=1463524&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrServerProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrServerProvider.java
Tue Apr  2 13:24:19 2013
@@ -42,7 +42,7 @@ import org.xml.sax.SAXException;
 /**
  * {@link SolrServerProvider} which (spawns if needed and) exposes an embedded Solr server
  */
-@Component(metatype = true, immediate = true)
+@Component
 @Service(SolrServerProvider.class)
 public class EmbeddedSolrServerProvider implements SolrServerProvider {
 

Added: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/FixedNodeStateConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/FixedNodeStateConfiguration.java?rev=1463524&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/FixedNodeStateConfiguration.java
(added)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/FixedNodeStateConfiguration.java
Tue Apr  2 13:24:19 2013
@@ -0,0 +1,37 @@
+/*
+ * 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.oak.plugins.index.solr.embedded;
+
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+/**
+ * A {@link OakSolrNodeStateConfiguration} whose {@link org.apache.jackrabbit.oak.spi.state.NodeState}
is given once
+ * and never updated so that the configuration is fixed.
+ */
+public class FixedNodeStateConfiguration extends OakSolrNodeStateConfiguration {
+
+    private final NodeState configurationNodeState;
+
+    public FixedNodeStateConfiguration(NodeState configurationNodeState) {
+        this.configurationNodeState = configurationNodeState;
+    }
+
+    @Override
+    protected NodeState getConfigurationNodeState() {
+        return configurationNodeState;
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/FixedNodeStateConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java?rev=1463524&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java
(added)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java
Tue Apr  2 13:24:19 2013
@@ -0,0 +1,138 @@
+/*
+ * 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.oak.plugins.index.solr.embedded;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.plugins.index.solr.CommitPolicy;
+import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration;
+import org.apache.jackrabbit.oak.spi.query.Filter;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+
+/**
+ * An {@link org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration} specified
via a given {@link org.apache.jackrabbit.oak.spi.state.NodeState}.
+ * For each of the supported properties a default is provided if either the
+ * property doesn't exist in the node or if the value is <code>null</code> or
+ * empty <code>String</code>.
+ * <p/>
+ * Subclasses of this should at least provide the {@link org.apache.jackrabbit.oak.spi.state.NodeState}
which holds
+ * the configuration.
+ */
+public abstract class OakSolrNodeStateConfiguration implements OakSolrConfiguration {
+
+    /**
+     * get the {@link org.apache.jackrabbit.oak.spi.state.NodeState} which contains the properties
for the Oak -
+     * Solr configuration.
+     *
+     * @return a {@link org.apache.jackrabbit.oak.spi.state.NodeState} for the Solr configuration
or <code>null</code>
+     *         if such a {@link org.apache.jackrabbit.oak.spi.state.NodeState} doesn't exist.
+     */
+    protected abstract NodeState getConfigurationNodeState();
+
+    @Override
+    public String getFieldNameFor(Type<?> propertyType) {
+        if (Type.BINARIES.equals(propertyType) || Type.BINARY.equals(propertyType)) {
+            // TODO : use Tika / SolrCell here
+            return propertyType.toString() + "_bin";
+        }
+        return null;
+    }
+
+    @Override
+    public String getPathField() {
+        return getStringValueFor(Properties.PATH_FIELD, "path_exact");
+    }
+
+    @Override
+    public String getFieldForPathRestriction(Filter.PathRestriction pathRestriction) {
+        String fieldName = null;
+        switch (pathRestriction) {
+            case ALL_CHILDREN: {
+                fieldName = getStringValueFor(Properties.DESCENDANTS_FIELD, "path_des");
+                break;
+            }
+            case DIRECT_CHILDREN: {
+                fieldName = getStringValueFor(Properties.CHILDREN_FIELD, "path_child");
+                break;
+            }
+            case EXACT: {
+                fieldName = getStringValueFor(Properties.PATH_FIELD, "path_exact");
+                break;
+            }
+            case PARENT: {
+                fieldName = getStringValueFor(Properties.PARENT_FIELD, "path_anc");
+                break;
+            }
+
+        }
+        return fieldName;
+    }
+
+    @Override
+    public String getFieldForPropertyRestriction(Filter.PropertyRestriction propertyRestriction)
{
+        return null;
+    }
+
+    @Override
+    public CommitPolicy getCommitPolicy() {
+        return CommitPolicy.valueOf(getStringValueFor(Properties.COMMIT_POLICY, CommitPolicy.HARD.toString()));
+    }
+
+    public String getSolrHomePath() {
+        return getStringValueFor(Properties.SOLRHOME_PATH, "./");
+    }
+
+    public String getSolrConfigPath() {
+        return getStringValueFor(Properties.SOLRCONFIG_PATH, "./solr.xml");
+    }
+
+    @Override
+    public String getCoreName() {
+        return getStringValueFor(Properties.CORE_NAME, "oak");
+    }
+
+    protected String getStringValueFor(String propertyName, String defaultValue) {
+        String value = null;
+        NodeState configurationNodeState = getConfigurationNodeState();
+        if (configurationNodeState != null) {
+            PropertyState property = configurationNodeState.getProperty(propertyName);
+            if (property != null) {
+                value = property.getValue(Type.STRING);
+            }
+            if (value == null || value.length() == 0) {
+                value = defaultValue;
+            }
+        }
+        return value;
+    }
+
+    /**
+     * Properties that may be retrieved from the configuration {@link org.apache.jackrabbit.oak.spi.state.NodeState}.
+     */
+    public final class Properties {
+
+        public static final String SOLRHOME_PATH = "solrHomePath";
+        public static final String SOLRCONFIG_PATH = "solrConfigPath";
+        public static final String CORE_NAME = "coreName";
+        public static final String PATH_FIELD = "pathField";
+        public static final String PARENT_FIELD = "parentField";
+        public static final String CHILDREN_FIELD = "childrenField";
+        public static final String DESCENDANTS_FIELD = "descendantsField";
+        public static final String COMMIT_POLICY = "commitPolicy";
+
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfiguration.java?rev=1463524&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfiguration.java
(added)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfiguration.java
Tue Apr  2 13:24:19 2013
@@ -0,0 +1,47 @@
+/*
+ * 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.oak.plugins.index.solr.embedded;
+
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.apache.jackrabbit.oak.spi.state.NodeStore;
+
+/**
+ * A {@link OakSolrNodeStateConfiguration} whose {@link org.apache.jackrabbit.oak.spi.state.NodeState}
is retrieved
+ * via the {@link org.apache.jackrabbit.oak.spi.state.NodeStore} and a given <code>String</code>
path.
+ */
+public class UpToDateNodeStateConfiguration extends OakSolrNodeStateConfiguration {
+
+    private final NodeStore store;
+    private final String path;
+
+    public UpToDateNodeStateConfiguration(NodeStore store, String path) {
+        this.store = store;
+        this.path = path;
+    }
+
+    @Override
+    protected NodeState getConfigurationNodeState() {
+        NodeState currentState = store.getRoot();
+        for (String child : path.split("/")) {
+            currentState = currentState.getChildNode(child);
+            if (currentState == null) {
+                break;
+            }
+        }
+        return currentState;
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfiguration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/oak/trunk/oak-solr-embedded/src/main/resources/solr/oak/conf/schema.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/main/resources/solr/oak/conf/schema.xml?rev=1463524&r1=1463523&r2=1463524&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/main/resources/solr/oak/conf/schema.xml (original)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/main/resources/solr/oak/conf/schema.xml Tue
Apr  2 13:24:19 2013
@@ -16,131 +16,131 @@
  limitations under the License.
 -->
 <schema name="minimal" version="1.5">
-    <types>
-        <fieldType name="string" class="solr.StrField"/>
-        <fieldType name="descendent_path" class="solr.TextField">
-            <analyzer type="index">
-                <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
-            </analyzer>
-            <analyzer type="query">
-                <tokenizer class="solr.KeywordTokenizerFactory" />
-            </analyzer>
-        </fieldType>
-        <fieldType name="children_path" class="solr.TextField">
-            <analyzer type="index">
-                <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" skip="1"
reverse="true" />
-                <filter class="solr.PatternReplaceFilterFactory" pattern="/" replacement=""
replace="all"/>
-            </analyzer>
-            <analyzer type="query">
-                <tokenizer class="solr.KeywordTokenizerFactory" />
-                <filter class="solr.PatternReplaceFilterFactory" pattern="/" replacement=""
replace="all"/>
-            </analyzer>
-        </fieldType>
-        <fieldType name="parent_path" class="solr.TextField">
-            <analyzer type="index">
-                <tokenizer class="solr.KeywordTokenizerFactory" />
-                <filter class="solr.PatternReplaceFilterFactory" pattern="/" replacement=""
replace="all"/>
-            </analyzer>
-            <analyzer type="query">
-                <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" skip="1"
reverse="true"/>
-                <filter class="solr.PatternReplaceFilterFactory" pattern="/" replacement=""
replace="all"/>
-            </analyzer>
-        </fieldType>
-        <fieldType name="text_keepcase" class="solr.TextField" positionIncrementGap="100">
-            <analyzer type="index">
-                <tokenizer class="solr.StandardTokenizerFactory"/>
-            </analyzer>
-            <analyzer type="query">
-                <tokenizer class="solr.StandardTokenizerFactory"/>
-            </analyzer>
-        </fieldType>
-        <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
-            <analyzer type="index">
-                <tokenizer class="solr.StandardTokenizerFactory"/>
-                <filter class="solr.LowerCaseFilterFactory"/>
-            </analyzer>
-            <analyzer type="query">
-                <tokenizer class="solr.StandardTokenizerFactory"/>
-                <filter class="solr.LowerCaseFilterFactory"/>
-            </analyzer>
-        </fieldType>
-
-        <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
-
-        <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
-        <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
-        <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
-        <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
-
-        <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/>
-        <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0"/>
-        <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0"/>
-        <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/>
-        <fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
-
-        <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0"/>
-
-        <fieldtype name="binary" class="solr.BinaryField"/>
-
-        <fieldType name="pint" class="solr.IntField"/>
-        <fieldType name="plong" class="solr.LongField"/>
-        <fieldType name="pfloat" class="solr.FloatField"/>
-        <fieldType name="pdouble" class="solr.DoubleField"/>
-        <fieldType name="pdate" class="solr.DateField" sortMissingLast="true"/>
-
-        <fieldType name="point" class="solr.PointType" dimension="2" subFieldSuffix="_d"/>
-
-        <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
-
-        <fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
-                   geo="true" distErrPct="0.025" maxDistErr="0.000009" units="degrees" />
-
-        <fieldType name="currency" class="solr.CurrencyField" precisionStep="8" defaultCurrency="USD"
currencyConfig="currency.xml" />
-        <fieldtype name="ignored" stored="false" indexed="false" multiValued="true" class="solr.StrField"/>
-    </types>
-    <fields>
-        <field name="path_exact" type="string" indexed="true" stored="true"/>
-        <field name="path_child" type="children_path" indexed="true" stored="false"/>
-        <field name="path_anc" type="parent_path" indexed="true" stored="false"/>
-        <field name="path_des" type="descendent_path" indexed="true" stored="false"/>
-        <field name="ignored" type="ignored" multiValued="true"/>
-        <field name="catch_all" type="text_general" indexed="true" stored="false" multiValued="true"/>
-        <field name="_version_" type="long" indexed="true" stored="true"/>
-
-        <dynamicField name="*_i"  type="int"    indexed="true"  stored="true"/>
-        <dynamicField name="*_is" type="int"    indexed="true"  stored="true"  multiValued="true"/>
-        <dynamicField name="*_s"  type="string"  indexed="true"  stored="true" />
-        <dynamicField name="*_ss" type="string"  indexed="true"  stored="true" multiValued="true"/>
-        <dynamicField name="*_l"  type="long"   indexed="true"  stored="true"/>
-        <dynamicField name="*_ls" type="long"   indexed="true"  stored="true"  multiValued="true"/>
-        <dynamicField name="*_t"  type="text_general"    indexed="true"  stored="true"/>
-        <dynamicField name="*_txt" type="text_general"   indexed="true"  stored="true"
multiValued="true"/>
-        <dynamicField name="*_b"  type="boolean" indexed="true" stored="true"/>
-        <dynamicField name="*_bs" type="boolean" indexed="true" stored="true"  multiValued="true"/>
-        <dynamicField name="*_f"  type="float"  indexed="true"  stored="true"/>
-        <dynamicField name="*_fs" type="float"  indexed="true"  stored="true"  multiValued="true"/>
-        <dynamicField name="*_d"  type="double" indexed="true"  stored="true"/>
-        <dynamicField name="*_ds" type="double" indexed="true"  stored="true"  multiValued="true"/>
-
-        <dynamicField name="*_coordinate"  type="tdouble" indexed="true"  stored="false"
/>
-
-        <dynamicField name="*_dt"  type="date"    indexed="true"  stored="true"/>
-        <dynamicField name="*_dts" type="date"    indexed="true"  stored="true" multiValued="true"/>
-        <dynamicField name="*_p"  type="location" indexed="true" stored="true"/>
-
-        <dynamicField name="*_ti" type="tint"    indexed="true"  stored="true"/>
-        <dynamicField name="*_tl" type="tlong"   indexed="true"  stored="true"/>
-        <dynamicField name="*_tf" type="tfloat"  indexed="true"  stored="true"/>
-        <dynamicField name="*_td" type="tdouble" indexed="true"  stored="true"/>
-        <dynamicField name="*_tdt" type="tdate"  indexed="true"  stored="true"/>
-
-        <dynamicField name="*_pi"  type="pint"    indexed="true"  stored="true"/>
-        <dynamicField name="*_c"   type="currency" indexed="true"  stored="true"/>
-        <dynamicField name="*" type="text_keepcase" indexed="true" stored="true" multiValued="true"/>
-    </fields>
-    <uniqueKey>path_exact</uniqueKey>
-    <copyField source="path_exact" dest="path_anc"/>
-    <copyField source="path_exact" dest="path_des"/>
-    <copyField source="path_exact" dest="path_child"/>
-    <copyField source="*" dest="catch_all"/>
+  <types>
+    <fieldType name="string" class="solr.StrField"/>
+    <fieldType name="descendent_path" class="solr.TextField">
+      <analyzer type="index">
+        <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" />
+      </analyzer>
+      <analyzer type="query">
+        <tokenizer class="solr.KeywordTokenizerFactory" />
+      </analyzer>
+    </fieldType>
+    <fieldType name="children_path" class="solr.TextField">
+      <analyzer type="index">
+        <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" skip="1" reverse="true"
/>
+        <filter class="solr.PatternReplaceFilterFactory" pattern="/" replacement="" replace="all"/>
+      </analyzer>
+      <analyzer type="query">
+        <tokenizer class="solr.KeywordTokenizerFactory" />
+        <filter class="solr.PatternReplaceFilterFactory" pattern="/" replacement="" replace="all"/>
+      </analyzer>
+    </fieldType>
+    <fieldType name="parent_path" class="solr.TextField">
+      <analyzer type="index">
+        <tokenizer class="solr.KeywordTokenizerFactory" />
+        <filter class="solr.PatternReplaceFilterFactory" pattern="/" replacement="" replace="all"/>
+      </analyzer>
+      <analyzer type="query">
+        <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" skip="1" reverse="true"/>
+        <filter class="solr.PatternReplaceFilterFactory" pattern="/" replacement="" replace="all"/>
+      </analyzer>
+    </fieldType>
+    <fieldType name="text_keepcase" class="solr.TextField" positionIncrementGap="100">
+      <analyzer type="index">
+        <tokenizer class="solr.StandardTokenizerFactory"/>
+      </analyzer>
+      <analyzer type="query">
+        <tokenizer class="solr.StandardTokenizerFactory"/>
+      </analyzer>
+    </fieldType>
+    <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
+      <analyzer type="index">
+        <tokenizer class="solr.StandardTokenizerFactory"/>
+        <filter class="solr.LowerCaseFilterFactory"/>
+      </analyzer>
+      <analyzer type="query">
+        <tokenizer class="solr.StandardTokenizerFactory"/>
+        <filter class="solr.LowerCaseFilterFactory"/>
+      </analyzer>
+    </fieldType>
+
+    <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true"/>
+
+    <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0"/>
+    <fieldType name="float" class="solr.TrieFloatField" precisionStep="0" positionIncrementGap="0"/>
+    <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0"/>
+    <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0"/>
+
+    <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0"/>
+    <fieldType name="tfloat" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0"/>
+    <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0"/>
+    <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0"/>
+    <fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0"/>
+
+    <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0"/>
+
+    <fieldtype name="binary" class="solr.BinaryField"/>
+
+    <fieldType name="pint" class="solr.IntField"/>
+    <fieldType name="plong" class="solr.LongField"/>
+    <fieldType name="pfloat" class="solr.FloatField"/>
+    <fieldType name="pdouble" class="solr.DoubleField"/>
+    <fieldType name="pdate" class="solr.DateField" sortMissingLast="true"/>
+
+    <fieldType name="point" class="solr.PointType" dimension="2" subFieldSuffix="_d"/>
+
+    <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>
+
+    <fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
+               geo="true" distErrPct="0.025" maxDistErr="0.000009" units="degrees" />
+
+    <fieldType name="currency" class="solr.CurrencyField" precisionStep="8" defaultCurrency="USD"
currencyConfig="currency.xml" />
+    <fieldtype name="ignored" stored="false" indexed="false" multiValued="true" class="solr.StrField"/>
+  </types>
+  <fields>
+    <field name="path_exact" type="string" indexed="true" stored="true"/>
+    <field name="path_child" type="children_path" indexed="true" stored="false"/>
+    <field name="path_anc" type="parent_path" indexed="true" stored="false"/>
+    <field name="path_des" type="descendent_path" indexed="true" stored="false"/>
+    <field name="ignored" type="ignored" multiValued="true"/>
+    <field name="catch_all" type="text_general" indexed="true" stored="false" multiValued="true"/>
+    <field name="_version_" type="long" indexed="true" stored="true"/>
+
+    <dynamicField name="*_i"  type="int"    indexed="true"  stored="true"/>
+    <dynamicField name="*_is" type="int"    indexed="true"  stored="true"  multiValued="true"/>
+    <dynamicField name="*_s"  type="string"  indexed="true"  stored="true" />
+    <dynamicField name="*_ss" type="string"  indexed="true"  stored="true" multiValued="true"/>
+    <dynamicField name="*_l"  type="long"   indexed="true"  stored="true"/>
+    <dynamicField name="*_ls" type="long"   indexed="true"  stored="true"  multiValued="true"/>
+    <dynamicField name="*_t"  type="text_general"    indexed="true"  stored="true"/>
+    <dynamicField name="*_txt" type="text_general"   indexed="true"  stored="true" multiValued="true"/>
+    <dynamicField name="*_b"  type="boolean" indexed="true" stored="true"/>
+    <dynamicField name="*_bs" type="boolean" indexed="true" stored="true"  multiValued="true"/>
+    <dynamicField name="*_f"  type="float"  indexed="true"  stored="true"/>
+    <dynamicField name="*_fs" type="float"  indexed="true"  stored="true"  multiValued="true"/>
+    <dynamicField name="*_d"  type="double" indexed="true"  stored="true"/>
+    <dynamicField name="*_ds" type="double" indexed="true"  stored="true"  multiValued="true"/>
+
+    <dynamicField name="*_coordinate"  type="tdouble" indexed="true"  stored="false" />
+
+    <dynamicField name="*_dt"  type="date"    indexed="true"  stored="true"/>
+    <dynamicField name="*_dts" type="date"    indexed="true"  stored="true" multiValued="true"/>
+    <dynamicField name="*_p"  type="location" indexed="true" stored="true"/>
+
+    <dynamicField name="*_ti" type="tint"    indexed="true"  stored="true"/>
+    <dynamicField name="*_tl" type="tlong"   indexed="true"  stored="true"/>
+    <dynamicField name="*_tf" type="tfloat"  indexed="true"  stored="true"/>
+    <dynamicField name="*_td" type="tdouble" indexed="true"  stored="true"/>
+    <dynamicField name="*_tdt" type="tdate"  indexed="true"  stored="true"/>
+
+    <dynamicField name="*_pi"  type="pint"    indexed="true"  stored="true"/>
+    <dynamicField name="*_c"   type="currency" indexed="true"  stored="true"/>
+    <dynamicField name="*" type="text_keepcase" indexed="true" stored="true" multiValued="true"/>
+  </fields>
+  <uniqueKey>path_exact</uniqueKey>
+  <copyField source="path_exact" dest="path_anc"/>
+  <copyField source="path_exact" dest="path_des"/>
+  <copyField source="path_exact" dest="path_child"/>
+  <copyField source="*" dest="catch_all"/>
 </schema>



Mime
View raw message