Author: dkatayev
Date: 2009-08-28 07:46:09 -0400 (Fri, 28 Aug 2009)
New Revision: 40
Added:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/AbstractRepositoryServiceConfiguration.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntryWrapper.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryInfo.java
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/AccessManagerEntry.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/CacheEntry.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/ContainerEntry.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/LockPersisterEntry.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/MappedParametrizedObjectEntry.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntry.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryConfigurationException.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryEntry.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryServiceConfiguration.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/ValueStorageEntry.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/WorkspaceEntry.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/WorkspaceInitializerEntry.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMerger.java
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
jcr/trunk/component/core/src/main/resources/binding.xml
Log:
EXOJCR-2 Sources migration to JBoss SVN
Added:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/AbstractRepositoryServiceConfiguration.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/AbstractRepositoryServiceConfiguration.java
(rev 0)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/AbstractRepositoryServiceConfiguration.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.config;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS .
+ *
+ * @author <a href="mailto:gavrikvetal@gmail.com">Vitaliy
Gulyy</a>
+ * @version $
+ */
+
+public abstract class AbstractRepositoryServiceConfiguration
+{
+
+ protected List<RepositoryEntry> repositoryConfigurations = new
ArrayList<RepositoryEntry>();
+
+ protected String defaultRepositoryName;
+
+ /**
+ * Set default repository name
+ *
+ * @param defaultRepositoryName
+ */
+ public void setDefaultRepositoryName(String defaultRepositoryName)
+ {
+ this.defaultRepositoryName = defaultRepositoryName;
+ }
+
+ /**
+ *
+ * Get default repository name
+ *
+ * @return
+ */
+ public final String getDefaultRepositoryName()
+ {
+ return defaultRepositoryName;
+ }
+
+ public List<RepositoryEntry> getRepositoryConfigurations()
+ {
+ return repositoryConfigurations;
+ }
+
+ /**
+ * Checks if current configuration can be saved.
+ *
+ * @return
+ */
+ public boolean isRetainable()
+ {
+ return false;
+ }
+
+}
Property changes on:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/AbstractRepositoryServiceConfiguration.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/AccessManagerEntry.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/AccessManagerEntry.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/AccessManagerEntry.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -25,8 +25,7 @@
* @version $Id: AccessManagerEntry.java 14923 2008-05-29 14:10:41Z pnedonosko $
*/
-public class AccessManagerEntry
- extends MappedParametrizedObjectEntry
+public class AccessManagerEntry extends MappedParametrizedObjectEntry
{
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/CacheEntry.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/CacheEntry.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/CacheEntry.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -27,8 +27,7 @@
* @version $Id: CacheEntry.java 11907 2008-03-13 15:36:21Z ksm $
*/
-public class CacheEntry
- extends MappedParametrizedObjectEntry
+public class CacheEntry extends MappedParametrizedObjectEntry
{
private boolean enabled;
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/ContainerEntry.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/ContainerEntry.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/ContainerEntry.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -27,8 +27,7 @@
* @version $Id: ContainerEntry.java 11907 2008-03-13 15:36:21Z ksm $
*/
-public class ContainerEntry
- extends MappedParametrizedObjectEntry
+public class ContainerEntry extends MappedParametrizedObjectEntry
{
private ArrayList<ValueStorageEntry> valueStorages;
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/LockPersisterEntry.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/LockPersisterEntry.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/LockPersisterEntry.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -22,8 +22,7 @@
* @author <a href="mailto:Sergey.Kabashnyuk@gmail.com">Sergey
Kabashnyuk</a>
* @version $Id: LockPersisterEntry.java 13891 2008-05-05 16:02:30Z pnedonosko $
*/
-public class LockPersisterEntry
- extends MappedParametrizedObjectEntry
+public class LockPersisterEntry extends MappedParametrizedObjectEntry
{
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/MappedParametrizedObjectEntry.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/MappedParametrizedObjectEntry.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/MappedParametrizedObjectEntry.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -21,10 +21,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.exoplatform.services.log.Log;
-
import org.exoplatform.services.jcr.util.StringNumberParser;
-import org.exoplatform.services.log.ExoLogger;
/**
* Created by The eXo Platform SAS.
@@ -36,21 +33,18 @@
public abstract class MappedParametrizedObjectEntry
{
- protected static final Log LOG =
ExoLogger.getLogger("jcr.MappedParametrizedObjectEntry");
-
protected String type;
- protected List<SimpleParameterEntry> parameters;
+ protected List<SimpleParameterEntry> parameters = new
ArrayList<SimpleParameterEntry>();
public MappedParametrizedObjectEntry()
{
- parameters = new ArrayList<SimpleParameterEntry>();
}
- public MappedParametrizedObjectEntry(String type, List params)
+ public MappedParametrizedObjectEntry(String type, List parameters)
{
this.type = type;
- this.parameters = params;
+ this.parameters = parameters;
}
public List<SimpleParameterEntry> getParameters()
@@ -98,6 +92,21 @@
return value;
}
+ public void putParameterValue(String name, String value)
+ {
+ for (SimpleParameterEntry p : parameters)
+ {
+ if (p.getName().equals(name))
+ {
+ p.setValue(value);
+ return;
+ }
+ }
+
+ SimpleParameterEntry newParam = new SimpleParameterEntry(name, value);
+ parameters.add(newParam);
+ }
+
/**
* Parse named parameter as Integer.
*
@@ -120,7 +129,7 @@
}
catch (NumberFormatException e)
{
- LOG.warn(name + ": unparseable Integer. " + e);
+ //LOG.warn(name + ": unparseable Integer. " + e);
}
}
}
@@ -128,6 +137,27 @@
}
/**
+ * Set parameter as integer
+ *
+ * @param name
+ * @param defaultValue
+ */
+ public void putIntegerParameter(String name, Integer value)
+ {
+ for (SimpleParameterEntry param : parameters)
+ {
+ if (param.getName().equals(name))
+ {
+ param.setValue(value.toString());
+ return;
+ }
+ }
+
+ SimpleParameterEntry newParam = new SimpleParameterEntry(name, value.toString());
+ parameters.add(newParam);
+ }
+
+ /**
* Parse named parameter as Integer.
*
* @param name
@@ -169,7 +199,7 @@
}
catch (NumberFormatException e)
{
- LOG.warn(name + ": unparseable Long. " + e);
+ //LOG.warn(name + ": unparseable Long. " + e);
}
}
}
@@ -219,7 +249,7 @@
}
catch (NumberFormatException e)
{
- LOG.warn(name + ": unparseable time (as Long). " + e);
+ //LOG.warn(name + ": unparseable time (as Long). " + e);
}
}
}
@@ -270,6 +300,28 @@
}
/**
+ * Set parameter as boolean
+ *
+ * @param name
+ * @param value
+ */
+ public void putBooleanParameter(String name, Boolean value)
+ {
+ for (int i = 0; i < parameters.size(); i++)
+ {
+ SimpleParameterEntry p = parameters.get(i);
+ if (p.getName().equals(name))
+ {
+ p.setValue(value.toString());
+ return;
+ }
+ }
+
+ SimpleParameterEntry newParam = new SimpleParameterEntry(name, value.toString());
+ parameters.add(newParam);
+ }
+
+ /**
* Parse named parameter as Boolean.
*
* @param name
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntry.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntry.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntry.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -1,697 +1,42 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.config;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-import javax.jcr.RepositoryException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Element;
-import org.xml.sax.SAXException;
-
-import org.exoplatform.services.log.Log;
-import org.apache.lucene.search.Query;
-
-import org.exoplatform.container.configuration.ConfigurationManager;
-import org.exoplatform.services.jcr.datamodel.IllegalNameException;
-import org.exoplatform.services.jcr.impl.Constants;
-import org.exoplatform.services.jcr.impl.core.query.ErrorLog;
-import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
-import org.exoplatform.services.jcr.impl.core.query.QueryHandlerContext;
-import org.exoplatform.services.jcr.impl.core.query.QueryImpl;
-import org.exoplatform.services.jcr.impl.core.query.lucene.DefaultHTMLExcerpt;
-import org.exoplatform.services.jcr.impl.core.query.lucene.ExcerptProvider;
-import org.exoplatform.services.jcr.impl.core.query.lucene.IndexingConfiguration;
-import
org.exoplatform.services.jcr.impl.core.query.lucene.IndexingConfigurationEntityResolver;
-import org.exoplatform.services.jcr.impl.core.query.lucene.IndexingConfigurationImpl;
-import org.exoplatform.services.jcr.impl.core.query.lucene.JcrStandartAnalyzer;
-import org.exoplatform.services.jcr.impl.core.query.lucene.NamespaceMappings;
-import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
-import org.exoplatform.services.jcr.impl.core.query.lucene.SpellChecker;
-import org.exoplatform.services.jcr.impl.core.query.lucene.SynonymProvider;
-import org.exoplatform.services.log.ExoLogger;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author <a href="mailto:geaz@users.sourceforge.net">Gennady Azarenkov
</a>
- * @version $Id: QueryHandlerEntry.java 14931 2008-05-29 15:02:08Z ksm $
- */
-
-public class QueryHandlerEntry
- extends MappedParametrizedObjectEntry
-{
- /**
- * The default value for property {@link #extractorBackLog}.
- */
- public static final int DEFAULT_EXTRACTOR_BACKLOG = 100;
-
- /**
- * The default value for property {@link #extractorPoolSize}.
- */
- public static final int DEFAULT_EXTRACTOR_POOLSIZE = 0;
-
- /**
- * The default timeout in milliseconds which is granted to the text extraction process
until
- * fulltext indexing is deferred to a background thread.
- */
- public static final long DEFAULT_EXTRACTOR_TIMEOUT = 100;
-
- /**
- * the default value for property {@link #maxFieldLength}.
- */
- public static final int DEFAULT_MAX_FIELD_LENGTH = 10000;
-
- /**
- * The default value for property {@link #maxMergeDocs}.
- */
- public static final int DEFAULT_MAX_MERGE_DOCS = Integer.MAX_VALUE;
-
- /**
- * the default value for property {@link #mergeFactor}.
- */
- public static final int DEFAULT_MERGE_FACTOR = 10;
-
- /**
- * The default value for property {@link #minMergeDocs}.
- */
- public static final int DEFAULT_MIN_MERGE_DOCS = 100;
-
- /**
- * Name of the file to persist search internal namespace mappings.
- */
- public static final String NS_MAPPING_FILE = "ns_mappings.properties"; //
TODO
-
- /**
- * The excerpt provider class. Implements {@link ExcerptProvider}.
- */
- private static final String DEDAULT_EXCERPTPROVIDER_CLASS =
DefaultHTMLExcerpt.class.getName();
-
- private static final String DEDAULT_INDEXINGCONFIGURATIONCLASS =
IndexingConfigurationImpl.class.getName();
-
- private static final boolean DEFAULT_AUTOREPAIR = true;
-
- private static final int DEFAULT_BUFFER_SIZE = 10;
-
- private static final int DEFAULT_CACHE_SIZE = 1000;
-
- private final static boolean DEFAULT_CONSISTENCYCHECKENABLED = false;
-
- private final static boolean DEFAULT_DOCUMENTORDER = true;
-
- private final static boolean DEFAULT_FORCECONSISTENCYCHECK = false;
-
- /**
- * Name of the default query implementation class.
- */
- private static final String DEFAULT_QUERY_HANDLER_CLASS =
SearchIndex.class.getName();
-
- /**
- * Name of the default query implementation class.
- */
- private static final String DEFAULT_QUERY_IMPL_CLASS = QueryImpl.class.getName();
-
- /**
- * The number of documents that are pre fetched when a query is executed. <p/>
Default value is:
- * {@link Integer#MAX_VALUE}.
- */
- private final static int DEFAULT_RESULTFETCHSIZE = Integer.MAX_VALUE;
-
- private final static boolean DEFAULT_SUPPORTHIGHLIGHTING = false;
-
- private final static boolean DEFAULT_USECOMPOUNDFILE = false;
-
- private final static int DEFAULT_VOLATILEIDLETIME = 3;
-
- /** The logger instance for this class */
- private static final Log log = ExoLogger.getLogger(QueryHandlerEntry.class);
-
- // after JCR-445
- private final static String PARAM_AUTO_REPAIR = "auto-repair";
-
- private final static String PARAM_BUFFER_SIZE = "buffer-size";
-
- private final static String PARAM_CACHE_SIZE = "cache-size";
-
- private final static String PARAM_CONSISTENCY_CHECK_ENABLED =
"consistency-check-enabled";
-
- private final static String PARAM_DOCUMENT_ORDER = "document-order";
-
- private final static String PARAM_EXCERPTPROVIDER_CLASS =
"excerptprovider-class";
-
- private final static String PARAM_EXCLUDED_NODE_IDENTIFERS =
"excluded-node-identifers";
-
- private final static String PARAM_EXTRACTOR_BACKLOG = "extractor-backlog";
-
- private final static String PARAM_EXTRACTOR_POOLSIZE =
"extractor-pool-size";
-
- private final static String PARAM_EXTRACTOR_TIMEOUT = "extractor-timeout";
-
- private final static String PARAM_FORCE_CONSISTENCYCHECK =
"force-consistencycheck";
-
- /**
- * ErrorLog file size in Kb.
- */
- private final static String PARAM_ERRORLOG_SIZE = "errorlog-size";
-
- /**
- * The location of the search index. <p/> Note: This is a
<b>mandatory</b> parameter!
- */
- private final static String PARAM_INDEX_DIR = "index-dir";
-
- private final static String OLD_PARAM_INDEX_DIR = "indexDir";
-
- private final static String PARAM_INDEXING_CONFIGURATION_PATH =
"indexing-configuration-path";
-
- private final static String PARAM_INDEXING_CONFIGURATION_CLASS =
"indexing-configuration-class";
-
- private final static String PARAM_MAX_FIELD_LENGTH = "max-field-length";
-
- private final static String PARAM_MAX_MERGE_DOCS = "max-merge-docs";
-
- private final static String PARAM_MERGE_FACTOR = "merge-factor";
-
- private final static String PARAM_MIN_MERGE_DOCS = "min-merge-docs";
-
- private final static String PARAM_QUERY_CLASS = "query-class";
-
- private final static String PARAM_RESULT_FETCH_SIZE = "result-fetch-size";
-
- private final static String PARAM_ROOT_NODE_ID = "root-node-id";
-
- private final static String PARAM_SPELLCHECKER_CLASS =
"spellchecker-class";
-
- private final static String PARAM_SUPPORT_HIGHLIGHTING =
"support-highlighting";
-
- private final static String PARAM_SYNONYMPROVIDER_CLASS =
"synonymprovider-class";
-
- private final static String PARAM_SYNONYMPROVIDER_CONFIG_PATH =
"synonymprovider-config-path";
-
- private final static String PARAM_USE_COMPOUNDFILE = "use-compoundfile";
-
- private final static String PARAM_VOLATILE_IDLE_TIME =
"volatile-idle-time";
-
- public QueryHandlerEntry queryHandler;
-
- public Integer volatileIdleTime;
-
- /**
- * The analyzer we use for indexing.
- */
- private JcrStandartAnalyzer analyzer;
-
- private String queryHandlerClass = DEFAULT_QUERY_HANDLER_CLASS;
-
- public QueryHandlerEntry()
- {
- super();
- this.analyzer = new JcrStandartAnalyzer();
- }
-
- public QueryHandlerEntry(String type, List params)
- {
- super(type, params);
- this.analyzer = new JcrStandartAnalyzer();
- }
-
- /**
- * Creates an excerpt provider for the given <code>query</code>.
- *
- * @param query the query.
- * @return an excerpt provider for the given <code>query</code>.
- * @throws IOException if the provider cannot be created.
- */
- public ExcerptProvider createExcerptProvider(Query query) throws IOException
- {
- ExcerptProvider ep;
- try
- {
- Class excerptProviderClass = Class.forName(getExcerptProviderClass(), true,
this.getClass().getClassLoader());
- ep = (ExcerptProvider) excerptProviderClass.newInstance();
- }
- catch (Exception e)
- {
- IOException ex = new IOException();
- ex.initCause(e);
- throw ex;
- }
-
- return ep;
- }
-
- /**
- * @param namespaceMappings The namespace mappings
- * @return the fulltext indexing configuration or <code>null</code> if
there is no configuration.
- */
- public IndexingConfiguration createIndexingConfiguration(NamespaceMappings
namespaceMappings,
- QueryHandlerContext context, ConfigurationManager cfm) throws IOException,
RepositoryConfigurationException
- {
- Element docElement = getIndexingConfigurationDOM(cfm);
- if (docElement == null)
- {
- return null;
- }
- IndexingConfiguration idxCfg = null;
- try
- {
- Class indexingConfigurationClass =
- Class.forName(getIndexingConfigurationClass(), true,
this.getClass().getClassLoader());
- idxCfg = (IndexingConfiguration) indexingConfigurationClass.newInstance();
- idxCfg.init(docElement, context, namespaceMappings);
- }
- catch (InstantiationException e)
- {
- log.warn("Exception initializing indexing configuration from: " +
getIndexingConfigurationPath(), e);
- }
- catch (IllegalAccessException e)
- {
- log.warn("Exception initializing indexing configuration from: " +
getIndexingConfigurationPath(), e);
- }
- catch (RepositoryException e)
- {
- log.warn("Exception initializing indexing configuration from: " +
getIndexingConfigurationPath(), e);
- }
- catch (IllegalNameException e)
- {
- log.warn("Exception initializing indexing configuration from: " +
getIndexingConfigurationPath(), e);
- }
- catch (ClassNotFoundException e)
- {
- log.warn("Exception initializing indexing configuration from: " +
getIndexingConfigurationPath(), e);
- }
- return idxCfg;
- }
-
- /**
- * Creates a spell checker for this query handler.
- *
- * @return the spell checker or <code>null</code> if none is configured or
an error occurs.
- */
- public SpellChecker createSpellChecker(QueryHandler handler)
- {
- SpellChecker spCheck = null;
- if (getSpellCheckerClass() != null)
- {
- try
- {
- Class spellCheckerClass = Class.forName(getSpellCheckerClass(), true,
this.getClass().getClassLoader());
- spCheck = (SpellChecker) spellCheckerClass.newInstance();
- spCheck.init(handler);
- }
- catch (Exception e)
- {
- log.warn("Exception initializing spell checker: " +
getSpellCheckerClass(), e);
- }
- }
- return spCheck;
- }
-
- /**
- * @param cfm
- * @return the configured synonym provider or <code>null</code> if none is
configured or an error
- * occurs.
- */
- public SynonymProvider createSynonymProvider(ConfigurationManager cfm)
- {
- SynonymProvider sp = null;
- if (getSynonymProviderClass() != null)
- {
- try
- {
- Class synonymProviderClass =
- Class.forName(getSynonymProviderClass(), true,
this.getClass().getClassLoader());
- sp = (SynonymProvider) synonymProviderClass.newInstance();
-
- sp.initialize(createSynonymProviderConfigResource(cfm));
- }
- catch (Exception e)
- {
- log.warn("Exception initializing synonym provider: " +
getSynonymProviderClass(), e);
- sp = null;
- }
- }
- return sp;
- }
-
- public JcrStandartAnalyzer getAnalyzer()
- {
- return analyzer;
- }
-
- /**
- * If set <code>true</code> errors detected by the consistency check are
repaired. If
- * <code>false</code> the errors are only reported in the log. <p/>
Default value is:
- * <code>true</code>.
- */
- public boolean getAutoRepair()
- {
- return getParameterBoolean(PARAM_AUTO_REPAIR, DEFAULT_AUTOREPAIR);
- }
-
- /**
- * Number of documents that are buffered before they are added to the index.
- */
- public int getBufferSize()
- {
- return getParameterInteger(PARAM_BUFFER_SIZE, DEFAULT_BUFFER_SIZE);
- }
-
- public int getCacheSize()
- {
- return getParameterInteger(PARAM_CACHE_SIZE, DEFAULT_CACHE_SIZE);
- }
-
- /**
- * Flag indicating whether document order is enable as the default ordering.
- */
-
- public boolean getDocumentOrder()
- {
- return getParameterBoolean(PARAM_DOCUMENT_ORDER, DEFAULT_DOCUMENTORDER);
- }
-
- /**
- * @return the class name of the excerpt provider implementation.
- */
- public String getExcerptProviderClass()
- {
- return getParameterValue(PARAM_EXCERPTPROVIDER_CLASS,
DEDAULT_EXCERPTPROVIDER_CLASS);
- }
-
- public String getExcludedNodeIdentifers()
- {
- return getParameterValue(PARAM_EXCLUDED_NODE_IDENTIFERS, null);
- }
-
- /**
- * @return the size of the extractor queue back log.
- */
- public int getExtractorBackLogSize()
- {
- return getParameterInteger(PARAM_EXTRACTOR_BACKLOG, DEFAULT_EXTRACTOR_BACKLOG);
- }
-
- /**
- * @return the size of the thread pool which is used to run the text extractors when
binary
- * content is indexed.
- */
- public int getExtractorPoolSize()
- {
- return getParameterInteger(PARAM_EXTRACTOR_POOLSIZE, DEFAULT_EXTRACTOR_POOLSIZE);
-
- }
-
- /**
- * @return the extractor timeout in milliseconds.
- */
- public long getExtractorTimeout()
- {
- return getParameterTime(PARAM_EXTRACTOR_TIMEOUT, DEFAULT_EXTRACTOR_TIMEOUT);
- }
-
- /**
- * Returns the location of the search index. Returns <code>null</code> if
not set.
- *
- * @return the location of the search index.
- * @throws RepositoryConfigurationException
- */
- public String getIndexDir() throws RepositoryConfigurationException
- {
-
- String indexDir;
- try
- {
- indexDir = getParameterValue(PARAM_INDEX_DIR);
- }
- catch (RepositoryConfigurationException e)
- {
- indexDir = getParameterValue(OLD_PARAM_INDEX_DIR);
- }
-
- indexDir = indexDir.replace("${java.io.tmpdir}",
System.getProperty("java.io.tmpdir"));
-
- return indexDir;
- }
-
- /**
- * @return the class name of the indexing configuration implementation.
- */
- public String getIndexingConfigurationClass()
- {
- return getParameterValue(PARAM_INDEXING_CONFIGURATION_CLASS,
DEDAULT_INDEXINGCONFIGURATIONCLASS);
- }
-
- /**
- * @return the path to the indexing configuration file.
- */
- public String getIndexingConfigurationPath()
- {
- return getParameterValue(PARAM_INDEXING_CONFIGURATION_PATH, null);
- }
-
- public int getMaxFieldLength()
- {
- return getParameterInteger(PARAM_MAX_FIELD_LENGTH, DEFAULT_MAX_FIELD_LENGTH);
- }
-
- /**
- * Returns the current value for maxMergeDocs.
- *
- * @return the current value for maxMergeDocs.
- */
- public int getMaxMergeDocs()
- {
- return getParameterInteger(PARAM_MAX_MERGE_DOCS, DEFAULT_MAX_MERGE_DOCS);
- }
-
- /**
- * Returns the current value for the merge factor.
- *
- * @return the current value for the merge factor.
- */
- public int getMergeFactor()
- {
- return getParameterInteger(PARAM_MERGE_FACTOR, DEFAULT_MERGE_FACTOR);
- }
-
- /**
- * Returns the current value for minMergeDocs.
- *
- * @return the current value for minMergeDocs.
- */
- public int getMinMergeDocs()
- {
- return getParameterInteger(PARAM_MIN_MERGE_DOCS, DEFAULT_MIN_MERGE_DOCS);
- }
-
- public String getQueryClass()
- {
- return getParameterValue(PARAM_QUERY_CLASS, DEFAULT_QUERY_IMPL_CLASS);
- }
-
- public QueryHandlerEntry getQueryHandler()
- {
- return queryHandler;
- }
-
- /**
- * @return the number of results the query handler will fetch initially when a query
is executed.
- */
- public int getResultFetchSize()
- {
- return getParameterInteger(PARAM_RESULT_FETCH_SIZE, DEFAULT_RESULTFETCHSIZE);
- }
-
- public String getRootNodeIdentifer()
- {
- return getParameterValue(PARAM_ROOT_NODE_ID, Constants.ROOT_UUID);
- }
-
- /**
- * Get spell checker class.
- *
- * @return the class name of the spell checker implementation or
<code>null</code> if none is set.
- */
- public String getSpellCheckerClass()
- {
- return getParameterValue(PARAM_SPELLCHECKER_CLASS, null);
- }
-
- /**
- * Get support highlighting.
- *
- * @return <code>true</code> if highlighting support is enabled.
- */
- public boolean getSupportHighlighting()
- {
- return getParameterBoolean(PARAM_SUPPORT_HIGHLIGHTING,
DEFAULT_SUPPORTHIGHLIGHTING);
- }
-
- /**
- * Get synonym provider class.
- *
- * @return the class name of the synonym provider implementation or
<code>null</code> if none is
- * set.
- */
- public String getSynonymProviderClass()
- {
- return getParameterValue(PARAM_SYNONYMPROVIDER_CLASS, null);
- }
-
- /**
- * Get synonym provider configuration path.
- *
- * @return the configuration path for the synonym provider. If none is set this method
returns
- * <code>null</code>.
- */
- public String getSynonymProviderConfigPath()
- {
- return getParameterValue(PARAM_SYNONYMPROVIDER_CONFIG_PATH, null);
- }
-
- /**
- * Returns the current value for useCompoundFile.
- *
- * @return the current value for useCompoundFile.
- */
- public boolean getUseCompoundFile()
- {
- return getParameterBoolean(PARAM_USE_COMPOUNDFILE, DEFAULT_USECOMPOUNDFILE);
- }
-
- /**
- * Returns the current value for volatileIdleTime.
- *
- * @return the current value for volatileIdleTime.
- */
- public int getVolatileIdleTime()
- {
- if (volatileIdleTime == null)
- volatileIdleTime = getParameterInteger(PARAM_VOLATILE_IDLE_TIME,
DEFAULT_VOLATILEIDLETIME);
-
- return volatileIdleTime;
- }
-
- /**
- * If set <code>true</code> the index is checked for consistency depending
on the
- * {@link #forceConsistencyCheck} parameter. If set to <code>false</code>,
no consistency check is
- * performed, even if the redo log had been applied on startup. <p/> Default
value is:
- * <code>false</code>.
- *
- * @return boolean
- */
- public boolean isConsistencyCheckEnabled()
- {
- return getParameterBoolean(PARAM_CONSISTENCY_CHECK_ENABLED,
DEFAULT_CONSISTENCYCHECKENABLED);
- }
-
- public boolean isForceConsistencyCheck()
- {
- return getParameterBoolean(PARAM_FORCE_CONSISTENCYCHECK,
DEFAULT_FORCECONSISTENCYCHECK);
- }
-
- /**
- * Creates a file system resource to the synonym provider configuration.
- *
- * @param cfm
- * @return a file system resource or <code>null</code> if no path was
configured.
- * @throws Exception
- */
- protected InputStream createSynonymProviderConfigResource(ConfigurationManager cfm)
throws Exception
- {
- if (getSynonymProviderConfigPath() != null)
- {
- return cfm.getInputStream(getSynonymProviderConfigPath());
- }
- return null;
- }
-
- /**
- * Returns the document element of the indexing configuration or
<code>null</code> if there is no
- * indexing configuration.
- *
- * @return the indexing configuration or <code>null</code> if there is
none.
- * @throws IOException
- * @throws RepositoryConfigurationException
- */
- protected Element getIndexingConfigurationDOM(ConfigurationManager cfm) throws
IOException,
- RepositoryConfigurationException
- {
- String indexingConfigPath = getIndexingConfigurationPath();
- Element indexingConfiguration = null;
- if (indexingConfigPath != null)
- {
-
- InputStream is;
- try
- {
- is = cfm.getInputStream(indexingConfigPath);
- }
- catch (Exception e1)
- {
- throw new IOException(e1.getLocalizedMessage());
- }
-
- if (is == null)
- throw new IOException("Resource does not exist: " +
indexingConfigPath);
-
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- try
- {
- DocumentBuilder builder = factory.newDocumentBuilder();
- builder.setEntityResolver(new IndexingConfigurationEntityResolver());
- indexingConfiguration = builder.parse(is).getDocumentElement();
- }
- catch (ParserConfigurationException e)
- {
- throw new RepositoryConfigurationException(e.getLocalizedMessage(), e);
- }
- catch (SAXException e)
- {
- throw new RepositoryConfigurationException(e.getLocalizedMessage(), e);
- }
- }
-
- return indexingConfiguration;
- }
-
- /**
- * Return ErrorLog file size in Kb String representation.
- *
- * @return int size in Kb
- */
- public int getErrorLogSize()
- {
- String size = getParameterValue(PARAM_ERRORLOG_SIZE, null);
- if ((size == null) || (size.equals("")))
- {
- return ErrorLog.DEFAULT_FILE_SIZE;
- }
- else
- {
- return new Integer(size);
- }
- }
-
-}
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.config;
+
+import java.util.List;
+
+/**
+ * Created by The eXo Platform SAS .
+ *
+ * @author <a href="mailto:gavrikvetal@gmail.com">Vitaliy
Gulyy</a>
+ * @version $
+ */
+
+public class QueryHandlerEntry extends MappedParametrizedObjectEntry
+{
+
+ public QueryHandlerEntry()
+ {
+ }
+
+ public QueryHandlerEntry(String type, List params)
+ {
+ super(type, params);
+ }
+
+}
Added:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntryWrapper.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntryWrapper.java
(rev 0)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntryWrapper.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -0,0 +1,682 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.config;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import javax.jcr.RepositoryException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
+
+import org.exoplatform.services.log.Log;
+import org.apache.lucene.search.Query;
+
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.jcr.datamodel.IllegalNameException;
+import org.exoplatform.services.jcr.impl.Constants;
+import org.exoplatform.services.jcr.impl.core.query.ErrorLog;
+import org.exoplatform.services.jcr.impl.core.query.QueryHandler;
+import org.exoplatform.services.jcr.impl.core.query.QueryHandlerContext;
+import org.exoplatform.services.jcr.impl.core.query.QueryImpl;
+import org.exoplatform.services.jcr.impl.core.query.lucene.DefaultHTMLExcerpt;
+import org.exoplatform.services.jcr.impl.core.query.lucene.ExcerptProvider;
+import org.exoplatform.services.jcr.impl.core.query.lucene.IndexingConfiguration;
+import
org.exoplatform.services.jcr.impl.core.query.lucene.IndexingConfigurationEntityResolver;
+import org.exoplatform.services.jcr.impl.core.query.lucene.IndexingConfigurationImpl;
+import org.exoplatform.services.jcr.impl.core.query.lucene.JcrStandartAnalyzer;
+import org.exoplatform.services.jcr.impl.core.query.lucene.NamespaceMappings;
+import org.exoplatform.services.jcr.impl.core.query.lucene.SearchIndex;
+import org.exoplatform.services.jcr.impl.core.query.lucene.SpellChecker;
+import org.exoplatform.services.jcr.impl.core.query.lucene.SynonymProvider;
+import org.exoplatform.services.jcr.util.StringNumberParser;
+import org.exoplatform.services.log.ExoLogger;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:geaz@users.sourceforge.net">Gennady Azarenkov
</a>
+ * @version $Id: QueryHandlerEntry.java 14931 2008-05-29 15:02:08Z ksm $
+ */
+
+public class QueryHandlerEntryWrapper implements QueryHandlerParams
+{
+
+ /**
+ * The default value for property {@link #extractorBackLog}.
+ */
+ public static final int DEFAULT_EXTRACTOR_BACKLOG = 100;
+
+ /**
+ * The default value for property {@link #extractorPoolSize}.
+ */
+ public static final int DEFAULT_EXTRACTOR_POOLSIZE = 0;
+
+ /**
+ * The default timeout in milliseconds which is granted to the text extraction process
until
+ * fulltext indexing is deferred to a background thread.
+ */
+ public static final int DEFAULT_EXTRACTOR_TIMEOUT = 100;
+
+ /**
+ * the default value for property {@link #maxFieldLength}.
+ */
+ public static final int DEFAULT_MAX_FIELD_LENGTH = 10000;
+
+ /**
+ * The default value for property {@link #maxMergeDocs}.
+ */
+ public static final int DEFAULT_MAX_MERGE_DOCS = Integer.MAX_VALUE;
+
+ /**
+ * the default value for property {@link #mergeFactor}.
+ */
+ public static final int DEFAULT_MERGE_FACTOR = 10;
+
+ /**
+ * The default value for property {@link #minMergeDocs}.
+ */
+ public static final int DEFAULT_MIN_MERGE_DOCS = 100;
+
+ /**
+ * Name of the file to persist search internal namespace mappings.
+ */
+ public static final String NS_MAPPING_FILE = "ns_mappings.properties"; //
TODO
+
+ /**
+ * The excerpt provider class. Implements {@link ExcerptProvider}.
+ */
+ private static final String DEDAULT_EXCERPTPROVIDER_CLASS =
DefaultHTMLExcerpt.class.getName();
+
+ private static final String DEDAULT_INDEXINGCONFIGURATIONCLASS =
IndexingConfigurationImpl.class.getName();
+
+ private static final boolean DEFAULT_AUTOREPAIR = true;
+
+ private static final int DEFAULT_BUFFER_SIZE = 10;
+
+ private static final int DEFAULT_CACHE_SIZE = 1000;
+
+ private final static boolean DEFAULT_CONSISTENCYCHECKENABLED = false;
+
+ private final static boolean DEFAULT_DOCUMENTORDER = true;
+
+ private final static boolean DEFAULT_FORCECONSISTENCYCHECK = false;
+
+ /**
+ * Name of the default query implementation class.
+ */
+ private static final String DEFAULT_QUERY_HANDLER_CLASS =
SearchIndex.class.getName();
+
+ /**
+ * Name of the default query implementation class.
+ */
+ private static final String DEFAULT_QUERY_IMPL_CLASS = QueryImpl.class.getName();
+
+ /**
+ * The number of documents that are pre fetched when a query is executed. <p/>
Default value is:
+ * {@link Integer#MAX_VALUE}.
+ */
+ private final static int DEFAULT_RESULTFETCHSIZE = Integer.MAX_VALUE;
+
+ private final static boolean DEFAULT_SUPPORTHIGHLIGHTING = false;
+
+ private final static boolean DEFAULT_USECOMPOUNDFILE = false;
+
+ private final static int DEFAULT_VOLATILEIDLETIME = 3;
+
+ private QueryHandlerEntry queryHandlerEntry;
+
+ public QueryHandlerEntry getQueryHandlerEntry()
+ {
+ return queryHandlerEntry;
+ }
+
+ private static void initDefaults(QueryHandlerEntry entry)
+ {
+ entry.putBooleanParameter(PARAM_AUTO_REPAIR, DEFAULT_AUTOREPAIR);
+ entry.putIntegerParameter(PARAM_BUFFER_SIZE, DEFAULT_BUFFER_SIZE);
+ entry.putIntegerParameter(PARAM_CACHE_SIZE, DEFAULT_CACHE_SIZE);
+ entry.putBooleanParameter(PARAM_DOCUMENT_ORDER, DEFAULT_DOCUMENTORDER);
+ entry.putParameterValue(PARAM_EXCERPTPROVIDER_CLASS,
DEDAULT_EXCERPTPROVIDER_CLASS);
+ entry.putParameterValue(PARAM_EXCLUDED_NODE_IDENTIFERS, null);
+ entry.putIntegerParameter(PARAM_EXTRACTOR_BACKLOG, DEFAULT_EXTRACTOR_BACKLOG);
+ entry.putIntegerParameter(PARAM_EXTRACTOR_POOLSIZE, DEFAULT_EXTRACTOR_POOLSIZE);
+ entry.putIntegerParameter(PARAM_EXTRACTOR_TIMEOUT, DEFAULT_EXTRACTOR_TIMEOUT);
+ }
+
+ public String getType()
+ {
+ return queryHandlerEntry.getType();
+ }
+
+ public static QueryHandlerEntry queryHandlerEntryFactory()
+ {
+ QueryHandlerEntry entry = new QueryHandlerEntry();
+ initDefaults(entry);
+ return entry;
+ }
+
+ /** The logger instance for this class */
+ private static final Log log = ExoLogger.getLogger(QueryHandlerEntry.class);
+
+ //public QueryHandlerEntry queryHandler;
+
+ public Integer volatileIdleTime;
+
+ /**
+ * The analyzer we use for indexing.
+ */
+ private JcrStandartAnalyzer analyzer;
+
+ private String queryHandlerClass = DEFAULT_QUERY_HANDLER_CLASS;
+
+ public QueryHandlerEntryWrapper(QueryHandlerEntry queryHandlerEntry)
+ {
+ this.queryHandlerEntry = queryHandlerEntry;
+ this.analyzer = new JcrStandartAnalyzer();
+ initDefaults(queryHandlerEntry);
+ }
+
+ public QueryHandlerEntryWrapper(String type, List params, QueryHandlerEntry
queryHandlerEntry)
+ {
+ this.queryHandlerEntry = queryHandlerEntry;
+ queryHandlerEntry.setType(type);
+ queryHandlerEntry.setParameters(params);
+ this.analyzer = new JcrStandartAnalyzer();
+ initDefaults(queryHandlerEntry);
+ }
+
+ /**
+ * Creates an excerpt provider for the given <code>query</code>.
+ *
+ * @param query the query.
+ * @return an excerpt provider for the given <code>query</code>.
+ * @throws IOException if the provider cannot be created.
+ */
+ public ExcerptProvider createExcerptProvider(Query query) throws IOException
+ {
+ ExcerptProvider ep;
+ try
+ {
+ Class excerptProviderClass = Class.forName(getExcerptProviderClass(), true,
this.getClass().getClassLoader());
+ ep = (ExcerptProvider)excerptProviderClass.newInstance();
+ }
+ catch (Exception e)
+ {
+ IOException ex = new IOException();
+ ex.initCause(e);
+ throw ex;
+ }
+
+ return ep;
+ }
+
+ /**
+ * @param namespaceMappings The namespace mappings
+ * @return the fulltext indexing configuration or <code>null</code> if
there is no configuration.
+ */
+ public IndexingConfiguration createIndexingConfiguration(NamespaceMappings
namespaceMappings,
+ QueryHandlerContext context, ConfigurationManager cfm) throws IOException,
RepositoryConfigurationException
+ {
+ Element docElement = getIndexingConfigurationDOM(cfm);
+ if (docElement == null)
+ {
+ return null;
+ }
+ IndexingConfiguration idxCfg = null;
+ try
+ {
+ Class indexingConfigurationClass =
+ Class.forName(getIndexingConfigurationClass(), true,
this.getClass().getClassLoader());
+ idxCfg = (IndexingConfiguration)indexingConfigurationClass.newInstance();
+ idxCfg.init(docElement, context, namespaceMappings);
+ }
+ catch (InstantiationException e)
+ {
+ log.warn("Exception initializing indexing configuration from: " +
getIndexingConfigurationPath(), e);
+ }
+ catch (IllegalAccessException e)
+ {
+ log.warn("Exception initializing indexing configuration from: " +
getIndexingConfigurationPath(), e);
+ }
+ catch (RepositoryException e)
+ {
+ log.warn("Exception initializing indexing configuration from: " +
getIndexingConfigurationPath(), e);
+ }
+ catch (IllegalNameException e)
+ {
+ log.warn("Exception initializing indexing configuration from: " +
getIndexingConfigurationPath(), e);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.warn("Exception initializing indexing configuration from: " +
getIndexingConfigurationPath(), e);
+ }
+ return idxCfg;
+ }
+
+ /**
+ * Creates a spell checker for this query handler.
+ *
+ * @return the spell checker or <code>null</code> if none is configured or
an error occurs.
+ */
+ public SpellChecker createSpellChecker(QueryHandler handler)
+ {
+ SpellChecker spCheck = null;
+ if (getSpellCheckerClass() != null)
+ {
+ try
+ {
+ Class spellCheckerClass = Class.forName(getSpellCheckerClass(), true,
this.getClass().getClassLoader());
+ spCheck = (SpellChecker)spellCheckerClass.newInstance();
+ spCheck.init(handler);
+ }
+ catch (Exception e)
+ {
+ log.warn("Exception initializing spell checker: " +
getSpellCheckerClass(), e);
+ }
+ }
+ return spCheck;
+ }
+
+ /**
+ * @param cfm
+ * @return the configured synonym provider or <code>null</code> if none is
configured or an error
+ * occurs.
+ */
+ public SynonymProvider createSynonymProvider(ConfigurationManager cfm)
+ {
+ SynonymProvider sp = null;
+ if (getSynonymProviderClass() != null)
+ {
+ try
+ {
+ Class synonymProviderClass =
+ Class.forName(getSynonymProviderClass(), true,
this.getClass().getClassLoader());
+ sp = (SynonymProvider)synonymProviderClass.newInstance();
+
+ sp.initialize(createSynonymProviderConfigResource(cfm));
+ }
+ catch (Exception e)
+ {
+ log.warn("Exception initializing synonym provider: " +
getSynonymProviderClass(), e);
+ sp = null;
+ }
+ }
+ return sp;
+ }
+
+ public JcrStandartAnalyzer getAnalyzer()
+ {
+ return analyzer;
+ }
+
+ private String getParameterString(String name)
+ {
+ return queryHandlerEntry.getParameterValue(name, null);
+ }
+
+ private Integer getParameterIntegerInitialized(String name)
+ {
+ String value = queryHandlerEntry.getParameterValue(name, null);
+ return StringNumberParser.parseInt(value);
+ }
+
+ private Boolean getParameterBooleanInitialized(String name)
+ {
+ String value = queryHandlerEntry.getParameterValue(name, "false");
+ return Boolean.parseBoolean(value);
+ }
+
+ /**
+ * If set <code>true</code> errors detected by the consistency check are
repaired. If
+ * <code>false</code> the errors are only reported in the log. <p/>
Default value is:
+ * <code>true</code>.
+ * @throws RepositoryConfigurationException
+ */
+ public boolean getAutoRepair() throws RepositoryConfigurationException
+ {
+ return getParameterBooleanInitialized(PARAM_AUTO_REPAIR);
+ }
+
+ /**
+ * Number of documents that are buffered before they are added to the index.
+ * @throws RepositoryConfigurationException
+ */
+ public int getBufferSize()
+ {
+ return getParameterIntegerInitialized(PARAM_BUFFER_SIZE);
+ }
+
+ public int getCacheSize()
+ {
+ return getParameterIntegerInitialized(PARAM_CACHE_SIZE);
+ }
+
+ /**
+ * Flag indicating whether document order is enable as the default ordering.
+ */
+ public boolean getDocumentOrder()
+ {
+ return getParameterBooleanInitialized(PARAM_DOCUMENT_ORDER);
+ }
+
+ /**
+ * @return the class name of the excerpt provider implementation.
+ */
+ public String getExcerptProviderClass()
+ {
+ return getParameterString(PARAM_EXCERPTPROVIDER_CLASS);
+ }
+
+ public String getExcludedNodeIdentifers()
+ {
+ return getParameterString(PARAM_EXCLUDED_NODE_IDENTIFERS);
+ }
+
+ /**
+ * @return the size of the extractor queue back log.
+ */
+ public int getExtractorBackLogSize()
+ {
+ return getParameterIntegerInitialized(PARAM_EXTRACTOR_BACKLOG);
+ }
+
+ /**
+ * @return the size of the thread pool which is used to run the text extractors when
binary
+ * content is indexed.
+ */
+ public int getExtractorPoolSize()
+ {
+ return getParameterIntegerInitialized(PARAM_EXTRACTOR_POOLSIZE);
+ }
+
+ /**
+ * @return the extractor timeout in milliseconds.
+ */
+ public long getExtractorTimeout()
+ {
+ return getParameterIntegerInitialized(PARAM_EXTRACTOR_TIMEOUT);
+ }
+
+ /**
+ * Returns the location of the search index. Returns <code>null</code> if
not set.
+ *
+ * @return the location of the search index.
+ * @throws RepositoryConfigurationException
+ */
+ public String getIndexDir() throws RepositoryConfigurationException
+ {
+
+ String indexDir;
+ try
+ {
+ indexDir = queryHandlerEntry.getParameterValue(PARAM_INDEX_DIR);
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ indexDir = queryHandlerEntry.getParameterValue(OLD_PARAM_INDEX_DIR);
+ }
+
+ indexDir = indexDir.replace("${java.io.tmpdir}",
System.getProperty("java.io.tmpdir"));
+
+ return indexDir;
+ }
+
+ /**
+ * @return the class name of the indexing configuration implementation.
+ */
+ public String getIndexingConfigurationClass()
+ {
+ return queryHandlerEntry
+ .getParameterValue(PARAM_INDEXING_CONFIGURATION_CLASS,
DEDAULT_INDEXINGCONFIGURATIONCLASS);
+ }
+
+ /**
+ * @return the path to the indexing configuration file.
+ */
+ public String getIndexingConfigurationPath()
+ {
+ return queryHandlerEntry.getParameterValue(PARAM_INDEXING_CONFIGURATION_PATH,
null);
+ }
+
+ public int getMaxFieldLength()
+ {
+ return queryHandlerEntry.getParameterInteger(PARAM_MAX_FIELD_LENGTH,
DEFAULT_MAX_FIELD_LENGTH);
+ }
+
+ /**
+ * Returns the current value for maxMergeDocs.
+ *
+ * @return the current value for maxMergeDocs.
+ */
+ public int getMaxMergeDocs()
+ {
+ return queryHandlerEntry.getParameterInteger(PARAM_MAX_MERGE_DOCS,
DEFAULT_MAX_MERGE_DOCS);
+ }
+
+ /**
+ * Returns the current value for the merge factor.
+ *
+ * @return the current value for the merge factor.
+ */
+ public int getMergeFactor()
+ {
+ return queryHandlerEntry.getParameterInteger(PARAM_MERGE_FACTOR,
DEFAULT_MERGE_FACTOR);
+ }
+
+ /**
+ * Returns the current value for minMergeDocs.
+ *
+ * @return the current value for minMergeDocs.
+ */
+ public int getMinMergeDocs()
+ {
+ return queryHandlerEntry.getParameterInteger(PARAM_MIN_MERGE_DOCS,
DEFAULT_MIN_MERGE_DOCS);
+ }
+
+ public String getQueryClass()
+ {
+ return queryHandlerEntry.getParameterValue(PARAM_QUERY_CLASS,
DEFAULT_QUERY_IMPL_CLASS);
+ }
+
+ /**
+ * @return the number of results the query handler will fetch initially when a query
is executed.
+ */
+ public int getResultFetchSize()
+ {
+ return queryHandlerEntry.getParameterInteger(PARAM_RESULT_FETCH_SIZE,
DEFAULT_RESULTFETCHSIZE);
+ }
+
+ public String getRootNodeIdentifer()
+ {
+ return queryHandlerEntry.getParameterValue(PARAM_ROOT_NODE_ID,
Constants.ROOT_UUID);
+ }
+
+ /**
+ * Get spell checker class.
+ *
+ * @return the class name of the spell checker implementation or
<code>null</code> if none is set.
+ */
+ public String getSpellCheckerClass()
+ {
+ return queryHandlerEntry.getParameterValue(PARAM_SPELLCHECKER_CLASS, null);
+ }
+
+ /**
+ * Get support highlighting.
+ *
+ * @return <code>true</code> if highlighting support is enabled.
+ */
+ public boolean getSupportHighlighting()
+ {
+ return queryHandlerEntry.getParameterBoolean(PARAM_SUPPORT_HIGHLIGHTING,
DEFAULT_SUPPORTHIGHLIGHTING);
+ }
+
+ /**
+ * Get synonym provider class.
+ *
+ * @return the class name of the synonym provider implementation or
<code>null</code> if none is
+ * set.
+ */
+ public String getSynonymProviderClass()
+ {
+ return queryHandlerEntry.getParameterValue(PARAM_SYNONYMPROVIDER_CLASS, null);
+ }
+
+ /**
+ * Get synonym provider configuration path.
+ *
+ * @return the configuration path for the synonym provider. If none is set this method
returns
+ * <code>null</code>.
+ */
+ public String getSynonymProviderConfigPath()
+ {
+ return queryHandlerEntry.getParameterValue(PARAM_SYNONYMPROVIDER_CONFIG_PATH,
null);
+ }
+
+ /**
+ * Returns the current value for useCompoundFile.
+ *
+ * @return the current value for useCompoundFile.
+ */
+ public boolean getUseCompoundFile()
+ {
+ return queryHandlerEntry.getParameterBoolean(PARAM_USE_COMPOUNDFILE,
DEFAULT_USECOMPOUNDFILE);
+ }
+
+ /**
+ * Returns the current value for volatileIdleTime.
+ *
+ * @return the current value for volatileIdleTime.
+ */
+ public int getVolatileIdleTime()
+ {
+ if (volatileIdleTime == null)
+ volatileIdleTime =
queryHandlerEntry.getParameterInteger(PARAM_VOLATILE_IDLE_TIME,
DEFAULT_VOLATILEIDLETIME);
+
+ return volatileIdleTime;
+ }
+
+ /**
+ * If set <code>true</code> the index is checked for consistency depending
on the
+ * {@link #forceConsistencyCheck} parameter. If set to <code>false</code>,
no consistency check is
+ * performed, even if the redo log had been applied on startup. <p/> Default
value is:
+ * <code>false</code>.
+ *
+ * @return boolean
+ */
+ public boolean isConsistencyCheckEnabled()
+ {
+ return queryHandlerEntry.getParameterBoolean(PARAM_CONSISTENCY_CHECK_ENABLED,
DEFAULT_CONSISTENCYCHECKENABLED);
+ }
+
+ public boolean isForceConsistencyCheck()
+ {
+ return queryHandlerEntry.getParameterBoolean(PARAM_FORCE_CONSISTENCYCHECK,
DEFAULT_FORCECONSISTENCYCHECK);
+ }
+
+ /**
+ * Creates a file system resource to the synonym provider configuration.
+ *
+ * @param cfm
+ * @return a file system resource or <code>null</code> if no path was
configured.
+ * @throws Exception
+ */
+ protected InputStream createSynonymProviderConfigResource(ConfigurationManager cfm)
throws Exception
+ {
+ if (getSynonymProviderConfigPath() != null)
+ {
+ return cfm.getInputStream(getSynonymProviderConfigPath());
+ }
+ return null;
+ }
+
+ /**
+ * Returns the document element of the indexing configuration or
<code>null</code> if there is no
+ * indexing configuration.
+ *
+ * @return the indexing configuration or <code>null</code> if there is
none.
+ * @throws IOException
+ * @throws RepositoryConfigurationException
+ */
+ protected Element getIndexingConfigurationDOM(ConfigurationManager cfm) throws
IOException,
+ RepositoryConfigurationException
+ {
+ String indexingConfigPath = getIndexingConfigurationPath();
+ Element indexingConfiguration = null;
+ if (indexingConfigPath != null)
+ {
+
+ InputStream is;
+ try
+ {
+ is = cfm.getInputStream(indexingConfigPath);
+ }
+ catch (Exception e1)
+ {
+ throw new IOException(e1.getLocalizedMessage());
+ }
+
+ if (is == null)
+ throw new IOException("Resource does not exist: " +
indexingConfigPath);
+
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ try
+ {
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ builder.setEntityResolver(new IndexingConfigurationEntityResolver());
+ indexingConfiguration = builder.parse(is).getDocumentElement();
+ }
+ catch (ParserConfigurationException e)
+ {
+ throw new RepositoryConfigurationException(e.getLocalizedMessage(), e);
+ }
+ catch (SAXException e)
+ {
+ throw new RepositoryConfigurationException(e.getLocalizedMessage(), e);
+ }
+ }
+
+ return indexingConfiguration;
+ }
+
+ /**
+ * Return ErrorLog file size in Kb String representation.
+ *
+ * @return int size in Kb
+ */
+ public int getErrorLogSize()
+ {
+ String size = queryHandlerEntry.getParameterValue(PARAM_ERRORLOG_SIZE, null);
+ if ((size == null) || (size.equals("")))
+ {
+ return ErrorLog.DEFAULT_FILE_SIZE;
+ }
+ else
+ {
+ return new Integer(size);
+ }
+ }
+
+}
Property changes on:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerEntryWrapper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
(rev 0)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.config;
+
+/**
+ * Created by The eXo Platform SAS .
+ *
+ * @author <a href="mailto:gavrikvetal@gmail.com">Vitaliy
Gulyy</a>
+ * @version $
+ */
+
+public interface QueryHandlerParams
+{
+
+ // after JCR-445
+ public static final String PARAM_AUTO_REPAIR = "auto-repair";
+
+ public static final String PARAM_BUFFER_SIZE = "buffer-size";
+
+ public static final String PARAM_CACHE_SIZE = "cache-size";
+
+ public static final String PARAM_CONSISTENCY_CHECK_ENABLED =
"consistency-check-enabled";
+
+ public static final String PARAM_DOCUMENT_ORDER = "document-order";
+
+ public static final String PARAM_EXCERPTPROVIDER_CLASS =
"excerptprovider-class";
+
+ public static final String PARAM_EXCLUDED_NODE_IDENTIFERS =
"excluded-node-identifers";
+
+ public static final String PARAM_EXTRACTOR_BACKLOG = "extractor-backlog";
+
+ public static final String PARAM_EXTRACTOR_POOLSIZE =
"extractor-pool-size";
+
+ public static final String PARAM_EXTRACTOR_TIMEOUT = "extractor-timeout";
+
+ public static final String PARAM_FORCE_CONSISTENCYCHECK =
"force-consistencycheck";
+
+ /**
+ * ErrorLog file size in Kb.
+ */
+ public static final String PARAM_ERRORLOG_SIZE = "errorlog-size";
+
+ /**
+ * The location of the search index. <p/> Note: This is a
<b>mandatory</b> parameter!
+ */
+ public static final String PARAM_INDEX_DIR = "index-dir";
+
+ public static final String OLD_PARAM_INDEX_DIR = "indexDir";
+
+ public static final String PARAM_INDEXING_CONFIGURATION_PATH =
"indexing-configuration-path";
+
+ public static final String PARAM_INDEXING_CONFIGURATION_CLASS =
"indexing-configuration-class";
+
+ public static final String PARAM_MAX_FIELD_LENGTH = "max-field-length";
+
+ public static final String PARAM_MAX_MERGE_DOCS = "max-merge-docs";
+
+ public static final String PARAM_MERGE_FACTOR = "merge-factor";
+
+ public static final String PARAM_MIN_MERGE_DOCS = "min-merge-docs";
+
+ public static final String PARAM_QUERY_CLASS = "query-class";
+
+ public static final String PARAM_RESULT_FETCH_SIZE = "result-fetch-size";
+
+ public static final String PARAM_ROOT_NODE_ID = "root-node-id";
+
+ public static final String PARAM_SPELLCHECKER_CLASS = "spellchecker-class";
+
+ public static final String PARAM_SUPPORT_HIGHLIGHTING =
"support-highlighting";
+
+ public static final String PARAM_SYNONYMPROVIDER_CLASS =
"synonymprovider-class";
+
+ public static final String PARAM_SYNONYMPROVIDER_CONFIG_PATH =
"synonymprovider-config-path";
+
+ public static final String PARAM_USE_COMPOUNDFILE = "use-compoundfile";
+
+ public static final String PARAM_VOLATILE_IDLE_TIME = "volatile-idle-time";
+
+}
Property changes on:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/QueryHandlerParams.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryConfigurationException.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryConfigurationException.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryConfigurationException.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -28,8 +28,7 @@
/**
* This exception is thrown when condition occurred.
*/
-public class RepositoryConfigurationException
- extends Exception
+public class RepositoryConfigurationException extends Exception
{
/**
* Constructs an Exception without a message.
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryEntry.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryEntry.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryEntry.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -1,195 +1,59 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.config;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author <a href="mailto:geaz@users.sourceforge.net">Gennady Azarenkov
</a>
- * @version $Id: RepositoryEntry.java 11907 2008-03-13 15:36:21Z ksm $
- */
-
-public class RepositoryEntry
-{
-
- private String name;
-
- private String systemWorkspaceName;
-
- private String defaultWorkspaceName;
-
- private String accessControl;
-
- private String securityDomain;
-
- private ArrayList<WorkspaceEntry> workspaces;
-
- private String authenticationPolicy;
-
- private long sessionTimeOut;
-
- public RepositoryEntry()
- {
- workspaces = new ArrayList<WorkspaceEntry>();
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- /**
- * Get system workspace name.
- *
- * @return Returns the systemWorkspace.
- */
- public String getSystemWorkspaceName()
- {
- return systemWorkspaceName;
- }
-
- /**
- * Set system workspace name.
- *
- * @param systemWorkspace
- * The systemWorkspace to set.
- */
- public void setSystemWorkspaceName(String systemWorkspace)
- {
- this.systemWorkspaceName = systemWorkspace;
- }
-
- /**
- * Get workspaces.
- *
- * @return Returns the workspaces.
- */
- public List<WorkspaceEntry> getWorkspaceEntries()
- {
- return workspaces;
- }
-
- public void addWorkspace(WorkspaceEntry ws)
- {
- workspaces.add(ws);
- }
-
- /**
- * Get Access control.
- *
- * @return Returns the accessControl.
- */
- public String getAccessControl()
- {
- return accessControl;
- }
-
- /**
- * Set access control.
- *
- * @param accessControl
- * The accessControl to set.
- */
- public void setAccessControl(String accessControl)
- {
- this.accessControl = accessControl;
- }
-
- /**
- * Get security domain.
- *
- * @return Returns the securityDomain.
- */
- public String getSecurityDomain()
- {
- return securityDomain;
- }
-
- /**
- * Set security domain.
- *
- * @param securityDomain
- * The securityDomain to set.
- */
- public void setSecurityDomain(String securityDomain)
- {
- this.securityDomain = securityDomain;
- }
-
- /**
- * Get authentication policy.
- *
- * @return Returns the authenticationPolicy.
- */
- public String getAuthenticationPolicy()
- {
- return authenticationPolicy;
- }
-
- /**
- * Set authentication policy.
- *
- * @param authenticationPolicy
- * The authenticationPolicy to set.
- */
- public void setAuthenticationPolicy(String authenticationPolicy)
- {
- this.authenticationPolicy = authenticationPolicy;
- }
-
- /**
- * Get default workspace name.
- *
- * @return Returns the defaultWorkspaceName.
- */
- public String getDefaultWorkspaceName()
- {
- return defaultWorkspaceName;
- }
-
- /**
- * Set default workspace name.
- *
- * @param defaultWorkspaceName
- * The defaultWorkspaceName to set.
- */
- public void setDefaultWorkspaceName(String defaultWorkspaceName)
- {
- this.defaultWorkspaceName = defaultWorkspaceName;
- }
-
- public long getSessionTimeOut()
- {
- return sessionTimeOut;
- }
-
- public void setSessionTimeOut(long sessionTimeOut)
- {
- this.sessionTimeOut = sessionTimeOut;
- }
-
-}
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.config;
+
+import java.util.ArrayList;
+
+/**
+ * Created by The eXo Platform SAS .
+ *
+ * @author <a href="mailto:gavrikvetal@gmail.com">Vitaliy
Gulyy</a>
+ * @version $
+ */
+
+public class RepositoryEntry extends RepositoryInfo
+{
+
+ protected ArrayList<WorkspaceEntry> workspaces;
+
+ public RepositoryEntry()
+ {
+ workspaces = new ArrayList<WorkspaceEntry>();
+ }
+
+ /**
+ * Get workspaces.
+ *
+ * @return Returns the workspaces.
+ */
+ public ArrayList<WorkspaceEntry> getWorkspaceEntries()
+ {
+ return workspaces;
+ }
+
+ /**
+ * adds workspace entry object
+ * @param ws
+ */
+ public void addWorkspace(WorkspaceEntry ws)
+ {
+ workspaces.add(ws);
+ }
+
+}
Added:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryInfo.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryInfo.java
(rev 0)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryInfo.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -0,0 +1,192 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.config;
+
+/**
+ * Created by The eXo Platform SAS.
+ *
+ * @author <a href="mailto:geaz@users.sourceforge.net">Gennady Azarenkov
</a>
+ * @version $Id: $
+ *
+ * Short repository info, does not include workspaces collection.
+ * Tends to be extended with some workspaces collection info.
+ *
+ */
+
+public class RepositoryInfo
+{
+
+ protected String name;
+
+ protected String systemWorkspaceName;
+
+ protected String defaultWorkspaceName;
+
+ protected String accessControl;
+
+ protected String securityDomain;
+
+ protected String authenticationPolicy;
+
+ protected long sessionTimeOut;
+
+ public RepositoryInfo()
+ {
+
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+ /**
+ * @param name
+ */
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * Get system workspace name.
+ *
+ * @return Returns the systemWorkspace.
+ */
+ public String getSystemWorkspaceName()
+ {
+ return systemWorkspaceName;
+ }
+
+ /**
+ * Set system workspace name.
+ *
+ * @param systemWorkspace
+ * The systemWorkspace to set.
+ */
+ public void setSystemWorkspaceName(String systemWorkspace)
+ {
+ this.systemWorkspaceName = systemWorkspace;
+ }
+
+ /**
+ * Get Access control.
+ *
+ * @return Returns the accessControl.
+ */
+ public String getAccessControl()
+ {
+ return accessControl;
+ }
+
+ /**
+ * Set access control.
+ *
+ * @param accessControl
+ * The accessControl to set.
+ */
+ public void setAccessControl(String accessControl)
+ {
+ this.accessControl = accessControl;
+ }
+
+ /**
+ * Get security domain.
+ *
+ * @return Returns the securityDomain.
+ */
+ public String getSecurityDomain()
+ {
+ return securityDomain;
+ }
+
+ /**
+ * Set security domain.
+ *
+ * @param securityDomain
+ * The securityDomain to set.
+ */
+ public void setSecurityDomain(String securityDomain)
+ {
+ this.securityDomain = securityDomain;
+ }
+
+ /**
+ * Get authentication policy.
+ *
+ * @return Returns the authenticationPolicy.
+ */
+ public String getAuthenticationPolicy()
+ {
+ return authenticationPolicy;
+ }
+
+ /**
+ * Set authentication policy.
+ *
+ * @param authenticationPolicy
+ * The authenticationPolicy to set.
+ */
+ public void setAuthenticationPolicy(String authenticationPolicy)
+ {
+ this.authenticationPolicy = authenticationPolicy;
+ }
+
+ /**
+ * Get default workspace name.
+ *
+ * @return Returns the defaultWorkspaceName.
+ */
+ public String getDefaultWorkspaceName()
+ {
+ return defaultWorkspaceName;
+ }
+
+ /**
+ * Set default workspace name.
+ *
+ * @param defaultWorkspaceName
+ * The defaultWorkspaceName to set.
+ */
+ public void setDefaultWorkspaceName(String defaultWorkspaceName)
+ {
+ this.defaultWorkspaceName = defaultWorkspaceName;
+ }
+
+ /**
+ * @return session timeout in milliseconds
+ */
+ public long getSessionTimeOut()
+ {
+ return sessionTimeOut;
+ }
+
+ /**
+ * sets session timeout in milliseconds
+ * @param sessionTimeOut
+ */
+ public void setSessionTimeOut(long sessionTimeOut)
+ {
+ this.sessionTimeOut = sessionTimeOut;
+ }
+
+}
Property changes on:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryInfo.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryServiceConfiguration.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryServiceConfiguration.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/RepositoryServiceConfiguration.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -19,7 +19,6 @@
package org.exoplatform.services.jcr.config;
import java.io.InputStream;
-import java.util.List;
import javax.jcr.RepositoryException;
@@ -35,29 +34,14 @@
* @version $Id: RepositoryServiceConfiguration.java 2038 2005-10-05 16:50:11Z geaz $
*/
-public class RepositoryServiceConfiguration
+public class RepositoryServiceConfiguration extends
AbstractRepositoryServiceConfiguration
{
- private List<RepositoryEntry> repositoryConfigurations;
-
- private String defaultRepositoryName;
-
- public final String getDefaultRepositoryName()
- {
- return defaultRepositoryName;
- }
-
- public final List<RepositoryEntry> getRepositoryConfigurations()
- {
- return repositoryConfigurations;
- }
-
public final RepositoryEntry getRepositoryConfiguration(String name) throws
RepositoryConfigurationException
{
-
- for (int i = 0; i < repositoryConfigurations.size(); i++)
+ for (int i = 0; i < getRepositoryConfigurations().size(); i++)
{
- RepositoryEntry conf = repositoryConfigurations.get(i);
+ RepositoryEntry conf = (RepositoryEntry)getRepositoryConfigurations().get(i);
if (conf.getName().equals(name))
return conf;
}
@@ -70,10 +54,15 @@
{
IBindingFactory factory =
BindingDirectory.getFactory(RepositoryServiceConfiguration.class);
IUnmarshallingContext uctx = factory.createUnmarshallingContext();
- RepositoryServiceConfiguration conf = (RepositoryServiceConfiguration)
uctx.unmarshalDocument(is, null);
+ RepositoryServiceConfiguration conf =
(RepositoryServiceConfiguration)uctx.unmarshalDocument(is, null);
this.defaultRepositoryName = conf.getDefaultRepositoryName();
this.repositoryConfigurations = conf.getRepositoryConfigurations();
+
+ // setDefaultRepositoryName(conf.getDefaultRepositoryName());
+ // getRepositoryConfigurations().clear();
+ //
getRepositoryConfigurations().addAll(conf.getRepositoryConfigurations());
+
}
catch (JiBXException e)
{
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/ValueStorageEntry.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/ValueStorageEntry.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/ValueStorageEntry.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -27,8 +27,7 @@
* @version $Id: ValueStorageEntry.java 11907 2008-03-13 15:36:21Z ksm $
*/
-public class ValueStorageEntry
- extends MappedParametrizedObjectEntry
+public class ValueStorageEntry extends MappedParametrizedObjectEntry
{
private String id;
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/WorkspaceEntry.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/WorkspaceEntry.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/WorkspaceEntry.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -1,194 +1,196 @@
-/*
- * Copyright (C) 2009 eXo Platform SAS.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.exoplatform.services.jcr.config;
-
-/**
- * Created by The eXo Platform SAS.
- *
- * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
Azarenkov </a>
- * @version $Id: WorkspaceEntry.java 13991 2008-05-08 11:07:05Z pnedonosko $
- */
-public class WorkspaceEntry
-{
-
- private String name;
-
- private String autoInitializedRootNt;
-
- private ContainerEntry container;
-
- private QueryHandlerEntry queryHandler;
-
- private CacheEntry cache;
-
- private String uniqueName;
-
- private AccessManagerEntry accessManager;
-
- private LockManagerEntry lockManager;
-
- private WorkspaceInitializerEntry initializer;
-
- private String autoInitPermissions;
-
- public WorkspaceEntry()
- {
-
- }
-
- public WorkspaceEntry(String name, String rootNt)
- {
- this.name = name;
- this.autoInitializedRootNt = rootNt;
-
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-
- /**
- * @return Returns the autoInitializedRootNt.
- */
- @Deprecated
- public String getAutoInitializedRootNt()
- {
- return autoInitializedRootNt;
- }
-
- /**
- * @param autoInitializedRootNt
- * The autoInitializedRootNt to set.
- */
- @Deprecated
- public void setAutoInitializedRootNt(String autoInitializedRootNt)
- {
- this.autoInitializedRootNt = autoInitializedRootNt;
- }
-
- /**
- * @return Returns the container.
- */
- public ContainerEntry getContainer()
- {
- return container;
- }
-
- /**
- * @param container
- * The container to set.
- */
- public void setContainer(ContainerEntry container)
- {
- this.container = container;
- }
-
- /**
- * @return Returns the cache.
- */
- public CacheEntry getCache()
- {
- return cache;
- }
-
- /**
- * @param cache
- * The cache to set.
- */
- public void setCache(CacheEntry cache)
- {
- this.cache = cache;
- }
-
- /**
- * @return Returns the uniqueName.
- */
- public String getUniqueName()
- {
- return uniqueName;
- }
-
- /**
- * @param uniqueName
- * The uniqueName to set.
- */
- public void setUniqueName(String uniqueName)
- {
- this.uniqueName = uniqueName;
- }
-
- public AccessManagerEntry getAccessManager()
- {
- return accessManager;
- }
-
- public void setAccessManager(AccessManagerEntry accessManager)
- {
- this.accessManager = accessManager;
- }
-
- @Deprecated
- public String getAutoInitPermissions()
- {
- return autoInitPermissions;
- }
-
- @Deprecated
- public void setAutoInitPermissions(String autoInitPermissions)
- {
- this.autoInitPermissions = autoInitPermissions;
- }
-
- public LockManagerEntry getLockManager()
- {
- return lockManager;
- }
-
- public void setLockManager(LockManagerEntry lockManager)
- {
- this.lockManager = lockManager;
- }
-
- public QueryHandlerEntry getQueryHandler()
- {
- return queryHandler;
- }
-
- public void setQueryHandler(QueryHandlerEntry queryHandlerEntry)
- {
- this.queryHandler = queryHandlerEntry;
- }
-
- public WorkspaceInitializerEntry getInitializer()
- {
- return initializer;
- }
-
- public void setInitializer(WorkspaceInitializerEntry initializer)
- {
- this.initializer = initializer;
- }
-
-}
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.services.jcr.config;
+
+/**
+ * Created by The eXo Platform SAS .
+ *
+ * @author <a href="mailto:gavrikvetal@gmail.com">Vitaliy
Gulyy</a>
+ * @version $
+ */
+
+public class WorkspaceEntry
+{
+
+ protected String name;
+
+ @Deprecated
+ protected String autoInitializedRootNt;
+
+ protected ContainerEntry container;
+
+ protected QueryHandlerEntry queryHandler;
+
+ protected CacheEntry cache;
+
+ protected transient String uniqueName;
+
+ protected AccessManagerEntry accessManager;
+
+ protected LockManagerEntry lockManager;
+
+ protected WorkspaceInitializerEntry initializer;
+
+ @Deprecated
+ protected String autoInitPermissions;
+
+ public WorkspaceEntry()
+ {
+ }
+
+ @Deprecated
+ public WorkspaceEntry(String name, String rootNt)
+ {
+ this.name = name;
+ this.autoInitializedRootNt = rootNt;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ /**
+ * @return Returns the autoInitializedRootNt.
+ */
+ @Deprecated
+ public String getAutoInitializedRootNt()
+ {
+ return autoInitializedRootNt;
+ }
+
+ /**
+ * @param autoInitializedRootNt
+ * The autoInitializedRootNt to set.
+ */
+ @Deprecated
+ public void setAutoInitializedRootNt(String autoInitializedRootNt)
+ {
+ this.autoInitializedRootNt = autoInitializedRootNt;
+ }
+
+ /**
+ * @return Returns the container.
+ */
+ public ContainerEntry getContainer()
+ {
+ return container;
+ }
+
+ /**
+ * @param container
+ * The container to set.
+ */
+ public void setContainer(ContainerEntry container)
+ {
+ this.container = container;
+ }
+
+ /**
+ * @return Returns the cache.
+ */
+ public CacheEntry getCache()
+ {
+ return cache;
+ }
+
+ /**
+ * @param cache
+ * The cache to set.
+ */
+ public void setCache(CacheEntry cache)
+ {
+ this.cache = cache;
+ }
+
+ /**
+ * @return Returns the uniqueName.
+ */
+ public String getUniqueName()
+ {
+ return uniqueName;
+ }
+
+ /**
+ * @param uniqueName
+ * The uniqueName to set.
+ */
+ public void setUniqueName(String uniqueName)
+ {
+ this.uniqueName = uniqueName;
+ }
+
+ public AccessManagerEntry getAccessManager()
+ {
+ return accessManager;
+ }
+
+ public void setAccessManager(AccessManagerEntry accessManager)
+ {
+ this.accessManager = accessManager;
+ }
+
+ @Deprecated
+ public String getAutoInitPermissions()
+ {
+ return autoInitPermissions;
+ }
+
+ @Deprecated
+ public void setAutoInitPermissions(String autoInitPermissions)
+ {
+ this.autoInitPermissions = autoInitPermissions;
+ }
+
+ public LockManagerEntry getLockManager()
+ {
+ return lockManager;
+ }
+
+ public void setLockManager(LockManagerEntry lockManager)
+ {
+ this.lockManager = lockManager;
+ }
+
+ public QueryHandlerEntry getQueryHandler()
+ {
+ return queryHandler;
+ }
+
+ public void setQueryHandler(QueryHandlerEntry queryHandlerEntry)
+ {
+ this.queryHandler = queryHandlerEntry;
+ }
+
+ public WorkspaceInitializerEntry getInitializer()
+ {
+ return initializer;
+ }
+
+ public void setInitializer(WorkspaceInitializerEntry initializer)
+ {
+ this.initializer = initializer;
+ }
+
+}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/WorkspaceInitializerEntry.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/WorkspaceInitializerEntry.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/config/WorkspaceInitializerEntry.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -26,8 +26,7 @@
* @author <a href="mailto:peter.nedonosko@exoplatform.com.ua">Peter
Nedonosko</a>
* @version $Id: WorkspaceInitializerEntry.java 111 2008-11-11 11:11:11Z peterit $
*/
-public class WorkspaceInitializerEntry
- extends MappedParametrizedObjectEntry
+public class WorkspaceInitializerEntry extends MappedParametrizedObjectEntry
{
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -41,6 +41,7 @@
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.services.document.DocumentReaderService;
import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.QueryHandlerEntryWrapper;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
@@ -60,536 +61,455 @@
/**
* Acts as a global entry point to execute queries and index nodes.
*/
-public class SearchManager
- implements Startable, MandatoryItemsPersistenceListener
-{
+public class SearchManager implements Startable, MandatoryItemsPersistenceListener {
- /**
- * Logger instance for this class
- */
- private static final Log log = ExoLogger.getLogger(SearchManager.class);
+ /**
+ * Logger instance for this class
+ */
+ private static final Log log =
ExoLogger.getLogger(SearchManager.class);
- protected final QueryHandlerEntry config;
+ protected final QueryHandlerEntryWrapper config;
- /**
- * Text extractor for extracting text content of binary properties.
- */
- protected final DocumentReaderService extractor;
+ /**
+ * Text extractor for extracting text content of binary properties.
+ */
+ protected final DocumentReaderService extractor;
- /**
- * QueryHandler where query execution is delegated to
- */
- protected QueryHandler handler;
+ /**
+ * QueryHandler where query execution is delegated to
+ */
+ protected QueryHandler handler;
- /**
- * The shared item state manager instance for the workspace.
- */
- protected final ItemDataConsumer itemMgr;
+ /**
+ * The shared item state manager instance for the workspace.
+ */
+ protected final ItemDataConsumer itemMgr;
- /**
- * The namespace registry of the repository.
- */
- protected final NamespaceRegistryImpl nsReg;
+ /**
+ * The namespace registry of the repository.
+ */
+ protected final NamespaceRegistryImpl nsReg;
- /**
- * The node type registry.
- */
- protected final NodeTypeDataManager nodeTypeDataManager;
+ /**
+ * The node type registry.
+ */
+ protected final NodeTypeDataManager nodeTypeDataManager;
- /**
- * QueryHandler of the parent search manager or <code>null</code> if there
is
- * none.
- */
- protected final SearchManager parentSearchManager;
+ /**
+ * QueryHandler of the parent search manager or <code>null</code> if there
is
+ * none.
+ */
+ protected final SearchManager parentSearchManager;
- protected QPath indexingRoot;
+ protected QPath indexingRoot;
- protected List<QPath> excludedPaths = new ArrayList<QPath>();
+ protected List<QPath> excludedPaths = new
ArrayList<QPath>();
- private final ConfigurationManager cfm;
+ private final ConfigurationManager cfm;
- /**
- * Creates a new <code>SearchManager</code>.
- *
- * @param config the search configuration.
- * @param nsReg the namespace registry.
- * @param ntReg the node type registry.
- * @param itemMgr the shared item state manager.
- * @param rootNodeId the id of the root node.
- * @param parentMgr the parent search manager or <code>null</code> if
there is
- * no parent search manager.
- * @param excludedNodeId id of the node that should be excluded from indexing.
- * Any descendant of that node will also be excluded from indexing.
- * @throws RepositoryException if the search manager cannot be initialized
- * @throws RepositoryConfigurationException
- */
- public SearchManager(QueryHandlerEntry config, NamespaceRegistryImpl nsReg,
NodeTypeDataManager ntReg,
- WorkspacePersistentDataManager itemMgr, SystemSearchManagerHolder
parentSearchManager,
- DocumentReaderService extractor, ConfigurationManager cfm) throws
RepositoryException,
- RepositoryConfigurationException
- {
+ /**
+ * Creates a new <code>SearchManager</code>.
+ *
+ * @param config the search configuration.
+ * @param nsReg the namespace registry.
+ * @param ntReg the node type registry.
+ * @param itemMgr the shared item state manager.
+ * @param rootNodeId the id of the root node.
+ * @param parentMgr the parent search manager or <code>null</code> if there
is
+ * no parent search manager.
+ * @param excludedNodeId id of the node that should be excluded from indexing.
+ * Any descendant of that node will also be excluded from indexing.
+ * @throws RepositoryException if the search manager cannot be initialized
+ * @throws RepositoryConfigurationException
+ */
+ public SearchManager(QueryHandlerEntry config,
+ NamespaceRegistryImpl nsReg,
+ NodeTypeDataManager ntReg,
+ WorkspacePersistentDataManager itemMgr,
+ SystemSearchManagerHolder parentSearchManager,
+ DocumentReaderService extractor,
+ ConfigurationManager cfm) throws RepositoryException,
+ RepositoryConfigurationException {
- this.extractor = extractor;
+ this.extractor = extractor;
- this.config = config;
- this.nodeTypeDataManager = ntReg;
- this.nsReg = nsReg;
- this.itemMgr = itemMgr;
- this.cfm = cfm;
+ this.config = new QueryHandlerEntryWrapper(config);
+ this.nodeTypeDataManager = ntReg;
+ this.nsReg = nsReg;
+ this.itemMgr = itemMgr;
+ this.cfm = cfm;
- this.parentSearchManager = parentSearchManager != null ? parentSearchManager.get()
: null;
- itemMgr.addItemPersistenceListener(this);
- initializeQueryHandler();
- }
+ this.parentSearchManager = parentSearchManager != null ? parentSearchManager.get() :
null;
+ itemMgr.addItemPersistenceListener(this);
+
+ initializeQueryHandler();
+ }
- /**
- * Creates a query object from a node that can be executed on the workspace.
- *
- * @param session the session of the user executing the query.
- * @param itemMgr the item manager of the user executing the query. Needed to
- * return <code>Node</code> instances in the result set.
- * @param node a node of type nt:query.
- * @return a <code>Query</code> instance to execute.
- * @throws InvalidQueryException if <code>absPath</code> is not a valid
- * persisted query (that is, a node of type nt:query)
- * @throws RepositoryException if any other error occurs.
- */
- public Query createQuery(SessionImpl session, SessionDataManager sessionDataManager,
Node node)
- throws InvalidQueryException, RepositoryException
- {
- AbstractQueryImpl query = handler.createQueryInstance();
- query.init(session, sessionDataManager, handler, node);
- return query;
- }
+ /**
+ * Creates a query object from a node that can be executed on the workspace.
+ *
+ * @param session the session of the user executing the query.
+ * @param itemMgr the item manager of the user executing the query. Needed to
+ * return <code>Node</code> instances in the result set.
+ * @param node a node of type nt:query.
+ * @return a <code>Query</code> instance to execute.
+ * @throws InvalidQueryException if <code>absPath</code> is not a valid
+ * persisted query (that is, a node of type nt:query)
+ * @throws RepositoryException if any other error occurs.
+ */
+ public Query createQuery(SessionImpl session, SessionDataManager sessionDataManager,
Node node) throws InvalidQueryException,
+
RepositoryException {
+ AbstractQueryImpl query = handler.createQueryInstance();
+ query.init(session, sessionDataManager, handler, node);
+ return query;
+ }
- /**
- * Creates a query object that can be executed on the workspace.
- *
- * @param session the session of the user executing the query.
- * @param itemMgr the item manager of the user executing the query. Needed to
- * return <code>Node</code> instances in the result set.
- * @param statement the actual query statement.
- * @param language the syntax of the query statement.
- * @return a <code>Query</code> instance to execute.
- * @throws InvalidQueryException if the query is malformed or the
- * <code>language</code> is unknown.
- * @throws RepositoryException if any other error occurs.
- */
- public Query createQuery(SessionImpl session, SessionDataManager sessionDataManager,
String statement,
- String language) throws InvalidQueryException, RepositoryException
- {
- AbstractQueryImpl query = handler.createQueryInstance();
- query.init(session, sessionDataManager, handler, statement, language);
- return query;
- }
+ /**
+ * Creates a query object that can be executed on the workspace.
+ *
+ * @param session the session of the user executing the query.
+ * @param itemMgr the item manager of the user executing the query. Needed to
+ * return <code>Node</code> instances in the result set.
+ * @param statement the actual query statement.
+ * @param language the syntax of the query statement.
+ * @return a <code>Query</code> instance to execute.
+ * @throws InvalidQueryException if the query is malformed or the
+ * <code>language</code> is unknown.
+ * @throws RepositoryException if any other error occurs.
+ */
+ public Query createQuery(SessionImpl session,
+ SessionDataManager sessionDataManager,
+ String statement,
+ String language) throws InvalidQueryException,
RepositoryException {
+ AbstractQueryImpl query = handler.createQueryInstance();
+ query.init(session, sessionDataManager, handler, statement, language);
+ return query;
+ }
- /**
- * just for test use only
- */
- public QueryHandler getHandler()
- {
+ /**
+ * just for test use only
+ */
+ public QueryHandler getHandler() {
- return handler;
- }
+ return handler;
+ }
- public void onSaveItems(ItemStateChangesLog changesLog)
- {
- if (handler == null)
- return;
+ public void onSaveItems(ItemStateChangesLog changesLog) {
+ if (handler == null)
+ return;
- long time = System.currentTimeMillis();
+ long time = System.currentTimeMillis();
- // nodes that need to be removed from the index.
- final Set<String> removedNodes = new HashSet<String>();
- // nodes that need to be added to the index.
- final Set<String> addedNodes = new HashSet<String>();
+ // nodes that need to be removed from the index.
+ final Set<String> removedNodes = new HashSet<String>();
+ // nodes that need to be added to the index.
+ final Set<String> addedNodes = new HashSet<String>();
- final Map<String, List<ItemState>> updatedNodes = new
HashMap<String, List<ItemState>>();
+ final Map<String, List<ItemState>> updatedNodes = new HashMap<String,
List<ItemState>>();
- for (Iterator<ItemState> iter = changesLog.getAllStates().iterator();
iter.hasNext();)
- {
- ItemState itemState = iter.next();
+ for (Iterator<ItemState> iter = changesLog.getAllStates().iterator();
iter.hasNext();) {
+ ItemState itemState = iter.next();
- if (!isExcluded(itemState))
- {
- String uuid =
- itemState.isNode() ? itemState.getData().getIdentifier() :
itemState.getData()
- .getParentIdentifier();
+ if (!isExcluded(itemState)) {
+ String uuid = itemState.isNode() ? itemState.getData().getIdentifier()
+ : itemState.getData().getParentIdentifier();
- if (itemState.isAdded())
- {
- if (itemState.isNode())
- {
- addedNodes.add(uuid);
- }
- else
- {
- if (!addedNodes.contains(uuid))
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- }
+ if (itemState.isAdded()) {
+ if (itemState.isNode()) {
+ addedNodes.add(uuid);
+ } else {
+ if (!addedNodes.contains(uuid)) {
+ createNewOrAdd(uuid, itemState, updatedNodes);
}
- else if (itemState.isRenamed())
- {
- if (itemState.isNode())
- {
- addedNodes.add(uuid);
- }
- else
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
+ }
+ } else if (itemState.isRenamed()) {
+ if (itemState.isNode()) {
+ addedNodes.add(uuid);
+ } else {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ }
+ } else if (itemState.isUpdated()) {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ } else if (itemState.isMixinChanged()) {
+ createNewOrAdd(uuid, itemState, updatedNodes);
+ } else if (itemState.isDeleted()) {
+ if (itemState.isNode()) {
+ if (addedNodes.contains(uuid)) {
+ addedNodes.remove(uuid);
+ removedNodes.remove(uuid);
+ } else {
+ removedNodes.add(uuid);
}
- else if (itemState.isUpdated())
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
+ // remove all changes after node remove
+ updatedNodes.remove(uuid);
+ } else {
+ if (!removedNodes.contains(uuid) && !addedNodes.contains(uuid)) {
+ createNewOrAdd(uuid, itemState, updatedNodes);
}
- else if (itemState.isMixinChanged())
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- else if (itemState.isDeleted())
- {
- if (itemState.isNode())
- {
- if (addedNodes.contains(uuid))
- {
- addedNodes.remove(uuid);
- removedNodes.remove(uuid);
- }
- else
- {
- removedNodes.add(uuid);
- }
- // remove all changes after node remove
- updatedNodes.remove(uuid);
- }
- else
- {
- if (!removedNodes.contains(uuid) &&
!addedNodes.contains(uuid))
- {
- createNewOrAdd(uuid, itemState, updatedNodes);
- }
- }
- }
- }
+ }
+ }
}
- // TODO make quick changes
- for (String uuid : updatedNodes.keySet())
- {
- removedNodes.add(uuid);
- addedNodes.add(uuid);
- }
+ }
+ // TODO make quick changes
+ for (String uuid : updatedNodes.keySet()) {
+ removedNodes.add(uuid);
+ addedNodes.add(uuid);
+ }
- // // property events
- // List<ItemState> propEvents = new ArrayList<ItemState>();
- // List<ItemState> itemStates = changesLog.getAllStates();
- //
- // final Set<String> allRemovedNodesId = new HashSet<String>();
- // final Set<String> allAddedNodesId = new HashSet<String>();
- // for (ItemState itemState : itemStates) {
- // if (!isExcluded(itemState)) {
- // if (itemState.isNode()) {
- // if (itemState.isAdded() || itemState.isRenamed()) {
- // addedNodes.add(itemState.getData().getIdentifier());
- // allAddedNodesId.add(itemState.getData().getIdentifier());
- // } else if (itemState.isDeleted()) {
- // // remove node from add list, and if node not in add list add it to
- // // removed list
- // if (!addedNodes.remove(itemState.getData().getIdentifier()))
- // removedNodes.add(itemState.getData().getIdentifier());
- // allRemovedNodesId.add(itemState.getData().getIdentifier());
- // } else if (itemState.isMixinChanged()) {
- // removedNodes.add(itemState.getData().getIdentifier());
- // addedNodes.add(itemState.getData().getIdentifier());
- // }
- // } else {
- // propEvents.add(itemState);
- // }
- // }
- // }
- //
- // // sort out property events
- // for (int i = 0; i < propEvents.size(); i++) {
- // ItemState event = propEvents.get(i);
- // String nodeId = event.getData().getParentIdentifier();
- // if (event.isAdded()) {
- // if (!addedNodes.contains(nodeId) && !allAddedNodesId.contains(nodeId))
{
- // // only property added
- // // need to re-index
- // addedNodes.add(nodeId);
- // removedNodes.add(nodeId);
- // } else {
- // // the node where this prop belongs to is also new
- // }
- // } else if (event.isRenamed() || event.isUpdated()) {
- // // need to re-index
- // addedNodes.add(nodeId);
- // removedNodes.add(nodeId);
- // } else if (event.isDeleted()) {
- // if (!allRemovedNodesId.contains(nodeId)) {
- // addedNodes.add(nodeId);
- // removedNodes.add(nodeId);
- // }
- // }
- // }
+ // // property events
+ // List<ItemState> propEvents = new ArrayList<ItemState>();
+ // List<ItemState> itemStates = changesLog.getAllStates();
+ //
+ // final Set<String> allRemovedNodesId = new HashSet<String>();
+ // final Set<String> allAddedNodesId = new HashSet<String>();
+ // for (ItemState itemState : itemStates) {
+ // if (!isExcluded(itemState)) {
+ // if (itemState.isNode()) {
+ // if (itemState.isAdded() || itemState.isRenamed()) {
+ // addedNodes.add(itemState.getData().getIdentifier());
+ // allAddedNodesId.add(itemState.getData().getIdentifier());
+ // } else if (itemState.isDeleted()) {
+ // // remove node from add list, and if node not in add list add it to
+ // // removed list
+ // if (!addedNodes.remove(itemState.getData().getIdentifier()))
+ // removedNodes.add(itemState.getData().getIdentifier());
+ // allRemovedNodesId.add(itemState.getData().getIdentifier());
+ // } else if (itemState.isMixinChanged()) {
+ // removedNodes.add(itemState.getData().getIdentifier());
+ // addedNodes.add(itemState.getData().getIdentifier());
+ // }
+ // } else {
+ // propEvents.add(itemState);
+ // }
+ // }
+ // }
+ //
+ // // sort out property events
+ // for (int i = 0; i < propEvents.size(); i++) {
+ // ItemState event = propEvents.get(i);
+ // String nodeId = event.getData().getParentIdentifier();
+ // if (event.isAdded()) {
+ // if (!addedNodes.contains(nodeId) && !allAddedNodesId.contains(nodeId)) {
+ // // only property added
+ // // need to re-index
+ // addedNodes.add(nodeId);
+ // removedNodes.add(nodeId);
+ // } else {
+ // // the node where this prop belongs to is also new
+ // }
+ // } else if (event.isRenamed() || event.isUpdated()) {
+ // // need to re-index
+ // addedNodes.add(nodeId);
+ // removedNodes.add(nodeId);
+ // } else if (event.isDeleted()) {
+ // if (!allRemovedNodesId.contains(nodeId)) {
+ // addedNodes.add(nodeId);
+ // removedNodes.add(nodeId);
+ // }
+ // }
+ // }
- Iterator<NodeData> addedStates = new Iterator<NodeData>()
- {
- private final Iterator<String> iter = addedNodes.iterator();
+ Iterator<NodeData> addedStates = new Iterator<NodeData>() {
+ private final Iterator<String> iter = addedNodes.iterator();
- public boolean hasNext()
- {
- return iter.hasNext();
- }
+ public boolean hasNext() {
+ return iter.hasNext();
+ }
- public NodeData next()
- {
+ public NodeData next() {
- // cycle till find a next or meet the end of set
- do
- {
- String id = iter.next();
- try
- {
- ItemData item = itemMgr.getItemData(id);
- if (item != null)
- {
- if (item.isNode())
- return (NodeData) item; // return node
- else
- log.warn("Node not found, but property " + id + ",
" + item.getQPath().getAsString()
- + " found. ");
- }
- else
- log.warn("Unable to index node with id " + id + ",
node does not exist.");
+ // cycle till find a next or meet the end of set
+ do {
+ String id = iter.next();
+ try {
+ ItemData item = itemMgr.getItemData(id);
+ if (item != null) {
+ if (item.isNode())
+ return (NodeData) item; // return node
+ else
+ log.warn("Node not found, but property " + id + ", "
+ + item.getQPath().getAsString() + " found. ");
+ } else
+ log.warn("Unable to index node with id " + id + ", node does
not exist.");
- }
- catch (RepositoryException e)
- {
- log.error("Can't read next node data " + id, e);
- }
- }
- while (iter.hasNext()); // get next if error or node not found
+ } catch (RepositoryException e) {
+ log.error("Can't read next node data " + id, e);
+ }
+ } while (iter.hasNext()); // get next if error or node not found
- return null; // we met the end of iterator set
- }
+ return null; // we met the end of iterator set
+ }
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- };
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
- Iterator<String> removedIds = new Iterator<String>()
- {
- private final Iterator<String> iter = removedNodes.iterator();
+ Iterator<String> removedIds = new Iterator<String>() {
+ private final Iterator<String> iter = removedNodes.iterator();
- public boolean hasNext()
- {
- return iter.hasNext();
- }
+ public boolean hasNext() {
+ return iter.hasNext();
+ }
- public String next()
- {
- return nextNodeId();
- }
+ public String next() {
+ return nextNodeId();
+ }
- public String nextNodeId() throws NoSuchElementException
- {
- return iter.next();
- }
+ public String nextNodeId() throws NoSuchElementException {
+ return iter.next();
+ }
- public void remove()
- {
- throw new UnsupportedOperationException();
+ public void remove() {
+ throw new UnsupportedOperationException();
- }
- };
-
- if (removedNodes.size() > 0 || addedNodes.size() > 0)
- {
- try
- {
- handler.updateNodes(removedIds, addedStates);
- }
- catch (RepositoryException e)
- {
- log.error("Error indexing changes " + e, e);
- }
- catch (IOException e)
- {
- log.error("Error indexing changes " + e, e);
- try
- {
- handler.logErrorChanges(removedNodes, addedNodes);
- }
- catch (IOException ioe)
- {
- log.warn("Exception occure when errorLog writed. Error log is not
complete. " + ioe, ioe);
- }
- }
}
+ };
- if (log.isDebugEnabled())
- {
- log.debug("onEvent: indexing finished in " +
String.valueOf(System.currentTimeMillis() - time) + " ms.");
+ if (removedNodes.size() > 0 || addedNodes.size() > 0) {
+ try {
+ handler.updateNodes(removedIds, addedStates);
+ } catch (RepositoryException e) {
+ log.error("Error indexing changes " + e, e);
+ } catch (IOException e) {
+ log.error("Error indexing changes " + e, e);
+ try {
+ handler.logErrorChanges(removedNodes, addedNodes);
+ } catch (IOException ioe) {
+ log.warn("Exception occure when errorLog writed. Error log is not
complete. " + ioe, ioe);
+ }
}
- }
+ }
- public void createNewOrAdd(String key, ItemState state, Map<String,
List<ItemState>> updatedNodes)
- {
- List<ItemState> list = updatedNodes.get(key);
- if (list == null)
- {
- list = new ArrayList<ItemState>();
- updatedNodes.put(key, list);
- }
- list.add(state);
+ if (log.isDebugEnabled()) {
+ log.debug("onEvent: indexing finished in "
+ + String.valueOf(System.currentTimeMillis() - time) + " ms.");
+ }
+ }
- }
+ public void createNewOrAdd(String key, ItemState state, Map<String,
List<ItemState>> updatedNodes) {
+ List<ItemState> list = updatedNodes.get(key);
+ if (list == null) {
+ list = new ArrayList<ItemState>();
+ updatedNodes.put(key, list);
+ }
+ list.add(state);
- public void start()
- {
+ }
- if (log.isDebugEnabled())
- log.debug("start");
+ public void start() {
- // Calculating excluded node identifiers
- excludedPaths.add(Constants.JCR_SYSTEM_PATH);
+ if (log.isDebugEnabled())
+ log.debug("start");
- if (config.getExcludedNodeIdentifers() != null)
- {
- StringTokenizer stringTokenizer = new
StringTokenizer(config.getExcludedNodeIdentifers());
- while (stringTokenizer.hasMoreTokens())
- {
+ // Calculating excluded node identifiers
+ excludedPaths.add(Constants.JCR_SYSTEM_PATH);
- try
- {
- ItemData excludeData = itemMgr.getItemData(stringTokenizer.nextToken());
- if (excludeData != null)
- excludedPaths.add(excludeData.getQPath());
- }
- catch (RepositoryException e)
- {
- log.warn(e.getLocalizedMessage());
- }
- }
+ if (config.getExcludedNodeIdentifers() != null) {
+ StringTokenizer stringTokenizer = new
StringTokenizer(config.getExcludedNodeIdentifers());
+ while (stringTokenizer.hasMoreTokens()) {
+
+ try {
+ ItemData excludeData = itemMgr.getItemData(stringTokenizer.nextToken());
+ if (excludeData != null)
+ excludedPaths.add(excludeData.getQPath());
+ } catch (RepositoryException e) {
+ log.warn(e.getLocalizedMessage());
+ }
}
+ }
- indexingRoot = Constants.ROOT_PATH;
- if (config.getRootNodeIdentifer() != null)
- {
- try
- {
- ItemData indexingRootData =
itemMgr.getItemData(config.getRootNodeIdentifer());
- if (indexingRootData != null && indexingRootData.isNode())
- indexingRoot = indexingRootData.getQPath();
- }
- catch (RepositoryException e)
- {
- log.warn(e.getLocalizedMessage() + " Indexing root set to " +
indexingRoot.getAsString());
- }
-
+ indexingRoot = Constants.ROOT_PATH;
+ if (config.getRootNodeIdentifer() != null) {
+ try {
+ ItemData indexingRootData = itemMgr.getItemData(config.getRootNodeIdentifer());
+ if (indexingRootData != null && indexingRootData.isNode())
+ indexingRoot = indexingRootData.getQPath();
+ } catch (RepositoryException e) {
+ log.warn(e.getLocalizedMessage() + " Indexing root set to " +
indexingRoot.getAsString());
}
- handler.init();
- }
- public void stop()
- {
- handler.close();
- log.info("Search manager stopped");
- }
+ }
+ handler.init();
+ }
- /**
- * Checks if the given event should be excluded based on the
- * {@link #excludePath} setting.
- *
- * @param event observation event
- * @return <code>true</code> if the event should be excluded,
- * <code>false</code> otherwise
- */
- protected boolean isExcluded(ItemState event)
- {
+ public void stop() {
+ handler.close();
+ log.info("Search manager stopped");
+ }
- for (QPath excludedPath : excludedPaths)
- {
- if (event.getData().getQPath().isDescendantOf(excludedPath) ||
event.getData().getQPath().equals(excludedPath))
- return true;
- }
+ /**
+ * Checks if the given event should be excluded based on the
+ * {@link #excludePath} setting.
+ *
+ * @param event observation event
+ * @return <code>true</code> if the event should be excluded,
+ * <code>false</code> otherwise
+ */
+ protected boolean isExcluded(ItemState event) {
- return !event.getData().getQPath().isDescendantOf(indexingRoot)
- && !event.getData().getQPath().equals(indexingRoot);
- }
+ for (QPath excludedPath : excludedPaths) {
+ if (event.getData().getQPath().isDescendantOf(excludedPath)
+ || event.getData().getQPath().equals(excludedPath))
+ return true;
+ }
- protected QueryHandlerContext createQueryHandlerContext(QueryHandler parentHandler)
- throws RepositoryConfigurationException
- {
+ return !event.getData().getQPath().isDescendantOf(indexingRoot)
+ && !event.getData().getQPath().equals(indexingRoot);
+ }
- QueryHandlerContext context =
- new QueryHandlerContext(itemMgr, config.getRootNodeIdentifer() != null ?
config.getRootNodeIdentifer()
- : Constants.ROOT_UUID, nodeTypeDataManager, nsReg, parentHandler,
config.getIndexDir(),
- extractor);
- return context;
- }
+ protected QueryHandlerContext createQueryHandlerContext(QueryHandler parentHandler)
throws RepositoryConfigurationException {
- /**
- * Initializes the query handler.
- *
- * @throws RepositoryException if the query handler cannot be initialized.
- * @throws RepositoryConfigurationException
- * @throws ClassNotFoundException
- */
- private void initializeQueryHandler() throws RepositoryException,
RepositoryConfigurationException
- {
- // initialize query handler
- String className = config.getType();
- if (className == null)
- throw new RepositoryConfigurationException("Content hanler
configuration fail");
+ QueryHandlerContext context = new QueryHandlerContext(itemMgr,
+ config.getRootNodeIdentifer()
!= null ? config.getRootNodeIdentifer()
+
: Constants.ROOT_UUID,
+ nodeTypeDataManager,
+ nsReg,
+ parentHandler,
+ config.getIndexDir(),
+ extractor);
+ return context;
+ }
- try
- {
- Class qHandlerClass = Class.forName(className, true,
this.getClass().getClassLoader());
- Constructor constuctor = qHandlerClass.getConstructor(QueryHandlerEntry.class,
ConfigurationManager.class);
- handler = (QueryHandler) constuctor.newInstance(config, cfm);
+ /**
+ * Initializes the query handler.
+ *
+ * @throws RepositoryException if the query handler cannot be initialized.
+ * @throws RepositoryConfigurationException
+ * @throws ClassNotFoundException
+ */
+ private void initializeQueryHandler() throws RepositoryException,
+ RepositoryConfigurationException {
+ // initialize query handler
+ String className = config.getType();
+ if (className == null)
+ throw new RepositoryConfigurationException("Content hanler configuration
fail");
- QueryHandler parentHandler = (this.parentSearchManager != null) ?
parentSearchManager.getHandler() : null;
- QueryHandlerContext context = createQueryHandlerContext(parentHandler);
- handler.setContext(context);
- }
- catch (SecurityException e)
- {
- throw new RepositoryException(e.getMessage(), e);
- }
- catch (IllegalArgumentException e)
- {
- throw new RepositoryException(e.getMessage(), e);
- }
- catch (ClassNotFoundException e)
- {
- throw new RepositoryException(e.getMessage(), e);
- }
- catch (NoSuchMethodException e)
- {
- throw new RepositoryException(e.getMessage(), e);
- }
- catch (InstantiationException e)
- {
- throw new RepositoryException(e.getMessage(), e);
- }
- catch (IllegalAccessException e)
- {
- throw new RepositoryException(e.getMessage(), e);
- }
- catch (InvocationTargetException e)
- {
- throw new RepositoryException(e.getMessage(), e);
- }
- catch (IOException e)
- {
- throw new RepositoryException(e.getMessage(), e);
- }
- }
+ try {
+ Class qHandlerClass = Class.forName(className, true,
this.getClass().getClassLoader());
+ Constructor constuctor = qHandlerClass.getConstructor(QueryHandlerEntry.class,
ConfigurationManager.class);
+ handler = (QueryHandler) constuctor.newInstance(config.getQueryHandlerEntry(),
cfm);
+ QueryHandler parentHandler = (this.parentSearchManager != null) ?
parentSearchManager.getHandler()
+ : null;
+ QueryHandlerContext context = createQueryHandlerContext(parentHandler);
+ handler.setContext(context);
+ } catch (SecurityException e) {
+ throw new RepositoryException(e.getMessage(), e);
+ } catch (IllegalArgumentException e) {
+ throw new RepositoryException(e.getMessage(), e);
+ } catch (ClassNotFoundException e) {
+ throw new RepositoryException(e.getMessage(), e);
+ } catch (NoSuchMethodException e) {
+ throw new RepositoryException(e.getMessage(), e);
+ } catch (InstantiationException e) {
+ throw new RepositoryException(e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ throw new RepositoryException(e.getMessage(), e);
+ } catch (InvocationTargetException e) {
+ throw new RepositoryException(e.getMessage(), e);
+ } catch (IOException e) {
+ throw new RepositoryException(e.getMessage(), e);
+ }
+ }
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -21,8 +21,6 @@
import javax.jcr.RepositoryException;
-import org.exoplatform.services.log.Log;
-
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.services.document.DocumentReaderService;
import org.exoplatform.services.jcr.config.QueryHandlerEntry;
@@ -33,6 +31,7 @@
import org.exoplatform.services.jcr.impl.core.NamespaceRegistryImpl;
import
org.exoplatform.services.jcr.impl.dataflow.persistent.WorkspacePersistentDataManager;
import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
/**
* Created by The eXo Platform SAS.
@@ -41,69 +40,67 @@
* @version $Id: SystemSearchManager.java 13891 2008-05-05 16:02:30Z pnedonosko
* $
*/
-public class SystemSearchManager
- extends SearchManager
-{
+public class SystemSearchManager extends SearchManager {
- /**
- * Class logger.
- */
- private final Log log = ExoLogger.getLogger("jcr.SystemSearchManager");
+ /**
+ * Class logger.
+ */
+ private final Log log =
ExoLogger.getLogger("jcr.SystemSearchManager");
- /**
- * Is started flag.
- */
- private boolean isStarted = false;
+ /**
+ * Is started flag.
+ */
+ private boolean isStarted = false;
- /**
- * ChangesLog Buffer (used for saves before start).
- */
- private List<ItemStateChangesLog> changesLogBuffer = new
ArrayList<ItemStateChangesLog>();
+ /**
+ * ChangesLog Buffer (used for saves before start).
+ */
+ private List<ItemStateChangesLog> changesLogBuffer = new
ArrayList<ItemStateChangesLog>();
- public static final String INDEX_DIR_SUFFIX = "system";
+ public static final String INDEX_DIR_SUFFIX = "system";
- public SystemSearchManager(QueryHandlerEntry config, NamespaceRegistryImpl nsReg,
NodeTypeDataManager ntReg,
- WorkspacePersistentDataManager itemMgr, DocumentReaderService service,
ConfigurationManager cfm)
- throws RepositoryException, RepositoryConfigurationException
- {
- super(config, nsReg, ntReg, itemMgr, null, service, cfm);
- }
+ public SystemSearchManager(QueryHandlerEntry config,
+ NamespaceRegistryImpl nsReg,
+ NodeTypeDataManager ntReg,
+ WorkspacePersistentDataManager itemMgr,
+ DocumentReaderService service,
+ ConfigurationManager cfm) throws RepositoryException,
+ RepositoryConfigurationException {
+ super(config, nsReg, ntReg, itemMgr, null, service, cfm);
+ }
- @Override
- public void onSaveItems(ItemStateChangesLog changesLog)
- {
- if (!isStarted)
- {
- changesLogBuffer.add(changesLog);
- }
- else
- {
- super.onSaveItems(changesLog);
- }
- }
+ @Override
+ public void onSaveItems(ItemStateChangesLog changesLog) {
+ if (!isStarted) {
+ changesLogBuffer.add(changesLog);
+ } else {
+ super.onSaveItems(changesLog);
+ }
+ }
- @Override
- public void start()
- {
- indexingRoot = Constants.JCR_SYSTEM_PATH;
- excludedPaths.remove(Constants.JCR_SYSTEM_PATH);
- isStarted = true;
- handler.init();
- for (ItemStateChangesLog bufferedChangesLog : changesLogBuffer)
- {
- super.onSaveItems(bufferedChangesLog);
- }
- changesLogBuffer.clear();
- changesLogBuffer = null;
- }
+ @Override
+ public void start() {
+ indexingRoot = Constants.JCR_SYSTEM_PATH;
+ excludedPaths.remove(Constants.JCR_SYSTEM_PATH);
+ isStarted = true;
+ handler.init();
+ for (ItemStateChangesLog bufferedChangesLog : changesLogBuffer) {
+ super.onSaveItems(bufferedChangesLog);
+ }
+ changesLogBuffer.clear();
+ changesLogBuffer = null;
+ }
- @Override
- protected QueryHandlerContext createQueryHandlerContext(QueryHandler parentHandler)
- throws RepositoryConfigurationException
- {
- QueryHandlerContext context =
- new QueryHandlerContext(itemMgr, Constants.SYSTEM_UUID,
nodeTypeDataManager, nsReg, parentHandler,
- config.getIndexDir() + "_" + INDEX_DIR_SUFFIX,
extractor);
- return context;
- }
+ @Override
+ protected QueryHandlerContext createQueryHandlerContext(QueryHandler parentHandler)
throws RepositoryConfigurationException {
+ QueryHandlerContext context = new QueryHandlerContext(itemMgr,
+ Constants.SYSTEM_UUID,
+ nodeTypeDataManager,
+ nsReg,
+ parentHandler,
+ config.getIndexDir() +
"_"
+ + INDEX_DIR_SUFFIX,
+ extractor);
+ return context;
+ }
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -33,6 +33,7 @@
import org.apache.lucene.store.Directory;
import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.QueryHandlerEntryWrapper;
import org.exoplatform.services.log.ExoLogger;
/**
@@ -45,660 +46,547 @@
* {@link #getIndexWriter()} at a time.<br/> Concurrent access by
<b>one</b> modifying thread and
* multiple read-only threads is safe!
*/
-abstract class AbstractIndex
-{
+abstract class AbstractIndex {
- /** The logger instance for this class */
- private static final Log log = ExoLogger.getLogger(AbstractIndex.class);
+ /** The logger instance for this class */
+ private static final Log log =
ExoLogger.getLogger(AbstractIndex.class);
- /** PrintStream that pipes all calls to println(String) into log.info() */
- private static final LoggingPrintStream STREAM_LOGGER = new LoggingPrintStream();
+ /** PrintStream that pipes all calls to println(String) into log.info() */
+ private static final LoggingPrintStream STREAM_LOGGER = new LoggingPrintStream();
- /** Executor with a pool size equal to the number of available processors */
- private static final DynamicPooledExecutor EXECUTOR = new DynamicPooledExecutor();
+ /** Executor with a pool size equal to the number of available processors */
+ private static final DynamicPooledExecutor EXECUTOR = new
DynamicPooledExecutor();
- /** The currently set IndexWriter or <code>null</code> if none is set */
- private IndexWriter indexWriter;
+ /** The currently set IndexWriter or <code>null</code> if none is set */
+ private IndexWriter indexWriter;
- /** The currently set IndexReader or <code>null</code> if none is set */
- private CommittableIndexReader indexReader;
+ /** The currently set IndexReader or <code>null</code> if none is set */
+ private CommittableIndexReader indexReader;
- /** The underlying Directory where the index is stored */
- private Directory directory;
+ /** The underlying Directory where the index is stored */
+ private Directory directory;
- /** Analyzer we use to tokenize text */
- private Analyzer analyzer;
+ /** Analyzer we use to tokenize text */
+ private Analyzer analyzer;
- /** Compound file flag */
- private boolean useCompoundFile = true;
+ /** Compound file flag */
+ private boolean useCompoundFile = true;
- /** minMergeDocs config parameter */
- private int minMergeDocs = new Integer(QueryHandlerEntry.DEFAULT_MIN_MERGE_DOCS);
+ /** minMergeDocs config parameter */
+ private int minMergeDocs = new
Integer(QueryHandlerEntryWrapper.DEFAULT_MIN_MERGE_DOCS);
- /** maxMergeDocs config parameter */
- private int maxMergeDocs = new Integer(QueryHandlerEntry.DEFAULT_MAX_MERGE_DOCS);
+ /** maxMergeDocs config parameter */
+ private int maxMergeDocs = new
Integer(QueryHandlerEntryWrapper.DEFAULT_MAX_MERGE_DOCS);
- /** mergeFactor config parameter */
- private int mergeFactor = new Integer(QueryHandlerEntry.DEFAULT_MERGE_FACTOR);
+ /** mergeFactor config parameter */
+ private int mergeFactor = new
Integer(QueryHandlerEntryWrapper.DEFAULT_MERGE_FACTOR);
- /** maxFieldLength config parameter */
- private int maxFieldLength = new Integer(QueryHandlerEntry.DEFAULT_MAX_FIELD_LENGTH);
+ /** maxFieldLength config parameter */
+ private int maxFieldLength = new
Integer(QueryHandlerEntryWrapper.DEFAULT_MAX_FIELD_LENGTH);
- /**
- * The document number cache if this index may use one.
- */
- private DocNumberCache cache;
+ /**
+ * The document number cache if this index may use one.
+ */
+ private DocNumberCache cache;
- /** The shared IndexReader for all read-only IndexReaders */
- private SharedIndexReader sharedReader;
+ /** The shared IndexReader for all read-only IndexReaders */
+ private SharedIndexReader sharedReader;
- /**
- * The most recent read-only reader if there is any.
- */
- private ReadOnlyIndexReader readOnlyReader;
+ /**
+ * The most recent read-only reader if there is any.
+ */
+ private ReadOnlyIndexReader readOnlyReader;
- /**
- * The indexing queue.
- */
- private IndexingQueue indexingQueue;
+ /**
+ * The indexing queue.
+ */
+ private IndexingQueue indexingQueue;
- /**
- * Constructs an index with an <code>analyzer</code> and a
<code>directory</code>.
- *
- * @param analyzer
- * the analyzer for text tokenizing.
- * @param directory
- * the underlying directory.
- * @param cache
- * the document number cache if this index should use one; otherwise
<code>cache</code>
- * is <code>null</code>.
- * @param indexingQueue
- * the indexing queue.
- * @throws IOException
- * if the index cannot be initialized.
- */
- AbstractIndex(Analyzer analyzer, Directory directory, DocNumberCache cache,
IndexingQueue indexingQueue)
- throws IOException
- {
- this.analyzer = analyzer;
- this.directory = directory;
- this.cache = cache;
- this.indexingQueue = indexingQueue;
+ /**
+ * Constructs an index with an <code>analyzer</code> and a
<code>directory</code>.
+ *
+ * @param analyzer
+ * the analyzer for text tokenizing.
+ * @param directory
+ * the underlying directory.
+ * @param cache
+ * the document number cache if this index should use one; otherwise
<code>cache</code>
+ * is <code>null</code>.
+ * @param indexingQueue
+ * the indexing queue.
+ * @throws IOException
+ * if the index cannot be initialized.
+ */
+ AbstractIndex(Analyzer analyzer,
+ Directory directory,
+ DocNumberCache cache,
+ IndexingQueue indexingQueue) throws IOException {
+ this.analyzer = analyzer;
+ this.directory = directory;
+ this.cache = cache;
+ this.indexingQueue = indexingQueue;
- if (!IndexReader.indexExists(directory))
- {
- indexWriter = new IndexWriter(directory, analyzer);
- // immediately close, now that index has been created
- indexWriter.close();
- indexWriter = null;
- }
- }
+ if (!IndexReader.indexExists(directory)) {
+ indexWriter = new IndexWriter(directory, analyzer);
+ // immediately close, now that index has been created
+ indexWriter.close();
+ indexWriter = null;
+ }
+ }
- /**
- * Default implementation returns the same instance as passed in the constructor.
- *
- * @return the directory instance passed in the constructor
- * @throws IOException
- */
- Directory getDirectory() throws IOException
- {
- return directory;
- }
+ /**
+ * Default implementation returns the same instance as passed in the constructor.
+ *
+ * @return the directory instance passed in the constructor
+ * @throws IOException
+ */
+ Directory getDirectory() throws IOException {
+ return directory;
+ }
- /**
- * Adds documents to this index and invalidates the shared reader.
- *
- * @param docs
- * the documents to add.
- * @throws IOException
- * if an error occurs while writing to the index.
- */
- void addDocuments(Document[] docs) throws IOException
- {
- final IndexWriter writer = getIndexWriter();
- DynamicPooledExecutor.Command commands[] = new
DynamicPooledExecutor.Command[docs.length];
- for (int i = 0; i < docs.length; i++)
- {
- // check if text extractor completed its work
- final Document doc = getFinishedDocument(docs[i]);
- // create a command for inverting the document
- commands[i] = new DynamicPooledExecutor.Command()
- {
- public Object call() throws Exception
- {
- long time = System.currentTimeMillis();
- writer.addDocument(doc);
- return new Long(System.currentTimeMillis() - time);
- }
- };
+ /**
+ * Adds documents to this index and invalidates the shared reader.
+ *
+ * @param docs
+ * the documents to add.
+ * @throws IOException
+ * if an error occurs while writing to the index.
+ */
+ void addDocuments(Document[] docs) throws IOException {
+ final IndexWriter writer = getIndexWriter();
+ DynamicPooledExecutor.Command commands[] = new
DynamicPooledExecutor.Command[docs.length];
+ for (int i = 0; i < docs.length; i++) {
+ // check if text extractor completed its work
+ final Document doc = getFinishedDocument(docs[i]);
+ // create a command for inverting the document
+ commands[i] = new DynamicPooledExecutor.Command() {
+ public Object call() throws Exception {
+ long time = System.currentTimeMillis();
+ writer.addDocument(doc);
+ return new Long(System.currentTimeMillis() - time);
+ }
+ };
+ }
+ DynamicPooledExecutor.Result results[] = EXECUTOR.executeAndWait(commands);
+ invalidateSharedReader();
+ IOException ex = null;
+ for (int i = 0; i < results.length; i++) {
+ if (results[i].getException() != null) {
+ Throwable cause = results[i].getException().getCause();
+ if (ex == null) {
+ // only throw the first exception
+ if (cause instanceof IOException) {
+ ex = (IOException) cause;
+ } else {
+ IOException e = new IOException();
+ e.initCause(cause);
+ ex = e;
+ }
+ } else {
+ // all others are logged
+ log.warn("Exception while inverting document" + cause);
+ }
+ } else {
+ log.debug("Inverted document in" + results[i].get() + "ms");
}
- DynamicPooledExecutor.Result results[] = EXECUTOR.executeAndWait(commands);
- invalidateSharedReader();
- IOException ex = null;
- for (int i = 0; i < results.length; i++)
- {
- if (results[i].getException() != null)
- {
- Throwable cause = results[i].getException().getCause();
- if (ex == null)
- {
- // only throw the first exception
- if (cause instanceof IOException)
- {
- ex = (IOException) cause;
- }
- else
- {
- IOException e = new IOException();
- e.initCause(cause);
- ex = e;
- }
- }
- else
- {
- // all others are logged
- log.warn("Exception while inverting document" + cause);
- }
- }
- else
- {
- log.debug("Inverted document in" + results[i].get() +
"ms");
- }
- }
- if (ex != null)
- {
- throw ex;
- }
- }
+ }
+ if (ex != null) {
+ throw ex;
+ }
+ }
- /**
- * Removes the document from this index. This call will not invalidate the shared
reader. If a
- * subclass whishes to do so, it should overwrite this method and call
- * {@link #invalidateSharedReader()}.
- *
- * @param idTerm
- * the id term of the document to remove.
- * @throws IOException
- * if an error occurs while removing the document.
- * @return number of documents deleted
- */
- int removeDocument(Term idTerm) throws IOException
- {
- return (getIndexReader()).deleteDocuments(idTerm);
- }
+ /**
+ * Removes the document from this index. This call will not invalidate the shared
reader. If a
+ * subclass whishes to do so, it should overwrite this method and call
+ * {@link #invalidateSharedReader()}.
+ *
+ * @param idTerm
+ * the id term of the document to remove.
+ * @throws IOException
+ * if an error occurs while removing the document.
+ * @return number of documents deleted
+ */
+ int removeDocument(Term idTerm) throws IOException {
+ return (getIndexReader()).deleteDocuments(idTerm);
+ }
- /**
- * Returns an <code>IndexReader</code> on this index. This index reader
may be used to delete
- * documents.
- *
- * @return an <code>IndexReader</code> on this index.
- * @throws IOException
- * if the reader cannot be obtained.
- */
- protected synchronized CommittableIndexReader getIndexReader() throws IOException
- {
- if (indexWriter != null)
- {
- indexWriter.close();
- log.debug("closing IndexWriter.");
- indexWriter = null;
- }
- if (indexReader == null)
- {
- indexReader = new CommittableIndexReader(IndexReader.open(getDirectory()));
- }
- return indexReader;
- }
+ /**
+ * Returns an <code>IndexReader</code> on this index. This index reader may
be used to delete
+ * documents.
+ *
+ * @return an <code>IndexReader</code> on this index.
+ * @throws IOException
+ * if the reader cannot be obtained.
+ */
+ protected synchronized CommittableIndexReader getIndexReader() throws IOException {
+ if (indexWriter != null) {
+ indexWriter.close();
+ log.debug("closing IndexWriter.");
+ indexWriter = null;
+ }
+ if (indexReader == null) {
+ indexReader = new CommittableIndexReader(IndexReader.open(getDirectory()));
+ }
+ return indexReader;
+ }
- /**
- * Returns a read-only index reader, that can be used concurrently with other threads
writing to
- * this index. The returned index reader is read-only, that is, any attempt to delete
a document
- * from the index will throw an
<code>UnsupportedOperationException</code>.
- *
- * @return a read-only index reader.
- * @throws IOException
- * if an error occurs while obtaining the index reader.
- */
- synchronized ReadOnlyIndexReader getReadOnlyIndexReader() throws IOException
- {
- // get current modifiable index reader
- CommittableIndexReader modifiableReader = getIndexReader();
- long modCount = modifiableReader.getModificationCount();
- if (readOnlyReader != null)
- {
- if (readOnlyReader.getDeletedDocsVersion() == modCount)
- {
- // reader up-to-date
- readOnlyReader.incrementRefCount();
- return readOnlyReader;
- }
- else
- {
- // reader outdated
- if (readOnlyReader.getRefCount() == 1)
- {
- // not in use, except by this index
- // update the reader
- readOnlyReader.updateDeletedDocs(modifiableReader);
- readOnlyReader.incrementRefCount();
- return readOnlyReader;
- }
- else
- {
- // cannot update reader, it is still in use
- // need to create a new instance
- readOnlyReader.close();
- readOnlyReader = null;
- }
- }
+ /**
+ * Returns a read-only index reader, that can be used concurrently with other threads
writing to
+ * this index. The returned index reader is read-only, that is, any attempt to delete a
document
+ * from the index will throw an
<code>UnsupportedOperationException</code>.
+ *
+ * @return a read-only index reader.
+ * @throws IOException
+ * if an error occurs while obtaining the index reader.
+ */
+ synchronized ReadOnlyIndexReader getReadOnlyIndexReader() throws IOException {
+ // get current modifiable index reader
+ CommittableIndexReader modifiableReader = getIndexReader();
+ long modCount = modifiableReader.getModificationCount();
+ if (readOnlyReader != null) {
+ if (readOnlyReader.getDeletedDocsVersion() == modCount) {
+ // reader up-to-date
+ readOnlyReader.incrementRefCount();
+ return readOnlyReader;
+ } else {
+ // reader outdated
+ if (readOnlyReader.getRefCount() == 1) {
+ // not in use, except by this index
+ // update the reader
+ readOnlyReader.updateDeletedDocs(modifiableReader);
+ readOnlyReader.incrementRefCount();
+ return readOnlyReader;
+ } else {
+ // cannot update reader, it is still in use
+ // need to create a new instance
+ readOnlyReader.close();
+ readOnlyReader = null;
+ }
}
- // if we get here there is no up-to-date read-only reader
- // capture snapshot of deleted documents
- BitSet deleted = new BitSet(modifiableReader.maxDoc());
- for (int i = 0; i < modifiableReader.maxDoc(); i++)
- {
- if (modifiableReader.isDeleted(i))
- {
- deleted.set(i);
- }
+ }
+ // if we get here there is no up-to-date read-only reader
+ // capture snapshot of deleted documents
+ BitSet deleted = new BitSet(modifiableReader.maxDoc());
+ for (int i = 0; i < modifiableReader.maxDoc(); i++) {
+ if (modifiableReader.isDeleted(i)) {
+ deleted.set(i);
}
- if (sharedReader == null)
- {
- // create new shared reader
- CachingIndexReader cr = new CachingIndexReader(IndexReader.open(getDirectory()),
cache);
- sharedReader = new SharedIndexReader(cr);
- }
- readOnlyReader = new ReadOnlyIndexReader(sharedReader, deleted, modCount);
- readOnlyReader.incrementRefCount();
- return readOnlyReader;
- }
+ }
+ if (sharedReader == null) {
+ // create new shared reader
+ CachingIndexReader cr = new CachingIndexReader(IndexReader.open(getDirectory()),
cache);
+ sharedReader = new SharedIndexReader(cr);
+ }
+ readOnlyReader = new ReadOnlyIndexReader(sharedReader, deleted, modCount);
+ readOnlyReader.incrementRefCount();
+ return readOnlyReader;
+ }
- /**
- * Returns an <code>IndexWriter</code> on this index.
- *
- * @return an <code>IndexWriter</code> on this index.
- * @throws IOException
- * if the writer cannot be obtained.
- */
- protected synchronized IndexWriter getIndexWriter() throws IOException
- {
- if (indexReader != null)
- {
- indexReader.close();
- log.debug("closing IndexReader.");
- indexReader = null;
- }
- if (indexWriter == null)
- {
- indexWriter = new IndexWriter(getDirectory(), analyzer);
- // since lucene 2.0 setMaxBuffereDocs is equivalent to previous
- // minMergeDocs attribute
- indexWriter.setMaxBufferedDocs(minMergeDocs);
- indexWriter.setMaxMergeDocs(maxMergeDocs);
- indexWriter.setMergeFactor(mergeFactor);
- indexWriter.setMaxFieldLength(maxFieldLength);
- indexWriter.setUseCompoundFile(useCompoundFile);
- indexWriter.setInfoStream(STREAM_LOGGER);
- }
- return indexWriter;
- }
+ /**
+ * Returns an <code>IndexWriter</code> on this index.
+ *
+ * @return an <code>IndexWriter</code> on this index.
+ * @throws IOException
+ * if the writer cannot be obtained.
+ */
+ protected synchronized IndexWriter getIndexWriter() throws IOException {
+ if (indexReader != null) {
+ indexReader.close();
+ log.debug("closing IndexReader.");
+ indexReader = null;
+ }
+ if (indexWriter == null) {
+ indexWriter = new IndexWriter(getDirectory(), analyzer);
+ // since lucene 2.0 setMaxBuffereDocs is equivalent to previous
+ // minMergeDocs attribute
+ indexWriter.setMaxBufferedDocs(minMergeDocs);
+ indexWriter.setMaxMergeDocs(maxMergeDocs);
+ indexWriter.setMergeFactor(mergeFactor);
+ indexWriter.setMaxFieldLength(maxFieldLength);
+ indexWriter.setUseCompoundFile(useCompoundFile);
+ indexWriter.setInfoStream(STREAM_LOGGER);
+ }
+ return indexWriter;
+ }
- /**
- * Commits all pending changes to the underlying <code>Directory</code>.
- *
- * @throws IOException
- * if an error occurs while commiting changes.
- */
- protected void commit() throws IOException
- {
- commit(false);
- }
+ /**
+ * Commits all pending changes to the underlying <code>Directory</code>.
+ *
+ * @throws IOException
+ * if an error occurs while commiting changes.
+ */
+ protected void commit() throws IOException {
+ commit(false);
+ }
- /**
- * Commits all pending changes to the underlying <code>Directory</code>.
- *
- * @param optimize
- * if <code>true</code> the index is optimized after the commit.
- * @throws IOException
- * if an error occurs while commiting changes.
- */
- protected synchronized void commit(boolean optimize) throws IOException
- {
- if (indexReader != null)
- {
- indexReader.commitDeleted();
- }
- if (indexWriter != null)
- {
- log.debug("committing IndexWriter.");
- indexWriter.close();
- indexWriter = null;
- }
- // optimize if requested
- if (optimize)
- {
- IndexWriter writer = getIndexWriter();
- writer.optimize();
- writer.close();
- indexWriter = null;
- }
- }
+ /**
+ * Commits all pending changes to the underlying <code>Directory</code>.
+ *
+ * @param optimize
+ * if <code>true</code> the index is optimized after the commit.
+ * @throws IOException
+ * if an error occurs while commiting changes.
+ */
+ protected synchronized void commit(boolean optimize) throws IOException {
+ if (indexReader != null) {
+ indexReader.commitDeleted();
+ }
+ if (indexWriter != null) {
+ log.debug("committing IndexWriter.");
+ indexWriter.close();
+ indexWriter = null;
+ }
+ // optimize if requested
+ if (optimize) {
+ IndexWriter writer = getIndexWriter();
+ writer.optimize();
+ writer.close();
+ indexWriter = null;
+ }
+ }
- /**
- * Closes this index, releasing all held resources.
- */
- synchronized void close()
- {
- if (indexWriter != null)
- {
- try
- {
- indexWriter.close();
- }
- catch (IOException e)
- {
- log.warn("Exception closing index writer: " + e.toString());
- }
- indexWriter = null;
+ /**
+ * Closes this index, releasing all held resources.
+ */
+ synchronized void close() {
+ if (indexWriter != null) {
+ try {
+ indexWriter.close();
+ } catch (IOException e) {
+ log.warn("Exception closing index writer: " + e.toString());
}
- if (indexReader != null)
- {
- try
- {
- indexReader.close();
- }
- catch (IOException e)
- {
- log.warn("Exception closing index reader: " + e.toString());
- }
- indexReader = null;
+ indexWriter = null;
+ }
+ if (indexReader != null) {
+ try {
+ indexReader.close();
+ } catch (IOException e) {
+ log.warn("Exception closing index reader: " + e.toString());
}
- if (readOnlyReader != null)
- {
- try
- {
- readOnlyReader.close();
- }
- catch (IOException e)
- {
- log.warn("Exception closing index reader: " + e.toString());
- }
+ indexReader = null;
+ }
+ if (readOnlyReader != null) {
+ try {
+ readOnlyReader.close();
+ } catch (IOException e) {
+ log.warn("Exception closing index reader: " + e.toString());
}
- if (sharedReader != null)
- {
- try
- {
- sharedReader.close();
- }
- catch (IOException e)
- {
- log.warn("Exception closing index reader: " + e.toString());
- }
+ }
+ if (sharedReader != null) {
+ try {
+ sharedReader.close();
+ } catch (IOException e) {
+ log.warn("Exception closing index reader: " + e.toString());
}
- if (directory != null)
- {
- try
- {
- directory.close();
- }
- catch (IOException e)
- {
- directory = null;
- }
+ }
+ if (directory != null) {
+ try {
+ directory.close();
+ } catch (IOException e) {
+ directory = null;
}
- }
+ }
+ }
- /**
- * Closes the shared reader.
- *
- * @throws IOException
- * if an error occurs while closing the reader.
- */
- protected synchronized void invalidateSharedReader() throws IOException
- {
- // also close the read-only reader
- if (readOnlyReader != null)
- {
- readOnlyReader.close();
- readOnlyReader = null;
+ /**
+ * Closes the shared reader.
+ *
+ * @throws IOException
+ * if an error occurs while closing the reader.
+ */
+ protected synchronized void invalidateSharedReader() throws IOException {
+ // also close the read-only reader
+ if (readOnlyReader != null) {
+ readOnlyReader.close();
+ readOnlyReader = null;
+ }
+ // invalidate shared reader
+ if (sharedReader != null) {
+ sharedReader.close();
+ sharedReader = null;
+ }
+ }
+
+ /**
+ * Returns a document that is finished with text extraction and is ready to be added to
the index.
+ *
+ * @param doc
+ * the document to check.
+ * @return <code>doc</code> if it is finished already or a stripped down
copy of <code>doc</code>
+ * without text extractors.
+ * @throws IOException
+ * if the document cannot be added to the indexing queue.
+ */
+ private Document getFinishedDocument(Document doc) throws IOException {
+ if (!Util.isDocumentReady(doc)) {
+ Document copy = new Document();
+ for (Iterator fields = doc.getFields().iterator(); fields.hasNext();) {
+ Field f = (Field) fields.next();
+ Field field = null;
+ Field.TermVector tv = getTermVectorParameter(f);
+ Field.Store stored = getStoreParameter(f);
+ Field.Index indexed = getIndexParameter(f);
+ if (f.readerValue() != null) {
+ // replace all readers with empty string reader
+ field = new Field(f.name(), new StringReader(""), tv);
+ } else if (f.stringValue() != null) {
+ field = new Field(f.name(), f.stringValue(), stored, indexed, tv);
+ } else if (f.isBinary()) {
+ field = new Field(f.name(), f.binaryValue(), stored);
+ }
+ if (field != null) {
+ field.setOmitNorms(f.getOmitNorms());
+ copy.add(field);
+ }
}
- // invalidate shared reader
- if (sharedReader != null)
- {
- sharedReader.close();
- sharedReader = null;
+ // schedule the original document for later indexing
+ Document existing = indexingQueue.addDocument(doc);
+ if (existing != null) {
+ // the queue already contained a pending document for this
+ // node. -> dispose the document
+ Util.disposeDocument(existing);
}
- }
+ // use the stripped down copy for now
+ doc = copy;
+ }
+ return doc;
+ }
- /**
- * Returns a document that is finished with text extraction and is ready to be added
to the index.
- *
- * @param doc
- * the document to check.
- * @return <code>doc</code> if it is finished already or a stripped down
copy of <code>doc</code>
- * without text extractors.
- * @throws IOException
- * if the document cannot be added to the indexing queue.
- */
- private Document getFinishedDocument(Document doc) throws IOException
- {
- if (!Util.isDocumentReady(doc))
- {
- Document copy = new Document();
- for (Iterator fields = doc.getFields().iterator(); fields.hasNext();)
- {
- Field f = (Field) fields.next();
- Field field = null;
- Field.TermVector tv = getTermVectorParameter(f);
- Field.Store stored = getStoreParameter(f);
- Field.Index indexed = getIndexParameter(f);
- if (f.readerValue() != null)
- {
- // replace all readers with empty string reader
- field = new Field(f.name(), new StringReader(""), tv);
- }
- else if (f.stringValue() != null)
- {
- field = new Field(f.name(), f.stringValue(), stored, indexed, tv);
- }
- else if (f.isBinary())
- {
- field = new Field(f.name(), f.binaryValue(), stored);
- }
- if (field != null)
- {
- field.setOmitNorms(f.getOmitNorms());
- copy.add(field);
- }
- }
- // schedule the original document for later indexing
- Document existing = indexingQueue.addDocument(doc);
- if (existing != null)
- {
- // the queue already contained a pending document for this
- // node. -> dispose the document
- Util.disposeDocument(existing);
- }
- // use the stripped down copy for now
- doc = copy;
- }
- return doc;
- }
+ // -------------------------< properties >-----------------------------------
- // -------------------------< properties >-----------------------------------
+ /**
+ * The lucene index writer property: useCompountFile
+ */
+ void setUseCompoundFile(boolean b) {
+ useCompoundFile = b;
+ if (indexWriter != null) {
+ indexWriter.setUseCompoundFile(b);
+ }
+ }
- /**
- * The lucene index writer property: useCompountFile
- */
- void setUseCompoundFile(boolean b)
- {
- useCompoundFile = b;
- if (indexWriter != null)
- {
- indexWriter.setUseCompoundFile(b);
- }
- }
+ /**
+ * The lucene index writer property: minMergeDocs
+ */
+ void setMinMergeDocs(int minMergeDocs) {
+ this.minMergeDocs = minMergeDocs;
+ if (indexWriter != null) {
+ // since lucene 2.0 setMaxBuffereDocs is equivalent to previous
+ // minMergeDocs attribute
+ indexWriter.setMaxBufferedDocs(minMergeDocs);
+ }
+ }
- /**
- * The lucene index writer property: minMergeDocs
- */
- void setMinMergeDocs(int minMergeDocs)
- {
- this.minMergeDocs = minMergeDocs;
- if (indexWriter != null)
- {
- // since lucene 2.0 setMaxBuffereDocs is equivalent to previous
- // minMergeDocs attribute
- indexWriter.setMaxBufferedDocs(minMergeDocs);
- }
- }
+ /**
+ * The lucene index writer property: maxMergeDocs
+ */
+ void setMaxMergeDocs(int maxMergeDocs) {
+ this.maxMergeDocs = maxMergeDocs;
+ if (indexWriter != null) {
+ indexWriter.setMaxMergeDocs(maxMergeDocs);
+ }
+ }
- /**
- * The lucene index writer property: maxMergeDocs
- */
- void setMaxMergeDocs(int maxMergeDocs)
- {
- this.maxMergeDocs = maxMergeDocs;
- if (indexWriter != null)
- {
- indexWriter.setMaxMergeDocs(maxMergeDocs);
- }
- }
+ /**
+ * The lucene index writer property: mergeFactor
+ */
+ void setMergeFactor(int mergeFactor) {
+ this.mergeFactor = mergeFactor;
+ if (indexWriter != null) {
+ indexWriter.setMergeFactor(mergeFactor);
+ }
+ }
- /**
- * The lucene index writer property: mergeFactor
- */
- void setMergeFactor(int mergeFactor)
- {
- this.mergeFactor = mergeFactor;
- if (indexWriter != null)
- {
- indexWriter.setMergeFactor(mergeFactor);
- }
- }
+ /**
+ * The lucene index writer property: maxFieldLength
+ */
+ void setMaxFieldLength(int maxFieldLength) {
+ this.maxFieldLength = maxFieldLength;
+ if (indexWriter != null) {
+ indexWriter.setMaxFieldLength(maxFieldLength);
+ }
+ }
- /**
- * The lucene index writer property: maxFieldLength
- */
- void setMaxFieldLength(int maxFieldLength)
- {
- this.maxFieldLength = maxFieldLength;
- if (indexWriter != null)
- {
- indexWriter.setMaxFieldLength(maxFieldLength);
- }
- }
+ // ------------------------------< internal >--------------------------------
- // ------------------------------< internal >--------------------------------
+ /**
+ * Returns the index parameter set on <code>f</code>.
+ *
+ * @param f
+ * a lucene field.
+ * @return the index parameter on <code>f</code>.
+ */
+ private Field.Index getIndexParameter(Field f) {
+ if (!f.isIndexed()) {
+ return Field.Index.NO;
+ } else if (f.isTokenized()) {
+ return Field.Index.TOKENIZED;
+ } else {
+ return Field.Index.UN_TOKENIZED;
+ }
+ }
- /**
- * Returns the index parameter set on <code>f</code>.
- *
- * @param f
- * a lucene field.
- * @return the index parameter on <code>f</code>.
- */
- private Field.Index getIndexParameter(Field f)
- {
- if (!f.isIndexed())
- {
- return Field.Index.NO;
- }
- else if (f.isTokenized())
- {
- return Field.Index.TOKENIZED;
- }
- else
- {
- return Field.Index.UN_TOKENIZED;
- }
- }
+ /**
+ * Returns the store parameter set on <code>f</code>.
+ *
+ * @param f
+ * a lucene field.
+ * @return the store parameter on <code>f</code>.
+ */
+ private Field.Store getStoreParameter(Field f) {
+ if (f.isCompressed()) {
+ return Field.Store.COMPRESS;
+ } else if (f.isStored()) {
+ return Field.Store.YES;
+ } else {
+ return Field.Store.NO;
+ }
+ }
- /**
- * Returns the store parameter set on <code>f</code>.
- *
- * @param f
- * a lucene field.
- * @return the store parameter on <code>f</code>.
- */
- private Field.Store getStoreParameter(Field f)
- {
- if (f.isCompressed())
- {
- return Field.Store.COMPRESS;
- }
- else if (f.isStored())
- {
- return Field.Store.YES;
- }
- else
- {
- return Field.Store.NO;
- }
- }
+ /**
+ * Returns the term vector parameter set on <code>f</code>.
+ *
+ * @param f
+ * a lucene field.
+ * @return the term vector parameter on <code>f</code>.
+ */
+ private Field.TermVector getTermVectorParameter(Field f) {
+ if (f.isStorePositionWithTermVector() && f.isStoreOffsetWithTermVector()) {
+ return Field.TermVector.WITH_POSITIONS_OFFSETS;
+ } else if (f.isStorePositionWithTermVector()) {
+ return Field.TermVector.WITH_POSITIONS;
+ } else if (f.isStoreOffsetWithTermVector()) {
+ return Field.TermVector.WITH_OFFSETS;
+ } else if (f.isTermVectorStored()) {
+ return Field.TermVector.YES;
+ } else {
+ return Field.TermVector.NO;
+ }
+ }
- /**
- * Returns the term vector parameter set on <code>f</code>.
- *
- * @param f
- * a lucene field.
- * @return the term vector parameter on <code>f</code>.
- */
- private Field.TermVector getTermVectorParameter(Field f)
- {
- if (f.isStorePositionWithTermVector() && f.isStoreOffsetWithTermVector())
- {
- return Field.TermVector.WITH_POSITIONS_OFFSETS;
- }
- else if (f.isStorePositionWithTermVector())
- {
- return Field.TermVector.WITH_POSITIONS;
- }
- else if (f.isStoreOffsetWithTermVector())
- {
- return Field.TermVector.WITH_OFFSETS;
- }
- else if (f.isTermVectorStored())
- {
- return Field.TermVector.YES;
- }
- else
- {
- return Field.TermVector.NO;
- }
- }
+ /**
+ * Adapter to pipe info messages from lucene into log messages.
+ */
+ private static final class LoggingPrintStream extends PrintStream {
- /**
- * Adapter to pipe info messages from lucene into log messages.
- */
- private static final class LoggingPrintStream
- extends PrintStream
- {
+ /** Buffer print calls until a newline is written */
+ private StringBuffer buffer = new StringBuffer();
- /** Buffer print calls until a newline is written */
- private StringBuffer buffer = new StringBuffer();
+ public LoggingPrintStream() {
+ super(new OutputStream() {
+ public void write(int b) {
+ // do nothing
+ }
+ });
+ }
- public LoggingPrintStream()
- {
- super(new OutputStream()
- {
- public void write(int b)
- {
- // do nothing
- }
- });
- }
+ public void print(String s) {
+ buffer.append(s);
+ }
- public void print(String s)
- {
- buffer.append(s);
+ public void println(String s) {
+ buffer.append(s);
+ log.debug(buffer.toString());
+ buffer.setLength(0);
}
-
- public void println(String s)
- {
- buffer.append(s);
- log.debug(buffer.toString());
- buffer.setLength(0);
- }
}
}
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMerger.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMerger.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMerger.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -26,19 +26,16 @@
import org.apache.commons.collections.Buffer;
import org.apache.commons.collections.BufferUtils;
import org.apache.commons.collections.buffer.UnboundedFifoBuffer;
-import org.exoplatform.services.log.Log;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
-
-import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.QueryHandlerEntryWrapper;
import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
/**
* Merges indexes in a separate deamon thread.
*/
-class IndexMerger
- extends Thread
- implements IndexListener
+class IndexMerger extends Thread implements IndexListener
{
/**
@@ -54,17 +51,17 @@
/**
* minMergeDocs config parameter.
*/
- private int minMergeDocs = new Integer(QueryHandlerEntry.DEFAULT_MIN_MERGE_DOCS);
+ private int minMergeDocs = new
Integer(QueryHandlerEntryWrapper.DEFAULT_MIN_MERGE_DOCS);
/**
* maxMergeDocs config parameter
*/
- private int maxMergeDocs = new Integer(QueryHandlerEntry.DEFAULT_MAX_MERGE_DOCS);
+ private int maxMergeDocs = new
Integer(QueryHandlerEntryWrapper.DEFAULT_MAX_MERGE_DOCS);
/**
* mergeFactor config parameter
*/
- private int mergeFactor = new Integer(QueryHandlerEntry.DEFAULT_MERGE_FACTOR);
+ private int mergeFactor = new Integer(QueryHandlerEntryWrapper.DEFAULT_MERGE_FACTOR);
/**
* Queue of merge Tasks
@@ -298,7 +295,7 @@
mergerIdle.release();
isIdle = true;
}
- Merge task = (Merge) mergeTasks.remove();
+ Merge task = (Merge)mergeTasks.remove();
if (task == QUIT)
{
mergerIdle.release();
@@ -438,8 +435,7 @@
* Implements a simple struct that holds the name of an index and how many document it
contains.
* <code>Index</code> is comparable using the number of documents it
contains.
*/
- private static final class Index
- implements Comparable
+ private static final class Index implements Comparable
{
/**
@@ -476,7 +472,7 @@
*/
public int compareTo(Object o)
{
- Index other = (Index) o;
+ Index other = (Index)o;
int val = numDocs < other.numDocs ? -1 : (numDocs == other.numDocs ? 0 : 1);
if (val != 0)
{
@@ -522,8 +518,7 @@
* Implements a <code>List</code> with a document limit value. An
<code>IndexBucket</code>
* contains {@link Index}es with documents less or equal the document limit of the
bucket.
*/
- private static final class IndexBucket
- extends ArrayList<Index>
+ private static final class IndexBucket extends ArrayList<Index>
{
/**
Modified:
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
---
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2009-08-28
11:17:55 UTC (rev 39)
+++
jcr/trunk/component/core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2009-08-28
11:46:09 UTC (rev 40)
@@ -48,6 +48,7 @@
import org.exoplatform.container.configuration.ConfigurationManager;
import org.exoplatform.services.document.DocumentReaderService;
import org.exoplatform.services.jcr.config.QueryHandlerEntry;
+import org.exoplatform.services.jcr.config.QueryHandlerEntryWrapper;
import org.exoplatform.services.jcr.config.RepositoryConfigurationException;
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.InternalQName;
@@ -68,8 +69,7 @@
* Implements a {@link org.apache.jackrabbit.core.query.QueryHandler} using
* Lucene.
*/
-public class SearchIndex
- implements QueryHandler
+public class SearchIndex implements QueryHandler
{
private static final DefaultQueryNodeFactory DEFAULT_QUERY_NODE_FACTORY = new
DefaultQueryNodeFactory();
@@ -130,7 +130,7 @@
*/
private NamespaceMappings nsMappings;
- private final QueryHandlerEntry queryHandlerConfig;
+ private final QueryHandlerEntryWrapper queryHandlerConfig;
/**
* The spell checker for this query handler or <code>null</code> if none
is
@@ -155,7 +155,7 @@
public SearchIndex(QueryHandlerEntry queryHandlerConfig, ConfigurationManager cfm)
{
- this.queryHandlerConfig = queryHandlerConfig;
+ this.queryHandlerConfig = new QueryHandlerEntryWrapper(queryHandlerConfig);
this.cfm = cfm;
}
@@ -203,27 +203,27 @@
* @return A <code>Query</code> object.
*/
public ExecutableQuery createExecutableQuery(SessionImpl session, SessionDataManager
itemMgr, String statement,
- String language) throws InvalidQueryException
+ String language) throws InvalidQueryException
{
QueryImpl query =
- new QueryImpl(session, itemMgr, this,
getContext().getPropertyTypeRegistry(), statement, language,
- getQueryNodeFactory());
+ new QueryImpl(session, itemMgr, this, getContext().getPropertyTypeRegistry(),
statement, language,
+ getQueryNodeFactory());
query.setRespectDocumentOrder(queryHandlerConfig.getDocumentOrder());
return query;
}
public org.exoplatform.services.jcr.impl.core.query.AbstractQueryImpl
createQueryInstance()
- throws RepositoryException
+ throws RepositoryException
{
try
{
Object obj = Class.forName(queryHandlerConfig.getQueryClass()).newInstance();
if (obj instanceof
org.exoplatform.services.jcr.impl.core.query.AbstractQueryImpl)
{
- return (org.exoplatform.services.jcr.impl.core.query.AbstractQueryImpl) obj;
+ return (org.exoplatform.services.jcr.impl.core.query.AbstractQueryImpl)obj;
}
throw new IllegalArgumentException(queryHandlerConfig.getQueryClass() + "
is not of type "
- + AbstractQueryImpl.class.getName());
+ + AbstractQueryImpl.class.getName());
}
catch (Throwable t)
@@ -245,7 +245,7 @@
}
public QueryHits executeQuery(Query query, boolean needsSystemTree, InternalQName[]
orderProps, boolean[] orderSpecs)
- throws IOException
+ throws IOException
{
checkOpen();
SortField[] sortFields = createSortFields(orderProps, orderSpecs);
@@ -287,7 +287,7 @@
{
if (getContext().getParentHandler() instanceof SearchIndex)
{
- SearchIndex parent = (SearchIndex) getContext().getParentHandler();
+ SearchIndex parent = (SearchIndex)getContext().getParentHandler();
if (parent.getIndexFormatVersion().getVersion() <
index.getIndexFormatVersion().getVersion())
{
indexFormatVersion = parent.getIndexFormatVersion();
@@ -343,14 +343,13 @@
CachingMultiIndexReader parentReader = null;
if (parentHandler instanceof SearchIndex && includeSystemIndex)
{
- parentReader = ((SearchIndex) parentHandler).index.getIndexReader();
+ parentReader = ((SearchIndex)parentHandler).index.getIndexReader();
}
CachingMultiIndexReader reader = index.getIndexReader();
if (parentReader != null)
{
- CachingMultiIndexReader[] readers =
- {reader, parentReader};
+ CachingMultiIndexReader[] readers = {reader, parentReader};
return new CombinedIndexReader(readers);
}
return reader;
@@ -389,7 +388,7 @@
}
QueryHandler handler = getContext().getParentHandler();
if (handler instanceof SearchIndex)
- return ((SearchIndex) handler).getSynonymProvider();
+ return ((SearchIndex)handler).getSynonymProvider();
return null;
}
@@ -447,7 +446,7 @@
if (context.getParentHandler() instanceof SearchIndex)
{
// use system namespace mappings
- SearchIndex sysIndex = (SearchIndex) context.getParentHandler();
+ SearchIndex sysIndex = (SearchIndex)context.getParentHandler();
nsMappings = sysIndex.getNamespaceMappings();
}
else
@@ -480,7 +479,7 @@
index.createInitialIndex(context.getItemStateManager(),
context.getRootNodeIdentifer());
}
if (queryHandlerConfig.isConsistencyCheckEnabled()
- && (index.getRedoLogApplied() ||
queryHandlerConfig.isForceConsistencyCheck()))
+ && (index.getRedoLogApplied() ||
queryHandlerConfig.isForceConsistencyCheck()))
{
log.info("Running consistency check... ");
@@ -508,7 +507,7 @@
spellChecker = queryHandlerConfig.createSpellChecker(this);
log.info("Index initialized: " + queryHandlerConfig.getIndexDir() +
" Version: "
- + index.getIndexFormatVersion() + "");
+ + index.getIndexFormatVersion() + "");
File file = new File(indexDir, ERROR_LOG);
errorLog = new ErrorLog(file, queryHandlerConfig.getErrorLogSize());
@@ -575,11 +574,11 @@
{
if (item.isNode())
{
- return (NodeData) item; // return node here
+ return (NodeData)item; // return node here
}
else
log.warn("Node expected but property found with id " +
id + ". Skipping "
- + item.getQPath().getAsString());
+ + item.getQPath().getAsString());
}
else
{
@@ -636,7 +635,7 @@
* @throws IOException if an error occurs while updating the index.
*/
public void updateNodes(final Iterator<String> remove, final
Iterator<NodeData> add) throws RepositoryException,
- IOException
+ IOException
{
checkOpen();
@@ -649,7 +648,7 @@
{
public Object next()
{
- String nodeId = (String) super.next();
+ String nodeId = (String)super.next();
removedNodeIds.add(nodeId);
return nodeId;
}
@@ -657,7 +656,7 @@
{
public Object next()
{
- NodeData state = (NodeData) super.next();
+ NodeData state = (NodeData)super.next();
if (state == null)
{
return null;
@@ -673,8 +672,7 @@
catch (RepositoryException e)
{
log
- .warn("Exception while creating document for node: " +
state.getIdentifier() + ": "
- + e.toString(), e);
+ .warn("Exception while creating document for node: " +
state.getIdentifier() + ": " + e.toString(), e);
}
return doc;
@@ -701,7 +699,7 @@
{
public Object next()
{
- NodeData state = (NodeData) super.next();
+ NodeData state = (NodeData)super.next();
try
{
return createDocument(state, getNamespaceMappings(),
index.getIndexFormatVersion());
@@ -709,8 +707,7 @@
catch (RepositoryException e)
{
log
- .warn("Exception while creating document for node: "
+ state.getIdentifier() + ": "
- + e.toString());
+ .warn("Exception while creating document for node: " +
state.getIdentifier() + ": " + e.toString());
}
return null;
}
@@ -733,7 +730,7 @@
* <code>node</code>.
*/
protected Document createDocument(NodeData node, NamespaceMappings nsMappings,
IndexFormatVersion indexFormatVersion)
- throws RepositoryException
+ throws RepositoryException
{
NodeIndexer indexer = new NodeIndexer(node, getContext().getItemStateManager(),
nsMappings, extractor);
indexer.setSupportHighlighting(queryHandlerConfig.getSupportHighlighting());
@@ -840,7 +837,7 @@
doc.add(fulltextFields[k]);
}
doc.add(new Field(FieldNames.AGGREGATED_NODE_UUID,
aggregates[j].getIdentifier().toString(),
- Field.Store.NO, Field.Index.NO_NORMS));
+ Field.Store.NO, Field.Index.NO_NORMS));
}
}
// only use first aggregate definition that matches
@@ -851,8 +848,7 @@
{
// do not fail if aggregate cannot be created
log
- .warn("Exception while building indexing aggregate for " +
"node with UUID: "
- + state.getIdentifier(), e);
+ .warn("Exception while building indexing aggregate for " +
"node with UUID: " + state.getIdentifier(), e);
}
}
}
@@ -937,7 +933,7 @@
continue;
if (!itd.isNode())
throw new RepositoryException("Item with id:" + uuid
+ " is not a node");
- map.put(uuid, (NodeData) itd);
+ map.put(uuid, (NodeData)itd);
found++;
}
}
@@ -979,9 +975,7 @@
* Combines multiple {@link CachingMultiIndexReader} into a
* <code>MultiReader</code> with {@link HierarchyResolver} support.
*/
- protected static final class CombinedIndexReader
- extends MultiReader
- implements HierarchyResolver, MultiIndexReader
+ protected static final class CombinedIndexReader extends MultiReader implements
HierarchyResolver, MultiIndexReader
{
/**
@@ -1032,7 +1026,7 @@
{
if (obj instanceof CombinedIndexReader)
{
- CombinedIndexReader other = (CombinedIndexReader) obj;
+ CombinedIndexReader other = (CombinedIndexReader)obj;
return Arrays.equals(subReaders, other.subReaders);
}
return false;
@@ -1125,7 +1119,7 @@
}
}
- public QueryHandlerEntry getQueryHandlerConfig()
+ public QueryHandlerEntryWrapper getQueryHandlerConfig()
{
return queryHandlerConfig;
}
Modified: jcr/trunk/component/core/src/main/resources/binding.xml
===================================================================
--- jcr/trunk/component/core/src/main/resources/binding.xml 2009-08-28 11:17:55 UTC (rev
39)
+++ jcr/trunk/component/core/src/main/resources/binding.xml 2009-08-28 11:46:09 UTC (rev
40)
@@ -1,85 +1,100 @@
<binding>
- <mapping name="repository-service"
class="org.exoplatform.services.jcr.config.RepositoryServiceConfiguration">
- <value name="default-repository"
field="defaultRepositoryName" style="attribute" />
- <collection name="repositories"
field="repositoryConfigurations"
item-type="org.exoplatform.services.jcr.config.RepositoryEntry"
factory="org.jibx.runtime.Utility.arrayListFactory" />
- </mapping>
+ <mapping name="repository-service"
class="org.exoplatform.services.jcr.config.RepositoryServiceConfiguration">
+ <value name="default-repository" field="defaultRepositoryName"
style="attribute" />
+ <collection name="repositories"
field="repositoryConfigurations"
+ item-type="org.exoplatform.services.jcr.config.RepositoryEntry"
+ factory="org.jibx.runtime.Utility.arrayListFactory" />
+ </mapping>
- <mapping name="repository"
class="org.exoplatform.services.jcr.config.RepositoryEntry">
- <value name="name" field="name" style="attribute"
/>
- <value name="system-workspace" field="systemWorkspaceName"
style="attribute" />
- <value name="default-workspace" field="defaultWorkspaceName"
style="attribute" />
- <value name="security-domain" field="securityDomain" />
- <value name="access-control" field="accessControl"
usage="optional" />
- <value name="session-max-age" field="sessionTimeOut"
deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseTime"
usage="optional" />
- <value name="authentication-policy"
field="authenticationPolicy" />
- <collection name="workspaces" field="workspaces"
item-type="org.exoplatform.services.jcr.config.WorkspaceEntry" />
- </mapping>
+ <mapping name="repository"
class="org.exoplatform.services.jcr.config.RepositoryEntry">
+ <value name="name" field="name" style="attribute"
/>
+ <value name="system-workspace" field="systemWorkspaceName"
style="attribute" />
+ <value name="default-workspace" field="defaultWorkspaceName"
style="attribute" />
+ <value name="security-domain" field="securityDomain" />
+ <value name="access-control" field="accessControl"
usage="optional" />
+ <value name="session-max-age" field="sessionTimeOut"
+
deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseTime"
usage="optional" />
+ <value name="authentication-policy"
field="authenticationPolicy" />
+ <collection name="workspaces" field="workspaces"
item-type="org.exoplatform.services.jcr.config.WorkspaceEntry" />
+ </mapping>
- <mapping name="workspace"
class="org.exoplatform.services.jcr.config.WorkspaceEntry">
- <value name="name" field="name" style="attribute"
/>
- <value name="auto-init-root-nodetype"
field="autoInitializedRootNt" style="attribute"
usage="optional" />
- <value name="auto-init-permissions"
field="autoInitPermissions" style="attribute"
usage="optional" />
+ <mapping name="workspace"
class="org.exoplatform.services.jcr.config.WorkspaceEntry">
+ <value name="name" field="name" style="attribute"
/>
+ <value name="auto-init-root-nodetype"
field="autoInitializedRootNt" style="attribute"
usage="optional" />
+ <value name="auto-init-permissions"
field="autoInitPermissions" style="attribute"
usage="optional" />
- <structure name="container" field="container">
- <value name="class" field="type"
style="attribute" />
- <collection name="properties" field="parameters"
usage="optional"
item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
- factory="org.jibx.runtime.Utility.arrayListFactory" />
- <collection name="value-storages" field="valueStorages"
usage="optional"
item-type="org.exoplatform.services.jcr.config.ValueStorageEntry" />
- </structure>
+ <structure name="container" field="container">
+ <value name="class" field="type" style="attribute"
/>
+ <collection name="properties" field="parameters"
usage="optional"
+ item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
+ factory="org.jibx.runtime.Utility.arrayListFactory" />
+ <collection name="value-storages" field="valueStorages"
usage="optional"
+ item-type="org.exoplatform.services.jcr.config.ValueStorageEntry"
/>
+ </structure>
+
+ <structure name="initializer" field="initializer"
usage="optional">
+ <value name="class" field="type" style="attribute"
usage="optional" />
+ <collection name="properties" field="parameters"
usage="optional"
+ item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
+ factory="org.jibx.runtime.Utility.arrayListFactory" />
+ </structure>
- <structure name="initializer" field="initializer"
usage="optional">
- <value name="class" field="type"
style="attribute" usage="optional" />
- <collection name="properties" field="parameters"
usage="optional"
item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
- factory="org.jibx.runtime.Utility.arrayListFactory" />
- </structure>
+ <structure name="cache" field="cache"
usage="optional">
+ <value name="enabled" field="enabled"
style="attribute" />
+ <value name="class" field="type" style="attribute"
usage="optional" />
+ <collection name="properties" field="parameters"
usage="optional"
+ item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
+ factory="org.jibx.runtime.Utility.arrayListFactory" />
+ </structure>
- <structure name="cache" field="cache"
usage="optional">
- <value name="enabled" field="enabled"
style="attribute" />
- <value name="class" field="type"
style="attribute" usage="optional" />
- <collection name="properties" field="parameters"
usage="optional"
item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
- factory="org.jibx.runtime.Utility.arrayListFactory" />
- </structure>
+ <structure name="query-handler" field="queryHandler"
+
factory="org.exoplatform.services.jcr.config.QueryHandlerEntryWrapper.queryHandlerEntryFactory"
+ usage="optional">
+ <value name="class" field="type" style="attribute"
/>
+ <collection name="properties" field="parameters"
usage="optional"
+ item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
+ factory="org.jibx.runtime.Utility.arrayListFactory" />
+ </structure>
- <structure name="query-handler" field="queryHandler"
usage="optional">
- <value name="class" field="type"
style="attribute" />
- <collection name="properties" field="parameters"
usage="optional"
item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
- factory="org.jibx.runtime.Utility.arrayListFactory" />
- </structure>
+ <structure name="access-manager" field="accessManager"
usage="optional">
+ <value name="class" field="type" style="attribute"
/>
+ <collection name="properties" field="parameters"
usage="optional"
+ item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
+ factory="org.jibx.runtime.Utility.arrayListFactory" />
+ </structure>
- <structure name="access-manager" field="accessManager"
usage="optional">
- <value name="class" field="type"
style="attribute" />
- <collection name="properties" field="parameters"
usage="optional"
item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
- factory="org.jibx.runtime.Utility.arrayListFactory" />
+ <structure name="lock-manager" field="lockManager"
usage="optional">
+ <value name="time-out" field="timeout"
usage="optional"
+
deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseTime"
/>
+ <structure name="persister" field="persister"
usage="optional">
+ <value name="class" field="type"
style="attribute" />
+ <collection name="properties" field="parameters"
usage="optional"
+ item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
+ factory="org.jibx.runtime.Utility.arrayListFactory" />
</structure>
+ </structure>
+ </mapping>
- <structure name="lock-manager" field="lockManager"
usage="optional">
- <value name="time-out" field="timeout"
usage="optional"
deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseTime"
/>
- <structure name="persister" field="persister"
usage="optional">
- <value name="class" field="type"
style="attribute" />
- <collection name="properties" field="parameters"
usage="optional"
item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
- factory="org.jibx.runtime.Utility.arrayListFactory" />
- </structure>
- </structure>
- </mapping>
+ <mapping name="property"
class="org.exoplatform.services.jcr.config.SimpleParameterEntry">
+ <value name="name" field="name" style="attribute"
/>
+ <value name="value" field="value" style="attribute"
deserializer="org.exoplatform.container.xml.Deserializer.resolveString" />
+ </mapping>
- <mapping name="property"
class="org.exoplatform.services.jcr.config.SimpleParameterEntry">
- <value name="name" field="name" style="attribute"
/>
- <value name="value" field="value"
style="attribute"
deserializer="org.exoplatform.container.xml.Deserializer.resolveString" />
- </mapping>
+ <mapping name="value-storage"
class="org.exoplatform.services.jcr.config.ValueStorageEntry">
+ <value name="class" field="type" style="attribute"
/>
+ <value name="id" field="id" style="attribute" />
+ <collection name="properties" field="parameters"
usage="optional"
+ item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
+ factory="org.jibx.runtime.Utility.arrayListFactory" />
+ <collection name="filters" field="filters"
item-type="org.exoplatform.services.jcr.config.ValueStorageFilterEntry" />
+ </mapping>
+ <mapping name="filter"
class="org.exoplatform.services.jcr.config.ValueStorageFilterEntry">
+ <value name="property-type" field="propertyType"
style="attribute" usage="optional" />
+ <value name="min-value-size" field="minValueSize"
style="attribute"
+
deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseLong"
usage="optional" />
+ <value name="ancestor-path" field="ancestorPath"
style="attribute" usage="optional" />
+ <value name="property-name" field="propertyName"
style="attribute" usage="optional" />
+ </mapping>
- <mapping name="value-storage"
class="org.exoplatform.services.jcr.config.ValueStorageEntry">
- <value name="class" field="type" style="attribute"
/>
- <value name="id" field="id" style="attribute"
/>
- <collection name="properties" field="parameters"
usage="optional"
item-type="org.exoplatform.services.jcr.config.SimpleParameterEntry"
factory="org.jibx.runtime.Utility.arrayListFactory" />
- <collection name="filters" field="filters"
item-type="org.exoplatform.services.jcr.config.ValueStorageFilterEntry" />
- </mapping>
- <mapping name="filter"
class="org.exoplatform.services.jcr.config.ValueStorageFilterEntry">
- <value name="property-type" field="propertyType"
style="attribute" usage="optional" />
- <value name="min-value-size" field="minValueSize"
style="attribute"
deserializer="org.exoplatform.services.jcr.util.ConfigurationFormat.parseLong"
- usage="optional" />
- <value name="ancestor-path" field="ancestorPath"
style="attribute" usage="optional" />
- <value name="property-name" field="propertyName"
style="attribute" usage="optional" />
- </mapping>
-
</binding>