Return-Path: X-Original-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5081410ACA for ; Thu, 10 Oct 2013 08:54:16 +0000 (UTC) Received: (qmail 87105 invoked by uid 500); 10 Oct 2013 08:54:14 -0000 Delivered-To: apmail-jackrabbit-oak-commits-archive@jackrabbit.apache.org Received: (qmail 87077 invoked by uid 500); 10 Oct 2013 08:54:11 -0000 Mailing-List: contact oak-commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-commits@jackrabbit.apache.org Received: (qmail 87050 invoked by uid 99); 10 Oct 2013 08:54:08 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Oct 2013 08:54:08 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,NORMAL_HTTP_TO_IP X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Oct 2013 08:53:57 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D2D8A2388831; Thu, 10 Oct 2013 08:53:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1530880 [1/2] - in /jackrabbit/oak/trunk: oak-parent/ oak-solr-core/ oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/ oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/ oak-solr... Date: Thu, 10 Oct 2013 08:53:33 -0000 To: oak-commits@jackrabbit.apache.org From: tommaso@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131010085334.D2D8A2388831@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tommaso Date: Thu Oct 10 08:53:31 2013 New Revision: 1530880 URL: http://svn.apache.org/r1530880 Log: OAK-1078 - moved generic configuration stuff in oak-solr-core Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/CommitPolicy.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfigurationProvider.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/FixedNodeStateConfiguration.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationProvider.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrNodeStateConfiguration.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfiguration.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationProvider.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/UpToDateNodeStateConfiguration.java (with props) 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/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultSolrServerProvider.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerProvider.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/OakSolrUtils.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrIndexInitializer.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/resources/ jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/ jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/ jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/ jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/currency.xml (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/solrconfig.xml (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/solr.xml (with props) jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/zoo.cfg jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/FixedNodeStateConfigurationTest.java (with props) jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/UpToDateNodeStateConfigurationTest.java (with props) Removed: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/CommitPolicy.java jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfiguration.java jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfigurationProvider.java jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrUtils.java jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/SolrIndexInitializer.java jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/SolrServerProvider.java jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/FixedNodeStateConfiguration.java jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/SolrServerConfiguration.java jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/SolrServerConfigurationDefaults.java jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/SolrServerConfigurationProvider.java jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfiguration.java jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfigurationTest.java Modified: jackrabbit/oak/trunk/oak-parent/pom.xml jackrabbit/oak/trunk/oak-solr-core/pom.xml jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/SolrBaseTest.java jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrCommitHookIT.java jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookIT.java 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/EmbeddedSolrConfiguration.java jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrConfigurationProvider.java 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/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/EmbeddedSolrProviderService.java jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/osgi/OsgiSolrServerConfigurationProvider.java jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrServerProviderTest.java jackrabbit/oak/trunk/oak-solr-remote/pom.xml jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrConfigurationProvider.java jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrServerProvider.java jackrabbit/oak/trunk/oak-solr-remote/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrServerProviderIT.java Modified: jackrabbit/oak/trunk/oak-parent/pom.xml URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-parent/pom.xml?rev=1530880&r1=1530879&r2=1530880&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-parent/pom.xml (original) +++ jackrabbit/oak/trunk/oak-parent/pom.xml Thu Oct 10 08:53:31 2013 @@ -46,7 +46,7 @@ MongoMKDB MongoMKDB2 SegmentMK - 4.0.0 + 4.1.0 Modified: jackrabbit/oak/trunk/oak-solr-core/pom.xml URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/pom.xml?rev=1530880&r1=1530879&r2=1530880&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/pom.xml (original) +++ jackrabbit/oak/trunk/oak-solr-core/pom.xml Thu Oct 10 08:53:31 2013 @@ -40,9 +40,11 @@ - org.apache.jackrabbit.oak.plugins.index.solr, + org.apache.jackrabbit.oak.plugins.index.solr.configuration, org.apache.jackrabbit.oak.plugins.index.solr.index, - org.apache.jackrabbit.oak.plugins.index.solr.query + org.apache.jackrabbit.oak.plugins.index.solr.query, + org.apache.jackrabbit.oak.plugins.index.solr.server, + org.apache.jackrabbit.oak.plugins.index.solr.util solr-solrj @@ -54,7 +56,6 @@ maven-failsafe-plugin - 2.12 @@ -169,7 +170,6 @@ junit junit - 4.7 test Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/CommitPolicy.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/CommitPolicy.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/CommitPolicy.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/CommitPolicy.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,35 @@ +/* + * 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.configuration; + +/** + * Enum for describing Solr commit policy used in a certain instance + */ +public enum CommitPolicy { + /** + * for default Solr commit + */ + HARD, + /** + * for Solr soft commit + */ + SOFT, + /** + * if no commits should be sent (relying on auto(soft)commit on the instance itself) + */ + AUTO +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/CommitPolicy.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,80 @@ +/* + * 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.configuration; + +import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.spi.query.Filter; + +/** + * An {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration} for the embedded Solr server + */ +public class DefaultSolrConfiguration implements OakSolrConfiguration { + + @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 SolrServerConfigurationDefaults.PATH_FIELD_NAME; + } + + @Override + public String getFieldForPathRestriction(Filter.PathRestriction pathRestriction) { + String fieldName = null; + switch (pathRestriction) { + case ALL_CHILDREN: { + fieldName = SolrServerConfigurationDefaults.DESC_FIELD_NAME; + break; + } + case DIRECT_CHILDREN: { + fieldName = SolrServerConfigurationDefaults.CHILD_FIELD_NAME; + break; + } + case EXACT: { + fieldName = SolrServerConfigurationDefaults.PATH_FIELD_NAME; + break; + } + case PARENT: { + fieldName = SolrServerConfigurationDefaults.ANC_FIELD_NAME; + break; + } + case NO_RESTRICTION: + break; + default: + break; + + } + return fieldName; + } + + @Override + public String getFieldForPropertyRestriction(Filter.PropertyRestriction propertyRestriction) { + return null; + } + + @Override + public CommitPolicy getCommitPolicy() { + return CommitPolicy.SOFT; + } + +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfiguration.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfigurationProvider.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfigurationProvider.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfigurationProvider.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfigurationProvider.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,39 @@ +/* + * 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.configuration; + + +/** + * The default {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider} + */ +public class DefaultSolrConfigurationProvider implements OakSolrConfigurationProvider { + + private final OakSolrConfiguration defaultConfiguration; + + public DefaultSolrConfigurationProvider() { + defaultConfiguration = new DefaultSolrConfiguration(); + } + + public DefaultSolrConfigurationProvider(OakSolrConfiguration configuration) { + this.defaultConfiguration = configuration; + } + + @Override + public OakSolrConfiguration getConfiguration() { + return defaultConfiguration; + } +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/DefaultSolrConfigurationProvider.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/FixedNodeStateConfiguration.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/FixedNodeStateConfiguration.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/FixedNodeStateConfiguration.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/FixedNodeStateConfiguration.java Thu Oct 10 08:53:31 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.configuration; + +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-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/FixedNodeStateConfiguration.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,66 @@ +/* + * 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.configuration; + +import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.spi.query.Filter; + +/** + * A Solr configuration holding all the possible customizable parameters that + * can be leveraged for an Oak search index. + */ +public interface OakSolrConfiguration { + + /** + * Provide a field name to be used for indexing / searching a certain {@link org.apache.jackrabbit.oak.api.Type} + * + * @param propertyType the {@link org.apache.jackrabbit.oak.api.Type} to be indexed / searched + * @return a String representing the Solr field to be used for the given {@link org.apache.jackrabbit.oak.api.Type}. + */ + public String getFieldNameFor(Type propertyType); + + /** + * Provide the field name for indexing / searching paths + * + * @return a String representing the Solr field to be used for paths. + */ + public String getPathField(); + + /** + * Provide a field name to search over for the given {@link org.apache.jackrabbit.oak.spi.query.Filter.PathRestriction} + * + * @param pathRestriction the {@link org.apache.jackrabbit.oak.spi.query.Filter.PathRestriction} used for filtering search results + * @return the field name as a String to be used by Solr for the given restriction + */ + public String getFieldForPathRestriction(Filter.PathRestriction pathRestriction); + + /** + * Provide a field name to search over for the given {@link org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction} + * + * @param propertyRestriction the {@link org.apache.jackrabbit.oak.spi.query.Filter.PropertyRestriction} used for filtering search results + * @return the field name as a String to be used by Solr for the given restriction + */ + public String getFieldForPropertyRestriction(Filter.PropertyRestriction propertyRestriction); + + /** + * Provide the commit policy to be used with the underlying Solr instance + * + * @return a {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.CommitPolicy} + */ + public CommitPolicy getCommitPolicy(); + +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfiguration.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationProvider.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationProvider.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationProvider.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationProvider.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,30 @@ +/* + * 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.configuration; + +/** + * A provider for {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration}s + */ +public interface OakSolrConfigurationProvider { + + /** + * Provides a Solr configuration for Oak + * + * @return a {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration} + */ + public OakSolrConfiguration getConfiguration(); +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrConfigurationProvider.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrNodeStateConfiguration.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrNodeStateConfiguration.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrNodeStateConfiguration.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrNodeStateConfiguration.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,141 @@ +/* + * 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.configuration; + +import org.apache.jackrabbit.oak.api.PropertyState; +import org.apache.jackrabbit.oak.api.Type; +import org.apache.jackrabbit.oak.spi.query.Filter; +import org.apache.jackrabbit.oak.spi.state.NodeState; + +/** + * An {@link 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 null or + * empty String. + *

+ * 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, SolrServerConfigurationProvider { + + /** + * get the {@link org.apache.jackrabbit.oak.spi.state.NodeState} which contains the properties for the Oak - + * Solr configuration. + * + * @return a (possibly non-existent) node state for the Solr configuration + */ + 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 getFieldForPropertyRestriction(Filter.PropertyRestriction propertyRestriction) { + return null; + } + + @Override + public String getPathField() { + return getStringValueFor(Properties.PATH_FIELD, SolrServerConfigurationDefaults.PATH_FIELD_NAME); + } + + @Override + public String getFieldForPathRestriction(Filter.PathRestriction pathRestriction) { + String fieldName = null; + switch (pathRestriction) { + case ALL_CHILDREN: { + fieldName = getStringValueFor(Properties.DESCENDANTS_FIELD, SolrServerConfigurationDefaults.DESC_FIELD_NAME); + break; + } + case DIRECT_CHILDREN: { + fieldName = getStringValueFor(Properties.CHILDREN_FIELD, SolrServerConfigurationDefaults.CHILD_FIELD_NAME); + break; + } + case EXACT: { + fieldName = getStringValueFor(Properties.PATH_FIELD, SolrServerConfigurationDefaults.PATH_FIELD_NAME); + break; + } + case PARENT: { + fieldName = getStringValueFor(Properties.PARENT_FIELD, SolrServerConfigurationDefaults.ANC_FIELD_NAME); + break; + } + case NO_RESTRICTION: + break; + default: + break; + + } + return fieldName; + } + + @Override + public CommitPolicy getCommitPolicy() { + return CommitPolicy.valueOf(getStringValueFor(Properties.COMMIT_POLICY, CommitPolicy.SOFT.toString())); + } + + protected String getStringValueFor(String propertyName, String defaultValue) { + String value = null; + NodeState configurationNodeState = getConfigurationNodeState(); + if (configurationNodeState.exists()) { + PropertyState property = configurationNodeState.getProperty(propertyName); + if (property != null) { + value = property.getValue(Type.STRING); + } + } + if (value == null || value.length() == 0) { + value = defaultValue; + } + return value; + } + + @Override + public SolrServerConfiguration getSolrServerConfiguration() { + String solrHomePath = getStringValueFor(Properties.SOLRHOME_PATH, SolrServerConfigurationDefaults.SOLR_HOME_PATH); + String solrConfigPath = getStringValueFor(Properties.SOLRCONFIG_PATH, SolrServerConfigurationDefaults.SOLR_CONFIG_PATH); + String coreName = getStringValueFor(Properties.CORE_NAME, SolrServerConfigurationDefaults.CORE_NAME); + + String context = getStringValueFor(Properties.CONTEXT, SolrServerConfigurationDefaults.CONTEXT); + Integer httpPort = Integer.valueOf(getStringValueFor(Properties.HTTP_PORT, SolrServerConfigurationDefaults.HTTP_PORT)); + + return new SolrServerConfiguration(solrHomePath, + solrConfigPath, coreName).withHttpConfiguration(context, httpPort); + } + + /** + * 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 CONTEXT = "solrContext"; + public static final String HTTP_PORT = "httpPort"; + 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-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/OakSolrNodeStateConfiguration.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfiguration.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfiguration.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfiguration.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfiguration.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,97 @@ +/* + * 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.configuration; + +/** + * Configuration parameters for starting a {@link org.apache.solr.client.solrj.SolrServer} + */ +public class SolrServerConfiguration { + + private final String solrHomePath; + private final String solrConfigPath; + private final String coreName; + private HttpConfiguration httpConfiguration; + + public SolrServerConfiguration(String solrHomePath, String solrConfigPath, String coreName) { + this.solrHomePath = solrHomePath; + this.solrConfigPath = solrConfigPath; + this.coreName = coreName; + } + + public SolrServerConfiguration withHttpConfiguration(String context, Integer httpPort) { + if (context != null && context.length() > 0 && httpPort != null && httpPort > 0) { + this.httpConfiguration = new HttpConfiguration(context, httpPort); + } + return this; + } + + /** + * get the Solr home path where all the configuration files are stored + * + * @return a String representing a path to the Solr home. + */ + public String getSolrHomePath() { + return solrHomePath; + } + + /** + * get the name of the main Solr configuration file (solr.xml for multicore + * deployments or solrconfig.xml for single core deployments). + * + * @return a String representing a path to the main Solr config file. + */ + public String getSolrConfigPath() { + return solrConfigPath; + } + + /** + * get the default core name to use for the Solr server + * + * @return a String representing the core name + */ + public String getCoreName() { + return coreName; + } + + /** + * get the {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration.HttpConfiguration} holding parameters for enabling Solr + * server with HTTP bindings + * + * @return a {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration.HttpConfiguration} or null if not set + */ + public HttpConfiguration getHttpConfiguration() { + return httpConfiguration; + } + + public class HttpConfiguration { + private String context; + private Integer httpPort; + + HttpConfiguration(String context, Integer httpPort) { + this.context = context; + this.httpPort = httpPort; + } + + public String getContext() { + return context; + } + + public Integer getHttpPort() { + return httpPort; + } + } +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfiguration.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java Thu Oct 10 08:53:31 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.configuration; + +/** + * Defaults for Solr server configurations. + */ +public class SolrServerConfigurationDefaults { + + public static final String SOLR_HOME_PATH = "solr"; + public static final String SOLR_CONFIG_PATH = "solr.xml"; + public static final String CORE_NAME = "oak"; + + public static final String HTTP_PORT = "8983"; + public static final String LOCAL_BASE_URL = "http://127.0.0.1"; + public static final String CONTEXT = "/solr"; + + public static final String PATH_FIELD_NAME = "path_exact"; + public static final String CHILD_FIELD_NAME = "path_child"; + public static final String DESC_FIELD_NAME = "path_desc"; + public static final String ANC_FIELD_NAME = "path_anc"; + +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationDefaults.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationProvider.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationProvider.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationProvider.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationProvider.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,31 @@ +/* + * 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.configuration; + +/** + * {@link org.apache.solr.client.solrj.SolrServer} configuration provider. + */ +public interface SolrServerConfigurationProvider { + + /** + * Provide a {@lin SolrServerConfiguration} to be used to initialize a specific + * {@link org.apache.solr.client.solrj.SolrServer} implementation. + * + * @return the {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfiguration} holding the configuration parameters + */ + public SolrServerConfiguration getSolrServerConfiguration(); +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/SolrServerConfigurationProvider.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/UpToDateNodeStateConfiguration.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/UpToDateNodeStateConfiguration.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/UpToDateNodeStateConfiguration.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/UpToDateNodeStateConfiguration.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,44 @@ +/* + * 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.configuration; + +import org.apache.jackrabbit.oak.spi.state.NodeState; +import org.apache.jackrabbit.oak.spi.state.NodeStore; + +/** + * A {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.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 String 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); + } + return currentState; + } +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/configuration/UpToDateNodeStateConfiguration.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java?rev=1530880&r1=1530879&r2=1530880&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java (original) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexEditor.java Thu Oct 10 08:53:31 2013 @@ -25,8 +25,8 @@ import org.apache.jackrabbit.oak.api.Pro import org.apache.jackrabbit.oak.api.Type; import org.apache.jackrabbit.oak.commons.PathUtils; import org.apache.jackrabbit.oak.plugins.index.IndexEditor; -import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration; -import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrUtils; +import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration; +import org.apache.jackrabbit.oak.plugins.index.solr.util.OakSolrUtils; import org.apache.jackrabbit.oak.spi.commit.Editor; import org.apache.jackrabbit.oak.spi.state.NodeBuilder; import org.apache.jackrabbit.oak.spi.state.NodeState; Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java?rev=1530880&r1=1530879&r2=1530880&view=diff ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java (original) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/query/SolrQueryIndex.java Thu Oct 10 08:53:31 2013 @@ -19,7 +19,7 @@ package org.apache.jackrabbit.oak.plugin import java.util.Collection; import org.apache.jackrabbit.oak.api.PropertyValue; -import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration; +import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfiguration; import org.apache.jackrabbit.oak.spi.query.Cursor; import org.apache.jackrabbit.oak.spi.query.Filter; import org.apache.jackrabbit.oak.spi.query.IndexRow; @@ -73,18 +73,11 @@ public class SolrQueryIndex implements Q private SolrQuery getQuery(Filter filter) { SolrQuery solrQuery = new SolrQuery(); - solrQuery.setParam("q.op", "AND"); - - // TODO : change this to be not hard coded - solrQuery.setParam("df", "catch_all"); - - // TODO : can we handle this better? - solrQuery.setParam("rows", String.valueOf(Integer.MAX_VALUE)); + setDefaults(solrQuery); StringBuilder queryBuilder = new StringBuilder(); // TODO : handle node type restriction - Filter.PathRestriction pathRestriction = filter.getPathRestriction(); if (pathRestriction != null) { String path = purgePath(filter); @@ -106,7 +99,7 @@ public class SolrQueryIndex implements Q Collection propertyRestrictions = filter.getPropertyRestrictions(); if (propertyRestrictions != null && !propertyRestrictions.isEmpty()) { for (Filter.PropertyRestriction pr : propertyRestrictions) { - if (pr.propertyName.contains("/")) { + if (pr.propertyName.contains("/")) { // lucene cannot handle child-level property restrictions continue; } @@ -126,7 +119,7 @@ public class SolrQueryIndex implements Q queryBuilder.append(configuration.getPathField()); queryBuilder.append(':'); queryBuilder.append(first); - if (!first.equals("\\/")) { + if (first!= null && !"\\/".equals(first)) { queryBuilder.append("\\/"); } } else { @@ -167,6 +160,16 @@ public class SolrQueryIndex implements Q return solrQuery; } + private void setDefaults(SolrQuery solrQuery) { + solrQuery.setParam("q.op", "AND"); + + // TODO : change this to be not hard coded + solrQuery.setParam("df", "catch_all"); + + // TODO : can we handle this better? + solrQuery.setParam("rows", String.valueOf(Integer.MAX_VALUE)); + } + private static String createRangeQuery(String first, String last, boolean firstIncluding, boolean lastIncluding) { // TODO : handle inclusion / exclusion of bounds StringBuilder rangeQueryBuilder = new StringBuilder("["); Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultSolrServerProvider.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultSolrServerProvider.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultSolrServerProvider.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultSolrServerProvider.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,38 @@ +/* + * 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.server; + +import org.apache.jackrabbit.oak.plugins.index.solr.configuration.SolrServerConfigurationDefaults; +import org.apache.solr.client.solrj.SolrServer; +import org.apache.solr.client.solrj.impl.HttpSolrServer; + +public class DefaultSolrServerProvider implements SolrServerProvider { + + private SolrServer solrServer; + + @Override + public SolrServer getSolrServer() throws Exception { + if (solrServer == null) { + String url = new StringBuilder(SolrServerConfigurationDefaults.LOCAL_BASE_URL) + .append(':').append(SolrServerConfigurationDefaults.HTTP_PORT) + .append(SolrServerConfigurationDefaults.CONTEXT).append('/') + .append(SolrServerConfigurationDefaults.CORE_NAME).toString(); + solrServer = new HttpSolrServer(url); + } + return solrServer; + } +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/DefaultSolrServerProvider.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerProvider.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerProvider.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerProvider.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerProvider.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,33 @@ +/* + * 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.server; + +import org.apache.solr.client.solrj.SolrServer; + +/** + * Provider of {@link org.apache.solr.client.solrj.SolrServer}s instances + */ +public interface SolrServerProvider { + + /** + * provides an already initialized {@link org.apache.solr.client.solrj.SolrServer} to be used from within Oak + * + * @return a {@link org.apache.solr.client.solrj.SolrServer} instance + * @throws Exception if anything goes wrong while providing the {@link org.apache.solr.client.solrj.SolrServer} + */ + public SolrServer getSolrServer() throws Exception; +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/server/SolrServerProvider.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/OakSolrUtils.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/OakSolrUtils.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/OakSolrUtils.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/OakSolrUtils.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,206 @@ +/* + * 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.util; + +import java.io.IOException; + +import javax.annotation.Nonnull; + +import org.apache.jackrabbit.oak.plugins.index.solr.configuration.CommitPolicy; +import org.apache.jackrabbit.oak.plugins.index.solr.configuration.DefaultSolrConfigurationProvider; +import org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider; +import org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider; +import org.apache.jackrabbit.oak.plugins.index.solr.server.DefaultSolrServerProvider; +import org.apache.jackrabbit.oak.plugins.index.solr.server.SolrServerProvider; +import org.apache.jackrabbit.oak.spi.query.QueryIndexProvider; +import org.apache.solr.client.solrj.SolrServer; +import org.apache.solr.client.solrj.SolrServerException; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleReference; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; + +/** + * Utilities for Oak Solr integration. + */ +public class OakSolrUtils { + + /** + * Check if a given Solr instance is alive + * + * @param solrServer + * the {@link org.apache.solr.client.solrj.SolrServer} used to communicate with the Solr instance + * @return true if the given Solr instance is alive and responding + * @throws java.io.IOException + * if any low level IO error occurs + * @throws org.apache.solr.client.solrj.SolrServerException + * if any error occurs while trying to communicate with the Solr instance + */ + public static boolean checkServerAlive(@Nonnull SolrServer solrServer) + throws IOException, SolrServerException { + return solrServer.ping().getStatus() == 0; + } + + /** + * adapts the OSGi Solr {@link org.apache.jackrabbit.oak.spi.query.QueryIndexProvider} service + * + * @return a {@link org.apache.jackrabbit.oak.plugins.index.solr.query.SolrQueryIndexProvider} + */ + public static QueryIndexProvider adaptOsgiQueryIndexProvider() { + QueryIndexProvider queryIndexProvider = null; + try { + BundleContext ctx = BundleReference.class + .cast(SolrQueryIndexProvider.class.getClassLoader()).getBundle() + .getBundleContext(); + + ServiceReference serviceReference = ctx.getServiceReference(QueryIndexProvider.class + .getName()); + if (serviceReference != null) { + queryIndexProvider = QueryIndexProvider.class + .cast(ctx.getService(serviceReference)); + } + } catch (Throwable e) { + // do nothing + } + return queryIndexProvider; + } + + /** + * adapt the OSGi Solr {@link SolrServerProvider} service of a given extending class and tries + * to instantiate it if non existing. + * + * @param providerClass + * the {@link Class} extending {@link SolrServerProvider} to adapt or instantiate + * @param + * the {@link SolrServerProvider} extension + * @return a {@link SolrServerProvider} adapted from the OSGi service, or a directly + * instantiated one or null if both failed + */ + public static SolrServerProvider adaptOsgiSolrServerProvider( + Class providerClass) { + SolrServerProvider solrServerProvider = null; + try { + BundleContext ctx = FrameworkUtil.getBundle(providerClass).getBundleContext(); + ServiceReference serviceReference = ctx.getServiceReference(SolrServerProvider.class + .getName()); + if (serviceReference != null) { + solrServerProvider = SolrServerProvider.class + .cast(ctx.getService(serviceReference)); + } + } catch (Throwable e) { + // do nothing + } + + return solrServerProvider; + } + + public static SolrServerProvider getSolrServerProvider( + Class providerClass) { + SolrServerProvider solrServerProvider = adaptOsgiSolrServerProvider(providerClass); + if (solrServerProvider == null && providerClass != null) { + try { + solrServerProvider = providerClass.newInstance(); + } catch (InstantiationException e) { + // do nothing + } catch (IllegalAccessException e) { + // do nothing + } + } + if (solrServerProvider == null) { + solrServerProvider = new DefaultSolrServerProvider(); + } + return solrServerProvider; + } + + /** + * adapt the OSGi Solr {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider} service of a given extending class + * and tries to instantiate it if non existing. + * + * @param providerClass + * the {@link Class} extending {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider} to adapt or + * instantiate + * @param + * the {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider} extension + * @return a {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.OakSolrConfigurationProvider} adapted from the OSGi service, or a directly + * instantiated one or null if both failed + */ + public static OakSolrConfigurationProvider adaptOsgiOakSolrConfigurationProvider( + Class providerClass) { + OakSolrConfigurationProvider oakSolrConfigurationProvider = null; + try { + BundleContext ctx = FrameworkUtil.getBundle(providerClass).getBundleContext(); + ServiceReference serviceReference = ctx + .getServiceReference(OakSolrConfigurationProvider.class.getName()); + if (serviceReference != null) { + oakSolrConfigurationProvider = OakSolrConfigurationProvider.class.cast(ctx + .getService(serviceReference)); + } + } catch (Throwable e) { + // do nothing + } + + return oakSolrConfigurationProvider; + } + + public static OakSolrConfigurationProvider getOakSolrConfigurationProvider( + Class providerClass) { + OakSolrConfigurationProvider oakSolrConfigurationProvider = OakSolrUtils + .adaptOsgiOakSolrConfigurationProvider(providerClass); + if (oakSolrConfigurationProvider == null && providerClass != null) { + try { + oakSolrConfigurationProvider = providerClass.newInstance(); + } catch (InstantiationException e) { + // do nothing + } catch (IllegalAccessException e) { + // do nothing + } + } + if (oakSolrConfigurationProvider == null) { + oakSolrConfigurationProvider = new DefaultSolrConfigurationProvider(); + } + return oakSolrConfigurationProvider; + } + + /** + * Trigger a Solr commit on the basis of the given commit policy (e.g. hard, soft, auto) + * + * @param solrServer + * the {@link org.apache.solr.client.solrj.SolrServer} used to communicate with the Solr instance + * @param commitPolicy + * the {@link org.apache.jackrabbit.oak.plugins.index.solr.configuration.CommitPolicy} used to commit changes to a Solr index + * @throws java.io.IOException + * if any low level IO error occurs + * @throws org.apache.solr.client.solrj.SolrServerException + * if any error occurs while trying to communicate with the Solr instance + */ + public static void commitByPolicy(SolrServer solrServer, CommitPolicy commitPolicy) + throws IOException, SolrServerException { + switch (commitPolicy) { + case HARD: { + solrServer.commit(); + break; + } + case SOFT: { + solrServer.commit(false, false, true); + break; + } + case AUTO: { + break; + } + } + } +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/OakSolrUtils.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrIndexInitializer.java URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrIndexInitializer.java?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrIndexInitializer.java (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrIndexInitializer.java Thu Oct 10 08:53:31 2013 @@ -0,0 +1,44 @@ +/* + * 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.util; + +import javax.annotation.Nonnull; + +import org.apache.jackrabbit.JcrConstants; +import org.apache.jackrabbit.oak.plugins.index.IndexConstants; +import org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer; +import org.apache.jackrabbit.oak.spi.state.NodeBuilder; + +/** + * A {@link org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer} for Solr index + */ +public class SolrIndexInitializer implements RepositoryInitializer { + + private static final String SOLR_IDX = "solr"; + + @Override + public void initialize(@Nonnull NodeBuilder builder) { + if (builder.hasChildNode(IndexConstants.INDEX_DEFINITIONS_NAME) + && !builder.getChildNode(IndexConstants.INDEX_DEFINITIONS_NAME).hasChildNode(SOLR_IDX)) { + builder = builder.getChildNode(IndexConstants.INDEX_DEFINITIONS_NAME).child(SOLR_IDX); + builder.setProperty(JcrConstants.JCR_PRIMARYTYPE, IndexConstants.INDEX_DEFINITIONS_NODE_TYPE) + .setProperty(IndexConstants.TYPE_PROPERTY_NAME, "solr") + .setProperty(IndexConstants.REINDEX_PROPERTY_NAME, "true"); + + } + } +} Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/util/SolrIndexInitializer.java ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/currency.xml URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/currency.xml?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/currency.xml (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/currency.xml Thu Oct 10 08:53:31 2013 @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/currency.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml?rev=1530880&view=auto ============================================================================== --- jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml (added) +++ jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml Thu Oct 10 08:53:31 2013 @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + path_exact + + + + + Propchange: jackrabbit/oak/trunk/oak-solr-core/src/main/resources/solr/oak/conf/schema.xml ------------------------------------------------------------------------------ svn:eol-style = native