exo-jcr SVN: r2138 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-03-25 11:44:18 -0400 (Thu, 25 Mar 2010)
New Revision: 2138
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
Log:
EXOJCR-549 : The implementation backup/restore whole repository in HTTPBackupAgent.
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 15:31:56 UTC (rev 2137)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 15:44:18 UTC (rev 2138)
@@ -147,6 +147,12 @@
* The current or completed backup info operations.
*/
public static final String CURRENT_OR_COMPLETED_BACKUP_INFO = "/info/backup";
+
+ /**
+ * The current or completed repository backup info operations.
+ */
+ public static final String CURRENT_OR_COMPLETED_BACKUP_REPOSITORY_INFO = "/info/backup-repository-id";
+
/**
* The current restore info operations for specific workspace.
@@ -985,8 +991,8 @@
@GET
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("administrators")
- @Path("/info/backup-repository/{id}")
- public Response infoBackupRepositoryId(@PathParam("id") String id)
+ @Path("/info/backup-repository-id/{id}")
+ public Response infoRepositoryBackupId(@PathParam("id") String id)
{
try
{
@@ -1209,7 +1215,8 @@
}
/**
- * Will be returned the list short info of current and completed repository backups.
+ * Will be returned the list short info of current and completed backups. Filtered by specific
+ * repository.
*
* @param repository
* String, the repository name
@@ -1219,14 +1226,14 @@
@GET
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("administrators")
- @Path("/info/backup/repository/{repo}")
+ @Path("/info/backup-repository/{repo}")
public Response infoBackupByRepository(@PathParam("repo") String repository)
{
try
{
List<ShortInfo> list = new ArrayList<ShortInfo>();
- for (BackupChain chain : backupManager.getCurrentBackups())
+ for (RepositoryBackupChain chain : backupManager.getCurrentRepositoryBackups())
{
if (repository.equals(chain.getBackupConfig().getRepository()))
{
@@ -1234,9 +1241,9 @@
}
}
- for (BackupChainLog chainLog : backupManager.getBackupsLogs())
+ for (RepositoryBackupChainLog chainLog : backupManager.getRepositoryBackupsLogs())
{
- if (backupManager.findBackup(chainLog.getBackupId()) == null
+ if (backupManager.findRepositoryBackupId(chainLog.getBackupId()) == null
&& repository.equals(chainLog.getBackupConfig().getRepository()))
{
list.add(new ShortInfo(ShortInfo.COMPLETED, chainLog));
@@ -1249,10 +1256,10 @@
}
catch (Throwable e)
{
- log.error("Can not get information about current or completed backups", e);
+ log.error("Can not get information about current or completed repository backups", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about current or completed backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
+ "Can not get information about current or completed repository backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
.cacheControl(noCache).build();
}
}
@@ -1320,8 +1327,8 @@
@GET
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("administrators")
- @Path("/info/restore/{repo}")
- public Response infoRestore(@PathParam("repo") String repository)
+ @Path("/info/restore-repository/{repo}")
+ public Response infoRestoreRepository(@PathParam("repo") String repository)
{
try
{
14 years, 2 months
exo-jcr SVN: r2137 - in jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr: config and 21 other directories.
by do-not-reply@jboss.org
Author: sergiykarpenko
Date: 2010-03-25 11:31:56 -0400 (Thu, 25 Mar 2010)
New Revision: 2137
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessControlList.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/SearchManagerEntry.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/ExtendedItemDefinition.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/NodeTypeDataImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemState.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/WorkspaceContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/JCRPath.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/LocationFactory.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceRegistryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionFactory.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionRegistry.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/XASessionImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/access/BaseAuthenticator.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/itemfilters/ItemDataNamePatternFilter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockRemover.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableSessionLockManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/LockJDBCContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/InmemoryNodeTypeRepository.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionDataHolder.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeDefinitionImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataHierarchyHolder.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeManagerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/PropertyDefinitionImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/VolatileNodeTypeDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeDefinitionComparator.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeConverter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataValidator.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/RelatedDefinition.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/XmlNodeTypeDataPersister.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ObservationManagerRegistry.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryHandler.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ErrorLog.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexException.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerIoModeHandler.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/OnWorkspaceInconsistency.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/PropertyTypeRegistry.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryTreeBuilderRegistry.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/RepositoryIndexSearcherHolder.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingletonStoreCacheLoader.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexUpdateMonitor.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractExcerpt.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractNamespaceMappings.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AggregateRuleImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/CachingIndexReader.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ConsistencyCheck.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocNumberCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocOrderScoreNodeIterator.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMerger.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMigration.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingConfigurationImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueue.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueueStore.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LazyTextExtractorField.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneVirtualTableResolver.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQueryResult.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIteratorImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PropertiesSynonymProvider.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Recovery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RedoLog.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RowIteratorImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScoreNodeIteratorImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SimpleExcerptProvider.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SortedLuceneQueryHits.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TermDocsCache.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WeightedHighlighter.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WildcardQuery.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/hits/AdaptingHits.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/sql/JCRSQLQueryBuilder.java
Log:
EXOJCR-605: jcr.core Loggers updated
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessControlList.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessControlList.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessControlList.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -44,7 +44,7 @@
private static final long serialVersionUID = 5848327750178729120L;
- private Log log = ExoLogger.getLogger("jcr.AccessControlList");
+ private Log log = ExoLogger.getLogger("exo.jcr.component.core.AccessControlList");
public static final String DELIMITER = ";";
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessManager.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/access/AccessManager.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -44,7 +44,7 @@
public abstract class AccessManager
{
- protected static Log log = ExoLogger.getLogger("jcr.AccessManager");
+ protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.AccessManager");
protected final Map<String, String> parameters;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/SearchManagerEntry.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/SearchManagerEntry.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/config/SearchManagerEntry.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -34,7 +34,7 @@
/**
* Class logger.
*/
- private final Log log = ExoLogger.getLogger("jcr.SearchManagerEntry");
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.SearchManagerEntry");
/**
* Name of the default query implementation class.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/ExtendedItemDefinition.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/ExtendedItemDefinition.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/ExtendedItemDefinition.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -31,7 +31,7 @@
{
/**
- * Remove it from NodeImpl.findNodeType, BaseXmlExporter.findNodeType, tests
+ * TODO Remove it from NodeImpl.findNodeType, BaseXmlExporter.findNodeType, tests
*/
// @Deprecated
// public static String RESIDUAL_SET = "*";
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/NodeTypeDataImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/NodeTypeDataImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/nodetype/NodeTypeDataImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -48,15 +48,15 @@
protected Boolean mixin;
- // protected Boolean isAbstract;
+ // protected Boolean isAbstract;
-// /**
-// * Default true.
-// */
-// protected boolean isQueryable;
+ // /**
+ // * Default true.
+ // */
+ // protected boolean isQueryable;
public NodeTypeDataImpl(InternalQName name, InternalQName primaryItemName, boolean mixin,
- boolean hasOrderableChildNodes, InternalQName[] declaredSupertypeNames,
+ boolean hasOrderableChildNodes, InternalQName[] declaredSupertypeNames,
PropertyDefinitionData[] declaredPropertyDefinitions, NodeDefinitionData[] declaredChildNodeDefinitions)
{
@@ -70,14 +70,6 @@
this.declaredPropertyDefinitions = declaredPropertyDefinitions;
this.declaredChildNodeDefinitions = declaredChildNodeDefinitions;
}
-//
-// /**
-// * @see org.exoplatform.services.jcr.core.nodetype.NodeTypeData#isAbstract()
-// */
-// public boolean isAbstract()
-// {
-// return isAbstract;
-// }
/**
* @see org.exoplatform.services.jcr.core.nodetype.NodeTypeData#getDeclaredChildNodeDefinitions()
@@ -211,12 +203,12 @@
return mixin;
}
-// /**
-// * @see org.exoplatform.services.jcr.core.nodetype.NodeTypeData#isQueryable()
-// */
-// public boolean isQueryable()
-// {
-// return isQueryable;
-// }
+ // /**
+ // * @see org.exoplatform.services.jcr.core.nodetype.NodeTypeData#isQueryable()
+ // */
+ // public boolean isQueryable()
+ // {
+ // return isQueryable;
+ // }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemState.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemState.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/ItemState.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -39,7 +39,7 @@
private static final long serialVersionUID = 7967457831325761318L;
- private static Log log = ExoLogger.getLogger("jcr.ItemState");
+ private static Log log = ExoLogger.getLogger("exo.jcr.component.core.ItemState");
public static final int ADDED = 1;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/dataflow/persistent/PersistedItemData.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -18,11 +18,6 @@
*/
package org.exoplatform.services.jcr.dataflow.persistent;
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.QPath;
@@ -33,8 +28,6 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import javax.jcr.RepositoryException;
-
/**
* Created by The eXo Platform SAS. </br>
*
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/datamodel/QPath.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -41,7 +41,7 @@
/**
* Logger.
*/
- protected static final Log LOG = ExoLogger.getLogger("jcr.QPath");
+ protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.QPath");
/**
* QPath prefix delimiter.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryContainer.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -41,7 +41,6 @@
import org.exoplatform.services.jcr.impl.core.WorkspaceInitializer;
import org.exoplatform.services.jcr.impl.core.access.DefaultAccessManagerImpl;
import org.exoplatform.services.jcr.impl.core.lock.LockManagerImpl;
-import org.exoplatform.services.jcr.impl.core.lock.jbosscache.CacheableLockManagerImpl;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeDataManagerImpl;
import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerImpl;
import org.exoplatform.services.jcr.impl.core.nodetype.registration.JCRNodeTypeDataPersister;
@@ -98,7 +97,7 @@
/**
* Logger.
*/
- private final Log log = ExoLogger.getLogger("jcr.RepositoryContainer");
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.RepositoryContainer");
/**
* RepositoryContainer constructor.
@@ -267,24 +266,24 @@
}
}
-
- if (wsConfig.getLockManager() != null && wsConfig.getLockManager().getType() != null)
+ if (wsConfig.getLockManager() != null && wsConfig.getLockManager().getType() != null)
{
try
{
Class<?> lockManagerType = Class.forName(wsConfig.getLockManager().getType());
workspaceContainer.registerComponentImplementation(lockManagerType);
- } catch (ClassNotFoundException e) {
+ }
+ catch (ClassNotFoundException e)
+ {
throw new RepositoryConfigurationException("Class not found for workspace lock manager "
- + wsConfig.getLockManager().getType() + ", container " + wsConfig.getUniqueName()
- + " : " + e);
+ + wsConfig.getLockManager().getType() + ", container " + wsConfig.getUniqueName() + " : " + e);
}
}
else
{
workspaceContainer.registerComponentImplementation(LockManagerImpl.class);
}
-
+
// Query handler
if (wsConfig.getQueryHandler() != null)
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/RepositoryServiceImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -60,7 +60,7 @@
public class RepositoryServiceImpl implements RepositoryService, Startable
{
- protected static Log log = ExoLogger.getLogger("jcr.RepositoryService");
+ protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.RepositoryServiceImpl");
private final RepositoryServiceConfiguration config;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/WorkspaceContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/WorkspaceContainer.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/WorkspaceContainer.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -47,7 +47,7 @@
public class WorkspaceContainer extends ExoContainer
{
- protected static Log log = ExoLogger.getLogger("jcr.WorkspaceContainer");
+ protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.WorkspaceContainer");
private final String name;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/config/JDBCConfigurationPersister.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -35,7 +35,6 @@
import java.sql.ResultSet;
import java.sql.SQLException;
-import javax.jcr.RepositoryException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
@@ -49,7 +48,7 @@
public class JDBCConfigurationPersister implements ConfigurationPersister
{
- protected static Log LOG = ExoLogger.getLogger("jcr.JDBCConfigurationPersister");
+ protected static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.JDBCConfigurationPersister");
public final static String PARAM_SOURCE_NAME = "source-name";
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ItemImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -82,7 +82,7 @@
/**
* Logger.
*/
- private static Log log = ExoLogger.getLogger("jcr.ItemImpl");
+ private static Log log = ExoLogger.getLogger("exo.jcr.component.core.ItemImpl");
/**
* Session object.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/JCRPath.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/JCRPath.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/JCRPath.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -46,7 +46,7 @@
public final static String PARENT_RELPATH = "..";
- protected static Log log = ExoLogger.getLogger("jcr.JCRPath");
+ protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.JCRPath");
protected PathElement[] names;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/LocationFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/LocationFactory.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/LocationFactory.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -39,7 +39,7 @@
public class LocationFactory
{
- protected static Log log = ExoLogger.getLogger("jcr.LocationFactory");
+ protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.LocationFactory");
private NamespaceAccessor namespaces;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceRegistryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceRegistryImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NamespaceRegistryImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -50,7 +50,7 @@
private final static Set<String> PROTECTED_NAMESPACES = new HashSet<String>();
- protected final static Log log = ExoLogger.getLogger("jcr.NamespaceRegistryImpl");
+ protected final static Log log = ExoLogger.getLogger("exo.jcr.component.core.NamespaceRegistryImpl");
private boolean started = false;
static
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/NodeImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -118,7 +118,7 @@
/**
* Logger.
*/
- protected static final Log LOG = ExoLogger.getLogger("jcr.NodeImpl");
+ protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.NodeImpl");
/**
* System LocationFactory.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/PropertyImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -26,7 +26,6 @@
import org.exoplatform.services.jcr.datamodel.ItemData;
import org.exoplatform.services.jcr.datamodel.NodeData;
import org.exoplatform.services.jcr.datamodel.PropertyData;
-import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.nodetype.PropertyDefinitionImpl;
import org.exoplatform.services.jcr.impl.core.value.BaseValue;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/RepositoryImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -81,7 +81,7 @@
/**
* Logger.
*/
- protected static final Log LOG = ExoLogger.getLogger("jcr:RepositoryImpl");
+ protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.RepositoryImpl");
static
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/ScratchWorkspaceInitializer.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -66,7 +66,7 @@
public class ScratchWorkspaceInitializer implements WorkspaceInitializer
{
- protected static final Log log = ExoLogger.getLogger("jcr.WorkspaceInitializer");
+ protected static final Log log = ExoLogger.getLogger("exo.jcr.component.core.WorkspaceInitializer");
private final String systemWorkspaceName;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionDataManager.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -80,7 +80,7 @@
public static final int MERGE_ITEMS = 3;
- protected static Log log = ExoLogger.getLogger("jcr.SessionDataManager");
+ protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.SessionDataManager");
protected final SessionImpl session;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionFactory.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionFactory.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionFactory.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -29,7 +29,6 @@
import javax.jcr.LoginException;
import javax.jcr.RepositoryException;
-import javax.transaction.xa.XAException;
/**
* Created by The eXo Platform SAS.<br/> the factory for jcr Session
@@ -41,7 +40,7 @@
public class SessionFactory
{
- protected static Log LOG = ExoLogger.getLogger("jcr.SessionFactory");
+ protected static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.SessionFactory");
private final ExoContainer container;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionRegistry.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionRegistry.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SessionRegistry.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -44,7 +44,7 @@
// 1 min
public final static int DEFAULT_CLEANER_TIMEOUT = 60 * 1000;
- protected static Log log = ExoLogger.getLogger("jcr.SessionRegistry");
+ protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.SessionRegistry");
private SessionCleaner sessionCleaner;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/SysViewWorkspaceInitializer.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -83,7 +83,7 @@
public static final String RESTORE_PATH_PARAMETER = "restore-path";
- protected static final Log log = ExoLogger.getLogger("jcr.WorkspaceInitializer");
+ protected static final Log log = ExoLogger.getLogger("exo.jcr.component.core.WorkspaceInitializer");
protected final String workspaceName;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/WorkspaceImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -82,7 +82,7 @@
public class WorkspaceImpl implements ExtendedWorkspace
{
- protected static Log log = ExoLogger.getLogger("jcr.WorkspaceImpl");
+ protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.WorkspaceImpl");
private final SessionImpl session;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/XASessionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/XASessionImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/XASessionImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -47,7 +47,7 @@
/**
* Session logger.
*/
- private static final Log LOG = ExoLogger.getLogger("jcr.XASessionImpl");
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.XASessionImpl");
/**
* Transaction service.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/access/BaseAuthenticator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/access/BaseAuthenticator.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/access/BaseAuthenticator.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -41,7 +41,7 @@
abstract public class BaseAuthenticator implements AuthenticationPolicy
{
- protected static Log log = ExoLogger.getLogger("jcr.BaseAuthenticator");
+ protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.BaseAuthenticator");
protected RepositoryEntry config;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/itemfilters/ItemDataNamePatternFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/itemfilters/ItemDataNamePatternFilter.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/itemfilters/ItemDataNamePatternFilter.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -45,7 +45,7 @@
/**
* Logger.
*/
- protected static final Log LOG = ExoLogger.getLogger("jcr.ItemDataNamePatternFilter");
+ protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.ItemDataNamePatternFilter");
private final SessionImpl session;
@@ -61,19 +61,6 @@
{
String token = parser.nextToken();
- // String expr;
- // int prefixIndex = token.indexOf(":");
- // if (prefixIndex > 0)
- // {
- // expr =
- // "[" + session.getNamespaceURI(token.substring(0, prefixIndex)) + "]"
- // + (prefixIndex < token.length() - 1 ? token.substring(prefixIndex + 1) : "");
- // }
- // else
- // {
- // expr = token;
- // }
-
expressions.add(token.trim());
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/FileSystemLockPersister.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -62,7 +62,7 @@
/**
* logger.
*/
- private final Log log = ExoLogger.getLogger("jcr.lock.LockPersister");
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.FileSystemLockPersister");
/**
* The directory which stores information of the locks.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockManagerImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -102,7 +102,7 @@
/**
* Logger
*/
- private final Log log = ExoLogger.getLogger("jcr.lock.LockManagerImpl");
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.LockManagerImpl");
/**
* Map NodeIdentifier -- lockData
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockRemover.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockRemover.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/LockRemover.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -31,7 +31,7 @@
public class LockRemover extends WorkerThread
{
- private final Log log = ExoLogger.getLogger("jcr.lock.LockRemover");
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.LockRemover");
public static final long DEFAULT_THREAD_TIMEOUT = 30000; // 30
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableLockManagerImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -135,7 +135,7 @@
/**
* Logger
*/
- private final Log LOG = ExoLogger.getLogger("jcr.lock.CacheableLockManagerImpl");
+ private final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.CacheableLockManagerImpl");
/**
* Data manager.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableSessionLockManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableSessionLockManager.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/CacheableSessionLockManager.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -51,7 +51,7 @@
/**
* Logger
*/
- private final Log log = ExoLogger.getLogger("jcr.lock.SessionLockManager");
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.CacheableSessionLockManager");
/**
* Session identifier.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/CacheableJDBCLockManagerImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -121,7 +121,7 @@
/**
* Logger
*/
- private final Log log = ExoLogger.getLogger("jcr.lock.CacheableLockManagerImpl");
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.CacheableJDBCLockManagerImpl");
/**
* Data manager.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/LockJDBCContainer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/LockJDBCContainer.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/jbosscache/jdbc/LockJDBCContainer.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -18,8 +18,6 @@
*/
package org.exoplatform.services.jcr.impl.core.lock.jbosscache.jdbc;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DBConstants;
-import org.exoplatform.services.jcr.impl.storage.jdbc.DialectDetecter;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializer;
import org.exoplatform.services.jcr.impl.util.jdbc.DBInitializerException;
import org.exoplatform.services.log.ExoLogger;
@@ -152,8 +150,7 @@
* @throws IOException
* @throws DBInitializerException
*/
- protected void initDatabase(String dataSource, Connection jdbcConn) throws IOException,
- DBInitializerException
+ protected void initDatabase(String dataSource, Connection jdbcConn) throws IOException, DBInitializerException
{
DBInitializer dbInitializer = new DBInitializer(dataSource, jdbcConn, "/conf/storage/jcr-lock-jdbc.sql");
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/InmemoryNodeTypeRepository.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/InmemoryNodeTypeRepository.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/InmemoryNodeTypeRepository.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -39,15 +39,13 @@
*/
public class InmemoryNodeTypeRepository extends AbstractNodeTypeRepository
{
- private final Log log = ExoLogger.getLogger(InmemoryNodeTypeRepository.class.getName());
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.InmemoryNodeTypeRepository");
private final ItemDefinitionDataHolder defsHolder;
private final NodeTypeDataHierarchyHolder hierarchy;
-
- private boolean haveTypes = false;
-
+ private boolean haveTypes = false;
/**
* @param defsHolder
@@ -80,7 +78,7 @@
{
hierarchy.addNodeType(nodeType, volatileNodeTypes);
-
+
// put supers
final Set<InternalQName> supers = hierarchy.getSupertypes(nodeType.getName(), volatileNodeTypes);
@@ -89,7 +87,7 @@
defsHolder.putDefinitions(nodeType.getName(), hierarchy.getNodeType(superName, volatileNodeTypes));
}
haveTypes = true;
-
+
// put prop def
defsHolder.putDefinitions(nodeType.getName(), nodeType);
}
@@ -243,6 +241,6 @@
}
// remove it self
defsHolder.removeDefinitions(nodeTypeName, nodeType);
- haveTypes = hierarchy.getAllNodeTypes().size()>0;
+ haveTypes = hierarchy.getAllNodeTypes().size() > 0;
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemAutocreator.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -60,7 +60,7 @@
public class ItemAutocreator
{
- private final Log log = ExoLogger.getLogger(getClass().getName());
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.ItemAutocreator");
private final NodeTypeDataManager nodeTypeDataManager;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionDataHolder.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionDataHolder.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionDataHolder.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -45,7 +45,7 @@
public class ItemDefinitionDataHolder
{
- private static Log LOG = ExoLogger.getLogger("jcr.ItemDefinitionDataHolder");
+ private static Log LOG = ExoLogger.getLogger("exo.jcr.component.core.ItemDefinitionDataHolder");
private final Map<InternalQName, Map<InternalQName, Map<InternalQName, NodeDefinitionData>>> nodeDefinitions;
@@ -202,7 +202,7 @@
for (PropertyDefinitionData propDef : propDefs)
{
addPropertyDefinitionInternal(name, propDef.getName(), propDef.isMultiple(), propDef);
-
+
if (LOG.isDebugEnabled())
{
LOG.debug("PropDef added: parent NT: " + name.getAsString() + " child propName: "
@@ -235,7 +235,7 @@
{
LOG.debug("Default NodeDef removed: parent NT: " + name.getAsString() + " child nodeName: "
+ nodeDef.getName());
- }
+ }
}
// remove defs
@@ -324,12 +324,12 @@
if (def == null)
{
def = new HashMap<Boolean, PropertyDefinitionData>();
- defs.put(childName, def);
+ defs.put(childName, def);
}
- def.put(multiValued, propDef);
+ def.put(multiValued, propDef);
}
-
+
private void removePropertyDefinitionInternal(InternalQName parentNodeType, InternalQName childName,
boolean multiValued)
{
@@ -343,9 +343,9 @@
{
return;
}
- def.remove(multiValued);
+ def.remove(multiValued);
}
-
+
private NodeDefinitionData getNodeDefinitionDataInternal(InternalQName parentNodeType, InternalQName childName,
InternalQName childNodeType)
{
@@ -361,7 +361,7 @@
}
return def.get(childNodeType);
}
-
+
private void addNodeDefinitionDataInternal(InternalQName parentNodeType, InternalQName childName,
InternalQName childNodeType, NodeDefinitionData nodeDef)
{
@@ -375,12 +375,12 @@
if (def == null)
{
def = new HashMap<InternalQName, NodeDefinitionData>();
- defs.put(childName, def);
+ defs.put(childName, def);
}
- def.put(childNodeType, nodeDef);
+ def.put(childNodeType, nodeDef);
}
-
+
private void removeNodeDefinitionDataInternal(InternalQName parentNodeType, InternalQName childName,
InternalQName childNodeType)
{
@@ -394,9 +394,9 @@
{
return;
}
- def.remove(childNodeType);
+ def.remove(childNodeType);
}
-
+
/**
* Create copy of holder.
*
@@ -407,12 +407,12 @@
return new ItemDefinitionDataHolder(cloneMap(nodeDefinitions), cloneMap(propertyDefinitions),
cloneMap(defNodeDefinitions));
}
-
+
@SuppressWarnings("unchecked")
- private static <K,V> Map<K,V> cloneMap(Map<? extends K, ? extends V> map)
+ private static <K, V> Map<K, V> cloneMap(Map<? extends K, ? extends V> map)
{
- Map<K,V> copyMap = (Map<K,V>)((HashMap<K, V>)map).clone();
-
+ Map<K, V> copyMap = (Map<K, V>)((HashMap<K, V>)map).clone();
+
for (Entry<K, V> entry : copyMap.entrySet())
{
if (entry.getValue() instanceof Map<?, ?>)
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/ItemDefinitionImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -42,7 +42,7 @@
/**
* Class logger.
*/
- private static final Log LOG = ExoLogger.getLogger(ItemDefinitionImpl.class);
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.ItemDefinitionImpl");
protected final NodeTypeDataManager nodeTypeDataManager;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeDefinitionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeDefinitionImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeDefinitionImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -43,7 +43,7 @@
/**
* Class logger.
*/
- private static final Log LOG = ExoLogger.getLogger(NodeDefinitionImpl.class);
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.NodeDefinitionImpl");
private final NodeDefinitionData nodeDefinitionData;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataHierarchyHolder.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataHierarchyHolder.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataHierarchyHolder.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -44,7 +44,7 @@
/**
* Class logger.
*/
- private static final Log LOG = ExoLogger.getLogger(NodeTypeDataHierarchyHolder.class);
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.NodeTypeDataHierarchyHolder");
private final Map<InternalQName, NodeTypeHolder> nodeTypes;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDataManagerImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -84,7 +84,7 @@
private static final String NODETYPES_FILE = "nodetypes.xml";
- private final Log log = ExoLogger.getLogger(NodeTypeDataManagerImpl.class.getName());
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.NodeTypeDataManagerImpl");
protected final String accessControlPolicy;
@@ -196,7 +196,7 @@
}
}
}
-
+
for (final NodeDefinitionData cnd : this.nodeTypeRepository.getNodeType(ntname)
.getDeclaredChildNodeDefinitions())
{
@@ -210,7 +210,7 @@
}
}
}
-
+
defsAny.addAll(defs.values());
return defsAny.toArray(new NodeDefinitionData[defsAny.size()]);
@@ -243,14 +243,14 @@
{
final Collection<PropertyDefinitionData> defsAny = new ArrayList<PropertyDefinitionData>();
final HashMap<InternalQName, PropertyDefinitionData> defs = new HashMap<InternalQName, PropertyDefinitionData>();
-
+
for (final InternalQName ntname : nodeTypeNames)
{
for (final InternalQName suname : this.nodeTypeRepository.getSupertypes(ntname))
{
for (final PropertyDefinitionData pd : this.nodeTypeRepository.getNodeType(suname)
- .getDeclaredPropertyDefinitions())
+ .getDeclaredPropertyDefinitions())
{
if (pd.getName().equals(Constants.JCR_ANY_NAME))
{
@@ -264,7 +264,7 @@
}
for (final PropertyDefinitionData pd : this.nodeTypeRepository.getNodeType(ntname)
- .getDeclaredPropertyDefinitions())
+ .getDeclaredPropertyDefinitions())
{
if (pd.getName().equals(Constants.JCR_ANY_NAME))
{
@@ -276,7 +276,7 @@
}
}
}
-
+
defsAny.addAll(defs.values());
return defsAny.toArray(new PropertyDefinitionData[defsAny.size()]);
@@ -395,7 +395,7 @@
PropertyDefinitionDatas propertyDefinitions =
this.nodeTypeRepository.getPropertyDefinitions(propertyName, nodeTypeNames);
-
+
// Try super
if (propertyDefinitions == null)
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeDefinitionImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -36,12 +36,12 @@
* @author <a href="mailto:Sergey.Kabashnyuk@gmail.com">Sergey Kabashnyuk</a>
* @version $Id: $
*/
-public class NodeTypeDefinitionImpl
+public class NodeTypeDefinitionImpl
{
/**
* Class logger.
*/
- private static final Log LOG = ExoLogger.getLogger(NodeTypeDefinitionImpl.class);
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.NodeTypeDefinitionImpl");
protected NodeTypeData nodeTypeData;
@@ -213,13 +213,13 @@
return nodeTypeData.hasOrderableChildNodes();
}
-// /**
-// * {@inheritDoc}
-// */
-// public boolean isAbstract()
-// {
-// return nodeTypeData.isAbstract();
-// }
+ // /**
+ // * {@inheritDoc}
+ // */
+ // public boolean isAbstract()
+ // {
+ // return nodeTypeData.isAbstract();
+ // }
/**
* {@inheritDoc}
@@ -229,12 +229,12 @@
return nodeTypeData.isMixin();
}
-// /**
-// * {@inheritDoc}
-// */
-// public boolean isQueryable()
-// {
-// return nodeTypeData.isQueryable();
-// }
+ // /**
+ // * {@inheritDoc}
+ // */
+ // public boolean isQueryable()
+ // {
+ // return nodeTypeData.isQueryable();
+ // }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -63,7 +63,7 @@
/**
* Logger.
*/
- protected static final Log LOG = ExoLogger.getLogger("jcr.NodeTypeImpl");
+ protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.NodeTypeImpl");
/**
* @param nodeTypeData
@@ -693,13 +693,13 @@
}
}
- /**
- * Check value constrains.
- *
- * @param constraints - string constrains.
- * @param value - value to check.
- * @return result of check.
- */
+ /**
+ * Check value constrains.
+ *
+ * @param constraints - string constrains.
+ * @param value - value to check.
+ * @return result of check.
+ */
private boolean checkValueConstraints(String[] constraints, Value value)
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeManagerImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/NodeTypeManagerImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -59,7 +59,7 @@
public class NodeTypeManagerImpl implements ExtendedNodeTypeManager
{
- protected static final Log LOG = ExoLogger.getLogger("jcr.NodeTypeManagerImpl");
+ protected static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.NodeTypeManagerImpl");
public static final String NODETYPES_ROOT = "/jcr:system/jcr:nodetypes";
@@ -220,6 +220,7 @@
return typesManager.getNodeType(locationFactory.parseJCRName(name).getInternalName()) != null;
}
+
/**
* {@inheritDoc}
*/
@@ -269,7 +270,7 @@
return types;
}
-
+
/**
* {@inheritDoc}
*
@@ -280,7 +281,8 @@
public NodeTypeIterator registerNodeTypes(InputStream xml, int alreadyExistsBehaviour) throws RepositoryException
{
- Collection<NodeTypeData> nts = typesManager.registerNodeTypes(xml, alreadyExistsBehaviour, NodeTypeDataManager.TEXT_XML);
+ Collection<NodeTypeData> nts =
+ typesManager.registerNodeTypes(xml, alreadyExistsBehaviour, NodeTypeDataManager.TEXT_XML);
EntityCollection types = new EntityCollection();
for (NodeTypeData ntdata : nts)
types.add(new NodeTypeImpl(ntdata, typesManager, this, locationFactory, valueFactory));
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/PropertyDefinitionImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/PropertyDefinitionImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/PropertyDefinitionImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -40,6 +40,11 @@
public class PropertyDefinitionImpl extends ItemDefinitionImpl implements PropertyDefinition
{
+ /**
+ * Class logger.
+ */
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.PropertyDefinitionImpl");
+
private final PropertyDefinitionData propertyDefinitionData;
/**
@@ -58,11 +63,6 @@
}
/**
- * Class logger.
- */
- private static final Log LOG = ExoLogger.getLogger(PropertyDefinitionImpl.class);
-
- /**
* {@inheritDoc}
*/
public Value[] getDefaultValues()
@@ -104,29 +104,29 @@
{
return propertyDefinitionData.isMultiple();
}
-//
-// /**
-// * {@inheritDoc}
-// */
-// public String[] getAvailableQueryOperators()
-// {
-// return propertyDefinitionData.getAvailableQueryOperators();
-// }
-//
-// /**
-// * {@inheritDoc}
-// */
-// public boolean isFullTextSearchable()
-// {
-// return propertyDefinitionData.isFullTextSearchable();
-// }
-//
-// /**
-// * {@inheritDoc}
-// */
-// public boolean isQueryOrderable()
-// {
-// return propertyDefinitionData.isQueryOrderable();
-// }
+ //
+ // /**
+ // * {@inheritDoc}
+ // */
+ // public String[] getAvailableQueryOperators()
+ // {
+ // return propertyDefinitionData.getAvailableQueryOperators();
+ // }
+ //
+ // /**
+ // * {@inheritDoc}
+ // */
+ // public boolean isFullTextSearchable()
+ // {
+ // return propertyDefinitionData.isFullTextSearchable();
+ // }
+ //
+ // /**
+ // * {@inheritDoc}
+ // */
+ // public boolean isQueryOrderable()
+ // {
+ // return propertyDefinitionData.isQueryOrderable();
+ // }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/VolatileNodeTypeDataManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/VolatileNodeTypeDataManager.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/VolatileNodeTypeDataManager.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -41,7 +41,7 @@
/**
* Class logger.
*/
- private final Log log = ExoLogger.getLogger(VolatileNodeTypeDataManager.class);
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.VolatileNodeTypeDataManager");
public VolatileNodeTypeDataManager(final NodeTypeDataManagerImpl nodeTypeDataManagerImpl) throws RepositoryException
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/JCRNodeTypeDataPersister.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -64,7 +64,7 @@
public class JCRNodeTypeDataPersister implements NodeTypeDataPersister
{
- protected final Log log = ExoLogger.getLogger(getClass().getName());
+ protected final Log log = ExoLogger.getLogger("exo.jcr.component.core.JCRNodeTypeDataPersister");
private final DataManager dataManager;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeDefinitionComparator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeDefinitionComparator.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeDefinitionComparator.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -52,7 +52,7 @@
/**
* Class logger.
*/
- private static final Log LOG = ExoLogger.getLogger(NodeDefinitionComparator.class);
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.NodeDefinitionComparator");
private final List<NodeData> affectedNodes;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeConverter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeConverter.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeConverter.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -49,7 +49,7 @@
/**
* Class logger.
*/
- private final Log log = ExoLogger.getLogger(NodeTypeConverter.class);
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.NodeTypeConverter");
private final LocationFactory locationFactory;
@@ -105,8 +105,7 @@
pd =
new PropertyDefinitionData(locationFactory.parseJCRName(v.getName()).getInternalName(), ntName, v
.isAutoCreate(), v.isMandatory(), v.getOnVersion(), v.isReadOnly(), v.getRequiredType(),
- safeListToArray(v.getValueConstraints()), safeListToArray(v.getDefaultValueStrings()),
- v.isMultiple());
+ safeListToArray(v.getValueConstraints()), safeListToArray(v.getDefaultValueStrings()), v.isMultiple());
props[i] = pd;
}
@@ -140,7 +139,8 @@
primaryItemName = locationFactory.parseJCRName(ntvalue.getPrimaryItemName()).getInternalName();
NodeTypeData nodeTypeData =
- new NodeTypeDataImpl(ntName, primaryItemName, ntvalue.isMixin(), ntvalue.isOrderableChild(), supertypes, props, nodes);
+ new NodeTypeDataImpl(ntName, primaryItemName, ntvalue.isMixin(), ntvalue.isOrderableChild(), supertypes,
+ props, nodes);
nodeTypeDataList.add(nodeTypeData);
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataValidator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataValidator.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/NodeTypeDataValidator.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -43,7 +43,7 @@
/**
* Class logger.
*/
- private final Log log = ExoLogger.getLogger(NodeTypeDataValidator.class);
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.NodeTypeDataValidator");
protected final NodeTypeRepository hierarchy;
@@ -112,13 +112,13 @@
{
msg += " " + internalQName.getAsString();
}
-
- msg +=" Unresolved ";
+
+ msg += " Unresolved ";
for (InternalQName internalQName : unresolvedDependecies)
{
msg += " " + internalQName.getAsString();
}
-
+
throw new RepositoryException(msg);
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/PropertyDefinitionComparator.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -57,7 +57,7 @@
/**
* Class logger.
*/
- private static final Log LOG = ExoLogger.getLogger(PropertyDefinitionComparator.class);
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.PropertyDefinitionComparator");
private final List<NodeData> affectedNodes;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/RelatedDefinition.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/RelatedDefinition.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/RelatedDefinition.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -32,7 +32,7 @@
/**
* Class logger.
*/
- private static final Log LOG = ExoLogger.getLogger(RelatedDefinition.class);
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.RelatedDefinition");
private final T ancestorDefinition;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/XmlNodeTypeDataPersister.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/XmlNodeTypeDataPersister.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/nodetype/registration/XmlNodeTypeDataPersister.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -46,7 +46,7 @@
/**
* Class logger.
*/
- private final Log log = ExoLogger.getLogger(XmlNodeTypeDataPersister.class);
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.XmlNodeTypeDataPersister");
private final NodeTypeConverter converter;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ActionLauncher.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -56,7 +56,7 @@
public final int SKIP_EVENT = Integer.MIN_VALUE;
- private final Log log = ExoLogger.getLogger("jcr.ActionLauncher");
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.ActionLauncher");
private final ObservationManagerRegistry observationRegistry;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ObservationManagerRegistry.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ObservationManagerRegistry.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/observation/ObservationManagerRegistry.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -43,7 +43,7 @@
public class ObservationManagerRegistry
{
- protected static Log log = ExoLogger.getLogger("jcr.RepositoryService");
+ protected static Log log = ExoLogger.getLogger("exo.jcr.component.core.ObservationManagerRegistry");
protected Map<EventListener, ListenerCriteria> listenersMap;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryHandler.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryHandler.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryHandler.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -39,7 +39,7 @@
/**
* Logger instance for this class
*/
- private static final Logger log = LoggerFactory.getLogger(AbstractQueryHandler.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.AbstractQueryHandler");
/**
* The context for this query handler.
@@ -87,7 +87,8 @@
public void setIndexerIoModeHandler(IndexerIoModeHandler modeHandler) throws IOException
{
this.modeHandler = modeHandler;
- }
+ }
+
/**
* @see org.exoplatform.services.jcr.impl.core.query.QueryHandler#setContext(org.exoplatform.services.jcr.impl.core.query.QueryHandlerContext)
*/
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/AbstractQueryImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,68 +16,46 @@
*/
package org.exoplatform.services.jcr.impl.core.query;
+import org.exoplatform.services.jcr.impl.core.SessionDataManager;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.query.InvalidQueryException;
import javax.jcr.query.Query;
-import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
-import org.exoplatform.services.jcr.impl.core.SessionDataManager;
-import org.exoplatform.services.jcr.impl.core.SessionImpl;
-
/**
* Defines common initialization methods for all query implementations.
*/
-public abstract class AbstractQueryImpl implements Query {
+public abstract class AbstractQueryImpl implements Query
+{
- /**
- * Initializes a query instance from a query string.
- *
- * @param session the session of the user executing this query.
- * @param itemMgr the item manager of the session executing this query.
- * @param handler the query handler of the search index.
- * @param statement the query statement.
- * @param language the syntax of the query statement.
- * @throws InvalidQueryException if the query statement is invalid according
- * to the specified <code>language</code>.
- */
- public abstract void init(SessionImpl session,
- SessionDataManager itemMgr,
- QueryHandler handler,
- String statement,
- String language) throws InvalidQueryException;
+ /**
+ * Initializes a query instance from a query string.
+ *
+ * @param session the session of the user executing this query.
+ * @param itemMgr the item manager of the session executing this query.
+ * @param handler the query handler of the search index.
+ * @param statement the query statement.
+ * @param language the syntax of the query statement.
+ * @throws InvalidQueryException if the query statement is invalid according
+ * to the specified <code>language</code>.
+ */
+ public abstract void init(SessionImpl session, SessionDataManager itemMgr, QueryHandler handler, String statement,
+ String language) throws InvalidQueryException;
- /**
- * Initializes a query instance from a nt:query node.
- *
- * @param session the session of the user executing this query.
- * @param itemMgr the item manager of the session executing this query.
- * @param handler the query handler of the search index.
- * @param node a node of type <code>nt:query</code>.
- * @throws InvalidQueryException If <code>node</code> is not a valid persisted query
- * (that is, a node of type <code>nt:query</code>).
- * @throws RepositoryException if another error occurs
- */
- public abstract void init(SessionImpl session,
- SessionDataManager itemMgr,
- QueryHandler handler,
- Node node)
- throws InvalidQueryException, RepositoryException;
+ /**
+ * Initializes a query instance from a nt:query node.
+ *
+ * @param session the session of the user executing this query.
+ * @param itemMgr the item manager of the session executing this query.
+ * @param handler the query handler of the search index.
+ * @param node a node of type <code>nt:query</code>.
+ * @throws InvalidQueryException If <code>node</code> is not a valid persisted query
+ * (that is, a node of type <code>nt:query</code>).
+ * @throws RepositoryException if another error occurs
+ */
+ public abstract void init(SessionImpl session, SessionDataManager itemMgr, QueryHandler handler, Node node)
+ throws InvalidQueryException, RepositoryException;
-// /**
-// * Initializes a query instance from a query object model.
-// *
-// * @param session the session of the user executing this query.
-// * @param itemMgr the item manager of the session executing this query.
-// * @param handler the query handler of the search index.
-// * @param qomTree the query object model tree.
-// * @param language the original query syntax from where the JQOM was
-// * created.
-// * @throws RepositoryException if another error occurs
-// */
-// public abstract void init(SessionImpl session,
-// ItemManager itemMgr,
-// QueryHandler handler,
-// QueryObjectModelTree qomTree,
-// String language) throws RepositoryException;
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ErrorLog.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ErrorLog.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/ErrorLog.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -42,196 +42,229 @@
* @version $Id: $
*/
-public class ErrorLog {
+public class ErrorLog
+{
- /**
- * Logger instance for this class
- */
- private static final Log LOG = ExoLogger.getLogger(ErrorLog.class);
+ /**
+ * Logger instance for this class
+ */
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.ErrorLog");
- /**
- * REMOVE term.
- */
- public static final String REMOVE = "rem";
+ /**
+ * REMOVE term.
+ */
+ public static final String REMOVE = "rem";
- /**
- * ADD term.
- */
- public static final String ADD = "add";
+ /**
+ * ADD term.
+ */
+ public static final String ADD = "add";
- /**
- * The log file
- */
- private final File logFile;
+ /**
+ * The log file
+ */
+ private final File logFile;
- /**
- * Writer to the log file
- */
- private FileChannel out;
+ /**
+ * Writer to the log file
+ */
+ private FileChannel out;
- /**
- * File size in Kb. Used on create and clear(truncate) methods.
- */
- private int fileSize = 0; // Kb
+ /**
+ * File size in Kb. Used on create and clear(truncate) methods.
+ */
+ private int fileSize = 0; // Kb
- /**
- * ErrorLog constructor.
- *
- * @param file
- * @param errorLogSize
- * @throws IOException
- */
- public ErrorLog(File file, int errorLogSize) throws IOException {
- fileSize = errorLogSize;
- logFile = file;
- openFile(file);
- }
+ /**
+ * ErrorLog constructor.
+ *
+ * @param file
+ * @param errorLogSize
+ * @throws IOException
+ */
+ public ErrorLog(File file, int errorLogSize) throws IOException
+ {
+ fileSize = errorLogSize;
+ logFile = file;
+ openFile(file);
+ }
- /**
- * openFile.
- *
- * @param log
- * @throws IOException
- */
- private void openFile(File log) throws IOException {
- // set file size;
- if (!log.exists()) {
- log.getParentFile().mkdirs();
- log.createNewFile();
+ /**
+ * openFile.
+ *
+ * @param log
+ * @throws IOException
+ */
+ private void openFile(File log) throws IOException
+ {
+ // set file size;
+ if (!log.exists())
+ {
+ log.getParentFile().mkdirs();
+ log.createNewFile();
- out = new FileOutputStream(log).getChannel();
- out.position(1024 * fileSize - 1);
- out.write(ByteBuffer.wrap(new byte[] { 0 }));
- out.position(0);
- out.force(false);
- } else {
- out = new FileOutputStream(log, true).getChannel();
- }
- }
+ out = new FileOutputStream(log).getChannel();
+ out.position(1024 * fileSize - 1);
+ out.write(ByteBuffer.wrap(new byte[]{0}));
+ out.position(0);
+ out.force(false);
+ }
+ else
+ {
+ out = new FileOutputStream(log, true).getChannel();
+ }
+ }
- /**
- * Appends an action to the log.
- *
- * @param action
- * the action to append.
- * @throws IOException
- * if the node cannot be written to the redo log.
- */
- public void append(String action, String uuid) throws IOException {
- initOut();
- out.write(ByteBuffer.wrap((action + " " + uuid + "\n").getBytes()));
- }
+ /**
+ * Appends an action to the log.
+ *
+ * @param action
+ * the action to append.
+ * @throws IOException
+ * if the node cannot be written to the redo log.
+ */
+ public void append(String action, String uuid) throws IOException
+ {
+ initOut();
+ out.write(ByteBuffer.wrap((action + " " + uuid + "\n").getBytes()));
+ }
- /**
- * Flushes all pending writes to the underlying file.
- *
- * @throws IOException
- * if an error occurs while writing.
- */
- public void flush() throws IOException {
- if (out != null) {
- out.force(false);
- }
- }
+ /**
+ * Flushes all pending writes to the underlying file.
+ *
+ * @throws IOException
+ * if an error occurs while writing.
+ */
+ public void flush() throws IOException
+ {
+ if (out != null)
+ {
+ out.force(false);
+ }
+ }
- /**
- * Clears the redo log.
- *
- * @throws IOException
- * if the redo log cannot be cleared.
- */
- public void clear() throws IOException {
- if (out != null) {
- out.truncate(0);
- out.close();
- out = new FileOutputStream(logFile).getChannel();
- out.position(1024 * fileSize - 1);
- out.write(ByteBuffer.wrap(new byte[] { 0 }));
- out.position(0);
- out.force(false);
- }
- }
+ /**
+ * Clears the redo log.
+ *
+ * @throws IOException
+ * if the redo log cannot be cleared.
+ */
+ public void clear() throws IOException
+ {
+ if (out != null)
+ {
+ out.truncate(0);
+ out.close();
+ out = new FileOutputStream(logFile).getChannel();
+ out.position(1024 * fileSize - 1);
+ out.write(ByteBuffer.wrap(new byte[]{0}));
+ out.position(0);
+ out.force(false);
+ }
+ }
- /**
- * Initializes the {@link #out} stream if it is not yet set.
- *
- * @throws IOException
- * if an error occurs while creating the output stream.
- */
- private void initOut() throws IOException {
- if (out == null) {
- FileOutputStream os = new FileOutputStream(logFile, false);
- out = os.getChannel();
- }
- }
+ /**
+ * Initializes the {@link #out} stream if it is not yet set.
+ *
+ * @throws IOException
+ * if an error occurs while creating the output stream.
+ */
+ private void initOut() throws IOException
+ {
+ if (out == null)
+ {
+ FileOutputStream os = new FileOutputStream(logFile, false);
+ out = os.getChannel();
+ }
+ }
- /**
- * Reads the log file .
- *
- * @throws IOException
- * if an error occurs while reading from the log file.
- */
- public List<String> readList() throws IOException {
- InputStream in = new FileInputStream(logFile);
- try {
- List<String> list = new ArrayList<String>();
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(in));
- String line;
- while ((line = reader.readLine()) != null) {
- if (!line.matches("\\x00++")) {
- list.add(line);
- }
- }
- return list;
+ /**
+ * Reads the log file .
+ *
+ * @throws IOException
+ * if an error occurs while reading from the log file.
+ */
+ public List<String> readList() throws IOException
+ {
+ InputStream in = new FileInputStream(logFile);
+ try
+ {
+ List<String> list = new ArrayList<String>();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ String line;
+ while ((line = reader.readLine()) != null)
+ {
+ if (!line.matches("\\x00++"))
+ {
+ list.add(line);
+ }
+ }
+ return list;
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- LOG.warn("Exception while closing error log: "
- + e.toString());
- }
- }
- }
- }
+ }
+ finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ LOG.warn("Exception while closing error log: " + e.toString());
+ }
+ }
+ }
+ }
- public void readChanges(Set<String> rem, Set<String> add)
- throws IOException {
- List<String> list = readList();
+ public void readChanges(Set<String> rem, Set<String> add) throws IOException
+ {
+ List<String> list = readList();
- Iterator<String> it = list.iterator();
- while (it.hasNext()) {
- String[] str = it.next().split(" ");
- if (str.length == 2) {
- if (str[0].equals(ADD)) {
- add.add(str[1]);
- } else if (str[0].equals(REMOVE)) {
- rem.add(str[1]);
- }
- }
- }
- }
+ Iterator<String> it = list.iterator();
+ while (it.hasNext())
+ {
+ String[] str = it.next().split(" ");
+ if (str.length == 2)
+ {
+ if (str[0].equals(ADD))
+ {
+ add.add(str[1]);
+ }
+ else if (str[0].equals(REMOVE))
+ {
+ rem.add(str[1]);
+ }
+ }
+ }
+ }
- public void writeChanges(Set<String> removed, Set<String> added)
- throws IOException {
- try {
- if (!removed.isEmpty()) {
- Iterator<String> rem = removed.iterator();
- while (rem.hasNext()) {
- append(ErrorLog.REMOVE, rem.next());
- }
- }
- if (!added.isEmpty()) {
- Iterator<String> add = added.iterator();
- while (add.hasNext()) {
- append(ErrorLog.ADD, add.next());
- }
- }
- } finally {
- flush();
- }
- }
+ public void writeChanges(Set<String> removed, Set<String> added) throws IOException
+ {
+ try
+ {
+ if (!removed.isEmpty())
+ {
+ Iterator<String> rem = removed.iterator();
+ while (rem.hasNext())
+ {
+ append(ErrorLog.REMOVE, rem.next());
+ }
+ }
+ if (!added.isEmpty())
+ {
+ Iterator<String> add = added.iterator();
+ while (add.hasNext())
+ {
+ append(ErrorLog.ADD, add.next());
+ }
+ }
+ }
+ finally
+ {
+ flush();
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexException.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexException.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexException.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -39,7 +39,7 @@
/**
* Class logger.
*/
- private static final Log LOG = ExoLogger.getLogger(IndexException.class);
+ private static final Log LOG = ExoLogger.getLogger("exo.jcr.component.core.IndexException");
/**
*
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerChangesFilter.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -44,7 +44,7 @@
/**
* Logger instance for this class
*/
- private static final Log log = ExoLogger.getLogger(DefaultChangesFilter.class);
+ private static final Log log = ExoLogger.getLogger("exo.jcr.component.core.DefaultChangesFilter");
protected final SearchManager searchManager;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerIoModeHandler.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerIoModeHandler.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/IndexerIoModeHandler.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -34,13 +34,13 @@
/**
* The logger instance for this class
*/
- private static final Logger log = LoggerFactory.getLogger(IndexerIoModeHandler.class);
-
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.IndexerIoModeHandler");
+
/**
* The current mode
*/
private volatile IndexerIoMode mode;
-
+
/**
* The list of all the listeners
*/
@@ -73,7 +73,7 @@
{
if (this.mode != mode)
{
- log.info("Indexer io mode=" + mode);
+ log.info("Indexer io mode=" + mode);
this.mode = mode;
for (IndexerIoModeListener listener : listeners)
{
@@ -81,7 +81,7 @@
}
}
}
-
+
/**
* Add a new IndexerIoModeListener to the list of listeners
* @param listener the listener to add
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/OnWorkspaceInconsistency.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/OnWorkspaceInconsistency.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/OnWorkspaceInconsistency.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,17 +16,17 @@
*/
package org.exoplatform.services.jcr.impl.core.query;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.HashMap;
import java.util.Map;
import javax.jcr.ItemNotFoundException;
import javax.jcr.RepositoryException;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* <code>OnWorkspaceInconsistency</code> defines an interface to handle
* workspace inconsistencies.
@@ -37,7 +37,7 @@
/**
* Logger instance for this class.
*/
- private static final Logger log = LoggerFactory.getLogger(OnWorkspaceInconsistency.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.OnWorkspaceInconsistency");
/**
* An handler that simply logs the path of the parent node and the name
@@ -51,11 +51,10 @@
{
//NamePathResolver resolver = new DefaultNamePathResolver(handler.getContext().getNamespaceRegistry());
log.error("TO DO ");
-// log.error("Node {} ({}) has missing child '{}' ({})", new Object[]{resolver.getJCRPath(path),
-// node.getNodeId().getUUID().toString(), resolver.getJCRName(child.getName()),
-// child.getId().getUUID().toString()});
-
-
+ // log.error("Node {} ({}) has missing child '{}' ({})", new Object[]{resolver.getJCRPath(path),
+ // node.getNodeId().getUUID().toString(), resolver.getJCRName(child.getName()),
+ // child.getId().getUUID().toString()});
+
throw exception;
}
};
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/PropertyTypeRegistry.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/PropertyTypeRegistry.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/PropertyTypeRegistry.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,6 +16,14 @@
*/
package org.exoplatform.services.jcr.impl.core.query;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
+import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
+import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionData;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -25,16 +33,7 @@
import java.util.Map;
import javax.jcr.PropertyType;
-import javax.jcr.nodetype.NoSuchNodeTypeException;
-import org.exoplatform.services.jcr.core.nodetype.NodeTypeData;
-import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
-import org.exoplatform.services.jcr.core.nodetype.PropertyDefinitionData;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.impl.core.nodetype.NodeTypeManagerListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* The <code>PropertyTypeRegistry</code> keeps track of registered node type
* definitions and its property types. It provides a fast type lookup for a
@@ -44,7 +43,7 @@
{
/** The logger instance for this class */
- private static final Logger log = LoggerFactory.getLogger(PropertyTypeRegistry.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.PropertyTypeRegistry");
/**
* Empty <code>TypeMapping</code> array as return value if no type is
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,25 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.core.query;
-import java.text.NumberFormat;
-
-import javax.jcr.ItemExistsException;
-import javax.jcr.ItemNotFoundException;
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.UnsupportedRepositoryOperationException;
-import javax.jcr.Value;
-import javax.jcr.lock.LockException;
-import javax.jcr.nodetype.ConstraintViolationException;
-import javax.jcr.query.InvalidQueryException;
-import javax.jcr.query.QueryResult;
-import javax.jcr.version.VersionException;
-
import org.exoplatform.services.jcr.core.ExtendedNode;
import org.exoplatform.services.jcr.core.nodetype.NodeTypeDataManager;
-import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.dataflow.ItemState;
import org.exoplatform.services.jcr.dataflow.PlainChangesLog;
import org.exoplatform.services.jcr.datamodel.NodeData;
@@ -48,10 +31,25 @@
import org.exoplatform.services.jcr.impl.dataflow.TransientNodeData;
import org.exoplatform.services.jcr.impl.dataflow.TransientPropertyData;
import org.exoplatform.services.jcr.impl.dataflow.TransientValueData;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.text.NumberFormat;
+
+import javax.jcr.ItemExistsException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.Value;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.query.QueryResult;
+import javax.jcr.version.VersionException;
+
/**
* Provides the default implementation for a JCR query.
*/
@@ -61,7 +59,7 @@
/**
* The logger instance for this class
*/
- private static final Logger log = LoggerFactory.getLogger(QueryImpl.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.QueryImpl");
/**
* A string constant representing the JCR-SQL2 query language.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryTreeBuilderRegistry.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryTreeBuilderRegistry.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/QueryTreeBuilderRegistry.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -19,79 +19,87 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.imageio.spi.ServiceRegistry;
-import javax.jcr.query.InvalidQueryException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
-import java.util.Iterator;
import java.util.Set;
+import javax.jcr.query.InvalidQueryException;
+
/**
* Implements a central access to QueryTreeBuilder instances.
*/
-public class QueryTreeBuilderRegistry {
+public class QueryTreeBuilderRegistry
+{
- /**
- * Logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(QueryTreeBuilderRegistry.class);
+ /**
+ * Logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.QueryTreeBuilderRegistry");
- /**
- * List of <code>QueryTreeBuilder</code> instances known to the classloader.
- */
- private static final List<QueryTreeBuilder> BUILDERS = new ArrayList<QueryTreeBuilder>();
- /**
- * Set of languages known to the registered builders.
- */
- private static final Set<String> LANGUAGES;
+ /**
+ * List of <code>QueryTreeBuilder</code> instances known to the classloader.
+ */
+ private static final List<QueryTreeBuilder> BUILDERS = new ArrayList<QueryTreeBuilder>();
- static {
- Set<String> languages = new HashSet<String>();
- try {
- BUILDERS.add(new org.exoplatform.services.jcr.impl.core.query.sql.QueryBuilder());
- BUILDERS.add(new org.exoplatform.services.jcr.impl.core.query.xpath.QueryBuilder());
+ /**
+ * Set of languages known to the registered builders.
+ */
+ private static final Set<String> LANGUAGES;
- for (QueryTreeBuilder builder : BUILDERS)
- {
- languages.addAll(Arrays.asList(builder.getSupportedLanguages()));
- }
- if (BUILDERS.size() < 1)
- log.warn("No builders found");
- } catch (Error e) {
- log.warn("Unable to load providers for QueryTreeBuilder: " + e);
- }
- LANGUAGES = Collections.unmodifiableSet(languages);
- }
+ static
+ {
+ Set<String> languages = new HashSet<String>();
+ try
+ {
+ BUILDERS.add(new org.exoplatform.services.jcr.impl.core.query.sql.QueryBuilder());
+ BUILDERS.add(new org.exoplatform.services.jcr.impl.core.query.xpath.QueryBuilder());
- /**
- * Returns the <code>QueryTreeBuilder</code> for <code>language</code>.
- *
- * @param language the language of the query statement.
- * @return the <code>QueryTreeBuilder</code> for <code>language</code>.
- * @throws InvalidQueryException if there is no query tree builder for
- * <code>language</code>.
- */
- public static QueryTreeBuilder getQueryTreeBuilder(String language)
- throws InvalidQueryException {
- for (int i = 0; i < BUILDERS.size(); i++) {
- QueryTreeBuilder builder = (QueryTreeBuilder) BUILDERS.get(i);
- if (builder.canHandle(language)) {
- return builder;
- }
- }
- throw new InvalidQueryException("Unsupported language: " + language);
- }
+ for (QueryTreeBuilder builder : BUILDERS)
+ {
+ languages.addAll(Arrays.asList(builder.getSupportedLanguages()));
+ }
+ if (BUILDERS.size() < 1)
+ log.warn("No builders found");
+ }
+ catch (Error e)
+ {
+ log.warn("Unable to load providers for QueryTreeBuilder: " + e);
+ }
+ LANGUAGES = Collections.unmodifiableSet(languages);
+ }
- /**
- * Returns the set of query languages supported by all registered
- * {@link QueryTreeBuilder} implementations.
- *
- * @return String array containing the names of the supported languages.
- */
- public static String[] getSupportedLanguages() {
- return (String[]) LANGUAGES.toArray(new String[LANGUAGES.size()]);
- }
+ /**
+ * Returns the <code>QueryTreeBuilder</code> for <code>language</code>.
+ *
+ * @param language the language of the query statement.
+ * @return the <code>QueryTreeBuilder</code> for <code>language</code>.
+ * @throws InvalidQueryException if there is no query tree builder for
+ * <code>language</code>.
+ */
+ public static QueryTreeBuilder getQueryTreeBuilder(String language) throws InvalidQueryException
+ {
+ for (int i = 0; i < BUILDERS.size(); i++)
+ {
+ QueryTreeBuilder builder = (QueryTreeBuilder)BUILDERS.get(i);
+ if (builder.canHandle(language))
+ {
+ return builder;
+ }
+ }
+ throw new InvalidQueryException("Unsupported language: " + language);
+ }
+
+ /**
+ * Returns the set of query languages supported by all registered
+ * {@link QueryTreeBuilder} implementations.
+ *
+ * @return String array containing the names of the supported languages.
+ */
+ public static String[] getSupportedLanguages()
+ {
+ return (String[])LANGUAGES.toArray(new String[LANGUAGES.size()]);
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/RepositoryIndexSearcherHolder.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/RepositoryIndexSearcherHolder.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/RepositoryIndexSearcherHolder.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -36,80 +36,89 @@
* @author <a href="mailto:Sergey.Kabashnyuk@gmail.com">Sergey Kabashnyuk</a>
* @version $Id: $
*/
-public class RepositoryIndexSearcherHolder implements Startable {
- private final List<SearchManager> indexSearchers;
+public class RepositoryIndexSearcherHolder implements Startable
+{
+ private final List<SearchManager> indexSearchers;
- /**
- * Class logger.
- */
- private final Log log = ExoLogger
- .getLogger(RepositoryIndexSearcherHolder.class);
+ /**
+ * Class logger.
+ */
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.RepositoryIndexSearcherHolder");
- /**
- * @param indexSearchers
- */
- public RepositoryIndexSearcherHolder() {
- super();
- this.indexSearchers = new ArrayList<SearchManager>();
- }
+ /**
+ * @param indexSearchers
+ */
+ public RepositoryIndexSearcherHolder()
+ {
+ super();
+ this.indexSearchers = new ArrayList<SearchManager>();
+ }
- /**
- * @return the indexSearchers
- */
- public void addIndexSearcher(final SearchManager indexSearcher) {
- this.indexSearchers.add(indexSearcher);
- }
+ /**
+ * @return the indexSearchers
+ */
+ public void addIndexSearcher(final SearchManager indexSearcher)
+ {
+ this.indexSearchers.add(indexSearcher);
+ }
- /**
- * @return
- * @throws IndexException
- */
- public Set<String> getFieldNames() throws IndexException {
- final Set<String> fildsSet = new HashSet<String>();
+ /**
+ * @return
+ * @throws IndexException
+ */
+ public Set<String> getFieldNames() throws IndexException
+ {
+ final Set<String> fildsSet = new HashSet<String>();
- for (final SearchManager queryHandler : this.indexSearchers) {
+ for (final SearchManager queryHandler : this.indexSearchers)
+ {
- fildsSet.addAll(queryHandler.getFieldNames());
- }
- return fildsSet;
- }
+ fildsSet.addAll(queryHandler.getFieldNames());
+ }
+ return fildsSet;
+ }
- public Set<String> getNodesByNodeType(final InternalQName nodeType)
- throws RepositoryException {
- final Set<String> result = new HashSet<String>();
- for (final SearchManager indexingService : this.indexSearchers) {
- result.addAll(indexingService.getNodesByNodeType(nodeType));
- }
+ public Set<String> getNodesByNodeType(final InternalQName nodeType) throws RepositoryException
+ {
+ final Set<String> result = new HashSet<String>();
+ for (final SearchManager indexingService : this.indexSearchers)
+ {
+ result.addAll(indexingService.getNodesByNodeType(nodeType));
+ }
- return result;
- }
+ return result;
+ }
- /**
- * @param uri
- * @return
- * @throws RepositoryException
- */
- public Set<String> getNodesByUri(final String uri)
- throws RepositoryException {
- final Set<String> result = new HashSet<String>();
- for (final SearchManager indexingService : this.indexSearchers) {
- result.addAll(indexingService.getNodesByUri(uri));
- }
+ /**
+ * @param uri
+ * @return
+ * @throws RepositoryException
+ */
+ public Set<String> getNodesByUri(final String uri) throws RepositoryException
+ {
+ final Set<String> result = new HashSet<String>();
+ for (final SearchManager indexingService : this.indexSearchers)
+ {
+ result.addAll(indexingService.getNodesByUri(uri));
+ }
- return result;
- }
+ return result;
+ }
- /**
- * @return the indexSearchers
- */
- public void removeIndexSearcher(final SearchManager indexSearcher) {
- this.indexSearchers.remove(indexSearcher);
- }
+ /**
+ * @return the indexSearchers
+ */
+ public void removeIndexSearcher(final SearchManager indexSearcher)
+ {
+ this.indexSearchers.remove(indexSearcher);
+ }
- public void start() {
- }
+ public void start()
+ {
+ }
- public void stop() {
- this.indexSearchers.clear();
- }
+ public void stop()
+ {
+ this.indexSearchers.clear();
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SearchManager.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -91,7 +91,7 @@
/**
* Logger instance for this class
*/
- private static final Log log = ExoLogger.getLogger(SearchManager.class);
+ private static final Log log = ExoLogger.getLogger("exo.jcr.component.core.SearchManager");
protected final QueryHandlerEntry config;
@@ -649,7 +649,8 @@
}
Constructor<? extends IndexerChangesFilter> constuctor =
changesFilterClass.getConstructor(SearchManager.class, SearchManager.class, QueryHandlerEntry.class,
- IndexingTree.class, IndexingTree.class, QueryHandler.class, QueryHandler.class, ConfigurationManager.class);
+ IndexingTree.class, IndexingTree.class, QueryHandler.class, QueryHandler.class,
+ ConfigurationManager.class);
if (parentSearchManager != null)
{
newChangesFilter =
@@ -812,7 +813,7 @@
{
for (final ValueData vdata : propertyData.getValues())
{
- final Value val = valueFactory.loadValue(vdata, propertyData.getType());
+ final Value val = valueFactory.loadValue(vdata, propertyData.getType());
if (propertyData.getType() == PropertyType.PATH)
{
if (isPrefixMatch(((PathValue)val).getQPath(), prefix))
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/SystemSearchManager.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -47,24 +47,13 @@
/**
* Class logger.
*/
- private final Log log = ExoLogger.getLogger("jcr.SystemSearchManager");
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.SystemSearchManager");
/**
* 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<List<WriteCommand>> writeCommandBuffer = new ArrayList<List<WriteCommand>>();
-
public static final String INDEX_DIR_SUFFIX = "system";
public SystemSearchManager(QueryHandlerEntry config, NamespaceRegistryImpl nsReg, NodeTypeDataManager ntReg,
@@ -74,19 +63,6 @@
super(config, nsReg, ntReg, itemMgr, null, service, cfm, indexSearcherHolder);
}
- // @Override
- // public void onSaveItems(ItemStateChangesLog changesLog)
- // {
- // if (!isStarted)
- // {
- // changesLogBuffer.add(changesLog);
- // }
- // else
- // {
- // super.onSaveItems(changesLog);
- // }
- // }
-
@Override
public void start()
{
@@ -123,93 +99,8 @@
}
isStarted = true;
}
- // if (changesLogBuffer.size() > 0)
- // {
- // for (ItemStateChangesLog bufferedChangesLog : changesLogBuffer)
- // {
- // super.onSaveItems(bufferedChangesLog);
- // }
- //
- // }
- //
- // if (writeCommandBuffer.size() > 0)
- // {
- // try
- // {
- // for (List<WriteCommand> bufferedWriteLog : writeCommandBuffer)
- // {
- // super.onSaveItems(bufferedWriteLog);
- // }
- // }
- // catch (RepositoryException e)
- // {
- // freeBuffers();
- // throw new RuntimeException(e);
- //
- // }
- // }
- // freeBuffers();
}
- // /**
- // * @see org.exoplatform.services.jcr.impl.core.query.SearchManager#initializeChangesFilter()
- // */
- // @Override
- // protected void initializeChangesFilter() throws RepositoryException, RepositoryConfigurationException
- // {
- // Class<? extends IndexerChangesFilter> changesFilterClass = DefaultChangesFilter.class;
- // String changesFilterClassName = config.getParameterValue(QueryHandlerParams.PARAM_CHANGES_FILTER_CLASS, null);
- // try
- // {
- // if (changesFilterClassName != null)
- // {
- // changesFilterClass =
- // (Class<? extends IndexerChangesFilter>)Class.forName(changesFilterClassName, true, this.getClass()
- // .getClassLoader());
- // }
- // Constructor<? extends IndexerChangesFilter> constuctor =
- // changesFilterClass.getConstructor(SearchManager.class, QueryHandlerEntry.class, Boolean.class,
- // IndexingTree.class);
- // changesFilter = constuctor.newInstance(this, config, true, indexingTree);
- // }
- // 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);
- // }
- // }
-
- // private void freeBuffers()
- // {
- // changesLogBuffer.clear();
- // changesLogBuffer = null;
- // writeCommandBuffer.clear();
- // writeCommandBuffer = null;
- // }
-
@Override
protected QueryHandlerContext createQueryHandlerContext(QueryHandler parentHandler)
throws RepositoryConfigurationException
@@ -219,21 +110,4 @@
+ INDEX_DIR_SUFFIX, extractor, true, virtualTableResolver);
return context;
}
- //
- // /* (non-Javadoc)
- // * @see org.exoplatform.services.jcr.impl.core.query.SearchManager#onSaveItems(java.util.List)
- // */
- // @Override
- // public void onSaveItems(List<WriteCommand> modifications) throws RepositoryException
- // {
- // if (!isStarted)
- // {
- // writeCommandBuffer.add(modifications);
- // }
- // else
- // {
- // super.onSaveItems(modifications);
- // }
- //
- // }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerCacheLoader.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -42,7 +42,7 @@
*/
public class IndexerCacheLoader extends AbstractWriteOnlyCacheLoader
{
- private final Log log = ExoLogger.getLogger(this.getClass().getName());
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.IndexerCacheLoader");
private SearchManager searchManager;
@@ -51,7 +51,7 @@
private QueryHandler handler;
private QueryHandler parentHandler;
-
+
private volatile IndexerIoModeHandler modeHandler;
/**
@@ -132,7 +132,7 @@
{
// do nothing
}
-
+
/**
* Switches Indexer mode from RO to RW, or from RW to RO
*
@@ -142,7 +142,7 @@
{
if (modeHandler != null)
{
- modeHandler.setMode(ioMode);
+ modeHandler.setMode(ioMode);
}
}
@@ -162,13 +162,15 @@
{
if (modeHandler == null)
{
- this.modeHandler = new IndexerIoModeHandler(cache.getRPCManager().isCoordinator() ? IndexerIoMode.READ_WRITE : IndexerIoMode.READ_ONLY);
+ this.modeHandler =
+ new IndexerIoModeHandler(cache.getRPCManager().isCoordinator() ? IndexerIoMode.READ_WRITE
+ : IndexerIoMode.READ_ONLY);
}
}
}
return modeHandler;
}
-
+
/**
* Flushes lists of added/removed nodes to SearchManagers, starting indexing.
*
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingletonStoreCacheLoader.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingletonStoreCacheLoader.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/IndexerSingletonStoreCacheLoader.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -25,9 +25,6 @@
import org.jboss.cache.Fqn;
import org.jboss.cache.NodeSPI;
import org.jboss.cache.loader.SingletonStoreCacheLoader;
-import org.jboss.cache.notifications.annotation.CacheListener;
-import org.jboss.cache.notifications.annotation.CacheStarted;
-import org.jboss.cache.notifications.event.Event;
import java.util.Collection;
import java.util.HashSet;
@@ -41,7 +38,7 @@
*/
public class IndexerSingletonStoreCacheLoader extends SingletonStoreCacheLoader
{
- private final Log log = ExoLogger.getLogger(this.getClass().getName());
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.IndexerSingletonStoreCacheLoader");
/**
* @see org.jboss.cache.loader.SingletonStoreCacheLoader#activeStatusChanged(boolean)
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexChangesFilter.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -56,7 +56,7 @@
/**
* Logger instance for this class
*/
- private final Log log = ExoLogger.getLogger(JBossCacheIndexChangesFilter.class);
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.JBossCacheIndexChangesFilter");
private final Cache<Serializable, Object> cache;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexInfos.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -55,7 +55,7 @@
public class JBossCacheIndexInfos extends IndexInfos implements IndexerIoModeListener
{
- private final Log log = ExoLogger.getLogger(this.getClass().getName());
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.JBossCacheIndexInfos");
private static final String INDEX_NAMES = "$names".intern();
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexUpdateMonitor.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexUpdateMonitor.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/jbosscache/JBossCacheIndexUpdateMonitor.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -50,7 +50,7 @@
/**
* Logger instance for this class
*/
- private final Log log = ExoLogger.getLogger(JBossCacheIndexUpdateMonitor.class);
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.JBossCacheIndexUpdateMonitor");
private final Cache<Serializable, Object> cache;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractExcerpt.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractExcerpt.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractExcerpt.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -50,7 +50,7 @@
/**
* Logger instance for this class.
*/
- private static final Logger log = LoggerFactory.getLogger(AbstractExcerpt.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.AbstractExcerpt");
/**
* The search index.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractIndex.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,13 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintStream;
-import java.io.StringReader;
-import java.util.BitSet;
-import java.util.Iterator;
-
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -35,6 +28,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.StringReader;
+import java.util.BitSet;
+import java.util.Iterator;
+
/**
* Implements common functionality for a lucene index.
* <p/>
@@ -53,7 +53,7 @@
{
/** The logger instance for this class */
- private static final Logger log = LoggerFactory.getLogger(AbstractIndex.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.AbstractIndex");
/** PrintStream that pipes all calls to println(String) into log.info() */
private static final LoggingPrintStream STREAM_LOGGER = new LoggingPrintStream();
@@ -255,7 +255,7 @@
log.debug("closing IndexWriter.");
indexWriter = null;
}
-
+
if (indexReader == null || !indexReader.isCurrent())
{
IndexReader reader = IndexReader.open(getDirectory());
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractNamespaceMappings.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractNamespaceMappings.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AbstractNamespaceMappings.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,58 +16,64 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import javax.jcr.NamespaceException;
-import javax.jcr.RepositoryException;
-
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
+import javax.jcr.RepositoryException;
/**
* <code>AbstractNamespaceMappings</code> is the base class for index internal
* namespace mappings.
*/
-public abstract class AbstractNamespaceMappings
- implements NamespaceMappings {
+public abstract class AbstractNamespaceMappings implements NamespaceMappings
+{
- /**
- * The name resolver used to translate the qualified name to JCR name
- */
- private final LocationFactory resolver;
+ /**
+ * The name resolver used to translate the qualified name to JCR name
+ */
+ private final LocationFactory resolver;
- public AbstractNamespaceMappings() {
- this.resolver = new LocationFactory(this);
- }
+ public AbstractNamespaceMappings()
+ {
+ this.resolver = new LocationFactory(this);
+ }
- //----------------------------< NamespaceMappings >-------------------------
+ //----------------------------< NamespaceMappings >-------------------------
- /**
- * {@inheritDoc}
- */
- public String translateName(InternalQName qName)
- throws IllegalNameException {
- try {
- return resolver.createJCRName(qName).getAsString();
- } catch (RepositoryException e) {
- // should never happen actually, because we create yet unknown
- // uri mappings on the fly.
- throw new IllegalNameException("Internal error.", e);
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String translateName(InternalQName qName) throws IllegalNameException
+ {
+ try
+ {
+ return resolver.createJCRName(qName).getAsString();
+ }
+ catch (RepositoryException e)
+ {
+ // should never happen actually, because we create yet unknown
+ // uri mappings on the fly.
+ throw new IllegalNameException("Internal error.", e);
+ }
+ }
- /**
- * {@inheritDoc}
- */
- public String translatePath(QPath path) throws IllegalNameException {
- try {
- return resolver.createJCRPath(path).getAsString(false);
- } catch (RepositoryException e) {
- // should never happen actually, because we create yet unknown
- // uri mappings on the fly.
- throw new IllegalNameException("Internal error.", e);
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String translatePath(QPath path) throws IllegalNameException
+ {
+ try
+ {
+ return resolver.createJCRPath(path).getAsString(false);
+ }
+ catch (RepositoryException e)
+ {
+ // should never happen actually, because we create yet unknown
+ // uri mappings on the fly.
+ throw new IllegalNameException("Internal error.", e);
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AggregateRuleImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AggregateRuleImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/AggregateRuleImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,15 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.NamespaceException;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.RepositoryException;
-
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.IllegalNameException;
import org.exoplatform.services.jcr.datamodel.IllegalPathException;
@@ -36,12 +27,19 @@
import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.Constants;
import org.exoplatform.services.jcr.impl.core.LocationFactory;
-
import org.exoplatform.services.jcr.util.Text;
import org.w3c.dom.CharacterData;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+
/**
* <code>AggregateRule</code> defines a configuration for a node index
* aggregate. It defines rules for items that should be included in the node
@@ -76,11 +74,6 @@
*/
private final ItemDataConsumer ism;
- // /**
- // * A hierarchy resolver for the item state manager.
- // */
- // private final HierarchyManager hmgr;
-
/**
* Creates a new indexing aggregate using the given <code>config</code>.
*
@@ -148,7 +141,7 @@
* @throws RepositoryException
* @throws ItemStateException if an error occurs.
*/
- public NodeData[] getAggregatedNodeStates(NodeData nodeState) throws RepositoryException
+ public NodeData[] getAggregatedNodeStates(NodeData nodeState) throws RepositoryException
{
if (nodeState.getPrimaryTypeName().equals(nodeTypeName))
{
@@ -169,7 +162,7 @@
* {@inheritDoc}
* @throws RepositoryException
*/
- public PropertyData[] getAggregatedPropertyStates(NodeData nodeState) throws RepositoryException
+ public PropertyData[] getAggregatedPropertyStates(NodeData nodeState) throws RepositoryException
{
if (nodeState.getPrimaryTypeName().equals(nodeTypeName))
{
@@ -214,8 +207,7 @@
* characters.
* @throws RepositoryException
*/
- private NodeInclude[] getNodeIncludes(Node config) throws IllegalNameException,
- RepositoryException
+ private NodeInclude[] getNodeIncludes(Node config) throws IllegalNameException, RepositoryException
{
List includes = new ArrayList();
NodeList childNodes = config.getChildNodes();
@@ -231,7 +223,7 @@
ntName = resolver.parseJCRName(ntAttr.getNodeValue()).getInternalName();
}
String[] elements = Text.explode(getTextContent(n), '/');
-
+
QPathEntry[] path = new QPathEntry[elements.length];
for (int j = 0; j < elements.length; j++)
{
@@ -244,7 +236,7 @@
path[j] = new QPathEntry(resolver.parseJCRName(elements[j]).getInternalName(), 0);
}
}
-
+
includes.add(new NodeInclude(new QPath(path), ntName));
}
}
@@ -272,16 +264,16 @@
if (n.getNodeName().equals("include-property"))
{
String[] elements = Text.explode(getTextContent(n), '/');
-
- QPathEntry[] path = new QPathEntry[elements.length];
+
+ QPathEntry[] path = new QPathEntry[elements.length];
for (int j = 0; j < elements.length; j++)
{
if (elements[j].equals("*"))
{
throw new IllegalNameException("* not supported in include-property");
}
-
- path[j] = new QPathEntry(resolver.parseJCRName(elements[j]).getInternalName(),1);
+
+ path[j] = new QPathEntry(resolver.parseJCRName(elements[j]).getInternalName(), 1);
}
includes.add(new PropertyInclude(new QPath(path)));
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/CachingIndexReader.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/CachingIndexReader.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/CachingIndexReader.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,15 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.text.NumberFormat;
-import java.util.BitSet;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-
import org.apache.commons.collections.map.LRUMap;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -38,499 +29,597 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.text.NumberFormat;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
/**
* Implements an <code>IndexReader</code> that maintains caches to resolve
* {@link #getParent(int, BitSet)} calls efficiently.
* <p/>
*/
-class CachingIndexReader extends FilterIndexReader {
+class CachingIndexReader extends FilterIndexReader
+{
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(CachingIndexReader.class);
+ /**
+ * The logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.CachingIndexReader");
- /**
- * The current value of the global creation tick counter.
- */
- private static long currentTick;
+ /**
+ * The current value of the global creation tick counter.
+ */
+ private static long currentTick;
- /**
- * BitSet where bits that correspond to document numbers are set for
- * shareable nodes.
- */
- private final BitSet shareableNodes;
+ /**
+ * BitSet where bits that correspond to document numbers are set for
+ * shareable nodes.
+ */
+ private final BitSet shareableNodes;
- /**
- * Cache of nodes parent relation. If an entry in the array is not null,
- * that means the node with the document number = array-index has the node
- * with <code>DocId</code> as parent.
- */
- private final DocId[] parents;
+ /**
+ * Cache of nodes parent relation. If an entry in the array is not null,
+ * that means the node with the document number = array-index has the node
+ * with <code>DocId</code> as parent.
+ */
+ private final DocId[] parents;
- /**
- * Initializes the {@link #parents} cache.
- */
- private CacheInitializer cacheInitializer;
+ /**
+ * Initializes the {@link #parents} cache.
+ */
+ private CacheInitializer cacheInitializer;
- /**
- * Tick when this index reader was created.
- */
- private final long creationTick = getNextCreationTick();
+ /**
+ * Tick when this index reader was created.
+ */
+ private final long creationTick = getNextCreationTick();
- /**
- * Document number cache if available. May be <code>null</code>.
- */
- private final DocNumberCache cache;
+ /**
+ * Document number cache if available. May be <code>null</code>.
+ */
+ private final DocNumberCache cache;
- /**
- * Maps document number to node UUID.
- */
- private final Map<Integer,String> docNumber2uuid;
+ /**
+ * Maps document number to node UUID.
+ */
+ private final Map<Integer, String> docNumber2uuid;
- /**
- * A cache of TermDocs that are regularly read from the index.
- */
- private final TermDocsCache termDocsCache;
+ /**
+ * A cache of TermDocs that are regularly read from the index.
+ */
+ private final TermDocsCache termDocsCache;
- /**
- * Creates a new <code>CachingIndexReader</code> based on
- * <code>delegatee</code>
- *
- * @param delegatee the base <code>IndexReader</code>.
- * @param cache a document number cache, or <code>null</code> if not
- * available to this reader.
- * @param initCache if the {@link #parents} cache should be initialized
- * when this index reader is constructed.
- * @throws IOException if an error occurs while reading from the index.
- */
- CachingIndexReader(IndexReader delegatee,
- DocNumberCache cache,
- boolean initCache)
- throws IOException {
- super(delegatee);
- this.cache = cache;
- this.parents = new DocId[delegatee.maxDoc()];
- this.shareableNodes = new BitSet();
- TermDocs tDocs = delegatee.termDocs(
- new Term(FieldNames.SHAREABLE_NODE, ""));
- try {
- while (tDocs.next()) {
- shareableNodes.set(tDocs.doc());
- }
- } finally {
- tDocs.close();
- }
- this.cacheInitializer = new CacheInitializer(delegatee);
- if (initCache) {
- cacheInitializer.run();
- }
- // limit cache to 1% of maxDoc(), but at least 10.
- this.docNumber2uuid = Collections.synchronizedMap(new LRUMap(
- Math.max(10, delegatee.maxDoc() / 100)));
- this.termDocsCache = new TermDocsCache(delegatee, FieldNames.PROPERTIES);
- }
+ /**
+ * Creates a new <code>CachingIndexReader</code> based on
+ * <code>delegatee</code>
+ *
+ * @param delegatee the base <code>IndexReader</code>.
+ * @param cache a document number cache, or <code>null</code> if not
+ * available to this reader.
+ * @param initCache if the {@link #parents} cache should be initialized
+ * when this index reader is constructed.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ CachingIndexReader(IndexReader delegatee, DocNumberCache cache, boolean initCache) throws IOException
+ {
+ super(delegatee);
+ this.cache = cache;
+ this.parents = new DocId[delegatee.maxDoc()];
+ this.shareableNodes = new BitSet();
+ TermDocs tDocs = delegatee.termDocs(new Term(FieldNames.SHAREABLE_NODE, ""));
+ try
+ {
+ while (tDocs.next())
+ {
+ shareableNodes.set(tDocs.doc());
+ }
+ }
+ finally
+ {
+ tDocs.close();
+ }
+ this.cacheInitializer = new CacheInitializer(delegatee);
+ if (initCache)
+ {
+ cacheInitializer.run();
+ }
+ // limit cache to 1% of maxDoc(), but at least 10.
+ this.docNumber2uuid = Collections.synchronizedMap(new LRUMap(Math.max(10, delegatee.maxDoc() / 100)));
+ this.termDocsCache = new TermDocsCache(delegatee, FieldNames.PROPERTIES);
+ }
- /**
- * Returns the <code>DocId</code> of the parent of <code>n</code> or
- * {@link DocId#NULL} if <code>n</code> does not have a parent
- * (<code>n</code> is the root node).
- *
- * @param n the document number.
- * @param deleted the documents that should be regarded as deleted.
- * @return the <code>DocId</code> of <code>n</code>'s parent.
- * @throws IOException if an error occurs while reading from the index.
- */
- DocId getParent(int n, BitSet deleted) throws IOException {
- DocId parent;
- boolean existing = false;
- parent = parents[n];
+ /**
+ * Returns the <code>DocId</code> of the parent of <code>n</code> or
+ * {@link DocId#NULL} if <code>n</code> does not have a parent
+ * (<code>n</code> is the root node).
+ *
+ * @param n the document number.
+ * @param deleted the documents that should be regarded as deleted.
+ * @return the <code>DocId</code> of <code>n</code>'s parent.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ DocId getParent(int n, BitSet deleted) throws IOException
+ {
+ DocId parent;
+ boolean existing = false;
+ parent = parents[n];
- if (parent != null) {
- existing = true;
+ if (parent != null)
+ {
+ existing = true;
- // check if valid and reset if necessary
- if (!parent.isValid(deleted)) {
- if (log.isDebugEnabled()) {
- log.debug(parent + " not valid anymore.");
- }
- parent = null;
+ // check if valid and reset if necessary
+ if (!parent.isValid(deleted))
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug(parent + " not valid anymore.");
}
- }
+ parent = null;
+ }
+ }
- if (parent == null) {
- Document doc = document(n, FieldSelectors.UUID_AND_PARENT);
- String[] parentUUIDs = doc.getValues(FieldNames.PARENT);
- if (parentUUIDs.length == 0 || parentUUIDs[0].length() == 0) {
- // root node
- parent = DocId.NULL;
- } else {
- if (shareableNodes.get(n)) {
- parent = DocId.create(parentUUIDs);
- } else {
- if (!existing) {
- Term id = new Term(FieldNames.UUID, parentUUIDs[0]);
- TermDocs docs = termDocs(id);
- try {
- while (docs.next()) {
- if (!deleted.get(docs.doc())) {
- parent = DocId.create(docs.doc());
- break;
- }
- }
- } finally {
- docs.close();
+ if (parent == null)
+ {
+ Document doc = document(n, FieldSelectors.UUID_AND_PARENT);
+ String[] parentUUIDs = doc.getValues(FieldNames.PARENT);
+ if (parentUUIDs.length == 0 || parentUUIDs[0].length() == 0)
+ {
+ // root node
+ parent = DocId.NULL;
+ }
+ else
+ {
+ if (shareableNodes.get(n))
+ {
+ parent = DocId.create(parentUUIDs);
+ }
+ else
+ {
+ if (!existing)
+ {
+ Term id = new Term(FieldNames.UUID, parentUUIDs[0]);
+ TermDocs docs = termDocs(id);
+ try
+ {
+ while (docs.next())
+ {
+ if (!deleted.get(docs.doc()))
+ {
+ parent = DocId.create(docs.doc());
+ break;
}
- }
- // if still null, then parent is not in this index, or existing
- // DocId was invalid. thus, only allowed to create DocId from uuid
- if (parent == null) {
- parent = DocId.create(parentUUIDs[0]);
- }
- }
+ }
+ }
+ finally
+ {
+ docs.close();
+ }
+ }
+ // if still null, then parent is not in this index, or existing
+ // DocId was invalid. thus, only allowed to create DocId from uuid
+ if (parent == null)
+ {
+ parent = DocId.create(parentUUIDs[0]);
+ }
}
+ }
- // finally put to cache
- parents[n] = parent;
- }
- return parent;
- }
+ // finally put to cache
+ parents[n] = parent;
+ }
+ return parent;
+ }
- /**
- * Returns the tick value when this reader was created.
- *
- * @return the creation tick for this reader.
- */
- public long getCreationTick() {
- return creationTick;
- }
+ /**
+ * Returns the tick value when this reader was created.
+ *
+ * @return the creation tick for this reader.
+ */
+ public long getCreationTick()
+ {
+ return creationTick;
+ }
- //--------------------< FilterIndexReader overwrites >----------------------
+ //--------------------< FilterIndexReader overwrites >----------------------
- /**
- * Uses the {@link #docNumber2uuid} cache for document lookups that are only
- * interested in the {@link FieldSelectors#UUID}.
- *
- * @param n the document number.
- * @param fieldSelector the field selector.
- * @return the document.
- * @throws CorruptIndexException if the index is corrupt.
- * @throws IOException if an error occurs while reading from the index.
- */
- public Document document(int n, FieldSelector fieldSelector)
- throws CorruptIndexException, IOException {
- if (fieldSelector == FieldSelectors.UUID) {
- Integer docNum = new Integer(n);
- Document doc;
- String uuid = docNumber2uuid.get(docNum);
- if (uuid == null) {
- doc = super.document(n, fieldSelector);
- uuid = doc.get(FieldNames.UUID);
- docNumber2uuid.put(docNum, uuid);
- } else {
- doc = new Document();
- doc.add(new Field(FieldNames.UUID, uuid.toString(),
- Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
+ /**
+ * Uses the {@link #docNumber2uuid} cache for document lookups that are only
+ * interested in the {@link FieldSelectors#UUID}.
+ *
+ * @param n the document number.
+ * @param fieldSelector the field selector.
+ * @return the document.
+ * @throws CorruptIndexException if the index is corrupt.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ public Document document(int n, FieldSelector fieldSelector) throws CorruptIndexException, IOException
+ {
+ if (fieldSelector == FieldSelectors.UUID)
+ {
+ Integer docNum = new Integer(n);
+ Document doc;
+ String uuid = docNumber2uuid.get(docNum);
+ if (uuid == null)
+ {
+ doc = super.document(n, fieldSelector);
+ uuid = doc.get(FieldNames.UUID);
+ docNumber2uuid.put(docNum, uuid);
+ }
+ else
+ {
+ doc = new Document();
+ doc.add(new Field(FieldNames.UUID, uuid.toString(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
+ }
+ return doc;
+ }
+ else
+ {
+ return super.document(n, fieldSelector);
+ }
+ }
+
+ /**
+ * If the field of <code>term</code> is {@link FieldNames#UUID} this
+ * <code>CachingIndexReader</code> returns a <code>TermDocs</code> instance
+ * with a cached document id. If <code>term</code> has any other field
+ * the call is delegated to the base <code>IndexReader</code>.<br/>
+ * If <code>term</code> is for a {@link FieldNames#UUID} field and this
+ * <code>CachingIndexReader</code> does not have such a document,
+ * {@link EmptyTermDocs#INSTANCE} is returned.
+ *
+ * @param term the term to start the <code>TermDocs</code> enumeration.
+ * @return a TermDocs instance.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ public TermDocs termDocs(Term term) throws IOException
+ {
+ if (term.field() == FieldNames.UUID)
+ {
+ // check cache if we have one
+ if (cache != null)
+ {
+ DocNumberCache.Entry e = cache.get(term.text());
+ if (e != null)
+ {
+ // check if valid
+ // the cache may contain entries from a different reader
+ // with the same uuid. that happens when a node is updated
+ // and is reindexed. the node 'travels' from an older index
+ // to a newer one. the cache will still contain a cache
+ // entry from the old until it is overwritten by the
+ // newer index.
+ if (e.creationTick == creationTick && !isDeleted(e.doc))
+ {
+ return new SingleTermDocs(e.doc);
+ }
}
- return doc;
- } else {
- return super.document(n, fieldSelector);
- }
- }
- /**
- * If the field of <code>term</code> is {@link FieldNames#UUID} this
- * <code>CachingIndexReader</code> returns a <code>TermDocs</code> instance
- * with a cached document id. If <code>term</code> has any other field
- * the call is delegated to the base <code>IndexReader</code>.<br/>
- * If <code>term</code> is for a {@link FieldNames#UUID} field and this
- * <code>CachingIndexReader</code> does not have such a document,
- * {@link EmptyTermDocs#INSTANCE} is returned.
- *
- * @param term the term to start the <code>TermDocs</code> enumeration.
- * @return a TermDocs instance.
- * @throws IOException if an error occurs while reading from the index.
- */
- public TermDocs termDocs(Term term) throws IOException {
- if (term.field() == FieldNames.UUID) {
- // check cache if we have one
- if (cache != null) {
- DocNumberCache.Entry e = cache.get(term.text());
- if (e != null) {
- // check if valid
- // the cache may contain entries from a different reader
- // with the same uuid. that happens when a node is updated
- // and is reindexed. the node 'travels' from an older index
- // to a newer one. the cache will still contain a cache
- // entry from the old until it is overwritten by the
- // newer index.
- if (e.creationTick == creationTick && !isDeleted(e.doc)) {
- return new SingleTermDocs(e.doc);
- }
- }
-
- // not in cache or invalid
- TermDocs docs = in.termDocs(term);
- try {
- if (docs.next()) {
- // put to cache
- cache.put(term.text(), this, docs.doc());
- // and return
- return new SingleTermDocs(docs.doc());
- } else {
- return EmptyTermDocs.INSTANCE;
- }
- } finally {
- docs.close();
- }
+ // not in cache or invalid
+ TermDocs docs = in.termDocs(term);
+ try
+ {
+ if (docs.next())
+ {
+ // put to cache
+ cache.put(term.text(), this, docs.doc());
+ // and return
+ return new SingleTermDocs(docs.doc());
+ }
+ else
+ {
+ return EmptyTermDocs.INSTANCE;
+ }
}
- }
- return termDocsCache.termDocs(term);
- }
+ finally
+ {
+ docs.close();
+ }
+ }
+ }
+ return termDocsCache.termDocs(term);
+ }
- /**
- * {@inheritDoc}
- */
- protected void doClose() throws IOException {
- try {
- cacheInitializer.waitUntilStopped();
- } catch (InterruptedException e) {
- // ignore
- }
- super.doClose();
- }
+ /**
+ * {@inheritDoc}
+ */
+ protected void doClose() throws IOException
+ {
+ try
+ {
+ cacheInitializer.waitUntilStopped();
+ }
+ catch (InterruptedException e)
+ {
+ // ignore
+ }
+ super.doClose();
+ }
- //----------------------< internal >----------------------------------------
+ //----------------------< internal >----------------------------------------
- /**
- * Returns the next creation tick value.
- *
- * @return the next creation tick value.
- */
- private static long getNextCreationTick() {
- synchronized (CachingIndexReader.class) {
- return currentTick++;
- }
- }
+ /**
+ * Returns the next creation tick value.
+ *
+ * @return the next creation tick value.
+ */
+ private static long getNextCreationTick()
+ {
+ synchronized (CachingIndexReader.class)
+ {
+ return currentTick++;
+ }
+ }
- /**
- * Initializes the {@link CachingIndexReader#parents} cache.
- */
- private class CacheInitializer implements Runnable {
+ /**
+ * Initializes the {@link CachingIndexReader#parents} cache.
+ */
+ private class CacheInitializer implements Runnable
+ {
- /**
- * From where to read.
- */
- private final IndexReader reader;
+ /**
+ * From where to read.
+ */
+ private final IndexReader reader;
- /**
- * Set to <code>true</code> while this initializer does its work.
- */
- private boolean running = false;
+ /**
+ * Set to <code>true</code> while this initializer does its work.
+ */
+ private boolean running = false;
- /**
- * Set to <code>true</code> when this index reader is about to be closed.
- */
- private volatile boolean stopRequested = false;
+ /**
+ * Set to <code>true</code> when this index reader is about to be closed.
+ */
+ private volatile boolean stopRequested = false;
- /**
- * Creates a new initializer with the given <code>reader</code>.
- *
- * @param reader an index reader.
- */
- public CacheInitializer(IndexReader reader) {
- this.reader = reader;
- }
+ /**
+ * Creates a new initializer with the given <code>reader</code>.
+ *
+ * @param reader an index reader.
+ */
+ public CacheInitializer(IndexReader reader)
+ {
+ this.reader = reader;
+ }
- /**
- * Initializes the cache.
- */
- public void run() {
- synchronized (this) {
- running = true;
+ /**
+ * Initializes the cache.
+ */
+ public void run()
+ {
+ synchronized (this)
+ {
+ running = true;
+ }
+ try
+ {
+ if (stopRequested)
+ {
+ // immediately return when stop is requested
+ return;
}
- try {
- if (stopRequested) {
- // immediately return when stop is requested
- return;
- }
- initializeParents(reader);
- } catch (Exception e) {
- // only log warn message during regular operation
- if (!stopRequested) {
- log.warn("Error initializing parents cache.", e);
- }
- } finally {
- synchronized (this) {
- running = false;
- notifyAll();
- }
+ initializeParents(reader);
+ }
+ catch (Exception e)
+ {
+ // only log warn message during regular operation
+ if (!stopRequested)
+ {
+ log.warn("Error initializing parents cache.", e);
}
- }
+ }
+ finally
+ {
+ synchronized (this)
+ {
+ running = false;
+ notifyAll();
+ }
+ }
+ }
- /**
- * Waits until this cache initializer is stopped.
- *
- * @throws InterruptedException if the current thread is interrupted.
- */
- public void waitUntilStopped() throws InterruptedException {
- stopRequested = true;
- synchronized (this) {
- while (running) {
- wait();
- }
+ /**
+ * Waits until this cache initializer is stopped.
+ *
+ * @throws InterruptedException if the current thread is interrupted.
+ */
+ public void waitUntilStopped() throws InterruptedException
+ {
+ stopRequested = true;
+ synchronized (this)
+ {
+ while (running)
+ {
+ wait();
}
- }
+ }
+ }
- /**
- * Initializes the {@link CachingIndexReader#parents} <code>DocId</code>
- * array.
- *
- * @param reader the underlying index reader.
- * @throws IOException if an error occurs while reading from the index.
- */
- private void initializeParents(IndexReader reader) throws IOException {
- long time = System.currentTimeMillis();
- final Map docs = new HashMap();
- // read UUIDs
- collectTermDocs(reader, new Term(FieldNames.UUID, ""), new TermDocsCollector() {
- public void collect(Term term, TermDocs tDocs) throws IOException {
- String uuid = term.text();
- while (tDocs.next()) {
- int doc = tDocs.doc();
- // skip shareable nodes
- if (!shareableNodes.get(doc)) {
- NodeInfo info = new NodeInfo(doc, uuid);
- docs.put(new Integer(doc), info);
- }
- }
- }
- });
+ /**
+ * Initializes the {@link CachingIndexReader#parents} <code>DocId</code>
+ * array.
+ *
+ * @param reader the underlying index reader.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ private void initializeParents(IndexReader reader) throws IOException
+ {
+ long time = System.currentTimeMillis();
+ final Map docs = new HashMap();
+ // read UUIDs
+ collectTermDocs(reader, new Term(FieldNames.UUID, ""), new TermDocsCollector()
+ {
+ public void collect(Term term, TermDocs tDocs) throws IOException
+ {
+ String uuid = term.text();
+ while (tDocs.next())
+ {
+ int doc = tDocs.doc();
+ // skip shareable nodes
+ if (!shareableNodes.get(doc))
+ {
+ NodeInfo info = new NodeInfo(doc, uuid);
+ docs.put(new Integer(doc), info);
+ }
+ }
+ }
+ });
- // read PARENTs
- collectTermDocs(reader, new Term(FieldNames.PARENT, "0"), new TermDocsCollector() {
- public void collect(Term term, TermDocs tDocs) throws IOException {
- String uuid = term.text();
- while (tDocs.next()) {
- Integer docId = new Integer(tDocs.doc());
- NodeInfo info = (NodeInfo) docs.get(docId);
- if (info == null) {
- // shareable node, see above
- } else {
- info.parent = uuid;
- docs.remove(docId);
- docs.put(info.uuid, info);
- }
- }
- }
- });
-
- if (stopRequested) {
- return;
+ // read PARENTs
+ collectTermDocs(reader, new Term(FieldNames.PARENT, "0"), new TermDocsCollector()
+ {
+ public void collect(Term term, TermDocs tDocs) throws IOException
+ {
+ String uuid = term.text();
+ while (tDocs.next())
+ {
+ Integer docId = new Integer(tDocs.doc());
+ NodeInfo info = (NodeInfo)docs.get(docId);
+ if (info == null)
+ {
+ // shareable node, see above
+ }
+ else
+ {
+ info.parent = uuid;
+ docs.remove(docId);
+ docs.put(info.uuid, info);
+ }
+ }
}
+ });
- double foreignParents = 0;
- Iterator it = docs.values().iterator();
- while (it.hasNext()) {
- NodeInfo info = (NodeInfo) it.next();
- NodeInfo parent = (NodeInfo) docs.get(info.parent);
- if (parent != null) {
- parents[info.docId] = DocId.create(parent.docId);
- } else if (info.parent != null) {
- foreignParents++;
- parents[info.docId] = DocId.create(info.parent);
- } else if (shareableNodes.get(info.docId)) {
- Document doc = reader.document(info.docId, FieldSelectors.UUID_AND_PARENT);
- parents[info.docId] = DocId.create(doc.getValues(FieldNames.PARENT));
- } else {
- // no parent -> root node
- parents[info.docId] = DocId.NULL;
- }
+ if (stopRequested)
+ {
+ return;
+ }
+
+ double foreignParents = 0;
+ Iterator it = docs.values().iterator();
+ while (it.hasNext())
+ {
+ NodeInfo info = (NodeInfo)it.next();
+ NodeInfo parent = (NodeInfo)docs.get(info.parent);
+ if (parent != null)
+ {
+ parents[info.docId] = DocId.create(parent.docId);
}
- if (log.isDebugEnabled()) {
- NumberFormat nf = NumberFormat.getPercentInstance();
- nf.setMaximumFractionDigits(1);
- time = System.currentTimeMillis() - time;
- if (parents.length > 0) {
- foreignParents /= parents.length;
- }
- log.debug("initialized {} DocIds in {} ms, {} foreign parents",
- new Object[]{
- new Integer(parents.length),
- new Long(time),
- nf.format(foreignParents)
- });
+ else if (info.parent != null)
+ {
+ foreignParents++;
+ parents[info.docId] = DocId.create(info.parent);
}
- }
+ else if (shareableNodes.get(info.docId))
+ {
+ Document doc = reader.document(info.docId, FieldSelectors.UUID_AND_PARENT);
+ parents[info.docId] = DocId.create(doc.getValues(FieldNames.PARENT));
+ }
+ else
+ {
+ // no parent -> root node
+ parents[info.docId] = DocId.NULL;
+ }
+ }
+ if (log.isDebugEnabled())
+ {
+ NumberFormat nf = NumberFormat.getPercentInstance();
+ nf.setMaximumFractionDigits(1);
+ time = System.currentTimeMillis() - time;
+ if (parents.length > 0)
+ {
+ foreignParents /= parents.length;
+ }
+ log.debug("initialized {} DocIds in {} ms, {} foreign parents", new Object[]{new Integer(parents.length),
+ new Long(time), nf.format(foreignParents)});
+ }
+ }
- /**
- * Collects term docs for a given start term. All terms with the same
- * field as <code>start</code> are enumerated.
- *
- * @param reader the index reader.
- * @param start the term where to start the term enumeration.
- * @param collector collects the term docs for each term.
- * @throws IOException if an error occurs while reading from the index.
- */
- private void collectTermDocs(IndexReader reader,
- Term start,
- TermDocsCollector collector)
- throws IOException {
- TermDocs tDocs = reader.termDocs();
- try {
- TermEnum terms = reader.terms(start);
- try {
- int count = 0;
- do {
- Term t = terms.term();
- if (t != null && t.field() == start.field()) {
- tDocs.seek(terms);
- collector.collect(t, tDocs);
- } else {
- break;
- }
- // once in a while check if we should quit
- if (++count % 10000 == 0) {
- if (stopRequested) {
- break;
- }
- }
- } while (terms.next());
- } finally {
- terms.close();
- }
- } finally {
- tDocs.close();
+ /**
+ * Collects term docs for a given start term. All terms with the same
+ * field as <code>start</code> are enumerated.
+ *
+ * @param reader the index reader.
+ * @param start the term where to start the term enumeration.
+ * @param collector collects the term docs for each term.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ private void collectTermDocs(IndexReader reader, Term start, TermDocsCollector collector) throws IOException
+ {
+ TermDocs tDocs = reader.termDocs();
+ try
+ {
+ TermEnum terms = reader.terms(start);
+ try
+ {
+ int count = 0;
+ do
+ {
+ Term t = terms.term();
+ if (t != null && t.field() == start.field())
+ {
+ tDocs.seek(terms);
+ collector.collect(t, tDocs);
+ }
+ else
+ {
+ break;
+ }
+ // once in a while check if we should quit
+ if (++count % 10000 == 0)
+ {
+ if (stopRequested)
+ {
+ break;
+ }
+ }
+ }
+ while (terms.next());
}
- }
- }
+ finally
+ {
+ terms.close();
+ }
+ }
+ finally
+ {
+ tDocs.close();
+ }
+ }
+ }
- /**
- * Simple interface to collect a term and its term docs.
- */
- private interface TermDocsCollector {
+ /**
+ * Simple interface to collect a term and its term docs.
+ */
+ private interface TermDocsCollector
+ {
- /**
- * Called for each term encountered.
- *
- * @param term the term.
- * @param tDocs the term docs of <code>term</code>.
- * @throws IOException if an error occurs while reading from the index.
- */
- void collect(Term term, TermDocs tDocs) throws IOException;
- }
+ /**
+ * Called for each term encountered.
+ *
+ * @param term the term.
+ * @param tDocs the term docs of <code>term</code>.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ void collect(Term term, TermDocs tDocs) throws IOException;
+ }
- private final static class NodeInfo {
+ private final static class NodeInfo
+ {
- final int docId;
+ final int docId;
- final String uuid;
+ final String uuid;
- String parent;
+ String parent;
- public NodeInfo(int docId, String uuid) {
- this.docId = docId;
- this.uuid = uuid;
- }
- }
+ public NodeInfo(int docId, String uuid)
+ {
+ this.docId = docId;
+ this.uuid = uuid;
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ChildAxisQuery.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,17 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.jcr.RepositoryException;
-
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
@@ -42,7 +31,6 @@
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import org.exoplatform.services.jcr.impl.core.query.LocationStepQueryNode;
import org.exoplatform.services.jcr.impl.core.query.lucene.hits.AdaptingHits;
@@ -51,6 +39,17 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.jcr.RepositoryException;
+
/**
* Implements a lucene <code>Query</code> which returns the child nodes of the
* nodes selected by another <code>Query</code>.
@@ -61,7 +60,7 @@
/**
* The logger instance for this class.
*/
- private static final Logger log = LoggerFactory.getLogger(ChildAxisQuery.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.ChildAxisQuery");
/**
* Threshold when children calculation is switched to
@@ -705,13 +704,14 @@
List<NodeData> childs = itemMgr.getChildNodesData(state);
List<NodeData> datas = new ArrayList<NodeData>();
- if (childs != null){
+ if (childs != null)
+ {
for (NodeData nodeData : childs)
{
- if(nameTest.equals(nodeData.getQPath().getName()))
+ if (nameTest.equals(nodeData.getQPath().getName()))
datas.add(nodeData);
}
-
+
}
entries = datas.iterator();//itemMgr.getChildNodesData(childNodeData).iterator();
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ConsistencyCheck.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ConsistencyCheck.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ConsistencyCheck.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -49,7 +49,7 @@
/**
* Logger instance for this class
*/
- private static final Logger log = LoggerFactory.getLogger(ConsistencyCheck.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.ConsistencyCheck");
/**
* The ItemStateManager of the workspace.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DescendantSelfAxisQuery.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,20 +16,7 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.util.BitSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-
import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Explanation;
import org.apache.lucene.search.HitCollector;
import org.apache.lucene.search.Query;
@@ -37,595 +24,689 @@
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.search.Sort;
-import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.Weight;
import org.exoplatform.services.jcr.impl.core.SessionDataManager;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
/**
* Implements a lucene <code>Query</code> which filters a sub query by checking
* whether the nodes selected by that sub query are descendants or self of
* nodes selected by a context query.
*/
-class DescendantSelfAxisQuery extends Query implements JcrQuery {
+class DescendantSelfAxisQuery extends Query implements JcrQuery
+{
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(DescendantSelfAxisQuery.class);
+ /**
+ * The logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.DescendantSelfAxisQuery");
- /**
- * The context query
- */
- private final Query contextQuery;
+ /**
+ * The context query
+ */
+ private final Query contextQuery;
- /**
- * The scorer of the context query
- */
- private Scorer contextScorer;
+ /**
+ * The scorer of the context query
+ */
+ private Scorer contextScorer;
- /**
- * The sub query to filter
- */
- private final Query subQuery;
+ /**
+ * The sub query to filter
+ */
+ private final Query subQuery;
- /**
- * The minimal levels required between context and sub nodes for a sub node
- * to match.
- */
- private final int minLevels;
+ /**
+ * The minimal levels required between context and sub nodes for a sub node
+ * to match.
+ */
+ private final int minLevels;
- /**
- * The scorer of the sub query to filter
- */
- private Scorer subScorer;
+ /**
+ * The scorer of the sub query to filter
+ */
+ private Scorer subScorer;
- /**
- * Creates a new <code>DescendantSelfAxisQuery</code> based on a
- * <code>context</code> and matches all descendants of the context nodes.
- * Whether the context nodes match as well is controlled by
- * <code>includeSelf</code>.
- *
- * @param context the context for this query.
- * @param includeSelf if <code>true</code> this query acts like a
- * descendant-or-self axis. If <code>false</code> this
- * query acts like a descendant axis.
- */
- public DescendantSelfAxisQuery(Query context, boolean includeSelf) {
- this(context, new MatchAllDocsQuery(), includeSelf);
- }
+ /**
+ * Creates a new <code>DescendantSelfAxisQuery</code> based on a
+ * <code>context</code> and matches all descendants of the context nodes.
+ * Whether the context nodes match as well is controlled by
+ * <code>includeSelf</code>.
+ *
+ * @param context the context for this query.
+ * @param includeSelf if <code>true</code> this query acts like a
+ * descendant-or-self axis. If <code>false</code> this
+ * query acts like a descendant axis.
+ */
+ public DescendantSelfAxisQuery(Query context, boolean includeSelf)
+ {
+ this(context, new MatchAllDocsQuery(), includeSelf);
+ }
- /**
- * Creates a new <code>DescendantSelfAxisQuery</code> based on a
- * <code>context</code> query and filtering the <code>sub</code> query.
- *
- * @param context the context for this query.
- * @param sub the sub query.
- */
- public DescendantSelfAxisQuery(Query context, Query sub) {
- this(context, sub, true);
- }
+ /**
+ * Creates a new <code>DescendantSelfAxisQuery</code> based on a
+ * <code>context</code> query and filtering the <code>sub</code> query.
+ *
+ * @param context the context for this query.
+ * @param sub the sub query.
+ */
+ public DescendantSelfAxisQuery(Query context, Query sub)
+ {
+ this(context, sub, true);
+ }
- /**
- * Creates a new <code>DescendantSelfAxisQuery</code> based on a
- * <code>context</code> query and filtering the <code>sub</code> query.
- *
- * @param context the context for this query.
- * @param sub the sub query.
- * @param includeSelf if <code>true</code> this query acts like a
- * descendant-or-self axis. If <code>false</code> this query acts like
- * a descendant axis.
- */
- public DescendantSelfAxisQuery(Query context, Query sub, boolean includeSelf) {
- this(context, sub, includeSelf ? 0 : 1);
- }
+ /**
+ * Creates a new <code>DescendantSelfAxisQuery</code> based on a
+ * <code>context</code> query and filtering the <code>sub</code> query.
+ *
+ * @param context the context for this query.
+ * @param sub the sub query.
+ * @param includeSelf if <code>true</code> this query acts like a
+ * descendant-or-self axis. If <code>false</code> this query acts like
+ * a descendant axis.
+ */
+ public DescendantSelfAxisQuery(Query context, Query sub, boolean includeSelf)
+ {
+ this(context, sub, includeSelf ? 0 : 1);
+ }
- /**
- * Creates a new <code>DescendantSelfAxisQuery</code> based on a
- * <code>context</code> query and filtering the <code>sub</code> query.
- *
- * @param context the context for this query.
- * @param sub the sub query.
- * @param minLevels the minimal levels required between context and sub
- * nodes for a sub node to match.
- */
- public DescendantSelfAxisQuery(Query context, Query sub, int minLevels) {
- this.contextQuery = context;
- this.subQuery = sub;
- this.minLevels = minLevels;
- }
+ /**
+ * Creates a new <code>DescendantSelfAxisQuery</code> based on a
+ * <code>context</code> query and filtering the <code>sub</code> query.
+ *
+ * @param context the context for this query.
+ * @param sub the sub query.
+ * @param minLevels the minimal levels required between context and sub
+ * nodes for a sub node to match.
+ */
+ public DescendantSelfAxisQuery(Query context, Query sub, int minLevels)
+ {
+ this.contextQuery = context;
+ this.subQuery = sub;
+ this.minLevels = minLevels;
+ }
- /**
- * @return the context query of this <code>DescendantSelfAxisQuery</code>.
- */
- Query getContextQuery() {
- return contextQuery;
- }
+ /**
+ * @return the context query of this <code>DescendantSelfAxisQuery</code>.
+ */
+ Query getContextQuery()
+ {
+ return contextQuery;
+ }
- /**
- * @return <code>true</code> if the sub query of this <code>DescendantSelfAxisQuery</code>
- * matches all nodes.
- */
- boolean subQueryMatchesAll() {
- return subQuery instanceof MatchAllDocsQuery;
- }
+ /**
+ * @return <code>true</code> if the sub query of this <code>DescendantSelfAxisQuery</code>
+ * matches all nodes.
+ */
+ boolean subQueryMatchesAll()
+ {
+ return subQuery instanceof MatchAllDocsQuery;
+ }
- /**
- * Returns the minimal levels required between context and sub nodes for a
- * sub node to match.
- * <ul>
- * <li><code>0</code>: a sub node <code>S</code> matches if it is a context
- * node or one of the ancestors of <code>S</code> is a context node.</li>
- * <li><code>1</code>: a sub node <code>S</code> matches if one of the
- * ancestors of <code>S</code> is a context node.</li>
- * <li><code>n</code>: a sub node <code>S</code> matches if
- * <code>S.getAncestor(S.getDepth() - n)</code> is a context node.</li>
- * </ul>
- *
- * @return the minimal levels required between context and sub nodes for a
- * sub node to match.
- */
- int getMinLevels() {
- return minLevels;
- }
+ /**
+ * Returns the minimal levels required between context and sub nodes for a
+ * sub node to match.
+ * <ul>
+ * <li><code>0</code>: a sub node <code>S</code> matches if it is a context
+ * node or one of the ancestors of <code>S</code> is a context node.</li>
+ * <li><code>1</code>: a sub node <code>S</code> matches if one of the
+ * ancestors of <code>S</code> is a context node.</li>
+ * <li><code>n</code>: a sub node <code>S</code> matches if
+ * <code>S.getAncestor(S.getDepth() - n)</code> is a context node.</li>
+ * </ul>
+ *
+ * @return the minimal levels required between context and sub nodes for a
+ * sub node to match.
+ */
+ int getMinLevels()
+ {
+ return minLevels;
+ }
- /**
- * Creates a <code>Weight</code> instance for this query.
- *
- * @param searcher the <code>Searcher</code> instance to use.
- * @return a <code>DescendantSelfAxisWeight</code>.
- */
- protected Weight createWeight(Searcher searcher) {
- return new DescendantSelfAxisWeight(searcher);
- }
+ /**
+ * Creates a <code>Weight</code> instance for this query.
+ *
+ * @param searcher the <code>Searcher</code> instance to use.
+ * @return a <code>DescendantSelfAxisWeight</code>.
+ */
+ protected Weight createWeight(Searcher searcher)
+ {
+ return new DescendantSelfAxisWeight(searcher);
+ }
- /**
- * {@inheritDoc}
- */
- public String toString(String field) {
- StringBuffer sb = new StringBuffer();
- sb.append("DescendantSelfAxisQuery(");
- sb.append(contextQuery);
- sb.append(", ");
- sb.append(subQuery);
- sb.append(", ");
- sb.append(minLevels);
- sb.append(")");
- return sb.toString();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String toString(String field)
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append("DescendantSelfAxisQuery(");
+ sb.append(contextQuery);
+ sb.append(", ");
+ sb.append(subQuery);
+ sb.append(", ");
+ sb.append(minLevels);
+ sb.append(")");
+ return sb.toString();
+ }
- /**
- * {@inheritDoc}
- */
- public void extractTerms(Set terms) {
- contextQuery.extractTerms(terms);
- subQuery.extractTerms(terms);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void extractTerms(Set terms)
+ {
+ contextQuery.extractTerms(terms);
+ subQuery.extractTerms(terms);
+ }
- /**
- * {@inheritDoc}
- */
- public Query rewrite(IndexReader reader) throws IOException {
- Query cQuery = contextQuery.rewrite(reader);
- Query sQuery = subQuery.rewrite(reader);
- if (contextQuery instanceof DescendantSelfAxisQuery) {
- DescendantSelfAxisQuery dsaq = (DescendantSelfAxisQuery) contextQuery;
- if (dsaq.subQueryMatchesAll()) {
- return new DescendantSelfAxisQuery(dsaq.getContextQuery(),
- sQuery, dsaq.getMinLevels() + getMinLevels()).rewrite(reader);
- }
- }
- if (cQuery == contextQuery && sQuery == subQuery) {
- return this;
- } else {
- return new DescendantSelfAxisQuery(cQuery, sQuery, minLevels);
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Query rewrite(IndexReader reader) throws IOException
+ {
+ Query cQuery = contextQuery.rewrite(reader);
+ Query sQuery = subQuery.rewrite(reader);
+ if (contextQuery instanceof DescendantSelfAxisQuery)
+ {
+ DescendantSelfAxisQuery dsaq = (DescendantSelfAxisQuery)contextQuery;
+ if (dsaq.subQueryMatchesAll())
+ {
+ return new DescendantSelfAxisQuery(dsaq.getContextQuery(), sQuery, dsaq.getMinLevels() + getMinLevels())
+ .rewrite(reader);
+ }
+ }
+ if (cQuery == contextQuery && sQuery == subQuery)
+ {
+ return this;
+ }
+ else
+ {
+ return new DescendantSelfAxisQuery(cQuery, sQuery, minLevels);
+ }
+ }
- //------------------------< JackrabbitQuery >-------------------------------
+ //------------------------< JackrabbitQuery >-------------------------------
- /**
- * {@inheritDoc}
- */
- public QueryHits execute(final JcrIndexSearcher searcher,
- final SessionImpl session,
- final Sort sort) throws IOException {
-// Query tt = ((BooleanClause)((BooleanQuery)subQuery).clauses().get(0)).getQuery();
-// searcher.search(((BooleanClause)((BooleanQuery)tt).clauses().get(0)).getQuery())
-// searcher.search(new TermQuery(new Term(FieldNames.UUID, "f7196dc97f0001015040af77592c3b2f")))
-// searcher.search(new TermQuery(new Term(FieldNames.FULLTEXT_PREFIX+":"+"title", "jumps")))
-// searcher.getIndexReader().document(468)
- if (sort.getSort().length == 0 && subQueryMatchesAll()) {
- // maps path String to NodeId
- Map startingPoints = new TreeMap();
- QueryHits result = searcher.evaluate(getContextQuery());
- try {
- // minLevels 0 and 1 are handled with a series of
- // NodeTraversingQueryHits directly on result. For minLevels >= 2
- // intermediate ChildNodesQueryHits are required.
- for (int i = 2; i <= getMinLevels(); i++) {
- result = new ChildNodesQueryHits(result, session);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public QueryHits execute(final JcrIndexSearcher searcher, final SessionImpl session, final Sort sort)
+ throws IOException
+ {
+ // Query tt = ((BooleanClause)((BooleanQuery)subQuery).clauses().get(0)).getQuery();
+ // searcher.search(((BooleanClause)((BooleanQuery)tt).clauses().get(0)).getQuery())
+ // searcher.search(new TermQuery(new Term(FieldNames.UUID, "f7196dc97f0001015040af77592c3b2f")))
+ // searcher.search(new TermQuery(new Term(FieldNames.FULLTEXT_PREFIX+":"+"title", "jumps")))
+ // searcher.getIndexReader().document(468)
+ if (sort.getSort().length == 0 && subQueryMatchesAll())
+ {
+ // maps path String to NodeId
+ Map startingPoints = new TreeMap();
+ QueryHits result = searcher.evaluate(getContextQuery());
+ try
+ {
+ // minLevels 0 and 1 are handled with a series of
+ // NodeTraversingQueryHits directly on result. For minLevels >= 2
+ // intermediate ChildNodesQueryHits are required.
+ for (int i = 2; i <= getMinLevels(); i++)
+ {
+ result = new ChildNodesQueryHits(result, session);
+ }
- ScoreNode sn;
- try {
- while ((sn = result.nextScoreNode()) != null) {
- //Node node = session.getNodeById(sn.getNodeId());
- Node node = (Node)session.getTransientNodesManager().getItemByIdentifier(sn.getNodeId(),true);
- startingPoints.put(node.getPath(), sn);
- }
- } catch (RepositoryException e) {
- throw Util.createIOException(e);
- }
- } finally {
- result.close();
+ ScoreNode sn;
+ try
+ {
+ while ((sn = result.nextScoreNode()) != null)
+ {
+ //Node node = session.getNodeById(sn.getNodeId());
+ Node node = (Node)session.getTransientNodesManager().getItemByIdentifier(sn.getNodeId(), true);
+ startingPoints.put(node.getPath(), sn);
+ }
}
+ catch (RepositoryException e)
+ {
+ throw Util.createIOException(e);
+ }
+ }
+ finally
+ {
+ result.close();
+ }
- // prune overlapping starting points
- String previousPath = null;
- for (Iterator it = startingPoints.keySet().iterator(); it.hasNext(); ) {
- String path = (String) it.next();
- // if the previous path is a prefix of this path then the
- // current path is obsolete
- if (previousPath != null && path.startsWith(previousPath)) {
- it.remove();
- } else {
- previousPath = path;
- }
+ // prune overlapping starting points
+ String previousPath = null;
+ for (Iterator it = startingPoints.keySet().iterator(); it.hasNext();)
+ {
+ String path = (String)it.next();
+ // if the previous path is a prefix of this path then the
+ // current path is obsolete
+ if (previousPath != null && path.startsWith(previousPath))
+ {
+ it.remove();
}
+ else
+ {
+ previousPath = path;
+ }
+ }
- final Iterator scoreNodes = startingPoints.values().iterator();
- return new AbstractQueryHits() {
+ final Iterator scoreNodes = startingPoints.values().iterator();
+ return new AbstractQueryHits()
+ {
- private NodeTraversingQueryHits currentTraversal;
+ private NodeTraversingQueryHits currentTraversal;
- private SessionDataManager itemMgr = session.getTransientNodesManager();
+ private SessionDataManager itemMgr = session.getTransientNodesManager();
- {
- fetchNextTraversal();
- }
+ {
+ fetchNextTraversal();
+ }
- public void close() throws IOException {
- if (currentTraversal != null) {
- currentTraversal.close();
- }
- }
+ public void close() throws IOException
+ {
+ if (currentTraversal != null)
+ {
+ currentTraversal.close();
+ }
+ }
- public ScoreNode nextScoreNode() throws IOException {
- while (currentTraversal != null) {
- ScoreNode sn = currentTraversal.nextScoreNode();
- if (sn != null) {
- return sn;
- } else {
- fetchNextTraversal();
- }
- }
- // if we get here there are no more score nodes
- return null;
- }
+ public ScoreNode nextScoreNode() throws IOException
+ {
+ while (currentTraversal != null)
+ {
+ ScoreNode sn = currentTraversal.nextScoreNode();
+ if (sn != null)
+ {
+ return sn;
+ }
+ else
+ {
+ fetchNextTraversal();
+ }
+ }
+ // if we get here there are no more score nodes
+ return null;
+ }
- private void fetchNextTraversal() throws IOException {
- if (currentTraversal != null) {
- currentTraversal.close();
- }
- if (scoreNodes.hasNext()) {
- ScoreNode sn = (ScoreNode) scoreNodes.next();
- try {
- //Node node = session.getNodeById(sn.getNodeId());
- Node node = (Node)session.getTransientNodesManager().getItemByIdentifier(sn.getNodeId(),true);
- currentTraversal = new NodeTraversingQueryHits(node,
- getMinLevels() == 0);
- } catch (RepositoryException e) {
- throw Util.createIOException(e);
- }
- } else {
- currentTraversal = null;
- }
- }
- };
- } else {
- return null;
- }
- }
+ private void fetchNextTraversal() throws IOException
+ {
+ if (currentTraversal != null)
+ {
+ currentTraversal.close();
+ }
+ if (scoreNodes.hasNext())
+ {
+ ScoreNode sn = (ScoreNode)scoreNodes.next();
+ try
+ {
+ //Node node = session.getNodeById(sn.getNodeId());
+ Node node = (Node)session.getTransientNodesManager().getItemByIdentifier(sn.getNodeId(), true);
+ currentTraversal = new NodeTraversingQueryHits(node, getMinLevels() == 0);
+ }
+ catch (RepositoryException e)
+ {
+ throw Util.createIOException(e);
+ }
+ }
+ else
+ {
+ currentTraversal = null;
+ }
+ }
+ };
+ }
+ else
+ {
+ return null;
+ }
+ }
- //--------------------< DescendantSelfAxisWeight >--------------------------
+ //--------------------< DescendantSelfAxisWeight >--------------------------
- /**
- * The <code>Weight</code> implementation for this
- * <code>DescendantSelfAxisWeight</code>.
- */
- private class DescendantSelfAxisWeight implements Weight {
+ /**
+ * The <code>Weight</code> implementation for this
+ * <code>DescendantSelfAxisWeight</code>.
+ */
+ private class DescendantSelfAxisWeight implements Weight
+ {
- /**
- * The searcher in use
- */
- private final Searcher searcher;
+ /**
+ * The searcher in use
+ */
+ private final Searcher searcher;
- /**
- * Creates a new <code>DescendantSelfAxisWeight</code> instance using
- * <code>searcher</code>.
- *
- * @param searcher a <code>Searcher</code> instance.
- */
- private DescendantSelfAxisWeight(Searcher searcher) {
- this.searcher = searcher;
- }
+ /**
+ * Creates a new <code>DescendantSelfAxisWeight</code> instance using
+ * <code>searcher</code>.
+ *
+ * @param searcher a <code>Searcher</code> instance.
+ */
+ private DescendantSelfAxisWeight(Searcher searcher)
+ {
+ this.searcher = searcher;
+ }
- //-----------------------------< Weight >-------------------------------
+ //-----------------------------< Weight >-------------------------------
- /**
- * Returns this <code>DescendantSelfAxisQuery</code>.
- *
- * @return this <code>DescendantSelfAxisQuery</code>.
- */
- public Query getQuery() {
- return DescendantSelfAxisQuery.this;
- }
+ /**
+ * Returns this <code>DescendantSelfAxisQuery</code>.
+ *
+ * @return this <code>DescendantSelfAxisQuery</code>.
+ */
+ public Query getQuery()
+ {
+ return DescendantSelfAxisQuery.this;
+ }
- /**
- * {@inheritDoc}
- */
- public float getValue() {
- return 1.0f;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public float getValue()
+ {
+ return 1.0f;
+ }
- /**
- * {@inheritDoc}
- */
- public float sumOfSquaredWeights() throws IOException {
- return 1.0f;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public float sumOfSquaredWeights() throws IOException
+ {
+ return 1.0f;
+ }
- /**
- * {@inheritDoc}
- */
- public void normalize(float norm) {
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void normalize(float norm)
+ {
+ }
- /**
- * Creates a scorer for this <code>DescendantSelfAxisScorer</code>.
- *
- * @param reader a reader for accessing the index.
- * @return a <code>DescendantSelfAxisScorer</code>.
- * @throws IOException if an error occurs while reading from the index.
- */
- public Scorer scorer(IndexReader reader) throws IOException {
- contextScorer = contextQuery.weight(searcher).scorer(reader);
- subScorer = subQuery.weight(searcher).scorer(reader);
- HierarchyResolver resolver = (HierarchyResolver) reader;
- return new DescendantSelfAxisScorer(searcher.getSimilarity(), reader, resolver);
- }
+ /**
+ * Creates a scorer for this <code>DescendantSelfAxisScorer</code>.
+ *
+ * @param reader a reader for accessing the index.
+ * @return a <code>DescendantSelfAxisScorer</code>.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ public Scorer scorer(IndexReader reader) throws IOException
+ {
+ contextScorer = contextQuery.weight(searcher).scorer(reader);
+ subScorer = subQuery.weight(searcher).scorer(reader);
+ HierarchyResolver resolver = (HierarchyResolver)reader;
+ return new DescendantSelfAxisScorer(searcher.getSimilarity(), reader, resolver);
+ }
- /**
- * {@inheritDoc}
- */
- public Explanation explain(IndexReader reader, int doc) throws IOException {
- return new Explanation();
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Explanation explain(IndexReader reader, int doc) throws IOException
+ {
+ return new Explanation();
+ }
+ }
- //----------------------< DescendantSelfAxisScorer >---------------------------------
- /**
- * Implements a <code>Scorer</code> for this
- * <code>DescendantSelfAxisQuery</code>.
- */
- private class DescendantSelfAxisScorer extends Scorer {
+ //----------------------< DescendantSelfAxisScorer >---------------------------------
+ /**
+ * Implements a <code>Scorer</code> for this
+ * <code>DescendantSelfAxisQuery</code>.
+ */
+ private class DescendantSelfAxisScorer extends Scorer
+ {
- /**
- * The <code>HierarchyResolver</code> of the index.
- */
- private final HierarchyResolver hResolver;
+ /**
+ * The <code>HierarchyResolver</code> of the index.
+ */
+ private final HierarchyResolver hResolver;
- /**
- * BitSet storing the id's of selected documents
- */
- private final BitSet contextHits;
+ /**
+ * BitSet storing the id's of selected documents
+ */
+ private final BitSet contextHits;
- /**
- * Set <code>true</code> once the context hits have been calculated.
- */
- private boolean contextHitsCalculated = false;
+ /**
+ * Set <code>true</code> once the context hits have been calculated.
+ */
+ private boolean contextHitsCalculated = false;
- /**
- * Remember document numbers of ancestors during validation
- */
- private int[] ancestorDocs = new int[2];
+ /**
+ * Remember document numbers of ancestors during validation
+ */
+ private int[] ancestorDocs = new int[2];
- /**
- * Reusable array that holds document numbers of parents.
- */
- private int[] pDocs = new int[1];
+ /**
+ * Reusable array that holds document numbers of parents.
+ */
+ private int[] pDocs = new int[1];
- /**
- * Reusable array that holds a single document number.
- */
- private final int[] singleDoc = new int[1];
+ /**
+ * Reusable array that holds a single document number.
+ */
+ private final int[] singleDoc = new int[1];
- /**
- * Creates a new <code>DescendantSelfAxisScorer</code>.
- *
- * @param similarity the <code>Similarity</code> instance to use.
- * @param reader for index access.
- * @param hResolver the hierarchy resolver of <code>reader</code>.
- */
- protected DescendantSelfAxisScorer(Similarity similarity,
- IndexReader reader,
- HierarchyResolver hResolver) {
- super(similarity);
- this.hResolver = hResolver;
- // todo reuse BitSets?
- this.contextHits = new BitSet(reader.maxDoc());
- }
+ /**
+ * Creates a new <code>DescendantSelfAxisScorer</code>.
+ *
+ * @param similarity the <code>Similarity</code> instance to use.
+ * @param reader for index access.
+ * @param hResolver the hierarchy resolver of <code>reader</code>.
+ */
+ protected DescendantSelfAxisScorer(Similarity similarity, IndexReader reader, HierarchyResolver hResolver)
+ {
+ super(similarity);
+ this.hResolver = hResolver;
+ // todo reuse BitSets?
+ this.contextHits = new BitSet(reader.maxDoc());
+ }
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
- collectContextHits();
- if (!subScorer.next() || contextHits.isEmpty()) {
- return false;
+ /**
+ * {@inheritDoc}
+ */
+ public boolean next() throws IOException
+ {
+ collectContextHits();
+ if (!subScorer.next() || contextHits.isEmpty())
+ {
+ return false;
+ }
+ int nextDoc = subScorer.doc();
+ while (nextDoc > -1)
+ {
+
+ if (isValid(nextDoc))
+ {
+ return true;
}
- int nextDoc = subScorer.doc();
- while (nextDoc > -1) {
- if (isValid(nextDoc)) {
- return true;
- }
+ // try next
+ nextDoc = subScorer.next() ? subScorer.doc() : -1;
+ }
+ return false;
+ }
- // try next
- nextDoc = subScorer.next() ? subScorer.doc() : -1;
- }
- return false;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int doc()
+ {
+ return subScorer.doc();
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
- return subScorer.doc();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public float score() throws IOException
+ {
+ return subScorer.score();
+ }
- /**
- * {@inheritDoc}
- */
- public float score() throws IOException {
- return subScorer.score();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean skipTo(int target) throws IOException
+ {
+ boolean match = subScorer.skipTo(target);
+ if (match)
+ {
+ collectContextHits();
+ return isValid(subScorer.doc()) || next();
+ }
+ else
+ {
+ return false;
+ }
+ }
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
- boolean match = subScorer.skipTo(target);
- if (match) {
- collectContextHits();
- return isValid(subScorer.doc()) || next();
- } else {
- return false;
+ private void collectContextHits() throws IOException
+ {
+ if (!contextHitsCalculated)
+ {
+ long time = System.currentTimeMillis();
+ contextScorer.score(new HitCollector()
+ {
+ public void collect(int doc, float score)
+ {
+ contextHits.set(doc);
+ }
+ }); // find all
+ contextHitsCalculated = true;
+ time = System.currentTimeMillis() - time;
+ if (log.isDebugEnabled())
+ {
+ log.debug("Collected {} context hits in {} ms for {}", new Object[]{
+ new Integer(contextHits.cardinality()), new Long(time), DescendantSelfAxisQuery.this});
}
- }
+ }
+ }
- private void collectContextHits() throws IOException {
- if (!contextHitsCalculated) {
- long time = System.currentTimeMillis();
- contextScorer.score(new HitCollector() {
- public void collect(int doc, float score) {
- contextHits.set(doc);
- }
- }); // find all
- contextHitsCalculated = true;
- time = System.currentTimeMillis() - time;
- if (log.isDebugEnabled()) {
- log.debug("Collected {} context hits in {} ms for {}",
- new Object[]{
- new Integer(contextHits.cardinality()),
- new Long(time),
- DescendantSelfAxisQuery.this
- });
- }
- }
- }
+ /**
+ * @throws UnsupportedOperationException this implementation always
+ * throws an <code>UnsupportedOperationException</code>.
+ */
+ public Explanation explain(int doc) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
- /**
- * @throws UnsupportedOperationException this implementation always
- * throws an <code>UnsupportedOperationException</code>.
- */
- public Explanation explain(int doc) throws IOException {
- throw new UnsupportedOperationException();
- }
+ /**
+ * Returns <code>true</code> if <code>doc</code> is a valid match from
+ * the sub scorer against the context hits. The caller must ensure
+ * that the context hits are calculated before this method is called!
+ *
+ * @param doc the document number.
+ * @return <code>true</code> if <code>doc</code> is valid.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ private boolean isValid(int doc) throws IOException
+ {
+ // check self if necessary
+ if (minLevels == 0 && contextHits.get(doc))
+ {
+ return true;
+ }
- /**
- * Returns <code>true</code> if <code>doc</code> is a valid match from
- * the sub scorer against the context hits. The caller must ensure
- * that the context hits are calculated before this method is called!
- *
- * @param doc the document number.
- * @return <code>true</code> if <code>doc</code> is valid.
- * @throws IOException if an error occurs while reading from the index.
- */
- private boolean isValid(int doc) throws IOException {
- // check self if necessary
- if (minLevels == 0 && contextHits.get(doc)) {
- return true;
- }
+ // check if doc is a descendant of one of the context nodes
+ pDocs = hResolver.getParents(doc, pDocs);
- // check if doc is a descendant of one of the context nodes
- pDocs = hResolver.getParents(doc, pDocs);
+ if (pDocs.length == 0 || pDocs[0] < 0)
+ {
+ return false;
+ }
- if (pDocs.length == 0 || pDocs[0] < 0) {
- return false;
- }
+ int ancestorCount = 0;
+ // can only remember one parent doc per level
+ ancestorDocs[ancestorCount++] = pDocs[0];
- int ancestorCount = 0;
- // can only remember one parent doc per level
- ancestorDocs[ancestorCount++] = pDocs[0];
-
- // traverse
- while (pDocs.length != 0) {
- boolean valid = false;
- for (int i = 0; i < pDocs.length; i++) {
- int pDoci = pDocs[i];
- if (pDoci >= 0 && pDoci <= contextHits.size() && ancestorCount >= minLevels && contextHits.get(pDoci)) {
- valid = true;
- break;
- }
- }
- if (valid) {
- break;
- } else {
- // load next level
- pDocs = getParents(pDocs, singleDoc);
- // resize array if needed
- if (ancestorCount == ancestorDocs.length) {
- // double the size of the new array
- int[] copy = new int[ancestorDocs.length * 2];
- System.arraycopy(ancestorDocs, 0, copy, 0, ancestorDocs.length);
- ancestorDocs = copy;
- }
- if (pDocs.length != 0) {
- // can only remember one parent doc per level
- ancestorDocs[ancestorCount++] = pDocs[0];
- }
- }
+ // traverse
+ while (pDocs.length != 0)
+ {
+ boolean valid = false;
+ for (int i = 0; i < pDocs.length; i++)
+ {
+ int pDoci = pDocs[i];
+ if (pDoci >= 0 && pDoci <= contextHits.size() && ancestorCount >= minLevels && contextHits.get(pDoci))
+ {
+ valid = true;
+ break;
+ }
}
+ if (valid)
+ {
+ break;
+ }
+ else
+ {
+ // load next level
+ pDocs = getParents(pDocs, singleDoc);
+ // resize array if needed
+ if (ancestorCount == ancestorDocs.length)
+ {
+ // double the size of the new array
+ int[] copy = new int[ancestorDocs.length * 2];
+ System.arraycopy(ancestorDocs, 0, copy, 0, ancestorDocs.length);
+ ancestorDocs = copy;
+ }
+ if (pDocs.length != 0)
+ {
+ // can only remember one parent doc per level
+ ancestorDocs[ancestorCount++] = pDocs[0];
+ }
+ }
+ }
- if (pDocs.length > 0) {
- // since current parentDocs are descendants of one of the context
- // docs we can promote all ancestorDocs to the context hits
- for (int i = 0; i < ancestorCount; i++) {
- contextHits.set(ancestorDocs[i]);
- }
- return true;
+ if (pDocs.length > 0)
+ {
+ // since current parentDocs are descendants of one of the context
+ // docs we can promote all ancestorDocs to the context hits
+ for (int i = 0; i < ancestorCount; i++)
+ {
+ contextHits.set(ancestorDocs[i]);
}
- return false;
- }
+ return true;
+ }
+ return false;
+ }
- /**
- * Returns the parent document numbers for the given <code>docs</code>.
- *
- * @param docs the current document numbers, for which to get the
- * parents.
- * @param pDocs an array of document numbers for reuse as return value.
- * @return the parent document number for the given <code>docs</code>.
- * @throws IOException if an error occurs while reading from the index.
- */
- private int[] getParents(int[] docs, int[] pDocs) throws IOException {
- // optimize single doc
- if (docs.length == 1) {
- return hResolver.getParents(docs[0], pDocs);
- } else {
- pDocs = new int[0];
- for (int i = 0; i < docs.length; i++) {
- int[] p = hResolver.getParents(docs[i], new int[0]);
- int[] tmp = new int[p.length + pDocs.length];
- System.arraycopy(pDocs, 0, tmp, 0, pDocs.length);
- System.arraycopy(p, 0, tmp, pDocs.length, p.length);
- pDocs = tmp;
- }
- return pDocs;
+ /**
+ * Returns the parent document numbers for the given <code>docs</code>.
+ *
+ * @param docs the current document numbers, for which to get the
+ * parents.
+ * @param pDocs an array of document numbers for reuse as return value.
+ * @return the parent document number for the given <code>docs</code>.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ private int[] getParents(int[] docs, int[] pDocs) throws IOException
+ {
+ // optimize single doc
+ if (docs.length == 1)
+ {
+ return hResolver.getParents(docs[0], pDocs);
+ }
+ else
+ {
+ pDocs = new int[0];
+ for (int i = 0; i < docs.length; i++)
+ {
+ int[] p = hResolver.getParents(docs[i], new int[0]);
+ int[] tmp = new int[p.length + pDocs.length];
+ System.arraycopy(pDocs, 0, tmp, 0, pDocs.length);
+ System.arraycopy(p, 0, tmp, pDocs.length, p.length);
+ pDocs = tmp;
}
- }
- }
+ return pDocs;
+ }
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocNumberCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocNumberCache.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocNumberCache.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,7 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-
import org.apache.commons.collections.map.LRUMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -24,176 +23,198 @@
/**
* Implements a Document number cache with a fixed size and a LRU strategy.
*/
-final class DocNumberCache {
+final class DocNumberCache
+{
- /**
- * Logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(DocNumberCache.class);
+ /**
+ * Logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.DocNumberCache");
- /**
- * Log cache statistics at most every 10 seconds.
- */
- private static final long LOG_INTERVAL = 1000 * 10;
+ /**
+ * Log cache statistics at most every 10 seconds.
+ */
+ private static final long LOG_INTERVAL = 1000 * 10;
- /**
- * The number of cache segments.
- */
- private static final int CACHE_SEGMENTS = 0x10;
+ /**
+ * The number of cache segments.
+ */
+ private static final int CACHE_SEGMENTS = 0x10;
- /**
- * Mask to calculate segment number.
- */
- private static final int CACHE_SEGMENTS_MASK = CACHE_SEGMENTS - 1;
+ /**
+ * Mask to calculate segment number.
+ */
+ private static final int CACHE_SEGMENTS_MASK = CACHE_SEGMENTS - 1;
- /**
- * LRU Maps where key=uuid value=reader;docNumber
- */
- private final LRUMap[] docNumbers = new LRUMap[CACHE_SEGMENTS];
+ /**
+ * LRU Maps where key=uuid value=reader;docNumber
+ */
+ private final LRUMap[] docNumbers = new LRUMap[CACHE_SEGMENTS];
- /**
- * Timestamp of the last cache statistics log.
- */
- private long lastLog;
+ /**
+ * Timestamp of the last cache statistics log.
+ */
+ private long lastLog;
- /**
- * Cache misses.
- */
- private long misses;
+ /**
+ * Cache misses.
+ */
+ private long misses;
- /**
- * Cache accesses;
- */
- private long accesses;
+ /**
+ * Cache accesses;
+ */
+ private long accesses;
- /**
- * Creates a new <code>DocNumberCache</code> with a limiting
- * <code>size</code>.
- *
- * @param size the cache limit.
- */
- DocNumberCache(int size) {
- size = size / CACHE_SEGMENTS;
- if (size < 0x40) {
- // minimum size is 0x40 * 0x10 = 1024
- size = 0x40;
- }
- for (int i = 0; i < docNumbers.length; i++) {
- docNumbers[i] = new LRUMap(size);
- }
- }
+ /**
+ * Creates a new <code>DocNumberCache</code> with a limiting
+ * <code>size</code>.
+ *
+ * @param size the cache limit.
+ */
+ DocNumberCache(int size)
+ {
+ size = size / CACHE_SEGMENTS;
+ if (size < 0x40)
+ {
+ // minimum size is 0x40 * 0x10 = 1024
+ size = 0x40;
+ }
+ for (int i = 0; i < docNumbers.length; i++)
+ {
+ docNumbers[i] = new LRUMap(size);
+ }
+ }
- /**
- * Puts a document number into the cache using a uuid as key. An entry is
- * only overwritten if the according reader is younger than the reader
- * associated with the existing entry.
- *
- * @param uuid the key.
- * @param reader the index reader from where the document number was read.
- * @param n the document number.
- */
- void put(String uuid, CachingIndexReader reader, int n) {
- LRUMap cacheSegment = docNumbers[getSegmentIndex(uuid.charAt(0))];
- //UUID key = UUID.fromString(uuid);
- String key = uuid;
- synchronized (cacheSegment) {
- Entry e = (Entry) cacheSegment.get(key);
- if (e != null) {
- // existing entry
- // ignore if reader is older than the one in entry
- if (reader.getCreationTick() <= e.creationTick) {
- if (log.isDebugEnabled()) {
- log.debug("Ignoring put(). New entry is not from a newer reader. "
- + "existing: " + e.creationTick
- + ", new: " + reader.getCreationTick());
- }
- e = null;
- }
- } else {
- // entry did not exist
- e = new Entry(reader.getCreationTick(), n);
+ /**
+ * Puts a document number into the cache using a uuid as key. An entry is
+ * only overwritten if the according reader is younger than the reader
+ * associated with the existing entry.
+ *
+ * @param uuid the key.
+ * @param reader the index reader from where the document number was read.
+ * @param n the document number.
+ */
+ void put(String uuid, CachingIndexReader reader, int n)
+ {
+ LRUMap cacheSegment = docNumbers[getSegmentIndex(uuid.charAt(0))];
+ //UUID key = UUID.fromString(uuid);
+ String key = uuid;
+ synchronized (cacheSegment)
+ {
+ Entry e = (Entry)cacheSegment.get(key);
+ if (e != null)
+ {
+ // existing entry
+ // ignore if reader is older than the one in entry
+ if (reader.getCreationTick() <= e.creationTick)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Ignoring put(). New entry is not from a newer reader. " + "existing: " + e.creationTick
+ + ", new: " + reader.getCreationTick());
+ }
+ e = null;
}
+ }
+ else
+ {
+ // entry did not exist
+ e = new Entry(reader.getCreationTick(), n);
+ }
- if (e != null) {
- cacheSegment.put(key, e);
- }
- }
- }
+ if (e != null)
+ {
+ cacheSegment.put(key, e);
+ }
+ }
+ }
- /**
- * Returns the cache entry for <code>uuid</code>, or <code>null</code> if
- * no entry exists for <code>uuid</code>.
- *
- * @param uuid the key.
- * @return cache entry or <code>null</code>.
- */
- Entry get(String uuid) {
- LRUMap cacheSegment = docNumbers[getSegmentIndex(uuid.charAt(0))];
- // uuid may be invalid
-// if (uuid.length() != UUID.UUID_FORMATTED_LENGTH) {
-// return null;
-// }
- String key = uuid;
- Entry entry;
- synchronized (cacheSegment) {
- entry = (Entry) cacheSegment.get(key);
- }
- if (log.isInfoEnabled()) {
- accesses++;
- if (entry == null) {
- misses++;
+ /**
+ * Returns the cache entry for <code>uuid</code>, or <code>null</code> if
+ * no entry exists for <code>uuid</code>.
+ *
+ * @param uuid the key.
+ * @return cache entry or <code>null</code>.
+ */
+ Entry get(String uuid)
+ {
+ LRUMap cacheSegment = docNumbers[getSegmentIndex(uuid.charAt(0))];
+ // uuid may be invalid
+ // if (uuid.length() != UUID.UUID_FORMATTED_LENGTH) {
+ // return null;
+ // }
+ String key = uuid;
+ Entry entry;
+ synchronized (cacheSegment)
+ {
+ entry = (Entry)cacheSegment.get(key);
+ }
+ if (log.isInfoEnabled())
+ {
+ accesses++;
+ if (entry == null)
+ {
+ misses++;
+ }
+ // log at most after 1000 accesses and every 10 seconds
+ if (accesses > 1000 && System.currentTimeMillis() - lastLog > LOG_INTERVAL)
+ {
+ long ratio = 100;
+ if (misses != 0)
+ {
+ ratio -= misses * 100L / accesses;
}
- // log at most after 1000 accesses and every 10 seconds
- if (accesses > 1000 && System.currentTimeMillis() - lastLog > LOG_INTERVAL) {
- long ratio = 100;
- if (misses != 0) {
- ratio -= misses * 100L / accesses;
- }
- StringBuffer statistics = new StringBuffer();
- int inUse = 0;
- for (int i = 0; i < docNumbers.length; i++) {
- inUse += docNumbers[i].size();
- }
- statistics.append("size=").append(inUse);
- statistics.append("/").append(docNumbers[0].maxSize() * CACHE_SEGMENTS);
- statistics.append(", #accesses=").append(accesses);
- statistics.append(", #hits=").append((accesses - misses));
- statistics.append(", #misses=").append(misses);
- statistics.append(", cacheRatio=").append(ratio).append("%");
- log.info(statistics.toString());
- accesses = 0;
- misses = 0;
- lastLog = System.currentTimeMillis();
+ StringBuffer statistics = new StringBuffer();
+ int inUse = 0;
+ for (int i = 0; i < docNumbers.length; i++)
+ {
+ inUse += docNumbers[i].size();
}
- }
- return entry;
- }
+ statistics.append("size=").append(inUse);
+ statistics.append("/").append(docNumbers[0].maxSize() * CACHE_SEGMENTS);
+ statistics.append(", #accesses=").append(accesses);
+ statistics.append(", #hits=").append((accesses - misses));
+ statistics.append(", #misses=").append(misses);
+ statistics.append(", cacheRatio=").append(ratio).append("%");
+ log.info(statistics.toString());
+ accesses = 0;
+ misses = 0;
+ lastLog = System.currentTimeMillis();
+ }
+ }
+ return entry;
+ }
- /**
- * Returns the segment index for character c.
- */
- private static int getSegmentIndex(char c) {
- if (c > '9') {
- c += 9;
- }
- return c & CACHE_SEGMENTS_MASK;
- }
+ /**
+ * Returns the segment index for character c.
+ */
+ private static int getSegmentIndex(char c)
+ {
+ if (c > '9')
+ {
+ c += 9;
+ }
+ return c & CACHE_SEGMENTS_MASK;
+ }
- public static final class Entry {
+ public static final class Entry
+ {
- /**
- * The creation tick of the IndexReader.
- */
- final long creationTick;
+ /**
+ * The creation tick of the IndexReader.
+ */
+ final long creationTick;
- /**
- * The document number.
- */
- final int doc;
+ /**
+ * The document number.
+ */
+ final int doc;
- Entry(long creationTick, int doc) {
- this.creationTick = creationTick;
- this.doc = doc;
- }
- }
+ Entry(long creationTick, int doc)
+ {
+ this.creationTick = creationTick;
+ this.doc = doc;
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocOrderScoreNodeIterator.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocOrderScoreNodeIterator.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/DocOrderScoreNodeIterator.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,6 +16,13 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
+import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.datamodel.QPathEntry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
@@ -27,94 +34,92 @@
import javax.jcr.RepositoryException;
-import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.datamodel.QPathEntry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Implements a ScoreNodeIterator that returns the score nodes in document order.
*/
-class DocOrderScoreNodeIterator implements ScoreNodeIterator {
+class DocOrderScoreNodeIterator implements ScoreNodeIterator
+{
- /** Logger instance for this class */
- private static final Logger log = LoggerFactory.getLogger(DocOrderScoreNodeIterator.class);
+ /** Logger instance for this class */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.DocOrderScoreNodeIterator");
- /** A node iterator with ordered nodes */
- private ScoreNodeIterator orderedNodes;
+ /** A node iterator with ordered nodes */
+ private ScoreNodeIterator orderedNodes;
- /** Unordered list of {@link ScoreNode}[]s. */
- private final List scoreNodes;
+ /** Unordered list of {@link ScoreNode}[]s. */
+ private final List scoreNodes;
- /** ItemManager to turn UUIDs into Node instances */
- protected final ItemDataConsumer itemMgr;
+ /** ItemManager to turn UUIDs into Node instances */
+ protected final ItemDataConsumer itemMgr;
- /**
- * Apply document order on the score nodes with this selectorIndex.
- */
- private final int selectorIndex;
+ /**
+ * Apply document order on the score nodes with this selectorIndex.
+ */
+ private final int selectorIndex;
- /**
- * Creates a <code>DocOrderScoreNodeIterator</code> that orders the nodes in
- * <code>scoreNodes</code> in document order.
- *
- * @param itemMgr the item manager of the session executing the
- * query.
- * @param scoreNodes the ids of the matching nodes with their score
- * value. <code>List<ScoreNode[]></code>
- * @param selectorIndex apply document order on the score nodes with this
- * selectorIndex.
- */
- DocOrderScoreNodeIterator(ItemDataConsumer itemMgr,
- List scoreNodes,
- int selectorIndex) {
- this.itemMgr = itemMgr;
- this.scoreNodes = scoreNodes;
- this.selectorIndex = selectorIndex;
- }
+ /**
+ * Creates a <code>DocOrderScoreNodeIterator</code> that orders the nodes in
+ * <code>scoreNodes</code> in document order.
+ *
+ * @param itemMgr the item manager of the session executing the
+ * query.
+ * @param scoreNodes the ids of the matching nodes with their score
+ * value. <code>List<ScoreNode[]></code>
+ * @param selectorIndex apply document order on the score nodes with this
+ * selectorIndex.
+ */
+ DocOrderScoreNodeIterator(ItemDataConsumer itemMgr, List scoreNodes, int selectorIndex)
+ {
+ this.itemMgr = itemMgr;
+ this.scoreNodes = scoreNodes;
+ this.selectorIndex = selectorIndex;
+ }
- /**
- * {@inheritDoc}
- */
- public Object next() {
- return nextScoreNodes();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Object next()
+ {
+ return nextScoreNodes();
+ }
- /**
- * {@inheritDoc}
- */
- public ScoreNode[] nextScoreNodes() {
- initOrderedIterator();
- return orderedNodes.nextScoreNodes();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public ScoreNode[] nextScoreNodes()
+ {
+ initOrderedIterator();
+ return orderedNodes.nextScoreNodes();
+ }
- /**
- * @throws UnsupportedOperationException always.
- */
- public void remove() {
- throw new UnsupportedOperationException("remove");
- }
+ /**
+ * @throws UnsupportedOperationException always.
+ */
+ public void remove()
+ {
+ throw new UnsupportedOperationException("remove");
+ }
- /**
- * {@inheritDoc}
- */
- public void skip(long skipNum) {
- initOrderedIterator();
- orderedNodes.skip(skipNum);
- }
- /**
- * {@inheritDoc}
- */
- public void skipBack(long skipNum)
+ /**
+ * {@inheritDoc}
+ */
+ public void skip(long skipNum)
{
- initOrderedIterator();
- orderedNodes.skipBack(skipNum);
-
+ initOrderedIterator();
+ orderedNodes.skip(skipNum);
}
/**
+ * {@inheritDoc}
+ */
+ public void skipBack(long skipNum)
+ {
+ initOrderedIterator();
+ orderedNodes.skipBack(skipNum);
+
+ }
+
+ /**
* Returns the number of nodes in this iterator.
* </p>
* Note: The number returned by this method may differ from the number
@@ -126,204 +131,223 @@
*
* @return the number of node in this iterator.
*/
- public long getSize() {
- if (orderedNodes != null) {
- return orderedNodes.getSize();
- } else {
- return scoreNodes.size();
- }
- }
+ public long getSize()
+ {
+ if (orderedNodes != null)
+ {
+ return orderedNodes.getSize();
+ }
+ else
+ {
+ return scoreNodes.size();
+ }
+ }
- /**
- * {@inheritDoc}
- */
- public long getPosition() {
- initOrderedIterator();
- return orderedNodes.getPosition();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public long getPosition()
+ {
+ initOrderedIterator();
+ return orderedNodes.getPosition();
+ }
- /**
- * {@inheritDoc}
- */
- public boolean hasNext() {
- initOrderedIterator();
- return orderedNodes.hasNext();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasNext()
+ {
+ initOrderedIterator();
+ return orderedNodes.hasNext();
+ }
- //------------------------< internal >--------------------------------------
+ //------------------------< internal >--------------------------------------
- /**
- * Initializes the NodeIterator in document order
- */
- private void initOrderedIterator() {
- if (orderedNodes != null) {
- return;
- }
- long time = System.currentTimeMillis();
- ScoreNode[][] nodes = (ScoreNode[][]) scoreNodes.toArray(new ScoreNode[scoreNodes.size()][]);
+ /**
+ * Initializes the NodeIterator in document order
+ */
+ private void initOrderedIterator()
+ {
+ if (orderedNodes != null)
+ {
+ return;
+ }
+ long time = System.currentTimeMillis();
+ ScoreNode[][] nodes = (ScoreNode[][])scoreNodes.toArray(new ScoreNode[scoreNodes.size()][]);
- final Set<String> invalidIDs = new HashSet<String>(2);
+ final Set<String> invalidIDs = new HashSet<String>(2);
- /** Cache for Nodes obtainer during the order (comparator work) */
- final Map<String, NodeData> lcache = new HashMap<String, NodeData>();
- do {
- if (invalidIDs.size() > 0) {
- // previous sort run was not successful -> remove failed uuids
- List tmp = new ArrayList();
- for (int i = 0; i < nodes.length; i++) {
- if (!invalidIDs.contains(nodes[i][selectorIndex].getNodeId())) {
- tmp.add(nodes[i]);
- }
- }
- nodes = (ScoreNode[][]) tmp.toArray(new ScoreNode[tmp.size()][]);
- invalidIDs.clear();
+ /** Cache for Nodes obtainer during the order (comparator work) */
+ final Map<String, NodeData> lcache = new HashMap<String, NodeData>();
+ do
+ {
+ if (invalidIDs.size() > 0)
+ {
+ // previous sort run was not successful -> remove failed uuids
+ List tmp = new ArrayList();
+ for (int i = 0; i < nodes.length; i++)
+ {
+ if (!invalidIDs.contains(nodes[i][selectorIndex].getNodeId()))
+ {
+ tmp.add(nodes[i]);
+ }
}
+ nodes = (ScoreNode[][])tmp.toArray(new ScoreNode[tmp.size()][]);
+ invalidIDs.clear();
+ }
- try {
- // sort the uuids
- Arrays.sort(nodes, new ScoreNodeComparator(lcache,invalidIDs));
- } catch (SortFailedException e) {
- // retry
- }
+ try
+ {
+ // sort the uuids
+ Arrays.sort(nodes, new ScoreNodeComparator(lcache, invalidIDs));
+ }
+ catch (SortFailedException e)
+ {
+ // retry
+ }
- } while (invalidIDs.size() > 0);
+ }
+ while (invalidIDs.size() > 0);
- if (log.isDebugEnabled()) {
- log.debug("" + nodes.length + " node(s) ordered in " + (System.currentTimeMillis() - time) + " ms");
- }
-
-
- orderedNodes = new ScoreNodeIteratorImpl(nodes);
- }
- private class ScoreNodeComparator implements Comparator<ScoreNode[]>
- {
- private final Map<String, NodeData> lcache;
+ if (log.isDebugEnabled())
+ {
+ log.debug("" + nodes.length + " node(s) ordered in " + (System.currentTimeMillis() - time) + " ms");
+ }
- private final Set<String> invalidIDs;
+ orderedNodes = new ScoreNodeIteratorImpl(nodes);
+ }
- public ScoreNodeComparator(Map<String, NodeData> lcache, Set<String> invalidIDs)
- {
- super();
- this.lcache = lcache;
- this.invalidIDs = invalidIDs;
- }
+ private class ScoreNodeComparator implements Comparator<ScoreNode[]>
+ {
+ private final Map<String, NodeData> lcache;
- private NodeData getNode(String id) throws RepositoryException
- {
- NodeData node = lcache.get(id);
- if (node == null)
- {
- node = (NodeData)itemMgr.getItemData(id);
- if (node != null)
- lcache.put(id, node);
+ private final Set<String> invalidIDs;
- }
- return node;
- }
+ public ScoreNodeComparator(Map<String, NodeData> lcache, Set<String> invalidIDs)
+ {
+ super();
+ this.lcache = lcache;
+ this.invalidIDs = invalidIDs;
+ }
- public int compare(final ScoreNode[] nodes1, final ScoreNode[] nodes2)
- {
- ScoreNode n1 = nodes1[selectorIndex];
- ScoreNode n2 = nodes2[selectorIndex];
- try
- {
- NodeData ndata1;
- try
- {
- ndata1 = getNode(n1.getNodeId());
- if (ndata1 == null)
- throw new RepositoryException("Node not found for " + n1.getNodeId());
- }
- catch (RepositoryException e)
- {
- // log.warn("Node " + n1.identifier + " does not exist anymore:
- // " + e);
- // node does not exist anymore
- invalidIDs.add(n1.getNodeId());
- throw new SortFailedException();
- }
+ private NodeData getNode(String id) throws RepositoryException
+ {
+ NodeData node = lcache.get(id);
+ if (node == null)
+ {
+ node = (NodeData)itemMgr.getItemData(id);
+ if (node != null)
+ lcache.put(id, node);
- NodeData ndata2;
- try
- {
- ndata2 = getNode(n2.getNodeId());
- if (ndata2 == null)
- throw new RepositoryException("Node not found for " + n2.getNodeId());
- }
- catch (RepositoryException e)
- {
- // log.warn("Node " + n2.identifier + " does not exist anymore:
- // " + e);
- // node does not exist anymore
- invalidIDs.add(n2.getNodeId());
- throw new SortFailedException();
- }
+ }
+ return node;
+ }
- QPath path1 = ndata1.getQPath();
- QPath path2 = ndata2.getQPath();
+ public int compare(final ScoreNode[] nodes1, final ScoreNode[] nodes2)
+ {
+ ScoreNode n1 = nodes1[selectorIndex];
+ ScoreNode n2 = nodes2[selectorIndex];
+ try
+ {
+ NodeData ndata1;
+ try
+ {
+ ndata1 = getNode(n1.getNodeId());
+ if (ndata1 == null)
+ throw new RepositoryException("Node not found for " + n1.getNodeId());
+ }
+ catch (RepositoryException e)
+ {
+ // log.warn("Node " + n1.identifier + " does not exist anymore:
+ // " + e);
+ // node does not exist anymore
+ invalidIDs.add(n1.getNodeId());
+ throw new SortFailedException();
+ }
- QPathEntry[] pentries1 = path1.getEntries();
- QPathEntry[] pentries2 = path2.getEntries();
+ NodeData ndata2;
+ try
+ {
+ ndata2 = getNode(n2.getNodeId());
+ if (ndata2 == null)
+ throw new RepositoryException("Node not found for " + n2.getNodeId());
+ }
+ catch (RepositoryException e)
+ {
+ // log.warn("Node " + n2.identifier + " does not exist anymore:
+ // " + e);
+ // node does not exist anymore
+ invalidIDs.add(n2.getNodeId());
+ throw new SortFailedException();
+ }
- // find nearest common ancestor
- int commonDepth = 0; // root
- while (pentries1.length > commonDepth && pentries2.length > commonDepth)
- {
- if (pentries1[commonDepth].equals(pentries2[commonDepth]))
- {
- commonDepth++;
- }
- else
- {
- break;
- }
- }
+ QPath path1 = ndata1.getQPath();
+ QPath path2 = ndata2.getQPath();
- // path elements at last depth were equal
- commonDepth--;
+ QPathEntry[] pentries1 = path1.getEntries();
+ QPathEntry[] pentries2 = path2.getEntries();
- // check if either path is an ancestor of the other
- if (pentries1.length - 1 == commonDepth)
- {
- // path1 itself is ancestor of path2
- return -1;
- }
+ // find nearest common ancestor
+ int commonDepth = 0; // root
+ while (pentries1.length > commonDepth && pentries2.length > commonDepth)
+ {
+ if (pentries1[commonDepth].equals(pentries2[commonDepth]))
+ {
+ commonDepth++;
+ }
+ else
+ {
+ break;
+ }
+ }
- if (pentries2.length - 1 == commonDepth)
- {
- // path2 itself is ancestor of path1
- return 1;
- }
+ // path elements at last depth were equal
+ commonDepth--;
- return ndata1.getOrderNumber() - ndata2.getOrderNumber();
- }
- catch (SortFailedException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- log.error("Exception while sorting nodes in document order: " + e.toString(), e);
- }
+ // check if either path is an ancestor of the other
+ if (pentries1.length - 1 == commonDepth)
+ {
+ // path1 itself is ancestor of path2
+ return -1;
+ }
- // if we get here something went wrong
- // remove both identifiers from array
- if (n1 != null)
- invalidIDs.add(n1.getNodeId());
- else
- log.warn("Null ScoreNode n1 will not be added into invalid identifiers set");
- if (n2 != null)
- invalidIDs.add(n2.getNodeId());
- else
- log.warn("Null ScoreNode n2 will not be added into invalid identifiers set");
+ if (pentries2.length - 1 == commonDepth)
+ {
+ // path2 itself is ancestor of path1
+ return 1;
+ }
- // terminate sorting
- throw new SortFailedException();
- }
- }
- /**
- * Indicates that sorting failed.
- */
- private static final class SortFailedException extends RuntimeException {
- }
+ return ndata1.getOrderNumber() - ndata2.getOrderNumber();
+ }
+ catch (SortFailedException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ log.error("Exception while sorting nodes in document order: " + e.toString(), e);
+ }
+
+ // if we get here something went wrong
+ // remove both identifiers from array
+ if (n1 != null)
+ invalidIDs.add(n1.getNodeId());
+ else
+ log.warn("Null ScoreNode n1 will not be added into invalid identifiers set");
+ if (n2 != null)
+ invalidIDs.add(n2.getNodeId());
+ else
+ log.warn("Null ScoreNode n2 will not be added into invalid identifiers set");
+
+ // terminate sorting
+ throw new SortFailedException();
+ }
+ }
+
+ /**
+ * Indicates that sorting failed.
+ */
+ private static final class SortFailedException extends RuntimeException
+ {
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/FileBasedNamespaceMappings.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -49,7 +49,7 @@
/**
* Default logger instance for this class
*/
- private static Logger log = LoggerFactory.getLogger(NamespaceMappings.class);
+ private static Logger log = LoggerFactory.getLogger("exo.jcr.component.core.NamespaceMappings");
/**
* Location of the file that persists the uri / prefix mappings
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMerger.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMerger.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMerger.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,11 +16,8 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
+import EDU.oswego.cs.dl.util.concurrent.Mutex;
+import EDU.oswego.cs.dl.util.concurrent.Sync;
import org.apache.commons.collections.Buffer;
import org.apache.commons.collections.BufferUtils;
@@ -30,470 +27,546 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import EDU.oswego.cs.dl.util.concurrent.Mutex;
-import EDU.oswego.cs.dl.util.concurrent.Sync;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
/**
* Merges indexes in a separate daemon thread.
*/
-class IndexMerger extends Thread implements IndexListener {
+class IndexMerger extends Thread implements IndexListener
+{
- /**
- * Logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(IndexMerger.class);
+ /**
+ * Logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.IndexMerger");
- /**
- * Marker task to signal the background thread to quit.
- */
- private static final Merge QUIT = new Merge(new Index[0]);
+ /**
+ * Marker task to signal the background thread to quit.
+ */
+ private static final Merge QUIT = new Merge(new Index[0]);
- /**
- * minMergeDocs config parameter.
- */
- private int minMergeDocs = SearchIndex.DEFAULT_MIN_MERGE_DOCS;
+ /**
+ * minMergeDocs config parameter.
+ */
+ private int minMergeDocs = SearchIndex.DEFAULT_MIN_MERGE_DOCS;
- /**
- * maxMergeDocs config parameter
- */
- private int maxMergeDocs = SearchIndex.DEFAULT_MAX_MERGE_DOCS;
+ /**
+ * maxMergeDocs config parameter
+ */
+ private int maxMergeDocs = SearchIndex.DEFAULT_MAX_MERGE_DOCS;
- /**
- * mergeFactor config parameter
- */
- private int mergeFactor = SearchIndex.DEFAULT_MERGE_FACTOR;
+ /**
+ * mergeFactor config parameter
+ */
+ private int mergeFactor = SearchIndex.DEFAULT_MERGE_FACTOR;
- /**
- * Queue of merge Tasks
- */
- private final Buffer mergeTasks = BufferUtils.blockingBuffer(new UnboundedFifoBuffer());
+ /**
+ * Queue of merge Tasks
+ */
+ private final Buffer mergeTasks = BufferUtils.blockingBuffer(new UnboundedFifoBuffer());
- /**
- * List of id <code>Term</code> that identify documents that were deleted
- * while a merge was running.
- */
- private final List deletedDocuments = Collections.synchronizedList(new ArrayList());
+ /**
+ * List of id <code>Term</code> that identify documents that were deleted
+ * while a merge was running.
+ */
+ private final List deletedDocuments = Collections.synchronizedList(new ArrayList());
- /**
- * List of <code>IndexBucket</code>s in ascending document limit.
- */
- private final List indexBuckets = new ArrayList();
+ /**
+ * List of <code>IndexBucket</code>s in ascending document limit.
+ */
+ private final List indexBuckets = new ArrayList();
- /**
- * The <code>MultiIndex</code> this index merger is working on.
- */
- private final MultiIndex multiIndex;
+ /**
+ * The <code>MultiIndex</code> this index merger is working on.
+ */
+ private final MultiIndex multiIndex;
- /**
- * Monitor object to synchronize merge calculation.
- */
- private final Object lock = new Object();
+ /**
+ * Monitor object to synchronize merge calculation.
+ */
+ private final Object lock = new Object();
- /**
- * Mutex that is acquired when replacing indexes on MultiIndex.
- */
- private final Sync indexReplacement = new Mutex();
+ /**
+ * Mutex that is acquired when replacing indexes on MultiIndex.
+ */
+ private final Sync indexReplacement = new Mutex();
- /**
- * When released, indicates that this index merger is idle.
- */
- private final Sync mergerIdle = new Mutex();
+ /**
+ * When released, indicates that this index merger is idle.
+ */
+ private final Sync mergerIdle = new Mutex();
- /**
- * Creates an <code>IndexMerger</code>.
- *
- * @param multiIndex the <code>MultiIndex</code>.
- */
- IndexMerger(MultiIndex multiIndex) {
- this.multiIndex = multiIndex;
- setName("IndexMerger");
- setDaemon(true);
- try {
- mergerIdle.acquire();
- } catch (InterruptedException e) {
- // will never happen, lock is free upon construction
- throw new InternalError("Unable to acquire mutex after construction");
- }
- }
+ /**
+ * Creates an <code>IndexMerger</code>.
+ *
+ * @param multiIndex the <code>MultiIndex</code>.
+ */
+ IndexMerger(MultiIndex multiIndex)
+ {
+ this.multiIndex = multiIndex;
+ setName("IndexMerger");
+ setDaemon(true);
+ try
+ {
+ mergerIdle.acquire();
+ }
+ catch (InterruptedException e)
+ {
+ // will never happen, lock is free upon construction
+ throw new InternalError("Unable to acquire mutex after construction");
+ }
+ }
- /**
- * Informs the index merger that an index was added / created.
- *
- * @param name the name of the index.
- * @param numDocs the number of documents it contains.
- */
- void indexAdded(String name, int numDocs) {
- if (numDocs < 0) {
- throw new IllegalArgumentException("numDocs must be positive");
- }
- // multiple threads may enter this method:
- // - the background thread of this IndexMerger, when it replaces indexes
- // after a successful merge
- // - a regular thread that updates the workspace
- //
- // therefore we have to synchronize this block
- synchronized (lock) {
- // initially create buckets
- if (indexBuckets.size() == 0) {
- long lower = 0;
- long upper = minMergeDocs;
- while (upper < maxMergeDocs) {
- indexBuckets.add(new IndexBucket(lower, upper, true));
- lower = upper + 1;
- upper *= mergeFactor;
- }
- // one with upper = maxMergeDocs
- indexBuckets.add(new IndexBucket(lower, maxMergeDocs, false));
- // and another one as overflow, just in case...
- indexBuckets.add(new IndexBucket(maxMergeDocs + 1, Long.MAX_VALUE, false));
+ /**
+ * Informs the index merger that an index was added / created.
+ *
+ * @param name the name of the index.
+ * @param numDocs the number of documents it contains.
+ */
+ void indexAdded(String name, int numDocs)
+ {
+ if (numDocs < 0)
+ {
+ throw new IllegalArgumentException("numDocs must be positive");
+ }
+ // multiple threads may enter this method:
+ // - the background thread of this IndexMerger, when it replaces indexes
+ // after a successful merge
+ // - a regular thread that updates the workspace
+ //
+ // therefore we have to synchronize this block
+ synchronized (lock)
+ {
+ // initially create buckets
+ if (indexBuckets.size() == 0)
+ {
+ long lower = 0;
+ long upper = minMergeDocs;
+ while (upper < maxMergeDocs)
+ {
+ indexBuckets.add(new IndexBucket(lower, upper, true));
+ lower = upper + 1;
+ upper *= mergeFactor;
}
+ // one with upper = maxMergeDocs
+ indexBuckets.add(new IndexBucket(lower, maxMergeDocs, false));
+ // and another one as overflow, just in case...
+ indexBuckets.add(new IndexBucket(maxMergeDocs + 1, Long.MAX_VALUE, false));
+ }
- // put index in bucket
- IndexBucket bucket = (IndexBucket) indexBuckets.get(indexBuckets.size() - 1);
- for (int i = 0; i < indexBuckets.size(); i++) {
- bucket = (IndexBucket) indexBuckets.get(i);
- if (bucket.fits(numDocs)) {
- break;
- }
+ // put index in bucket
+ IndexBucket bucket = (IndexBucket)indexBuckets.get(indexBuckets.size() - 1);
+ for (int i = 0; i < indexBuckets.size(); i++)
+ {
+ bucket = (IndexBucket)indexBuckets.get(i);
+ if (bucket.fits(numDocs))
+ {
+ break;
}
- bucket.add(new Index(name, numDocs));
+ }
+ bucket.add(new Index(name, numDocs));
- if (log.isDebugEnabled()) {
- log.debug("index added: name=" + name + ", numDocs=" + numDocs);
- }
+ if (log.isDebugEnabled())
+ {
+ log.debug("index added: name=" + name + ", numDocs=" + numDocs);
+ }
- // if bucket does not allow merge, we don't have to continue
- if (!bucket.allowsMerge()) {
- return;
- }
+ // if bucket does not allow merge, we don't have to continue
+ if (!bucket.allowsMerge())
+ {
+ return;
+ }
- // check if we need a merge
- if (bucket.size() >= mergeFactor) {
- long targetMergeDocs = bucket.upper;
- targetMergeDocs = Math.min(targetMergeDocs * mergeFactor, maxMergeDocs);
- // sum up docs in bucket
- List indexesToMerge = new ArrayList();
- int mergeDocs = 0;
- for (Iterator it = bucket.iterator(); it.hasNext() && mergeDocs <= targetMergeDocs;) {
- indexesToMerge.add(it.next());
- }
- if (indexesToMerge.size() > 2) {
- // found merge
- Index[] idxs = (Index[]) indexesToMerge.toArray(new Index[indexesToMerge.size()]);
- bucket.removeAll(indexesToMerge);
- if (log.isDebugEnabled()) {
- log.debug("requesting merge for " + indexesToMerge);
- }
- mergeTasks.add(new Merge(idxs));
- log.debug("merge queue now contains " + mergeTasks.size() + " tasks.");
- }
+ // check if we need a merge
+ if (bucket.size() >= mergeFactor)
+ {
+ long targetMergeDocs = bucket.upper;
+ targetMergeDocs = Math.min(targetMergeDocs * mergeFactor, maxMergeDocs);
+ // sum up docs in bucket
+ List indexesToMerge = new ArrayList();
+ int mergeDocs = 0;
+ for (Iterator it = bucket.iterator(); it.hasNext() && mergeDocs <= targetMergeDocs;)
+ {
+ indexesToMerge.add(it.next());
}
- }
- }
+ if (indexesToMerge.size() > 2)
+ {
+ // found merge
+ Index[] idxs = (Index[])indexesToMerge.toArray(new Index[indexesToMerge.size()]);
+ bucket.removeAll(indexesToMerge);
+ if (log.isDebugEnabled())
+ {
+ log.debug("requesting merge for " + indexesToMerge);
+ }
+ mergeTasks.add(new Merge(idxs));
+ log.debug("merge queue now contains " + mergeTasks.size() + " tasks.");
+ }
+ }
+ }
+ }
- /**
- * @inheritDoc
- */
- public void documentDeleted(Term id) {
- log.debug("document deleted: " + id.text());
- deletedDocuments.add(id);
- }
+ /**
+ * @inheritDoc
+ */
+ public void documentDeleted(Term id)
+ {
+ log.debug("document deleted: " + id.text());
+ deletedDocuments.add(id);
+ }
- /**
- * When the calling thread returns this index merger will be idle, that is
- * there will be no merge tasks pending anymore. The method returns immediately
- * if there are currently no tasks pending at all.
- */
- void waitUntilIdle() throws InterruptedException {
- mergerIdle.acquire();
- // and immediately release again
- mergerIdle.release();
- }
+ /**
+ * When the calling thread returns this index merger will be idle, that is
+ * there will be no merge tasks pending anymore. The method returns immediately
+ * if there are currently no tasks pending at all.
+ */
+ void waitUntilIdle() throws InterruptedException
+ {
+ mergerIdle.acquire();
+ // and immediately release again
+ mergerIdle.release();
+ }
- /**
- * Signals this <code>IndexMerger</code> to stop and waits until it
- * has terminated.
- */
- void dispose() {
- log.debug("dispose IndexMerger");
- // get mutex for index replacements
- try {
- indexReplacement.acquire();
- } catch (InterruptedException e) {
- log.warn("Interrupted while acquiring index replacement sync: " + e);
- // try to stop IndexMerger without the sync
- }
+ /**
+ * Signals this <code>IndexMerger</code> to stop and waits until it
+ * has terminated.
+ */
+ void dispose()
+ {
+ log.debug("dispose IndexMerger");
+ // get mutex for index replacements
+ try
+ {
+ indexReplacement.acquire();
+ }
+ catch (InterruptedException e)
+ {
+ log.warn("Interrupted while acquiring index replacement sync: " + e);
+ // try to stop IndexMerger without the sync
+ }
- // clear task queue
- mergeTasks.clear();
+ // clear task queue
+ mergeTasks.clear();
- // send quit
- mergeTasks.add(QUIT);
- log.debug("quit sent");
+ // send quit
+ mergeTasks.add(QUIT);
+ log.debug("quit sent");
- try {
- // give the merger thread some time to quit,
- // it is possible that the merger is busy working on a large index.
- // if that is the case we will just ignore it and the daemon will
- // die without being able to finish the merge.
- // at this point it is not possible anymore to replace indexes
- // on the MultiIndex because we hold the indexReplacement Sync.
- this.join(500);
- if (isAlive()) {
- log.info("Unable to stop IndexMerger. Daemon is busy.");
- } else {
- log.debug("IndexMerger thread stopped");
- }
- log.debug("merge queue size: " + mergeTasks.size());
- } catch (InterruptedException e) {
- log.warn("Interrupted while waiting for IndexMerger thread to terminate.");
- }
- }
+ try
+ {
+ // give the merger thread some time to quit,
+ // it is possible that the merger is busy working on a large index.
+ // if that is the case we will just ignore it and the daemon will
+ // die without being able to finish the merge.
+ // at this point it is not possible anymore to replace indexes
+ // on the MultiIndex because we hold the indexReplacement Sync.
+ this.join(500);
+ if (isAlive())
+ {
+ log.info("Unable to stop IndexMerger. Daemon is busy.");
+ }
+ else
+ {
+ log.debug("IndexMerger thread stopped");
+ }
+ log.debug("merge queue size: " + mergeTasks.size());
+ }
+ catch (InterruptedException e)
+ {
+ log.warn("Interrupted while waiting for IndexMerger thread to terminate.");
+ }
+ }
- /**
- * Implements the index merging.
- */
- public void run() {
- for (;;) {
- boolean isIdle = false;
- if (mergeTasks.size() == 0) {
- mergerIdle.release();
- isIdle = true;
+ /**
+ * Implements the index merging.
+ */
+ public void run()
+ {
+ for (;;)
+ {
+ boolean isIdle = false;
+ if (mergeTasks.size() == 0)
+ {
+ mergerIdle.release();
+ isIdle = true;
+ }
+ Merge task = (Merge)mergeTasks.remove();
+ if (task == QUIT)
+ {
+ mergerIdle.release();
+ break;
+ }
+ if (isIdle)
+ {
+ try
+ {
+ mergerIdle.acquire();
}
- Merge task = (Merge) mergeTasks.remove();
- if (task == QUIT) {
- mergerIdle.release();
- break;
+ catch (InterruptedException e)
+ {
+ Thread.interrupted();
+ log.warn("Unable to acquire mergerIdle sync");
}
- if (isIdle) {
- try {
- mergerIdle.acquire();
- } catch (InterruptedException e) {
- Thread.interrupted();
- log.warn("Unable to acquire mergerIdle sync");
- }
- }
+ }
- log.debug("accepted merge request");
+ log.debug("accepted merge request");
- // reset deleted documents
- deletedDocuments.clear();
+ // reset deleted documents
+ deletedDocuments.clear();
- // get readers
- String[] names = new String[task.indexes.length];
- for (int i = 0; i < task.indexes.length; i++) {
- names[i] = task.indexes[i].name;
- }
- try {
- log.debug("create new index");
- PersistentIndex index = multiIndex.getOrCreateIndex(null);
- boolean success = false;
- try {
+ // get readers
+ String[] names = new String[task.indexes.length];
+ for (int i = 0; i < task.indexes.length; i++)
+ {
+ names[i] = task.indexes[i].name;
+ }
+ try
+ {
+ log.debug("create new index");
+ PersistentIndex index = multiIndex.getOrCreateIndex(null);
+ boolean success = false;
+ try
+ {
- log.debug("get index readers from MultiIndex");
- IndexReader[] readers = multiIndex.getIndexReaders(names, this);
- try {
- // do the merge
- long time = System.currentTimeMillis();
- index.addIndexes(readers);
- time = System.currentTimeMillis() - time;
- int docCount = 0;
- for (int i = 0; i < readers.length; i++) {
- docCount += readers[i].numDocs();
- }
- log.info("merged " + docCount + " documents in " + time + " ms into " + index.getName() + ".");
- } finally {
- for (int i = 0; i < readers.length; i++) {
- try {
- Util.closeOrRelease(readers[i]);
- } catch (IOException e) {
- log.warn("Unable to close IndexReader: " + e);
- }
- }
- }
+ log.debug("get index readers from MultiIndex");
+ IndexReader[] readers = multiIndex.getIndexReaders(names, this);
+ try
+ {
+ // do the merge
+ long time = System.currentTimeMillis();
+ index.addIndexes(readers);
+ time = System.currentTimeMillis() - time;
+ int docCount = 0;
+ for (int i = 0; i < readers.length; i++)
+ {
+ docCount += readers[i].numDocs();
+ }
+ log.info("merged " + docCount + " documents in " + time + " ms into " + index.getName() + ".");
+ }
+ finally
+ {
+ for (int i = 0; i < readers.length; i++)
+ {
+ try
+ {
+ Util.closeOrRelease(readers[i]);
+ }
+ catch (IOException e)
+ {
+ log.warn("Unable to close IndexReader: " + e);
+ }
+ }
+ }
- // inform multi index
- // if we cannot get the sync immediately we have to quit
- if (!indexReplacement.attempt(0)) {
- log.debug("index merging canceled");
- break;
- }
- try {
- log.debug("replace indexes");
- multiIndex.replaceIndexes(names, index, deletedDocuments);
- } finally {
- indexReplacement.release();
- }
+ // inform multi index
+ // if we cannot get the sync immediately we have to quit
+ if (!indexReplacement.attempt(0))
+ {
+ log.debug("index merging canceled");
+ break;
+ }
+ try
+ {
+ log.debug("replace indexes");
+ multiIndex.replaceIndexes(names, index, deletedDocuments);
+ }
+ finally
+ {
+ indexReplacement.release();
+ }
- success = true;
+ success = true;
- } finally {
- if (!success) {
- // delete index
- log.debug("deleting index " + index.getName());
- multiIndex.deleteIndex(index);
- }
- }
- } catch (Throwable e) {
- log.error("Error while merging indexes: ", e);
}
- }
- log.info("IndexMerger terminated");
- }
+ finally
+ {
+ if (!success)
+ {
+ // delete index
+ log.debug("deleting index " + index.getName());
+ multiIndex.deleteIndex(index);
+ }
+ }
+ }
+ catch (Throwable e)
+ {
+ log.error("Error while merging indexes: ", e);
+ }
+ }
+ log.info("IndexMerger terminated");
+ }
- //-----------------------< merge properties >-------------------------------
+ //-----------------------< merge properties >-------------------------------
- /**
- * The merge factor.
- */
- public void setMergeFactor(int mergeFactor) {
- this.mergeFactor = mergeFactor;
- }
+ /**
+ * The merge factor.
+ */
+ public void setMergeFactor(int mergeFactor)
+ {
+ this.mergeFactor = mergeFactor;
+ }
+ /**
+ * The initial threshold for number of documents to merge to a new index.
+ */
+ public void setMinMergeDocs(int minMergeDocs)
+ {
+ this.minMergeDocs = minMergeDocs;
+ }
- /**
- * The initial threshold for number of documents to merge to a new index.
- */
- public void setMinMergeDocs(int minMergeDocs) {
- this.minMergeDocs = minMergeDocs;
- }
+ /**
+ * The maximum number of document to merge.
+ */
+ public void setMaxMergeDocs(int maxMergeDocs)
+ {
+ this.maxMergeDocs = maxMergeDocs;
+ }
- /**
- * The maximum number of document to merge.
- */
- public void setMaxMergeDocs(int maxMergeDocs) {
- this.maxMergeDocs = maxMergeDocs;
- }
+ //------------------------------< internal >--------------------------------
- //------------------------------< internal >--------------------------------
+ /**
+ * 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
+ {
- /**
- * 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 {
+ /**
+ * The name of the index.
+ */
+ private final String name;
- /**
- * The name of the index.
- */
- private final String name;
+ /**
+ * The number of documents the index contains.
+ */
+ private final int numDocs;
- /**
- * The number of documents the index contains.
- */
- private final int numDocs;
+ /**
+ * Creates a new index struct.
+ *
+ * @param name name of an index.
+ * @param numDocs number of documents it contains.
+ */
+ Index(String name, int numDocs)
+ {
+ this.name = name;
+ this.numDocs = numDocs;
+ }
- /**
- * Creates a new index struct.
- *
- * @param name name of an index.
- * @param numDocs number of documents it contains.
- */
- Index(String name, int numDocs) {
- this.name = name;
- this.numDocs = numDocs;
- }
+ /**
+ * Indexes are first ordered by {@link #numDocs} and then by {@link
+ * #name}.
+ *
+ * @param o the other <code>Index</code>.
+ * @return a negative integer, zero, or a positive integer as this
+ * Index is less than, equal to, or greater than the specified
+ * Index.
+ */
+ public int compareTo(Object o)
+ {
+ Index other = (Index)o;
+ int val = numDocs < other.numDocs ? -1 : (numDocs == other.numDocs ? 0 : 1);
+ if (val != 0)
+ {
+ return val;
+ }
+ else
+ {
+ return name.compareTo(other.name);
+ }
+ }
- /**
- * Indexes are first ordered by {@link #numDocs} and then by {@link
- * #name}.
- *
- * @param o the other <code>Index</code>.
- * @return a negative integer, zero, or a positive integer as this
- * Index is less than, equal to, or greater than the specified
- * Index.
- */
- public int compareTo(Object o) {
- Index other = (Index) o;
- int val = numDocs < other.numDocs ? -1 : (numDocs == other.numDocs ? 0 : 1);
- if (val != 0) {
- return val;
- } else {
- return name.compareTo(other.name);
- }
- }
+ /**
+ * @inheritDoc
+ */
+ public String toString()
+ {
+ return name + ":" + numDocs;
+ }
+ }
- /**
- * @inheritDoc
- */
- public String toString() {
- return name + ":" + numDocs;
- }
- }
+ /**
+ * Defines a merge task, to merge a couple of indexes into a new index.
+ */
+ private static final class Merge
+ {
- /**
- * Defines a merge task, to merge a couple of indexes into a new index.
- */
- private static final class Merge {
+ private final Index[] indexes;
- private final Index[] indexes;
+ /**
+ * Merge task, to merge <code>indexes</code> into a new index with
+ * <code>name</code>.
+ *
+ * @param indexes the indexes to merge.
+ */
+ Merge(Index[] indexes)
+ {
+ this.indexes = new Index[indexes.length];
+ System.arraycopy(indexes, 0, this.indexes, 0, indexes.length);
+ }
+ }
- /**
- * Merge task, to merge <code>indexes</code> into a new index with
- * <code>name</code>.
- *
- * @param indexes the indexes to merge.
- */
- Merge(Index[] indexes) {
- this.indexes = new Index[indexes.length];
- System.arraycopy(indexes, 0, this.indexes, 0, indexes.length);
- }
- }
+ /**
+ * 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
+ {
- /**
- * 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 {
+ /**
+ * The lower document limit.
+ */
+ private final long lower;
- /**
- * The lower document limit.
- */
- private final long lower;
+ /**
+ * The upper document limit.
+ */
+ private final long upper;
- /**
- * The upper document limit.
- */
- private final long upper;
+ /**
+ * Flag indicating if indexes in this bucket can be merged.
+ */
+ private final boolean allowMerge;
- /**
- * Flag indicating if indexes in this bucket can be merged.
- */
- private final boolean allowMerge;
+ /**
+ * Creates a new <code>IndexBucket</code>. Limits are both inclusive.
+ *
+ * @param lower document limit.
+ * @param upper document limit.
+ * @param allowMerge if indexes in this bucket can be merged.
+ */
+ IndexBucket(long lower, long upper, boolean allowMerge)
+ {
+ this.lower = lower;
+ this.upper = upper;
+ this.allowMerge = allowMerge;
+ }
- /**
- * Creates a new <code>IndexBucket</code>. Limits are both inclusive.
- *
- * @param lower document limit.
- * @param upper document limit.
- * @param allowMerge if indexes in this bucket can be merged.
- */
- IndexBucket(long lower, long upper, boolean allowMerge) {
- this.lower = lower;
- this.upper = upper;
- this.allowMerge = allowMerge;
- }
+ /**
+ * Returns <code>true</code> if the number of documents fit in this
+ * <code>IndexBucket</code>; otherwise <code>false</code>
+ *
+ * @param numDocs the number of documents.
+ * @return <code>true</code> if <code>numDocs</code> fit.
+ */
+ boolean fits(long numDocs)
+ {
+ return numDocs >= lower && numDocs <= upper;
+ }
- /**
- * Returns <code>true</code> if the number of documents fit in this
- * <code>IndexBucket</code>; otherwise <code>false</code>
- *
- * @param numDocs the number of documents.
- * @return <code>true</code> if <code>numDocs</code> fit.
- */
- boolean fits(long numDocs) {
- return numDocs >= lower && numDocs <= upper;
- }
-
- /**
- * Returns <code>true</code> if indexes in this bucket can be merged.
- *
- * @return <code>true</code> if indexes in this bucket can be merged.
- */
- boolean allowsMerge() {
- return allowMerge;
- }
- }
+ /**
+ * Returns <code>true</code> if indexes in this bucket can be merged.
+ *
+ * @return <code>true</code> if indexes in this bucket can be merged.
+ */
+ boolean allowsMerge()
+ {
+ return allowMerge;
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMigration.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMigration.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexMigration.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,8 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldSelector;
@@ -34,6 +32,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+
/**
* <code>IndexMigration</code> implements a utility that migrates a Jackrabbit
* 1.4.x index to version 1.5. Until version 1.4.x, indexes used the character
@@ -43,169 +43,208 @@
* quick check is run to find out whether a migration is required. See also
* JCR-1363 for more details.
*/
-public class IndexMigration {
+public class IndexMigration
+{
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(IndexMigration.class);
+ /**
+ * The logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.IndexMigration");
- /**
- * Checks if the given <code>index</code> needs to be migrated.
- *
- * @param index the index to check and migration if needed.
- * @param directoryManager the directory manager.
- * @throws IOException if an error occurs while migrating the index.
- */
- public static void migrate(PersistentIndex index,
- DirectoryManager directoryManager)
- throws IOException {
- Directory indexDir = index.getDirectory();
- log.debug("Checking {} ...", indexDir);
- ReadOnlyIndexReader reader = index.getReadOnlyIndexReader();
- try {
- if (IndexFormatVersion.getVersion(reader).getVersion() >=
- IndexFormatVersion.V3.getVersion()) {
- // index was created with Jackrabbit 1.5 or higher
- // no need for migration
- log.debug("IndexFormatVersion >= V3, no migration needed");
- return;
+ /**
+ * Checks if the given <code>index</code> needs to be migrated.
+ *
+ * @param index the index to check and migration if needed.
+ * @param directoryManager the directory manager.
+ * @throws IOException if an error occurs while migrating the index.
+ */
+ public static void migrate(PersistentIndex index, DirectoryManager directoryManager) throws IOException
+ {
+ Directory indexDir = index.getDirectory();
+ log.debug("Checking {} ...", indexDir);
+ ReadOnlyIndexReader reader = index.getReadOnlyIndexReader();
+ try
+ {
+ if (IndexFormatVersion.getVersion(reader).getVersion() >= IndexFormatVersion.V3.getVersion())
+ {
+ // index was created with Jackrabbit 1.5 or higher
+ // no need for migration
+ log.debug("IndexFormatVersion >= V3, no migration needed");
+ return;
+ }
+ // assert: there is at least one node in the index, otherwise the
+ // index format version would be at least V3
+ TermEnum terms = reader.terms(new Term(FieldNames.PROPERTIES, ""));
+ try
+ {
+ Term t = terms.term();
+ if (t.text().indexOf('\uFFFF') == -1)
+ {
+ log.debug("Index already migrated");
+ return;
}
- // assert: there is at least one node in the index, otherwise the
- // index format version would be at least V3
- TermEnum terms = reader.terms(new Term(FieldNames.PROPERTIES, ""));
- try {
- Term t = terms.term();
- if (t.text().indexOf('\uFFFF') == -1) {
- log.debug("Index already migrated");
- return;
- }
- } finally {
- terms.close();
- }
- } finally {
- reader.release();
- index.releaseWriterAndReaders();
- }
+ }
+ finally
+ {
+ terms.close();
+ }
+ }
+ finally
+ {
+ reader.release();
+ index.releaseWriterAndReaders();
+ }
- // if we get here then the index must be migrated
- log.debug("Index requires migration {}", indexDir);
+ // if we get here then the index must be migrated
+ log.debug("Index requires migration {}", indexDir);
- String migrationName = index.getName() + "_v2.3";
- if (directoryManager.hasDirectory(migrationName)) {
- directoryManager.delete(migrationName);
- }
+ String migrationName = index.getName() + "_v2.3";
+ if (directoryManager.hasDirectory(migrationName))
+ {
+ directoryManager.delete(migrationName);
+ }
- Directory migrationDir = directoryManager.getDirectory(migrationName);
- try {
- IndexWriter writer = new IndexWriter(migrationDir, new JcrStandartAnalyzer(),
- IndexWriter.MaxFieldLength.UNLIMITED);
- try {
- IndexReader r = new MigrationIndexReader(
- IndexReader.open(index.getDirectory()));
- try {
- writer.addIndexes(new IndexReader[]{r});
- writer.close();
- } finally {
- r.close();
- }
- } finally {
- writer.close();
+ Directory migrationDir = directoryManager.getDirectory(migrationName);
+ try
+ {
+ IndexWriter writer =
+ new IndexWriter(migrationDir, new JcrStandartAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
+ try
+ {
+ IndexReader r = new MigrationIndexReader(IndexReader.open(index.getDirectory()));
+ try
+ {
+ writer.addIndexes(new IndexReader[]{r});
+ writer.close();
}
- } finally {
- migrationDir.close();
- }
- directoryManager.delete(index.getName());
- if (!directoryManager.rename(migrationName, index.getName())) {
- throw new IOException("failed to move migrated directory " +
- migrationDir);
- }
- log.info("Migrated " + index.getName());
- }
+ finally
+ {
+ r.close();
+ }
+ }
+ finally
+ {
+ writer.close();
+ }
+ }
+ finally
+ {
+ migrationDir.close();
+ }
+ directoryManager.delete(index.getName());
+ if (!directoryManager.rename(migrationName, index.getName()))
+ {
+ throw new IOException("failed to move migrated directory " + migrationDir);
+ }
+ log.info("Migrated " + index.getName());
+ }
- //---------------------------< internal helper >----------------------------
+ //---------------------------< internal helper >----------------------------
- /**
- * An index reader that migrates stored field values and term text on the
- * fly.
- */
- private static class MigrationIndexReader extends FilterIndexReader {
+ /**
+ * An index reader that migrates stored field values and term text on the
+ * fly.
+ */
+ private static class MigrationIndexReader extends FilterIndexReader
+ {
- public MigrationIndexReader(IndexReader in) {
- super(in);
- }
+ public MigrationIndexReader(IndexReader in)
+ {
+ super(in);
+ }
- public Document document(int n, FieldSelector fieldSelector)
- throws CorruptIndexException, IOException {
- Document doc = super.document(n, fieldSelector);
- Fieldable[] fields = doc.getFieldables(FieldNames.PROPERTIES);
- if (fields != null) {
- doc.removeFields(FieldNames.PROPERTIES);
- for (int i = 0; i < fields.length; i++) {
- String value = fields[i].stringValue();
- value = value.replace('\uFFFF', '[');
- doc.add(new Field(FieldNames.PROPERTIES, value,
- Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
- }
+ public Document document(int n, FieldSelector fieldSelector) throws CorruptIndexException, IOException
+ {
+ Document doc = super.document(n, fieldSelector);
+ Fieldable[] fields = doc.getFieldables(FieldNames.PROPERTIES);
+ if (fields != null)
+ {
+ doc.removeFields(FieldNames.PROPERTIES);
+ for (int i = 0; i < fields.length; i++)
+ {
+ String value = fields[i].stringValue();
+ value = value.replace('\uFFFF', '[');
+ doc.add(new Field(FieldNames.PROPERTIES, value, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
}
- return doc;
- }
+ }
+ return doc;
+ }
- public TermEnum terms() throws IOException {
- return new MigrationTermEnum(in.terms());
- }
+ public TermEnum terms() throws IOException
+ {
+ return new MigrationTermEnum(in.terms());
+ }
- public TermPositions termPositions() throws IOException {
- return new MigrationTermPositions(in.termPositions());
- }
+ public TermPositions termPositions() throws IOException
+ {
+ return new MigrationTermPositions(in.termPositions());
+ }
- private static class MigrationTermEnum extends FilterTermEnum {
+ private static class MigrationTermEnum extends FilterTermEnum
+ {
- public MigrationTermEnum(TermEnum in) {
- super(in);
- }
+ public MigrationTermEnum(TermEnum in)
+ {
+ super(in);
+ }
- public Term term() {
- Term t = super.term();
- if (t == null) {
- return t;
- }
- if (t.field().equals(FieldNames.PROPERTIES)) {
- String text = t.text();
- return t.createTerm(text.replace('\uFFFF', '['));
- } else {
- return t;
- }
+ public Term term()
+ {
+ Term t = super.term();
+ if (t == null)
+ {
+ return t;
}
-
- TermEnum unwrap() {
- return in;
+ if (t.field().equals(FieldNames.PROPERTIES))
+ {
+ String text = t.text();
+ return t.createTerm(text.replace('\uFFFF', '['));
}
- }
+ else
+ {
+ return t;
+ }
+ }
- private static class MigrationTermPositions extends FilterTermPositions {
+ TermEnum unwrap()
+ {
+ return in;
+ }
+ }
- public MigrationTermPositions(TermPositions in) {
- super(in);
- }
+ private static class MigrationTermPositions extends FilterTermPositions
+ {
- public void seek(Term term) throws IOException {
- if (term.field().equals(FieldNames.PROPERTIES)) {
- char[] text = term.text().toCharArray();
- text[term.text().indexOf('[')] = '\uFFFF';
- super.seek(term.createTerm(new String(text)));
- } else {
- super.seek(term);
- }
+ public MigrationTermPositions(TermPositions in)
+ {
+ super(in);
+ }
+
+ public void seek(Term term) throws IOException
+ {
+ if (term.field().equals(FieldNames.PROPERTIES))
+ {
+ char[] text = term.text().toCharArray();
+ text[term.text().indexOf('[')] = '\uFFFF';
+ super.seek(term.createTerm(new String(text)));
}
+ else
+ {
+ super.seek(term);
+ }
+ }
- public void seek(TermEnum termEnum) throws IOException {
- if (termEnum instanceof MigrationTermEnum) {
- super.seek(((MigrationTermEnum) termEnum).unwrap());
- } else {
- super.seek(termEnum);
- }
+ public void seek(TermEnum termEnum) throws IOException
+ {
+ if (termEnum instanceof MigrationTermEnum)
+ {
+ super.seek(((MigrationTermEnum)termEnum).unwrap());
}
- }
- }
+ else
+ {
+ super.seek(termEnum);
+ }
+ }
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingConfigurationImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingConfigurationImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingConfigurationImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -65,14 +65,9 @@
/**
* The logger instance for this class
*/
- private static final Logger log = LoggerFactory.getLogger(IndexingConfigurationImpl.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.IndexingConfigurationImpl");
/**
- * The path factory instance.
- */
- // private static final PathFactory PATH_FACTORY =
- // PathFactoryImpl.getInstance();
- /**
* A namespace resolver for parsing QNames in the configuration.
*/
private LocationFactory resolver;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueue.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueue.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueue.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -35,179 +35,204 @@
* <code>IndexingQueue</code> implements a queue which contains all the
* documents with pending text extractor jobs.
*/
-public class IndexingQueue {
+public class IndexingQueue
+{
- /**
- * Logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(IndexingQueue.class);
+ /**
+ * Logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.IndexingQueue");
- /**
- * The store to persist uuids of pending documents.
- */
- private final IndexingQueueStore queueStore;
+ /**
+ * The store to persist uuids of pending documents.
+ */
+ private final IndexingQueueStore queueStore;
- /**
- * Maps UUID {@link String}s to {@link Document}s.
- */
- private final Map pendingDocuments = new HashMap();
+ /**
+ * Maps UUID {@link String}s to {@link Document}s.
+ */
+ private final Map pendingDocuments = new HashMap();
- /**
- * Flag that indicates whether this indexing queue had been
- * {@link #initialize(MultiIndex) initialized}.
- */
- private volatile boolean initialized = false;
+ /**
+ * Flag that indicates whether this indexing queue had been
+ * {@link #initialize(MultiIndex) initialized}.
+ */
+ private volatile boolean initialized = false;
- /**
- * Creates an indexing queue.
- *
- * @param queueStore the store where to read the pending extraction jobs.
- */
- IndexingQueue(IndexingQueueStore queueStore) {
- this.queueStore = queueStore;
- }
+ /**
+ * Creates an indexing queue.
+ *
+ * @param queueStore the store where to read the pending extraction jobs.
+ */
+ IndexingQueue(IndexingQueueStore queueStore)
+ {
+ this.queueStore = queueStore;
+ }
- /**
- * Initializes the indexing queue.
- *
- * @param index the multi index this indexing queue belongs to.
- * @throws IOException if an error occurs while reading from the index.
- */
- void initialize(MultiIndex index) throws IOException {
- if (initialized) {
- throw new IllegalStateException("already initialized");
- }
- // check index for nodes that need to be reindexed
- CachingMultiIndexReader reader = index.getIndexReader();
- try {
- TermDocs tDocs = reader.termDocs(
- new Term(FieldNames.REINDEXING_REQUIRED, ""));
- try {
- while (tDocs.next()) {
- queueStore.addUUID(reader.document(tDocs.doc(),
- FieldSelectors.UUID).get(FieldNames.UUID));
- }
- } finally {
- tDocs.close();
+ /**
+ * Initializes the indexing queue.
+ *
+ * @param index the multi index this indexing queue belongs to.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ void initialize(MultiIndex index) throws IOException
+ {
+ if (initialized)
+ {
+ throw new IllegalStateException("already initialized");
+ }
+ // check index for nodes that need to be reindexed
+ CachingMultiIndexReader reader = index.getIndexReader();
+ try
+ {
+ TermDocs tDocs = reader.termDocs(new Term(FieldNames.REINDEXING_REQUIRED, ""));
+ try
+ {
+ while (tDocs.next())
+ {
+ queueStore.addUUID(reader.document(tDocs.doc(), FieldSelectors.UUID).get(FieldNames.UUID));
}
- } finally {
- reader.release();
- }
- String[] uuids = queueStore.getPending();
- for (int i = 0; i < uuids.length; i++) {
- try {
- Document doc = index.createDocument(uuids[i]);
- pendingDocuments.put(uuids[i], doc);
- log.debug("added node {}. New size of indexing queue: {}",
- uuids[i], new Integer(pendingDocuments.size()));
- } catch (IllegalArgumentException e) {
- log.warn("Invalid UUID in indexing queue store: " + uuids[i]);
- } catch (RepositoryException e) {
- // node does not exist anymore
- log.debug("Node with uuid {} does not exist anymore", uuids[i]);
- queueStore.removeUUID(uuids[i]);
- }
- }
- initialized = true;
- }
+ }
+ finally
+ {
+ tDocs.close();
+ }
+ }
+ finally
+ {
+ reader.release();
+ }
+ String[] uuids = queueStore.getPending();
+ for (int i = 0; i < uuids.length; i++)
+ {
+ try
+ {
+ Document doc = index.createDocument(uuids[i]);
+ pendingDocuments.put(uuids[i], doc);
+ log.debug("added node {}. New size of indexing queue: {}", uuids[i], new Integer(pendingDocuments.size()));
+ }
+ catch (IllegalArgumentException e)
+ {
+ log.warn("Invalid UUID in indexing queue store: " + uuids[i]);
+ }
+ catch (RepositoryException e)
+ {
+ // node does not exist anymore
+ log.debug("Node with uuid {} does not exist anymore", uuids[i]);
+ queueStore.removeUUID(uuids[i]);
+ }
+ }
+ initialized = true;
+ }
- /**
- * Returns the {@link Document}s that are finished.
- *
- * @return the {@link Document}s that are finished.
- */
- public Document[] getFinishedDocuments() {
- checkInitialized();
- List finished = new ArrayList();
- synchronized (this) {
- finished.addAll(pendingDocuments.values());
- }
+ /**
+ * Returns the {@link Document}s that are finished.
+ *
+ * @return the {@link Document}s that are finished.
+ */
+ public Document[] getFinishedDocuments()
+ {
+ checkInitialized();
+ List finished = new ArrayList();
+ synchronized (this)
+ {
+ finished.addAll(pendingDocuments.values());
+ }
- Iterator it = finished.iterator();
- while (it.hasNext()) {
- Document doc = (Document) it.next();
- if (!Util.isDocumentReady(doc)) {
- it.remove();
- }
- }
- return (Document[]) finished.toArray(new Document[finished.size()]);
- }
+ Iterator it = finished.iterator();
+ while (it.hasNext())
+ {
+ Document doc = (Document)it.next();
+ if (!Util.isDocumentReady(doc))
+ {
+ it.remove();
+ }
+ }
+ return (Document[])finished.toArray(new Document[finished.size()]);
+ }
- /**
- * Removes the document with the given <code>uuid</code> from the indexing
- * queue.
- *
- * @param uuid the uuid of the document to return.
- * @return the document for the given <code>uuid</code> or <code>null</code>
- * if this queue does not contain a document with the given
- * <code>uuid</code>.
- */
- public synchronized Document removeDocument(String uuid) {
- checkInitialized();
- Document doc = (Document) pendingDocuments.remove(uuid);
- if (doc != null) {
- queueStore.removeUUID(uuid);
- log.debug("removed node {}. New size of indexing queue: {}",
- uuid, new Integer(pendingDocuments.size()));
- }
- return doc;
- }
+ /**
+ * Removes the document with the given <code>uuid</code> from the indexing
+ * queue.
+ *
+ * @param uuid the uuid of the document to return.
+ * @return the document for the given <code>uuid</code> or <code>null</code>
+ * if this queue does not contain a document with the given
+ * <code>uuid</code>.
+ */
+ public synchronized Document removeDocument(String uuid)
+ {
+ checkInitialized();
+ Document doc = (Document)pendingDocuments.remove(uuid);
+ if (doc != null)
+ {
+ queueStore.removeUUID(uuid);
+ log.debug("removed node {}. New size of indexing queue: {}", uuid, new Integer(pendingDocuments.size()));
+ }
+ return doc;
+ }
- /**
- * Adds a document to this indexing queue.
- *
- * @param doc the document to add.
- * @return an existing document in the queue with the same uuid as the one
- * in <code>doc</code> or <code>null</code> if there was no such
- * document.
- */
- public synchronized Document addDocument(Document doc) {
- checkInitialized();
- String uuid = doc.get(FieldNames.UUID);
- Document existing = (Document) pendingDocuments.put(uuid, doc);
- log.debug("added node {}. New size of indexing queue: {}",
- uuid, new Integer(pendingDocuments.size()));
- if (existing == null) {
- // document wasn't present, add it to the queue store
- queueStore.addUUID(uuid);
- }
- // return existing if any
- return existing;
- }
+ /**
+ * Adds a document to this indexing queue.
+ *
+ * @param doc the document to add.
+ * @return an existing document in the queue with the same uuid as the one
+ * in <code>doc</code> or <code>null</code> if there was no such
+ * document.
+ */
+ public synchronized Document addDocument(Document doc)
+ {
+ checkInitialized();
+ String uuid = doc.get(FieldNames.UUID);
+ Document existing = (Document)pendingDocuments.put(uuid, doc);
+ log.debug("added node {}. New size of indexing queue: {}", uuid, new Integer(pendingDocuments.size()));
+ if (existing == null)
+ {
+ // document wasn't present, add it to the queue store
+ queueStore.addUUID(uuid);
+ }
+ // return existing if any
+ return existing;
+ }
- /**
- * Closes this indexing queue and disposes all pending documents.
- */
- public synchronized void close() {
- checkInitialized();
- // go through pending documents and close readers
- Iterator it = pendingDocuments.values().iterator();
- while (it.hasNext()) {
- Document doc = (Document) it.next();
- Util.disposeDocument(doc);
- it.remove();
- }
- queueStore.close();
- }
+ /**
+ * Closes this indexing queue and disposes all pending documents.
+ */
+ public synchronized void close()
+ {
+ checkInitialized();
+ // go through pending documents and close readers
+ Iterator it = pendingDocuments.values().iterator();
+ while (it.hasNext())
+ {
+ Document doc = (Document)it.next();
+ Util.disposeDocument(doc);
+ it.remove();
+ }
+ queueStore.close();
+ }
- /**
- * Checks if this indexing queue is initialized and otherwise throws a
- * {@link IllegalStateException}.
- */
- private void checkInitialized() {
- if (!initialized) {
- throw new IllegalStateException("not initialized");
- }
- }
+ /**
+ * Checks if this indexing queue is initialized and otherwise throws a
+ * {@link IllegalStateException}.
+ */
+ private void checkInitialized()
+ {
+ if (!initialized)
+ {
+ throw new IllegalStateException("not initialized");
+ }
+ }
- //----------------------------< testing only >------------------------------
+ //----------------------------< testing only >------------------------------
- /**
- * <b>This method is for testing only!</b>
- *
- * @return the number of the currently pending documents.
- */
- public synchronized int getNumPendingDocuments() {
- return pendingDocuments.size();
- }
+ /**
+ * <b>This method is for testing only!</b>
+ *
+ * @return the number of the currently pending documents.
+ */
+ public synchronized int getNumPendingDocuments()
+ {
+ return pendingDocuments.size();
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueueStore.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueueStore.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/IndexingQueueStore.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,6 +16,11 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
+import org.apache.lucene.store.Directory;
+import org.exoplatform.services.jcr.impl.core.query.lucene.directory.IndexInputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -23,11 +28,6 @@
import java.util.HashSet;
import java.util.Set;
-import org.apache.lucene.store.Directory;
-import org.exoplatform.services.jcr.impl.core.query.lucene.directory.IndexInputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* <code>IndexingQueueStore</code> implements a store that keeps the uuids of
* nodes that are pending in the indexing queue. Until Jackrabbit 1.4 this store
@@ -35,130 +35,154 @@
* nodes are marked directly in the index with a special field.
* See {@link FieldNames#REINDEXING_REQUIRED}.
*/
-class IndexingQueueStore {
+class IndexingQueueStore
+{
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(IndexingQueueStore.class);
+ /**
+ * The logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.IndexingQueueStore");
- /**
- * Encoding of the indexing queue store.
- */
- private static final String ENCODING = "UTF-8";
+ /**
+ * Encoding of the indexing queue store.
+ */
+ private static final String ENCODING = "UTF-8";
- /**
- * Operation identifier for an added node.
- */
- private static final String ADD = "ADD";
+ /**
+ * Operation identifier for an added node.
+ */
+ private static final String ADD = "ADD";
- /**
- * Operation identifier for an removed node.
- */
- private static final String REMOVE = "REMOVE";
+ /**
+ * Operation identifier for an removed node.
+ */
+ private static final String REMOVE = "REMOVE";
- /**
- * Name of the file that contains the indexing queue log.
- */
- private static final String INDEXING_QUEUE_FILE = "indexing_queue.log";
+ /**
+ * Name of the file that contains the indexing queue log.
+ */
+ private static final String INDEXING_QUEUE_FILE = "indexing_queue.log";
- /**
- * The UUID Strings of the pending documents.
- */
- private final Set pending = new HashSet();
+ /**
+ * The UUID Strings of the pending documents.
+ */
+ private final Set pending = new HashSet();
- /**
- * The directory from where to read pending document UUIDs.
- */
- private final Directory dir;
+ /**
+ * The directory from where to read pending document UUIDs.
+ */
+ private final Directory dir;
- /**
- * Creates a new <code>IndexingQueueStore</code> using the given directory.
- *
- * @param directory the directory to use.
- * @throws IOException if an error ocurrs while reading pending UUIDs.
- */
- IndexingQueueStore(Directory directory) throws IOException {
- this.dir = directory;
- readStore();
- }
+ /**
+ * Creates a new <code>IndexingQueueStore</code> using the given directory.
+ *
+ * @param directory the directory to use.
+ * @throws IOException if an error ocurrs while reading pending UUIDs.
+ */
+ IndexingQueueStore(Directory directory) throws IOException
+ {
+ this.dir = directory;
+ readStore();
+ }
- /**
- * @return the UUIDs of the pending text extraction jobs.
- */
- public String[] getPending() {
- return (String[]) pending.toArray(new String[pending.size()]);
- }
+ /**
+ * @return the UUIDs of the pending text extraction jobs.
+ */
+ public String[] getPending()
+ {
+ return (String[])pending.toArray(new String[pending.size()]);
+ }
- /**
- * Adds a <code>uuid</code> to the store.
- *
- * @param uuid the uuid to add.
- */
- public void addUUID(String uuid) {
- pending.add(uuid);
- }
+ /**
+ * Adds a <code>uuid</code> to the store.
+ *
+ * @param uuid the uuid to add.
+ */
+ public void addUUID(String uuid)
+ {
+ pending.add(uuid);
+ }
- /**
- * Removes a <code>uuid</code> from the store.
- *
- * @param uuid the uuid to add.
- */
- public void removeUUID(String uuid) {
- pending.remove(uuid);
- }
+ /**
+ * Removes a <code>uuid</code> from the store.
+ *
+ * @param uuid the uuid to add.
+ */
+ public void removeUUID(String uuid)
+ {
+ pending.remove(uuid);
+ }
- /**
- * Closes this queue store.
- */
- public void close() {
- if (pending.isEmpty()) {
- try {
- if (dir.fileExists(INDEXING_QUEUE_FILE)) {
- dir.deleteFile(INDEXING_QUEUE_FILE);
- }
- } catch (IOException e) {
- log.warn("unable to delete " + INDEXING_QUEUE_FILE);
+ /**
+ * Closes this queue store.
+ */
+ public void close()
+ {
+ if (pending.isEmpty())
+ {
+ try
+ {
+ if (dir.fileExists(INDEXING_QUEUE_FILE))
+ {
+ dir.deleteFile(INDEXING_QUEUE_FILE);
}
- }
- }
+ }
+ catch (IOException e)
+ {
+ log.warn("unable to delete " + INDEXING_QUEUE_FILE);
+ }
+ }
+ }
- //----------------------------< internal >----------------------------------
+ //----------------------------< internal >----------------------------------
- /**
- * Reads all pending UUIDs from the file and puts them into {@link
- * #pending}.
- *
- * @throws IOException if an error occurs while reading.
- */
- private void readStore() throws IOException {
- if (dir.fileExists(INDEXING_QUEUE_FILE)) {
- InputStream in = new IndexInputStream(dir.openInput(INDEXING_QUEUE_FILE));
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(in, ENCODING));
- try {
- String line;
- while ((line = reader.readLine()) != null) {
- int idx = line.indexOf(' ');
- if (idx == -1) {
- // invalid line
- log.warn("invalid line in {}: {}", INDEXING_QUEUE_FILE, line);
- } else {
- String cmd = line.substring(0, idx);
- String uuid = line.substring(idx + 1, line.length());
- if (ADD.equals(cmd)) {
- pending.add(uuid);
- } else if (REMOVE.equals(cmd)) {
- pending.remove(uuid);
- } else {
- // invalid line
- log.warn("invalid line in {}: {}", INDEXING_QUEUE_FILE, line);
- }
- }
- }
- } finally {
- in.close();
+ /**
+ * Reads all pending UUIDs from the file and puts them into {@link
+ * #pending}.
+ *
+ * @throws IOException if an error occurs while reading.
+ */
+ private void readStore() throws IOException
+ {
+ if (dir.fileExists(INDEXING_QUEUE_FILE))
+ {
+ InputStream in = new IndexInputStream(dir.openInput(INDEXING_QUEUE_FILE));
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in, ENCODING));
+ try
+ {
+ String line;
+ while ((line = reader.readLine()) != null)
+ {
+ int idx = line.indexOf(' ');
+ if (idx == -1)
+ {
+ // invalid line
+ log.warn("invalid line in {}: {}", INDEXING_QUEUE_FILE, line);
+ }
+ else
+ {
+ String cmd = line.substring(0, idx);
+ String uuid = line.substring(idx + 1, line.length());
+ if (ADD.equals(cmd))
+ {
+ pending.add(uuid);
+ }
+ else if (REMOVE.equals(cmd))
+ {
+ pending.remove(uuid);
+ }
+ else
+ {
+ // invalid line
+ log.warn("invalid line in {}: {}", INDEXING_QUEUE_FILE, line);
+ }
+ }
}
- }
- }
+ }
+ finally
+ {
+ in.close();
+ }
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LazyTextExtractorField.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LazyTextExtractorField.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LazyTextExtractorField.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,16 +16,15 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.io.Reader;
-
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.AbstractField;
import org.apache.lucene.document.Field;
-import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.Reader;
+
/**
* <code>LazyTextExtractorField</code> implements a Lucene field with a String
* value that is lazily initialized from a given {@link Reader}. In addition
@@ -34,120 +33,130 @@
*
* @see #isExtractorFinished()
*/
-public class LazyTextExtractorField extends AbstractField {
+public class LazyTextExtractorField extends AbstractField
+{
- /**
- * The serial version UID.
- */
- private static final long serialVersionUID = -2707986404659820071L;
+ /**
+ * The serial version UID.
+ */
+ private static final long serialVersionUID = -2707986404659820071L;
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(LazyTextExtractorField.class);
+ /**
+ * The logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.LazyTextExtractorField");
- /**
- * The reader from where to read the text extract.
- */
- private final Reader reader;
+ /**
+ * The reader from where to read the text extract.
+ */
+ private final Reader reader;
- /**
- * The extract as obtained lazily from {@link #reader}.
- */
- private String extract;
+ /**
+ * The extract as obtained lazily from {@link #reader}.
+ */
+ private String extract;
- /**
- * Creates a new <code>LazyTextExtractorField</code> with the given
- * <code>name</code>.
- *
- * @param name the name of the field.
- * @param reader the reader where to obtain the string from.
- * @param store when set <code>true</code> the string value is stored in the
- * index.
- * @param withOffsets when set <code>true</code> a term vector with offsets
- * is written into the index.
- */
- public LazyTextExtractorField(String name,
- Reader reader,
- boolean store,
- boolean withOffsets) {
- super(name,
- store ? Field.Store.YES : Field.Store.NO,
- Field.Index.ANALYZED,
- withOffsets ? Field.TermVector.WITH_OFFSETS : Field.TermVector.NO);
- this.reader = reader;
- }
+ /**
+ * Creates a new <code>LazyTextExtractorField</code> with the given
+ * <code>name</code>.
+ *
+ * @param name the name of the field.
+ * @param reader the reader where to obtain the string from.
+ * @param store when set <code>true</code> the string value is stored in the
+ * index.
+ * @param withOffsets when set <code>true</code> a term vector with offsets
+ * is written into the index.
+ */
+ public LazyTextExtractorField(String name, Reader reader, boolean store, boolean withOffsets)
+ {
+ super(name, store ? Field.Store.YES : Field.Store.NO, Field.Index.ANALYZED, withOffsets
+ ? Field.TermVector.WITH_OFFSETS : Field.TermVector.NO);
+ this.reader = reader;
+ }
- /**
- * @return the string value of this field.
- */
- public String stringValue() {
- if (extract == null) {
- StringBuffer textExtract = new StringBuffer();
- char[] buffer = new char[1024];
- int len;
- try {
- while ((len = reader.read(buffer)) > -1) {
- textExtract.append(buffer, 0, len);
- }
- } catch (IOException e) {
- log.warn("Exception reading value for field: "
- + e.getMessage());
- log.debug("Dump:", e);
- } finally {
- //IOUtils.closeQuietly(reader);
- try
- {
- reader.close();
- }
- catch (IOException e)
- {
- log.error(e.getLocalizedMessage(),e);
- }
+ /**
+ * @return the string value of this field.
+ */
+ public String stringValue()
+ {
+ if (extract == null)
+ {
+ StringBuffer textExtract = new StringBuffer();
+ char[] buffer = new char[1024];
+ int len;
+ try
+ {
+ while ((len = reader.read(buffer)) > -1)
+ {
+ textExtract.append(buffer, 0, len);
}
- extract = textExtract.toString();
- }
- return extract;
- }
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception reading value for field: " + e.getMessage());
+ log.debug("Dump:", e);
+ }
+ finally
+ {
+ //IOUtils.closeQuietly(reader);
+ try
+ {
+ reader.close();
+ }
+ catch (IOException e)
+ {
+ log.error(e.getLocalizedMessage(), e);
+ }
+ }
+ extract = textExtract.toString();
+ }
+ return extract;
+ }
- /**
- * @return always <code>null</code>.
- */
- public Reader readerValue() {
- return null;
- }
+ /**
+ * @return always <code>null</code>.
+ */
+ public Reader readerValue()
+ {
+ return null;
+ }
- /**
- * @return always <code>null</code>.
- */
- public byte[] binaryValue() {
- return null;
- }
+ /**
+ * @return always <code>null</code>.
+ */
+ public byte[] binaryValue()
+ {
+ return null;
+ }
- /**
- * @return always <code>null</code>.
- */
- public TokenStream tokenStreamValue() {
- return null;
- }
+ /**
+ * @return always <code>null</code>.
+ */
+ public TokenStream tokenStreamValue()
+ {
+ return null;
+ }
- /**
- * @return <code>true</code> if the underlying reader is ready to provide
- * extracted text.
- */
- public boolean isExtractorFinished() {
- if (reader instanceof TextExtractorReader) {
- return ((TextExtractorReader) reader).isExtractorFinished();
- }
- return true;
- }
+ /**
+ * @return <code>true</code> if the underlying reader is ready to provide
+ * extracted text.
+ */
+ public boolean isExtractorFinished()
+ {
+ if (reader instanceof TextExtractorReader)
+ {
+ return ((TextExtractorReader)reader).isExtractorFinished();
+ }
+ return true;
+ }
- /**
- * Disposes this field and closes the underlying reader.
- *
- * @throws IOException if an error occurs while closing the reader.
- */
- public void dispose() throws IOException {
- reader.close();
- }
+ /**
+ * Disposes this field and closes the underlying reader.
+ *
+ * @throws IOException if an error occurs while closing the reader.
+ */
+ public void dispose() throws IOException
+ {
+ reader.close();
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneQueryBuilder.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -101,7 +101,8 @@
/**
* Logger for this class
*/
- private static final Logger log = LoggerFactory.getLogger(LuceneQueryBuilder.class);
+ private static final Logger log =
+ LoggerFactory.getLogger("exo.jcr.component.core." + LuceneQueryBuilder.class.getSimpleName());
/**
* Root node of the abstract query tree
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneVirtualTableResolver.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneVirtualTableResolver.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/LuceneVirtualTableResolver.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -43,106 +43,113 @@
* @version $Id: exo-jboss-codetemplates.xml 34027 2009-07-15 23:26:43Z
* aheritier $
*/
-public class LuceneVirtualTableResolver extends
- NodeTypeVirtualTableResolver<Query> {
+public class LuceneVirtualTableResolver extends NodeTypeVirtualTableResolver<Query>
+{
- private final LocationFactory locationFactory;
+ private final LocationFactory locationFactory;
- /**
- * Class logger.
- */
- private final Log log = ExoLogger
- .getLogger(LuceneVirtualTableResolver.class);
+ /**
+ * Class logger.
+ */
+ private final Log log = ExoLogger.getLogger("exo.jcr.component.core.LuceneVirtualTableResolver");
- private final String mixinTypesField;
+ private final String mixinTypesField;
- private final String primaryTypeField;
+ private final String primaryTypeField;
- /**
- * @param nodeTypeDataManager
- * @throws RepositoryException
- */
- public LuceneVirtualTableResolver(
- final NodeTypeDataManager nodeTypeDataManager,
- final NamespaceAccessor namespaceAccessor)
- throws RepositoryException {
- super(nodeTypeDataManager);
+ /**
+ * @param nodeTypeDataManager
+ * @throws RepositoryException
+ */
+ public LuceneVirtualTableResolver(final NodeTypeDataManager nodeTypeDataManager,
+ final NamespaceAccessor namespaceAccessor) throws RepositoryException
+ {
+ super(nodeTypeDataManager);
- locationFactory = new LocationFactory(namespaceAccessor);
- mixinTypesField = locationFactory.createJCRName(
- Constants.JCR_MIXINTYPES).getAsString();
- primaryTypeField = locationFactory.createJCRName(
- Constants.JCR_PRIMARYTYPE).getAsString();
+ locationFactory = new LocationFactory(namespaceAccessor);
+ mixinTypesField = locationFactory.createJCRName(Constants.JCR_MIXINTYPES).getAsString();
+ primaryTypeField = locationFactory.createJCRName(Constants.JCR_PRIMARYTYPE).getAsString();
- }
+ }
- /**
- * {@inheritDoc}
- */
- public Query resolve(final InternalQName tableName,
- final boolean includeInheritedTables) throws InvalidQueryException,
- RepositoryException {
+ /**
+ * {@inheritDoc}
+ */
+ public Query resolve(final InternalQName tableName, final boolean includeInheritedTables)
+ throws InvalidQueryException, RepositoryException
+ {
- final List<Term> terms = new ArrayList<Term>();
+ final List<Term> terms = new ArrayList<Term>();
- Query query = null;
- try {
- final String nodeTypeStringName = locationFactory.createJCRName(
- tableName).getAsString();
+ Query query = null;
+ try
+ {
+ final String nodeTypeStringName = locationFactory.createJCRName(tableName).getAsString();
- if (isMixin(tableName)) {
- // search for nodes where jcr:mixinTypes is set to this mixin
- Term t = new Term(FieldNames.PROPERTIES, FieldNames
- .createNamedValue(mixinTypesField, nodeTypeStringName));
- terms.add(t);
+ if (isMixin(tableName))
+ {
+ // search for nodes where jcr:mixinTypes is set to this mixin
+ Term t = new Term(FieldNames.PROPERTIES, FieldNames.createNamedValue(mixinTypesField, nodeTypeStringName));
+ terms.add(t);
- } else {
- // search for nodes where jcr:primaryType is set to this type
+ }
+ else
+ {
+ // search for nodes where jcr:primaryType is set to this type
- Term t = new Term(FieldNames.PROPERTIES, FieldNames
- .createNamedValue(primaryTypeField, nodeTypeStringName));
- terms.add(t);
- }
- if (includeInheritedTables) {
- // now search for all node types that are derived from base
- final Set<InternalQName> allTypes = getSubTypes(tableName);
- for (final InternalQName descendantNt : allTypes) {
- final String ntName = locationFactory.createJCRName(
- descendantNt).getAsString();
+ Term t = new Term(FieldNames.PROPERTIES, FieldNames.createNamedValue(primaryTypeField, nodeTypeStringName));
+ terms.add(t);
+ }
+ if (includeInheritedTables)
+ {
+ // now search for all node types that are derived from base
+ final Set<InternalQName> allTypes = getSubTypes(tableName);
+ for (final InternalQName descendantNt : allTypes)
+ {
+ final String ntName = locationFactory.createJCRName(descendantNt).getAsString();
- Term t;
- if (isMixin(descendantNt)) {
- // search on jcr:mixinTypes
- t = new Term(FieldNames.PROPERTIES, FieldNames
- .createNamedValue(mixinTypesField, ntName));
- } else {
- // search on jcr:primaryType
- t = new Term(FieldNames.PROPERTIES, FieldNames
- .createNamedValue(primaryTypeField, ntName));
- }
- terms.add(t);
- }
- }
- } catch (final NoSuchNodeTypeException e) {
- throw new InvalidQueryException(e.getMessage(), e);
- }
+ Term t;
+ if (isMixin(descendantNt))
+ {
+ // search on jcr:mixinTypes
+ t = new Term(FieldNames.PROPERTIES, FieldNames.createNamedValue(mixinTypesField, ntName));
+ }
+ else
+ {
+ // search on jcr:primaryType
+ t = new Term(FieldNames.PROPERTIES, FieldNames.createNamedValue(primaryTypeField, ntName));
+ }
+ terms.add(t);
+ }
+ }
+ }
+ catch (final NoSuchNodeTypeException e)
+ {
+ throw new InvalidQueryException(e.getMessage(), e);
+ }
- if (terms.size() == 0) {
- // exception occured
- query = new BooleanQuery();
+ if (terms.size() == 0)
+ {
+ // exception occured
+ query = new BooleanQuery();
- } else if (terms.size() == 1) {
- query = new JcrTermQuery(terms.get(0));
+ }
+ else if (terms.size() == 1)
+ {
+ query = new JcrTermQuery(terms.get(0));
- } else {
- final BooleanQuery b = new BooleanQuery();
- for (final Object element : terms) {
- // b.add(new TermQuery((Term) element), Occur.SHOULD);
- b.add(new JcrTermQuery((Term) element), Occur.SHOULD);
- }
- query = b;
- }
+ }
+ else
+ {
+ final BooleanQuery b = new BooleanQuery();
+ for (final Object element : terms)
+ {
+ // b.add(new TermQuery((Term) element), Occur.SHOULD);
+ b.add(new JcrTermQuery((Term)element), Occur.SHOULD);
+ }
+ query = b;
+ }
- return query;
- }
+ return query;
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQueryResult.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQueryResult.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiColumnQueryResult.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,67 +16,56 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-
-import javax.jcr.RepositoryException;
-
import org.exoplatform.services.jcr.access.AccessManager;
-import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.InternalQName;
import org.exoplatform.services.jcr.datamodel.QPath;
import org.exoplatform.services.jcr.impl.core.SessionDataManager;
import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import java.io.IOException;
+import javax.jcr.RepositoryException;
-
/**
* <code>MultiColumnQueryResult</code> implements a query result that executes
* a {@link MultiColumnQuery}.
*/
-public class MultiColumnQueryResult extends QueryResultImpl {
+public class MultiColumnQueryResult extends QueryResultImpl
+{
- /**
- * The query to execute.
- */
- private final MultiColumnQuery query;
+ /**
+ * The query to execute.
+ */
+ private final MultiColumnQuery query;
- public MultiColumnQueryResult(SearchIndex index,
- SessionDataManager itemMgr,
- SessionImpl session,
- AccessManager accessMgr,
- AbstractQueryImpl queryImpl,
- MultiColumnQuery query,
- SpellSuggestion spellSuggestion,
- InternalQName[] selectProps,
- QPath[] orderProps,
- boolean[] orderSpecs,
- boolean documentOrder,
- long offset,
- long limit) throws RepositoryException {
- super(index, itemMgr, session, accessMgr, queryImpl, spellSuggestion,
- selectProps, orderProps, orderSpecs, documentOrder, offset, limit);
-
- this.query = query;
- // if document order is requested get all results right away
- getResults(docOrder ? Integer.MAX_VALUE : index.getResultFetchSize());
- }
+ public MultiColumnQueryResult(SearchIndex index, SessionDataManager itemMgr, SessionImpl session,
+ AccessManager accessMgr, AbstractQueryImpl queryImpl, MultiColumnQuery query, SpellSuggestion spellSuggestion,
+ InternalQName[] selectProps, QPath[] orderProps, boolean[] orderSpecs, boolean documentOrder, long offset,
+ long limit) throws RepositoryException
+ {
+ super(index, itemMgr, session, accessMgr, queryImpl, spellSuggestion, selectProps, orderProps, orderSpecs,
+ documentOrder, offset, limit);
- /**
- * {@inheritDoc}
- * @throws RepositoryException
- */
- protected MultiColumnQueryHits executeQuery(long resultFetchHint)
- throws IOException, RepositoryException {
- return index.executeQuery(session, query, orderProps,
- orderSpecs, resultFetchHint);
- }
+ this.query = query;
+ // if document order is requested get all results right away
+ getResults(docOrder ? Integer.MAX_VALUE : index.getResultFetchSize());
+ }
- /**
- * {@inheritDoc}
- */
- protected ExcerptProvider createExcerptProvider() throws IOException {
- // TODO
- return null;
- }
+ /**
+ * {@inheritDoc}
+ * @throws RepositoryException
+ */
+ protected MultiColumnQueryHits executeQuery(long resultFetchHint) throws IOException, RepositoryException
+ {
+ return index.executeQuery(session, query, orderProps, orderSpecs, resultFetchHint);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected ExcerptProvider createExcerptProvider() throws IOException
+ {
+ // TODO
+ return null;
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/MultiIndex.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -83,7 +83,7 @@
/**
* The logger instance for this class
*/
- private static final Logger log = LoggerFactory.getLogger(MultiIndex.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.MultiIndex");
/**
* Names of active persistent index directories.
@@ -463,7 +463,7 @@
synchronized (updateMonitor)
{
indexUpdateMonitor.setUpdateInProgress(true, true);
- }
+ }
flush();
}
}
@@ -472,7 +472,7 @@
synchronized (updateMonitor)
{
//updateInProgress = false;
-
+
indexUpdateMonitor.setUpdateInProgress(false, flush);
updateMonitor.notifyAll();
releaseMultiReader();
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIndexer.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -60,7 +60,7 @@
/**
* The logger instance for this class.
*/
- private static final Logger log = LoggerFactory.getLogger(NodeIndexer.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.NodeIndexer");
/**
* The default boost for a lucene field: 1.0f.
@@ -298,9 +298,10 @@
// ok, have a reader
// if the prop obtainer from cache it will contains a values,
// otherwise read prop with values from DM
- PropertyData propData = prop.getValues().size() > 0 ? prop : ((PropertyData)stateProvider.getItemData(node,
- new QPathEntry(Constants.JCR_DATA, 0)));
-
+ PropertyData propData =
+ prop.getValues().size() > 0 ? prop : ((PropertyData)stateProvider.getItemData(node, new QPathEntry(
+ Constants.JCR_DATA, 0)));
+
// index if have jcr:mimeType sibling for this binary property only
try
{
@@ -308,7 +309,7 @@
extractor.getDocumentReader(new String(pmime.getValues().get(0).getAsByteArray()));
data = propData.getValues();
-
+
if (data == null)
log.warn("null value found at property " + prop.getQPath().getAsString());
@@ -376,14 +377,16 @@
}
catch (DocumentReadException e)
{
- log.error("Can not indexing the document by path " + propData.getQPath().getAsString() + ", propery id '" + propData.getIdentifier() + "' : " + e, e);
+ log.error("Can not indexing the document by path " + propData.getQPath().getAsString()
+ + ", propery id '" + propData.getIdentifier() + "' : " + e, e);
}
catch (HandlerNotFoundException e)
{
// no handler - no index
if (log.isDebugEnabled())
{
- log.debug("Can not indexing the document by path " + propData.getQPath().getAsString() + ", propery id '" + propData.getIdentifier() + "' : " + e, e);
+ log.debug("Can not indexing the document by path " + propData.getQPath().getAsString()
+ + ", propery id '" + propData.getIdentifier() + "' : " + e, e);
}
}
catch (IOException e)
@@ -391,12 +394,14 @@
// no data - no index
if (log.isWarnEnabled())
{
- log.warn("Binary value indexer IO error, document by path " + propData.getQPath().getAsString() + ", propery id '" + propData.getIdentifier() + "' : " + e, e);
+ log.warn("Binary value indexer IO error, document by path " + propData.getQPath().getAsString()
+ + ", propery id '" + propData.getIdentifier() + "' : " + e, e);
}
}
catch (Exception e)
{
- log.error("Binary value indexer error, document by path " + propData.getQPath().getAsString() + ", propery id '" + propData.getIdentifier() + "' : " + e, e);
+ log.error("Binary value indexer error, document by path " + propData.getQPath().getAsString()
+ + ", propery id '" + propData.getIdentifier() + "' : " + e, e);
}
}
}
@@ -411,7 +416,8 @@
// WARN. DON'T USE access item BY PATH - it's may be a node in case of
// residual definitions in NT
List<ValueData> data =
- prop.getValues().size() > 0 ? prop.getValues() : ((PropertyData)stateProvider.getItemData(prop.getIdentifier())).getValues();
+ prop.getValues().size() > 0 ? prop.getValues() : ((PropertyData)stateProvider.getItemData(prop
+ .getIdentifier())).getValues();
if (data == null)
log.warn("null value found at property " + prop.getQPath().getAsString());
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIteratorImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIteratorImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/NodeIteratorImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,18 +16,17 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
+import org.exoplatform.services.jcr.impl.core.NodeImpl;
+import org.exoplatform.services.jcr.impl.core.SessionDataManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.util.NoSuchElementException;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
-import org.exoplatform.services.jcr.impl.core.NodeImpl;
-import org.exoplatform.services.jcr.impl.core.SessionDataManager;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Implements a {@link javax.jcr.NodeIterator} returned by
* {@link javax.jcr.query.QueryResult#getNodes()}.
@@ -36,7 +35,7 @@
{
/** Logger instance for this class */
- private static final Logger log = LoggerFactory.getLogger(NodeIteratorImpl.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.NodeIteratorImpl");
/** The node ids of the nodes in the result set with their score value */
protected final ScoreNodeIterator scoreNodes;
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PropertiesSynonymProvider.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PropertiesSynonymProvider.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/PropertiesSynonymProvider.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,6 +16,9 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@@ -23,10 +26,6 @@
import java.util.Map;
import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Implements a synonym provider based on a properties file. Each line in the
* properties file is treated as a synonym definition. Example:
@@ -38,151 +37,172 @@
* same applies to B and C. However A is not considered a synonym for C, nor
* C a synonym for A.
*/
-public class PropertiesSynonymProvider implements SynonymProvider {
+public class PropertiesSynonymProvider implements SynonymProvider
+{
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(PropertiesSynonymProvider.class);
+ /**
+ * The logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.PropertiesSynonymProvider");
- /**
- * An empty string array. Returned when no synonym is found.
- */
- private static final String[] EMPTY_ARRAY = new String[0];
+ /**
+ * An empty string array. Returned when no synonym is found.
+ */
+ private static final String[] EMPTY_ARRAY = new String[0];
- /**
- * Check at most every 10 seconds for configuration updates.
- */
- private static final long CHECK_INTERVAL = 10 * 1000;
+ /**
+ * Check at most every 10 seconds for configuration updates.
+ */
+ private static final long CHECK_INTERVAL = 10 * 1000;
- /**
- * The file system resource that contains the configuration.
- */
- private InputStream config;
+ /**
+ * The file system resource that contains the configuration.
+ */
+ private InputStream config;
- /**
- * Timestamp when the configuration was checked last.
- */
- private long lastCheck;
+ /**
+ * Timestamp when the configuration was checked last.
+ */
+ private long lastCheck;
- /**
- * Timestamp when the configuration was last modified.
- */
- private long configLastModified;
+ /**
+ * Timestamp when the configuration was last modified.
+ */
+ private long configLastModified;
- /**
- * Contains the synonym mapping. Map<String, String[]>
- */
- private Map synonyms = new HashMap();
+ /**
+ * Contains the synonym mapping. Map<String, String[]>
+ */
+ private Map synonyms = new HashMap();
- /**
- * {@inheritDoc}
- */
- public synchronized void initialize(InputStream fsr)
- throws IOException {
- if (fsr == null) {
- throw new IOException("PropertiesSynonymProvider requires a path configuration");
- }
- try {
- config = fsr;
- synonyms = getSynonyms(config);
- configLastModified = System.currentTimeMillis();
- lastCheck = System.currentTimeMillis();
- } catch (Exception e) {
- throw Util.createIOException(e);
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public synchronized void initialize(InputStream fsr) throws IOException
+ {
+ if (fsr == null)
+ {
+ throw new IOException("PropertiesSynonymProvider requires a path configuration");
+ }
+ try
+ {
+ config = fsr;
+ synonyms = getSynonyms(config);
+ configLastModified = System.currentTimeMillis();
+ lastCheck = System.currentTimeMillis();
+ }
+ catch (Exception e)
+ {
+ throw Util.createIOException(e);
+ }
+ }
- /**
- * {@inheritDoc}
- */
- public String[] getSynonyms(String term) {
- checkConfigUpdated();
- term = term.toLowerCase();
- String[] syns;
- synchronized (this) {
- syns = (String[]) synonyms.get(term);
- }
- if (syns == null) {
- syns = EMPTY_ARRAY;
- }
- return syns;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public String[] getSynonyms(String term)
+ {
+ checkConfigUpdated();
+ term = term.toLowerCase();
+ String[] syns;
+ synchronized (this)
+ {
+ syns = (String[])synonyms.get(term);
+ }
+ if (syns == null)
+ {
+ syns = EMPTY_ARRAY;
+ }
+ return syns;
+ }
- //---------------------------------< internal >-----------------------------
+ //---------------------------------< internal >-----------------------------
- /**
- * Checks if the synonym properties file has been updated and this provider
- * should reload the synonyms. This method performs the actual check at most
- * every {@link #CHECK_INTERVAL}. If reloading fails an error is logged and
- * this provider will retry after {@link #CHECK_INTERVAL}.
- */
- private synchronized void checkConfigUpdated() {
- if (lastCheck + CHECK_INTERVAL > System.currentTimeMillis()) {
- return;
- }
- // check last modified
- try {
-// if (configLastModified != config.lastModified()) {
-// synonyms = getSynonyms(config);
-// configLastModified = config.lastModified();
-// log.info("Reloaded synonyms from {}", config.getPath());
-// }
- } catch (Exception e) {
- log.error("Exception while reading synonyms", e);
- }
- // update lastCheck timestamp, even if error occured (retry later)
- lastCheck = System.currentTimeMillis();
- }
+ /**
+ * Checks if the synonym properties file has been updated and this provider
+ * should reload the synonyms. This method performs the actual check at most
+ * every {@link #CHECK_INTERVAL}. If reloading fails an error is logged and
+ * this provider will retry after {@link #CHECK_INTERVAL}.
+ */
+ private synchronized void checkConfigUpdated()
+ {
+ if (lastCheck + CHECK_INTERVAL > System.currentTimeMillis())
+ {
+ return;
+ }
+ // check last modified
+ try
+ {
+ // if (configLastModified != config.lastModified()) {
+ // synonyms = getSynonyms(config);
+ // configLastModified = config.lastModified();
+ // log.info("Reloaded synonyms from {}", config.getPath());
+ // }
+ }
+ catch (Exception e)
+ {
+ log.error("Exception while reading synonyms", e);
+ }
+ // update lastCheck timestamp, even if error occured (retry later)
+ lastCheck = System.currentTimeMillis();
+ }
- /**
- * Reads the synonym properties file and returns the contents as a synonym
- * Map.
- *
- * @param config the synonym properties file.
- * @return a Map containing the synonyms.
- * @throws IOException if an error occurs while reading from the file system
- * resource.
- */
- private static Map getSynonyms(InputStream config) throws IOException {
- try {
- Map synonyms = new HashMap();
- Properties props = new Properties();
- props.load(config);
- Iterator it = props.entrySet().iterator();
- while (it.hasNext()) {
- Map.Entry e = (Map.Entry) it.next();
- String key = (String) e.getKey();
- String value = (String) e.getValue();
- addSynonym(key, value, synonyms);
- addSynonym(value, key, synonyms);
- }
- return synonyms;
- } catch (Exception e) {
- throw Util.createIOException(e);
- }
- }
+ /**
+ * Reads the synonym properties file and returns the contents as a synonym
+ * Map.
+ *
+ * @param config the synonym properties file.
+ * @return a Map containing the synonyms.
+ * @throws IOException if an error occurs while reading from the file system
+ * resource.
+ */
+ private static Map getSynonyms(InputStream config) throws IOException
+ {
+ try
+ {
+ Map synonyms = new HashMap();
+ Properties props = new Properties();
+ props.load(config);
+ Iterator it = props.entrySet().iterator();
+ while (it.hasNext())
+ {
+ Map.Entry e = (Map.Entry)it.next();
+ String key = (String)e.getKey();
+ String value = (String)e.getValue();
+ addSynonym(key, value, synonyms);
+ addSynonym(value, key, synonyms);
+ }
+ return synonyms;
+ }
+ catch (Exception e)
+ {
+ throw Util.createIOException(e);
+ }
+ }
- /**
- * Adds a synonym definition to the map.
- *
- * @param term the term
- * @param synonym synonym for <code>term</code>.
- * @param synonyms the Map containing the synonyms.
- */
- private static void addSynonym(String term, String synonym, Map synonyms) {
- term = term.toLowerCase();
- String[] syns = (String[]) synonyms.get(term);
- if (syns == null) {
- syns = new String[]{synonym};
- } else {
- String[] tmp = new String[syns.length + 1];
- System.arraycopy(syns, 0, tmp, 0, syns.length);
- tmp[syns.length] = synonym;
- syns = tmp;
- }
- synonyms.put(term, syns);
- }
+ /**
+ * Adds a synonym definition to the map.
+ *
+ * @param term the term
+ * @param synonym synonym for <code>term</code>.
+ * @param synonyms the Map containing the synonyms.
+ */
+ private static void addSynonym(String term, String synonym, Map synonyms)
+ {
+ term = term.toLowerCase();
+ String[] syns = (String[])synonyms.get(term);
+ if (syns == null)
+ {
+ syns = new String[]{synonym};
+ }
+ else
+ {
+ String[] tmp = new String[syns.length + 1];
+ System.arraycopy(syns, 0, tmp, 0, syns.length);
+ tmp[syns.length] = synonym;
+ syns = tmp;
+ }
+ synonyms.put(term, syns);
+ }
-
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -48,169 +48,174 @@
* Implements the {@link org.apache.jackrabbit.core.query.ExecutableQuery}
* interface.
*/
-public class QueryImpl extends AbstractQueryImpl {
+public class QueryImpl extends AbstractQueryImpl
+{
- /**
- * The logger instance for this class
- */
- private static final Logger log = LoggerFactory.getLogger(QueryImpl.class);
+ /**
+ * The logger instance for this class
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.QueryImpl");
- /**
- * The default selector name 's'.
- */
- public static final InternalQName DEFAULT_SELECTOR_NAME = new InternalQName(
- Constants.NS_DEFAULT_URI, "s");
+ /**
+ * The default selector name 's'.
+ */
+ public static final InternalQName DEFAULT_SELECTOR_NAME = new InternalQName(Constants.NS_DEFAULT_URI, "s");
- /**
- * The root node of the query tree
- */
- protected final QueryRootNode root;
+ /**
+ * The root node of the query tree
+ */
+ protected final QueryRootNode root;
- /**
- * Creates a new query instance from a query string.
- *
- * @param session
- * the session of the user executing this query.
- * @param itemMgr
- * the item manager of the session executing this query.
- * @param index
- * the search index.
- * @param propReg
- * the property type registry.
- * @param statement
- * the query statement.
- * @param language
- * the syntax of the query statement.
- * @param factory
- * the query node factory.
- * @throws InvalidQueryException
- * if the query statement is invalid according to the specified
- * <code>language</code>.
- */
- public QueryImpl(SessionImpl session, SessionDataManager itemMgr,
- SearchIndex index, PropertyTypeRegistry propReg, String statement,
- String language, QueryNodeFactory factory)
- throws InvalidQueryException {
- super(session, itemMgr, index, propReg);
- // parse query according to language
- // build query tree using the passed factory
- // this.root = QueryParser.parse(statement, language, session, factory);
- this.root = QueryParser.parse(statement, language, session
- .getLocationFactory(), factory);
- }
+ /**
+ * Creates a new query instance from a query string.
+ *
+ * @param session
+ * the session of the user executing this query.
+ * @param itemMgr
+ * the item manager of the session executing this query.
+ * @param index
+ * the search index.
+ * @param propReg
+ * the property type registry.
+ * @param statement
+ * the query statement.
+ * @param language
+ * the syntax of the query statement.
+ * @param factory
+ * the query node factory.
+ * @throws InvalidQueryException
+ * if the query statement is invalid according to the specified
+ * <code>language</code>.
+ */
+ public QueryImpl(SessionImpl session, SessionDataManager itemMgr, SearchIndex index, PropertyTypeRegistry propReg,
+ String statement, String language, QueryNodeFactory factory) throws InvalidQueryException
+ {
+ super(session, itemMgr, index, propReg);
+ // parse query according to language
+ // build query tree using the passed factory
+ // this.root = QueryParser.parse(statement, language, session, factory);
+ this.root = QueryParser.parse(statement, language, session.getLocationFactory(), factory);
+ }
- /**
- * Executes this query and returns a <code>{@link QueryResult}</code>.
- *
- * @param offset
- * the offset in the total result set
- * @param limit
- * the maximum result size
- * @return a <code>QueryResult</code>
- * @throws RepositoryException
- * if an error occurs
- */
- public QueryResult execute(long offset, long limit)
- throws RepositoryException {
- if (log.isDebugEnabled()) {
- log.debug("Executing query: \n" + root.dump());
- }
+ /**
+ * Executes this query and returns a <code>{@link QueryResult}</code>.
+ *
+ * @param offset
+ * the offset in the total result set
+ * @param limit
+ * the maximum result size
+ * @return a <code>QueryResult</code>
+ * @throws RepositoryException
+ * if an error occurs
+ */
+ public QueryResult execute(long offset, long limit) throws RepositoryException
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("Executing query: \n" + root.dump());
+ }
- // build lucene query
- Query query = LuceneQueryBuilder.createQuery(root, session, index
- .getContext().getItemStateManager(), index
- .getNamespaceMappings(), index.getTextAnalyzer(), propReg,
- index.getSynonymProvider(), index.getIndexFormatVersion(),
- index.getContext().getVirtualTableResolver());
+ // build lucene query
+ Query query =
+ LuceneQueryBuilder.createQuery(root, session, index.getContext().getItemStateManager(), index
+ .getNamespaceMappings(), index.getTextAnalyzer(), propReg, index.getSynonymProvider(), index
+ .getIndexFormatVersion(), index.getContext().getVirtualTableResolver());
- OrderQueryNode orderNode = root.getOrderNode();
+ OrderQueryNode orderNode = root.getOrderNode();
- OrderQueryNode.OrderSpec[] orderSpecs;
- if (orderNode != null) {
- orderSpecs = orderNode.getOrderSpecs();
- } else {
- orderSpecs = new OrderQueryNode.OrderSpec[0];
- }
- QPath[] orderProperties = new QPath[orderSpecs.length];
- boolean[] ascSpecs = new boolean[orderSpecs.length];
- for (int i = 0; i < orderSpecs.length; i++) {
- orderProperties[i] = orderSpecs[i].getPropertyPath();
- ascSpecs[i] = orderSpecs[i].isAscending();
- }
+ OrderQueryNode.OrderSpec[] orderSpecs;
+ if (orderNode != null)
+ {
+ orderSpecs = orderNode.getOrderSpecs();
+ }
+ else
+ {
+ orderSpecs = new OrderQueryNode.OrderSpec[0];
+ }
+ QPath[] orderProperties = new QPath[orderSpecs.length];
+ boolean[] ascSpecs = new boolean[orderSpecs.length];
+ for (int i = 0; i < orderSpecs.length; i++)
+ {
+ orderProperties[i] = orderSpecs[i].getPropertyPath();
+ ascSpecs[i] = orderSpecs[i].isAscending();
+ }
- return new SingleColumnQueryResult(index, itemMgr, session, session
- .getAccessManager(), this, query, new SpellSuggestion(index
- .getSpellChecker(), root), getSelectProperties(),
- orderProperties, ascSpecs, getRespectDocumentOrder(), offset,
- limit);
- }
+ return new SingleColumnQueryResult(index, itemMgr, session, session.getAccessManager(), this, query,
+ new SpellSuggestion(index.getSpellChecker(), root), getSelectProperties(), orderProperties, ascSpecs,
+ getRespectDocumentOrder(), offset, limit);
+ }
- /**
- * Returns the select properties for this query.
- *
- * @return array of select property names.
- * @throws RepositoryException
- * if an error occurs.
- */
- protected InternalQName[] getSelectProperties() throws RepositoryException {
- // get select properties
- List selectProps = new ArrayList();
- selectProps.addAll(Arrays.asList(root.getSelectProperties()));
- if (selectProps.size() == 0) {
- // use node type constraint
- LocationStepQueryNode[] steps = root.getLocationNode()
- .getPathSteps();
- final InternalQName[] ntName = new InternalQName[1];
- steps[steps.length - 1].acceptOperands(
- new DefaultQueryNodeVisitor() {
+ /**
+ * Returns the select properties for this query.
+ *
+ * @return array of select property names.
+ * @throws RepositoryException
+ * if an error occurs.
+ */
+ protected InternalQName[] getSelectProperties() throws RepositoryException
+ {
+ // get select properties
+ List selectProps = new ArrayList();
+ selectProps.addAll(Arrays.asList(root.getSelectProperties()));
+ if (selectProps.size() == 0)
+ {
+ // use node type constraint
+ LocationStepQueryNode[] steps = root.getLocationNode().getPathSteps();
+ final InternalQName[] ntName = new InternalQName[1];
+ steps[steps.length - 1].acceptOperands(new DefaultQueryNodeVisitor()
+ {
- public Object visit(AndQueryNode node, Object data)
- throws RepositoryException {
- return node.acceptOperands(this, data);
- }
+ public Object visit(AndQueryNode node, Object data) throws RepositoryException
+ {
+ return node.acceptOperands(this, data);
+ }
- public Object visit(NodeTypeQueryNode node, Object data) {
- ntName[0] = node.getValue();
- return data;
- }
- }, null);
- if (ntName[0] == null) {
- ntName[0] = Constants.NT_BASE;
- }
- NodeTypeData nt = session.getWorkspace().getNodeTypesHolder()
- .getNodeType(ntName[0]);
- PropertyDefinitionData[] propDefs = nt
- .getDeclaredPropertyDefinitions();
+ public Object visit(NodeTypeQueryNode node, Object data)
+ {
+ ntName[0] = node.getValue();
+ return data;
+ }
+ }, null);
+ if (ntName[0] == null)
+ {
+ ntName[0] = Constants.NT_BASE;
+ }
+ NodeTypeData nt = session.getWorkspace().getNodeTypesHolder().getNodeType(ntName[0]);
+ PropertyDefinitionData[] propDefs = nt.getDeclaredPropertyDefinitions();
- for (int i = 0; i < propDefs.length; i++) {
- PropertyDefinitionData propDef = propDefs[i];
- if (!propDef.isResidualSet() && !propDef.isMultiple()) {
- selectProps.add(propDef.getName());
- }
- }
- }
+ for (int i = 0; i < propDefs.length; i++)
+ {
+ PropertyDefinitionData propDef = propDefs[i];
+ if (!propDef.isResidualSet() && !propDef.isMultiple())
+ {
+ selectProps.add(propDef.getName());
+ }
+ }
+ }
- // add jcr:path and jcr:score if not selected already
- if (!selectProps.contains(Constants.JCR_PATH)) {
- selectProps.add(Constants.JCR_PATH);
- }
- if (!selectProps.contains(Constants.JCR_SCORE)) {
- selectProps.add(Constants.JCR_SCORE);
- }
+ // add jcr:path and jcr:score if not selected already
+ if (!selectProps.contains(Constants.JCR_PATH))
+ {
+ selectProps.add(Constants.JCR_PATH);
+ }
+ if (!selectProps.contains(Constants.JCR_SCORE))
+ {
+ selectProps.add(Constants.JCR_SCORE);
+ }
- return (InternalQName[]) selectProps
- .toArray(new InternalQName[selectProps.size()]);
- }
+ return (InternalQName[])selectProps.toArray(new InternalQName[selectProps.size()]);
+ }
- /**
- * Returns <code>true</code> if this query node needs items under
- * /jcr:system to be queried.
- *
- * @return <code>true</code> if this query node needs content under
- * /jcr:system to be queried; <code>false</code> otherwise.
- */
- public boolean needsSystemTree() {
- return this.root.needsSystemTree();
- }
+ /**
+ * Returns <code>true</code> if this query node needs items under
+ * /jcr:system to be queried.
+ *
+ * @return <code>true</code> if this query node needs content under
+ * /jcr:system to be queried; <code>false</code> otherwise.
+ */
+ public boolean needsSystemTree()
+ {
+ return this.root.needsSystemTree();
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/QueryResultImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,6 +16,16 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
+import org.exoplatform.services.jcr.access.AccessManager;
+import org.exoplatform.services.jcr.access.PermissionType;
+import org.exoplatform.services.jcr.datamodel.InternalQName;
+import org.exoplatform.services.jcr.datamodel.NodeData;
+import org.exoplatform.services.jcr.datamodel.QPath;
+import org.exoplatform.services.jcr.impl.core.SessionDataManager;
+import org.exoplatform.services.jcr.impl.core.SessionImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -28,17 +38,6 @@
import javax.jcr.query.QueryResult;
import javax.jcr.query.RowIterator;
-import org.exoplatform.services.jcr.access.AccessManager;
-import org.exoplatform.services.jcr.access.PermissionType;
-import org.exoplatform.services.jcr.datamodel.InternalQName;
-import org.exoplatform.services.jcr.datamodel.NodeData;
-import org.exoplatform.services.jcr.datamodel.QPath;
-import org.exoplatform.services.jcr.impl.core.SessionDataManager;
-import org.exoplatform.services.jcr.impl.core.SessionImpl;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Implements the <code>QueryResult</code> interface.
*/
@@ -48,7 +47,7 @@
/**
* The logger instance for this class
*/
- private static final Logger log = LoggerFactory.getLogger(QueryResultImpl.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.QueryResultImpl");
/**
* The search index to execute the query.
@@ -232,8 +231,8 @@
throw new RepositoryException(e);
}
}
- return new RowIteratorImpl(getScoreNodes(), selectProps, selectorNames, itemMgr, session.getLocationFactory(), excerptProvider,
- spellSuggestion);
+ return new RowIteratorImpl(getScoreNodes(), selectProps, selectorNames, itemMgr, session.getLocationFactory(),
+ excerptProvider, spellSuggestion);
}
/**
@@ -505,6 +504,7 @@
}
}
}
+
/**
*
* @see org.exoplatform.services.jcr.impl.core.query.lucene.TwoWayRangeIterator#skipBack(long)
@@ -529,7 +529,7 @@
position -= skipNum + 1;
fetchNext();
}
-
+
}
/**
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Recovery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Recovery.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Recovery.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,160 +16,188 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Implements the recovery process.
*/
-class Recovery {
+class Recovery
+{
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(Recovery.class);
+ /**
+ * The logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.Recovery");
- /**
- * The MultiIndex where to run the recovery on.
- */
- private final MultiIndex index;
+ /**
+ * The MultiIndex where to run the recovery on.
+ */
+ private final MultiIndex index;
- /**
- * The redo redoLog.
- */
- private final RedoLog redoLog;
+ /**
+ * The redo redoLog.
+ */
+ private final RedoLog redoLog;
- /**
- * The ids of the uncommitted transactions. Set of Integer objects.
- */
- private final Set losers = new HashSet();
+ /**
+ * The ids of the uncommitted transactions. Set of Integer objects.
+ */
+ private final Set losers = new HashSet();
- /**
- * Creates a new Recovery instance.
- *
- * @param index the MultiIndex to recover.
- * @param redoLog the redo redoLog.
- */
- private Recovery(MultiIndex index, RedoLog redoLog) {
- this.index = index;
- this.redoLog = redoLog;
- }
+ /**
+ * Creates a new Recovery instance.
+ *
+ * @param index the MultiIndex to recover.
+ * @param redoLog the redo redoLog.
+ */
+ private Recovery(MultiIndex index, RedoLog redoLog)
+ {
+ this.index = index;
+ this.redoLog = redoLog;
+ }
- /**
- * Runs a recovery on <code>index</code> if <code>redoLog</code> contains
- * log entries.
- * <p/>
- * If recovery succeeds the <code>index</code> is flushed and the redo log
- * is cleared. That is, the <code>index</code> is stable.<br/>
- * If recovery fails an IOException is thrown, and the redo log will not
- * be modified. The recovery process can then be executed again, after
- * fixing the cause of the IOException (e.g. disk full).
- *
- * @param index the index to recover.
- * @param redoLog the redo log.
- * @throws IOException if the recovery fails.
- */
- static void run(MultiIndex index, RedoLog redoLog) throws IOException {
- if (!redoLog.hasEntries()) {
- log.debug("RedoLog is empty, no recovery needed.");
- return;
- }
- log.info("Found uncommitted redo log. Applying changes now...");
- Recovery r = new Recovery(index, redoLog);
- r.run();
- log.info("Redo changes applied.");
- }
+ /**
+ * Runs a recovery on <code>index</code> if <code>redoLog</code> contains
+ * log entries.
+ * <p/>
+ * If recovery succeeds the <code>index</code> is flushed and the redo log
+ * is cleared. That is, the <code>index</code> is stable.<br/>
+ * If recovery fails an IOException is thrown, and the redo log will not
+ * be modified. The recovery process can then be executed again, after
+ * fixing the cause of the IOException (e.g. disk full).
+ *
+ * @param index the index to recover.
+ * @param redoLog the redo log.
+ * @throws IOException if the recovery fails.
+ */
+ static void run(MultiIndex index, RedoLog redoLog) throws IOException
+ {
+ if (!redoLog.hasEntries())
+ {
+ log.debug("RedoLog is empty, no recovery needed.");
+ return;
+ }
+ log.info("Found uncommitted redo log. Applying changes now...");
+ Recovery r = new Recovery(index, redoLog);
+ r.run();
+ log.info("Redo changes applied.");
+ }
- /**
- * Runs the recovery process.
- *
- * @throws IOException if the recovery fails.
- */
- private void run() throws IOException {
- List actions = redoLog.getActions();
+ /**
+ * Runs the recovery process.
+ *
+ * @throws IOException if the recovery fails.
+ */
+ private void run() throws IOException
+ {
+ List actions = redoLog.getActions();
- // find loser transactions
- for (Iterator it = actions.iterator(); it.hasNext();) {
- MultiIndex.Action a = (MultiIndex.Action) it.next();
- if (a.getType() == MultiIndex.Action.TYPE_START) {
- losers.add(new Long(a.getTransactionId()));
- } else if (a.getType() == MultiIndex.Action.TYPE_COMMIT) {
- losers.remove(new Long(a.getTransactionId()));
- }
- }
+ // find loser transactions
+ for (Iterator it = actions.iterator(); it.hasNext();)
+ {
+ MultiIndex.Action a = (MultiIndex.Action)it.next();
+ if (a.getType() == MultiIndex.Action.TYPE_START)
+ {
+ losers.add(new Long(a.getTransactionId()));
+ }
+ else if (a.getType() == MultiIndex.Action.TYPE_COMMIT)
+ {
+ losers.remove(new Long(a.getTransactionId()));
+ }
+ }
- // find last volatile commit without changes from a loser
- int lastSafeVolatileCommit = -1;
- Set transactionIds = new HashSet();
- for (int i = 0; i < actions.size(); i++) {
- MultiIndex.Action a = (MultiIndex.Action) actions.get(i);
- if (a.getType() == MultiIndex.Action.TYPE_COMMIT) {
- transactionIds.clear();
- } else if (a.getType() == MultiIndex.Action.TYPE_VOLATILE_COMMIT) {
- transactionIds.retainAll(losers);
- // check if transactionIds contains losers
- if (transactionIds.size() > 0) {
- // found dirty volatile commit
- break;
- } else {
- lastSafeVolatileCommit = i;
- }
- } else {
- transactionIds.add(new Long(a.getTransactionId()));
+ // find last volatile commit without changes from a loser
+ int lastSafeVolatileCommit = -1;
+ Set transactionIds = new HashSet();
+ for (int i = 0; i < actions.size(); i++)
+ {
+ MultiIndex.Action a = (MultiIndex.Action)actions.get(i);
+ if (a.getType() == MultiIndex.Action.TYPE_COMMIT)
+ {
+ transactionIds.clear();
+ }
+ else if (a.getType() == MultiIndex.Action.TYPE_VOLATILE_COMMIT)
+ {
+ transactionIds.retainAll(losers);
+ // check if transactionIds contains losers
+ if (transactionIds.size() > 0)
+ {
+ // found dirty volatile commit
+ break;
}
- }
-
- // delete dirty indexes
- for (int i = lastSafeVolatileCommit + 1; i < actions.size(); i++) {
- MultiIndex.Action a = (MultiIndex.Action) actions.get(i);
- if (a.getType() == MultiIndex.Action.TYPE_CREATE_INDEX) {
- a.undo(index);
+ else
+ {
+ lastSafeVolatileCommit = i;
}
- }
+ }
+ else
+ {
+ transactionIds.add(new Long(a.getTransactionId()));
+ }
+ }
- // replay actions up to last safe volatile commit
- // ignore add node actions, they are included in volatile commits
- for (int i = 0; i < actions.size() && i <= lastSafeVolatileCommit; i++) {
- MultiIndex.Action a = (MultiIndex.Action) actions.get(i);
- switch (a.getType()) {
- case MultiIndex.Action.TYPE_ADD_INDEX:
- case MultiIndex.Action.TYPE_CREATE_INDEX:
- case MultiIndex.Action.TYPE_DELETE_INDEX:
- case MultiIndex.Action.TYPE_DELETE_NODE:
- // ignore actions by the index merger.
- // the previously created index of a merge has been
- // deleted because it was considered dirty.
- // we are conservative here and let the index merger do
- // its work again.
- if (a.getTransactionId() == MultiIndex.Action.INTERNAL_TRANS_REPL_INDEXES) {
- continue;
- }
- a.execute(index);
- }
- }
+ // delete dirty indexes
+ for (int i = lastSafeVolatileCommit + 1; i < actions.size(); i++)
+ {
+ MultiIndex.Action a = (MultiIndex.Action)actions.get(i);
+ if (a.getType() == MultiIndex.Action.TYPE_CREATE_INDEX)
+ {
+ a.undo(index);
+ }
+ }
- // now replay the rest until we encounter a loser transaction
- for (int i = lastSafeVolatileCommit + 1; i < actions.size(); i++) {
- MultiIndex.Action a = (MultiIndex.Action) actions.get(i);
- if (losers.contains(new Long(a.getTransactionId()))) {
- break;
- } else {
- // ignore actions by the index merger.
- if (a.getTransactionId() == MultiIndex.Action.INTERNAL_TRANS_REPL_INDEXES) {
- continue;
- }
- a.execute(index);
+ // replay actions up to last safe volatile commit
+ // ignore add node actions, they are included in volatile commits
+ for (int i = 0; i < actions.size() && i <= lastSafeVolatileCommit; i++)
+ {
+ MultiIndex.Action a = (MultiIndex.Action)actions.get(i);
+ switch (a.getType())
+ {
+ case MultiIndex.Action.TYPE_ADD_INDEX :
+ case MultiIndex.Action.TYPE_CREATE_INDEX :
+ case MultiIndex.Action.TYPE_DELETE_INDEX :
+ case MultiIndex.Action.TYPE_DELETE_NODE :
+ // ignore actions by the index merger.
+ // the previously created index of a merge has been
+ // deleted because it was considered dirty.
+ // we are conservative here and let the index merger do
+ // its work again.
+ if (a.getTransactionId() == MultiIndex.Action.INTERNAL_TRANS_REPL_INDEXES)
+ {
+ continue;
+ }
+ a.execute(index);
+ }
+ }
+
+ // now replay the rest until we encounter a loser transaction
+ for (int i = lastSafeVolatileCommit + 1; i < actions.size(); i++)
+ {
+ MultiIndex.Action a = (MultiIndex.Action)actions.get(i);
+ if (losers.contains(new Long(a.getTransactionId())))
+ {
+ break;
+ }
+ else
+ {
+ // ignore actions by the index merger.
+ if (a.getTransactionId() == MultiIndex.Action.INTERNAL_TRANS_REPL_INDEXES)
+ {
+ continue;
}
- }
+ a.execute(index);
+ }
+ }
- // now we are consistent again -> flush
- index.flush();
- index.releaseMultiReader();
- }
+ // now we are consistent again -> flush
+ index.flush();
+ index.releaseMultiReader();
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RedoLog.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RedoLog.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RedoLog.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,6 +16,12 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
+import org.apache.lucene.store.Directory;
+import org.exoplatform.services.jcr.impl.core.query.lucene.directory.IndexInputStream;
+import org.exoplatform.services.jcr.impl.core.query.lucene.directory.IndexOutputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
@@ -27,12 +33,6 @@
import java.util.ArrayList;
import java.util.List;
-import org.apache.lucene.store.Directory;
-import org.exoplatform.services.jcr.impl.core.query.lucene.directory.IndexInputStream;
-import org.exoplatform.services.jcr.impl.core.query.lucene.directory.IndexOutputStream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
/**
* Implements a redo log for changes that have not been committed to disk. While
* nodes are added to and removed from the volatile index (held in memory) a
@@ -42,180 +42,210 @@
* <p/>
* This class is not thread-safe.
*/
-class RedoLog {
+class RedoLog
+{
- /**
- * Logger instance for this class
- */
- private static final Logger log = LoggerFactory.getLogger(RedoLog.class);
+ /**
+ * Logger instance for this class
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.RedoLog");
- /**
- * Default name of the redo log file
- */
- private static final String REDO_LOG = "redo.log";
+ /**
+ * Default name of the redo log file
+ */
+ private static final String REDO_LOG = "redo.log";
- /**
- * Implements a {@link ActionCollector} that counts all entries and sets
- * {@link #entryCount}.
- */
- private final ActionCollector ENTRY_COUNTER = new ActionCollector() {
- public void collect(MultiIndex.Action a) {
- entryCount++;
- }
- };
+ /**
+ * Implements a {@link ActionCollector} that counts all entries and sets
+ * {@link #entryCount}.
+ */
+ private final ActionCollector ENTRY_COUNTER = new ActionCollector()
+ {
+ public void collect(MultiIndex.Action a)
+ {
+ entryCount++;
+ }
+ };
- /**
- * The directory where the log file is stored.
- */
- private final Directory dir;
+ /**
+ * The directory where the log file is stored.
+ */
+ private final Directory dir;
- /**
- * The number of log entries in the log file
- */
- private int entryCount = 0;
+ /**
+ * The number of log entries in the log file
+ */
+ private int entryCount = 0;
- /**
- * Writer to the log file
- */
- private Writer out;
+ /**
+ * Writer to the log file
+ */
+ private Writer out;
- /**
- * Creates a new <code>RedoLog</code> instance, which stores its log in the
- * given directory.
- *
- * @param dir the directory where the redo log file is located.
- * @throws IOException if an error occurs while reading the redo log.
- */
- RedoLog(Directory dir) throws IOException {
- this.dir = dir;
- read(ENTRY_COUNTER);
- }
+ /**
+ * Creates a new <code>RedoLog</code> instance, which stores its log in the
+ * given directory.
+ *
+ * @param dir the directory where the redo log file is located.
+ * @throws IOException if an error occurs while reading the redo log.
+ */
+ RedoLog(Directory dir) throws IOException
+ {
+ this.dir = dir;
+ read(ENTRY_COUNTER);
+ }
- /**
- * Returns <code>true</code> if this redo log contains any entries,
- * <code>false</code> otherwise.
- * @return <code>true</code> if this redo log contains any entries,
- * <code>false</code> otherwise.
- */
- boolean hasEntries() {
- return entryCount > 0;
- }
+ /**
+ * Returns <code>true</code> if this redo log contains any entries,
+ * <code>false</code> otherwise.
+ * @return <code>true</code> if this redo log contains any entries,
+ * <code>false</code> otherwise.
+ */
+ boolean hasEntries()
+ {
+ return entryCount > 0;
+ }
- /**
- * Returns the number of entries in this redo log.
- * @return the number of entries in this redo log.
- */
- int getSize() {
- return entryCount;
- }
+ /**
+ * Returns the number of entries in this redo log.
+ * @return the number of entries in this redo log.
+ */
+ int getSize()
+ {
+ return entryCount;
+ }
- /**
- * Returns a List with all {@link MultiIndex.Action} instances in the
- * redo log.
- *
- * @return an List with all {@link MultiIndex.Action} instances in the
- * redo log.
- * @throws IOException if an error occurs while reading from the redo log.
- */
- List getActions() throws IOException {
- final List actions = new ArrayList();
- read(new ActionCollector() {
- public void collect(MultiIndex.Action a) {
- actions.add(a);
- }
- });
- return actions;
- }
+ /**
+ * Returns a List with all {@link MultiIndex.Action} instances in the
+ * redo log.
+ *
+ * @return an List with all {@link MultiIndex.Action} instances in the
+ * redo log.
+ * @throws IOException if an error occurs while reading from the redo log.
+ */
+ List getActions() throws IOException
+ {
+ final List actions = new ArrayList();
+ read(new ActionCollector()
+ {
+ public void collect(MultiIndex.Action a)
+ {
+ actions.add(a);
+ }
+ });
+ return actions;
+ }
- /**
- * Appends an action to the log.
- *
- * @param action the action to append.
- * @throws IOException if the node cannot be written to the redo
- * log.
- */
- void append(MultiIndex.Action action) throws IOException {
- initOut();
- out.write(action.toString() + "\n");
- entryCount++;
- }
+ /**
+ * Appends an action to the log.
+ *
+ * @param action the action to append.
+ * @throws IOException if the node cannot be written to the redo
+ * log.
+ */
+ void append(MultiIndex.Action action) throws IOException
+ {
+ initOut();
+ out.write(action.toString() + "\n");
+ entryCount++;
+ }
- /**
- * Flushes all pending writes to the underlying file.
- * @throws IOException if an error occurs while writing.
- */
- void flush() throws IOException {
- if (out != null) {
- out.flush();
- }
- }
+ /**
+ * Flushes all pending writes to the underlying file.
+ * @throws IOException if an error occurs while writing.
+ */
+ void flush() throws IOException
+ {
+ if (out != null)
+ {
+ out.flush();
+ }
+ }
- /**
- * Clears the redo log.
- * @throws IOException if the redo log cannot be cleared.
- */
- void clear() throws IOException {
- if (out != null) {
- out.close();
- out = null;
- }
- dir.deleteFile(REDO_LOG);
- entryCount = 0;
- }
+ /**
+ * Clears the redo log.
+ * @throws IOException if the redo log cannot be cleared.
+ */
+ void clear() throws IOException
+ {
+ if (out != null)
+ {
+ out.close();
+ out = null;
+ }
+ dir.deleteFile(REDO_LOG);
+ entryCount = 0;
+ }
- /**
- * Initializes the {@link #out} stream if it is not yet set.
- * @throws IOException if an error occurs while creating the
- * output stream.
- */
- private void initOut() throws IOException {
- if (out == null) {
- OutputStream os = new IndexOutputStream(dir.createOutput(REDO_LOG));
- out = new BufferedWriter(new OutputStreamWriter(os));
- }
- }
+ /**
+ * Initializes the {@link #out} stream if it is not yet set.
+ * @throws IOException if an error occurs while creating the
+ * output stream.
+ */
+ private void initOut() throws IOException
+ {
+ if (out == null)
+ {
+ OutputStream os = new IndexOutputStream(dir.createOutput(REDO_LOG));
+ out = new BufferedWriter(new OutputStreamWriter(os));
+ }
+ }
- /**
- * Reads the log file and calls back {@link RedoLog.ActionCollector}.
- *
- * @param collector called back for each {@link MultiIndex.Action} read.
- * @throws IOException if an error occurs while reading from the
- * log file.
- */
- private void read(ActionCollector collector) throws IOException {
- if (!dir.fileExists(REDO_LOG)) {
- return;
- }
- InputStream in = new IndexInputStream(dir.openInput(REDO_LOG));
- try {
- BufferedReader reader = new BufferedReader(new InputStreamReader(in));
- String line;
- while ((line = reader.readLine()) != null) {
- try {
- collector.collect(MultiIndex.Action.fromString(line));
- } catch (IllegalArgumentException e) {
- log.warn("Malformed redo entry: " + e.getMessage());
- }
+ /**
+ * Reads the log file and calls back {@link RedoLog.ActionCollector}.
+ *
+ * @param collector called back for each {@link MultiIndex.Action} read.
+ * @throws IOException if an error occurs while reading from the
+ * log file.
+ */
+ private void read(ActionCollector collector) throws IOException
+ {
+ if (!dir.fileExists(REDO_LOG))
+ {
+ return;
+ }
+ InputStream in = new IndexInputStream(dir.openInput(REDO_LOG));
+ try
+ {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ String line;
+ while ((line = reader.readLine()) != null)
+ {
+ try
+ {
+ collector.collect(MultiIndex.Action.fromString(line));
}
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- log.warn("Exception while closing redo log: " + e.toString());
- }
+ catch (IllegalArgumentException e)
+ {
+ log.warn("Malformed redo entry: " + e.getMessage());
}
- }
- }
+ }
+ }
+ finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception while closing redo log: " + e.toString());
+ }
+ }
+ }
+ }
- //-----------------------< internal >---------------------------------------
+ //-----------------------< internal >---------------------------------------
- /**
- * Helper interface to collect Actions read from the redo log.
- */
- interface ActionCollector {
+ /**
+ * Helper interface to collect Actions read from the redo log.
+ */
+ interface ActionCollector
+ {
- /** Called when an action is created */
- void collect(MultiIndex.Action action);
- }
+ /** Called when an action is created */
+ void collect(MultiIndex.Action action);
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RowIteratorImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RowIteratorImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/RowIteratorImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -58,7 +58,7 @@
/**
* The logger instance for this class.
*/
- private static final Logger log = LoggerFactory.getLogger(RowIteratorImpl.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.RowIteratorImpl");
/**
* The QValue factory.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScoreNodeIteratorImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScoreNodeIteratorImpl.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/ScoreNodeIteratorImpl.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,15 +16,10 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
import java.util.ListIterator;
import java.util.NoSuchElementException;
-import javax.jcr.RangeIterator;
-
/**
* <code>ScoreNodeIteratorImpl</code> implements a {@link ScoreNodeIterator}
* over an array of {@link ScoreNode ScoreNode[]}.
@@ -35,11 +30,10 @@
//private final ScoreNode[][] scoreNodes;
private ListIterator<ScoreNode[]> iterator;
-
-
+
public ScoreNodeIteratorImpl(ScoreNode[][] scoreNodes)
{
-
+
iterator = Arrays.asList(scoreNodes).listIterator();
//this.scoreNodes = scoreNodes;
///this(Arrays.asList(scoreNodes));
@@ -56,58 +50,10 @@
}
/**
- * Static instance of an empty {@link RangeIterator}.
- */
- //public static final RangeIterator EMPTY = new RangeIteratorAdapter(Collections.EMPTY_LIST);
-
- // /**
- // * The adapted iterator instance.
- // */
- // private final Iterator iterator;
-
- /**
* Number of elements in the adapted iterator, or -1 if unknown.
*/
private int size;
- /**
- * Current position of the iterator.
- */
- // private int position;
-
- // /**
- // * Creates an adapter for the given iterator of the given size.
- // *
- // * @param iterator adapted iterator
- // * @param size size of the iterator, or -1 if unknown
- // */
- // public ScoreNodeIteratorImpl(Iterator iterator, long size)
- // {
- // this.iterator = iterator;
- // this.size = size;
- // this.position = 0;
- // }
-
- // /**
- // * Creates an adapter for the given iterator of unknown size.
- // *
- // * @param iterator adapted iterator
- // */
- // public ScoreNodeIteratorImpl(Iterator iterator)
- // {
- // this(iterator, -1);
- // }
- //
- // /**
- // * Creates a {@link RangeIterator} for the given collection.
- // *
- // * @param collection the collection to iterate
- // */
- // public ScoreNodeIteratorImpl(Collection collection)
- // {
- // this(collection.iterator(), collection.size());
- // }
-
//-------------------------------------------------------< RangeIterator >
/**
@@ -143,7 +89,7 @@
{
throw new IllegalArgumentException("skip(" + n + ")");
}
-
+
for (long i = 0; i < n; i++)
{
next();
@@ -162,18 +108,6 @@
*/
public boolean hasNext()
{
- // if (iterator.hasNext())
- // {
- // return true;
- // }
- // else
- // {
- // if (size == -1)
- // {
- // size = position;
- // }
- // return false;
- // }
return iterator.hasNext();
}
@@ -199,8 +133,8 @@
*/
public void remove() throws UnsupportedOperationException, IllegalStateException
{
- iterator.remove();
- size--;
+ iterator.remove();
+ size--;
}
public void skipBack(long skipNum)
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SearchIndex.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -95,7 +95,7 @@
private static final DefaultQueryNodeFactory DEFAULT_QUERY_NODE_FACTORY = new DefaultQueryNodeFactory();
/** The logger instance for this class */
- private static final Logger log = LoggerFactory.getLogger(SearchIndex.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.SearchIndex");
/**
* Name of the file to persist search internal namespace mappings.
@@ -596,7 +596,7 @@
{
recoverErrorLog(errorLog);
}
-
+
modeHandler.addIndexerIoModeListener(this);
}
@@ -820,11 +820,6 @@
log.warn("Exception while closing FileSystem", e);
}
}
- // shutdown extractor
- if (extractor instanceof PooledTextExtractor)
- {
- // ((PooledTextExtractor)extractor).shutdown();
- }
if (spellChecker != null)
{
spellChecker.close();
@@ -2710,11 +2705,11 @@
}
catch (IOException e)
{
- log.error("Can not recover error log. On changed mode " + mode , e);
+ log.error("Can not recover error log. On changed mode " + mode, e);
}
catch (RepositoryException e)
{
log.error("Can not recover error log.", e);
- }
+ }
}
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SimpleExcerptProvider.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SimpleExcerptProvider.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SimpleExcerptProvider.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,13 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-
import org.apache.lucene.search.Query;
import org.exoplatform.services.jcr.dataflow.ItemDataConsumer;
import org.exoplatform.services.jcr.datamodel.ItemData;
@@ -33,6 +26,12 @@
import org.exoplatform.services.log.ExoLogger;
import org.exoplatform.services.log.Log;
+import java.io.IOException;
+import java.util.List;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+
/**
* <code>SimpleExcerptProvider</code> is a <b>very</b> simple excerpt provider.
* It does not do any highlighting and simply returns up to
@@ -45,7 +44,8 @@
/**
* Logger instance for this class
*/
- private static final Log log = ExoLogger.getLogger(SimpleExcerptProvider.class);
+ private static final Log log = ExoLogger.getLogger("exo.jcr.component.core.SimpleExcerptProvider");
+
/**
* The item state manager.
*/
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SortedLuceneQueryHits.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SortedLuceneQueryHits.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/SortedLuceneQueryHits.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,152 +16,156 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.TopFieldDocCollector;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* Wraps a lucene query result and adds a close method that allows to release
* resources after a query has been executed and the results have been read
* completely.
*/
-public final class SortedLuceneQueryHits extends AbstractQueryHits {
+public final class SortedLuceneQueryHits extends AbstractQueryHits
+{
- /**
- * The Logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(SortedLuceneQueryHits.class);
+ /**
+ * The Logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.SortedLuceneQueryHits");
- /**
- * The upper limit for the initial fetch size.
- */
- private static final int MAX_FETCH_SIZE = 32 * 1024;
+ /**
+ * The upper limit for the initial fetch size.
+ */
+ private static final int MAX_FETCH_SIZE = 32 * 1024;
- /**
- * The lower limit for the initial fetch size.
- */
- private static final int MIN_FETCH_SIZE = 32;
+ /**
+ * The lower limit for the initial fetch size.
+ */
+ private static final int MIN_FETCH_SIZE = 32;
- /**
- * The IndexReader in use by the lucene hits.
- */
- private final IndexReader reader;
+ /**
+ * The IndexReader in use by the lucene hits.
+ */
+ private final IndexReader reader;
- /**
- * The index searcher.
- */
- private final JcrIndexSearcher searcher;
+ /**
+ * The index searcher.
+ */
+ private final JcrIndexSearcher searcher;
- /**
- * The query to execute.
- */
- private final Query query;
+ /**
+ * The query to execute.
+ */
+ private final Query query;
- /**
- * The sort criteria.
- */
- private final Sort sort;
+ /**
+ * The sort criteria.
+ */
+ private final Sort sort;
- /**
- * The index of the current hit. Initially invalid.
- */
- private int hitIndex = -1;
+ /**
+ * The index of the current hit. Initially invalid.
+ */
+ private int hitIndex = -1;
- /**
- * The score nodes.
- */
- private final List scoreNodes = new ArrayList();
+ /**
+ * The score nodes.
+ */
+ private final List scoreNodes = new ArrayList();
- /**
- * The total number of hits.
- */
- private int size;
+ /**
+ * The total number of hits.
+ */
+ private int size;
- /**
- * Number of hits to retrieve.
- */
- private int numHits;
+ /**
+ * Number of hits to retrieve.
+ */
+ private int numHits;
- /**
- * Creates a new <code>QueryHits</code> instance wrapping <code>hits</code>.
- *
- * @param reader the IndexReader in use.
- * @param searcher the index searcher.
- * @param query the query to execute.
- * @param sort the sort criteria.
- * @param resultFetchHint a hint on how many results should be fetched.
- * @throws IOException if an error occurs while reading from the index.
- */
- public SortedLuceneQueryHits(IndexReader reader,
- JcrIndexSearcher searcher,
- Query query,
- Sort sort,
- long resultFetchHint) throws IOException {
- this.reader = reader;
- this.searcher = searcher;
- this.query = query;
- this.sort = sort;
- this.numHits = (int) Math.min(
- Math.max(resultFetchHint, MIN_FETCH_SIZE),
- MAX_FETCH_SIZE);
- getHits();
- }
+ /**
+ * Creates a new <code>QueryHits</code> instance wrapping <code>hits</code>.
+ *
+ * @param reader the IndexReader in use.
+ * @param searcher the index searcher.
+ * @param query the query to execute.
+ * @param sort the sort criteria.
+ * @param resultFetchHint a hint on how many results should be fetched.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ public SortedLuceneQueryHits(IndexReader reader, JcrIndexSearcher searcher, Query query, Sort sort,
+ long resultFetchHint) throws IOException
+ {
+ this.reader = reader;
+ this.searcher = searcher;
+ this.query = query;
+ this.sort = sort;
+ this.numHits = (int)Math.min(Math.max(resultFetchHint, MIN_FETCH_SIZE), MAX_FETCH_SIZE);
+ getHits();
+ }
- /**
- * {@inheritDoc}
- */
- public int getSize() {
+ /**
+ * {@inheritDoc}
+ */
+ public int getSize()
+ {
return size;
- }
+ }
- /**
- * {@inheritDoc}
- */
- public ScoreNode nextScoreNode() throws IOException {
- if (++hitIndex >= size) {
- // no more score nodes
- return null;
- } else if (hitIndex >= scoreNodes.size()) {
- // refill at least numHits or twice hitIndex
- this.numHits = Math.max(this.numHits, hitIndex * 2);
- getHits();
- }
- return (ScoreNode) scoreNodes.get(hitIndex);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public ScoreNode nextScoreNode() throws IOException
+ {
+ if (++hitIndex >= size)
+ {
+ // no more score nodes
+ return null;
+ }
+ else if (hitIndex >= scoreNodes.size())
+ {
+ // refill at least numHits or twice hitIndex
+ this.numHits = Math.max(this.numHits, hitIndex * 2);
+ getHits();
+ }
+ return (ScoreNode)scoreNodes.get(hitIndex);
+ }
- /**
- * Skips <code>n</code> hits.
- *
- * @param n the number of hits to skip.
- * @throws IOException if an error occurs while skipping.
- */
- public void skip(int n) throws IOException {
- hitIndex += n;
- }
+ /**
+ * Skips <code>n</code> hits.
+ *
+ * @param n the number of hits to skip.
+ * @throws IOException if an error occurs while skipping.
+ */
+ public void skip(int n) throws IOException
+ {
+ hitIndex += n;
+ }
- //-------------------------------< internal >-------------------------------
+ //-------------------------------< internal >-------------------------------
- private void getHits() throws IOException {
- TopFieldDocCollector collector = new TopFieldDocCollector(reader, sort, numHits);
- searcher.search(query, collector);
- this.size = collector.getTotalHits();
- ScoreDoc[] docs = collector.topDocs().scoreDocs;
- for (int i = scoreNodes.size(); i < docs.length; i++) {
- String uuid = reader.document(docs[i].doc).get(FieldNames.UUID);
- //NodeId id = new NodeId(UUID.fromString(uuid));
- scoreNodes.add(new ScoreNode(uuid, docs[i].score, docs[i].doc));
- }
- log.debug("getHits() {}/{}", new Integer(scoreNodes.size()), new Integer(numHits));
- // double hits for next round
- numHits *= 2;
- }
+ private void getHits() throws IOException
+ {
+ TopFieldDocCollector collector = new TopFieldDocCollector(reader, sort, numHits);
+ searcher.search(query, collector);
+ this.size = collector.getTotalHits();
+ ScoreDoc[] docs = collector.topDocs().scoreDocs;
+ for (int i = scoreNodes.size(); i < docs.length; i++)
+ {
+ String uuid = reader.document(docs[i].doc).get(FieldNames.UUID);
+ //NodeId id = new NodeId(UUID.fromString(uuid));
+ scoreNodes.add(new ScoreNode(uuid, docs[i].score, docs[i].doc));
+ }
+ log.debug("getHits() {}/{}", new Integer(scoreNodes.size()), new Integer(numHits));
+ // double hits for next round
+ numHits *= 2;
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TermDocsCache.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TermDocsCache.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TermDocsCache.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,13 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.BitSet;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-
import org.apache.commons.collections.map.LRUMap;
import org.apache.commons.collections.map.LinkedMap;
import org.apache.lucene.index.IndexReader;
@@ -32,250 +25,295 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
/**
* <code>TermDocsCache</code> implements a cache for frequently read
* {@link TermDocs}.
*/
-public class TermDocsCache {
+public class TermDocsCache
+{
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(TermDocsCache.class);
+ /**
+ * The logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.TermDocsCache");
- /**
- * The default cache size.
- */
- private static final int CACHE_SIZE = 10;
+ /**
+ * The default cache size.
+ */
+ private static final int CACHE_SIZE = 10;
- /**
- * The underlying index reader.
- */
- private final IndexReader reader;
+ /**
+ * The underlying index reader.
+ */
+ private final IndexReader reader;
- /**
- * Only TermDocs for the given <code>field</code> are cached.
- */
- private final String field;
+ /**
+ * Only TermDocs for the given <code>field</code> are cached.
+ */
+ private final String field;
- /**
- * Map of {@link Term#text()} that are unknown to the underlying index.
- */
- private final Map unknownValues = Collections.synchronizedMap(new LRUMap(100));
+ /**
+ * Map of {@link Term#text()} that are unknown to the underlying index.
+ */
+ private final Map unknownValues = Collections.synchronizedMap(new LRUMap(100));
- /**
- * The cache of the {@link #CACHE_SIZE} most frequently requested TermDocs.
- * Maps term text <code>String</code> to {@link CacheEntry}.
- */
- private final LinkedMap cache = new LinkedMap();
+ /**
+ * The cache of the {@link #CACHE_SIZE} most frequently requested TermDocs.
+ * Maps term text <code>String</code> to {@link CacheEntry}.
+ */
+ private final LinkedMap cache = new LinkedMap();
- /**
- * Creates a new cache for the given <code>reader</code> and
- * <code>field</code>.
- *
- * @param reader the index reader.
- * @param field the field name of the terms to potentially cache.
- */
- public TermDocsCache(IndexReader reader, String field) {
- this.reader = reader;
- this.field = field;
- }
+ /**
+ * Creates a new cache for the given <code>reader</code> and
+ * <code>field</code>.
+ *
+ * @param reader the index reader.
+ * @param field the field name of the terms to potentially cache.
+ */
+ public TermDocsCache(IndexReader reader, String field)
+ {
+ this.reader = reader;
+ this.field = field;
+ }
- /**
- * Returns the {@link TermDocs} for the given term.
- *
- * @param t the term.
- * @return the term docs for the given term.
- * @throws IOException if an error occurs while reading from the index.
- */
- public TermDocs termDocs(final Term t) throws IOException {
- if (t.field() != field) {
- return reader.termDocs(t);
- }
+ /**
+ * Returns the {@link TermDocs} for the given term.
+ *
+ * @param t the term.
+ * @return the term docs for the given term.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ public TermDocs termDocs(final Term t) throws IOException
+ {
+ if (t.field() != field)
+ {
+ return reader.termDocs(t);
+ }
- String text = t.text();
- if (unknownValues.get(text) != null) {
- log.debug("EmptyTermDocs({},{})", field, text);
- return EmptyTermDocs.INSTANCE;
- }
+ String text = t.text();
+ if (unknownValues.get(text) != null)
+ {
+ log.debug("EmptyTermDocs({},{})", field, text);
+ return EmptyTermDocs.INSTANCE;
+ }
- // maintain cache
- CacheEntry entry;
- synchronized (cache) {
- entry = (CacheEntry) cache.get(text);
- if (entry == null) {
- // check space
- if (cache.size() >= CACHE_SIZE) {
- // prune half of them and adjust the rest
- CacheEntry[] entries = (CacheEntry[]) cache.values().toArray(
- new CacheEntry[cache.size()]);
- Arrays.sort(entries);
- int threshold = entries[CACHE_SIZE / 2].numAccessed;
- for (Iterator it = cache.entrySet().iterator(); it.hasNext(); ) {
- Map.Entry e = (Map.Entry) it.next();
- if (((CacheEntry) e.getValue()).numAccessed <= threshold) {
- // prune
- it.remove();
- } else {
- // adjust
- CacheEntry ce = (CacheEntry) e.getValue();
- ce.numAccessed = (int) Math.sqrt(ce.numAccessed);
- }
- }
- }
- entry = new CacheEntry();
- cache.put(text, entry);
- } else {
- entry.numAccessed++;
+ // maintain cache
+ CacheEntry entry;
+ synchronized (cache)
+ {
+ entry = (CacheEntry)cache.get(text);
+ if (entry == null)
+ {
+ // check space
+ if (cache.size() >= CACHE_SIZE)
+ {
+ // prune half of them and adjust the rest
+ CacheEntry[] entries = (CacheEntry[])cache.values().toArray(new CacheEntry[cache.size()]);
+ Arrays.sort(entries);
+ int threshold = entries[CACHE_SIZE / 2].numAccessed;
+ for (Iterator it = cache.entrySet().iterator(); it.hasNext();)
+ {
+ Map.Entry e = (Map.Entry)it.next();
+ if (((CacheEntry)e.getValue()).numAccessed <= threshold)
+ {
+ // prune
+ it.remove();
+ }
+ else
+ {
+ // adjust
+ CacheEntry ce = (CacheEntry)e.getValue();
+ ce.numAccessed = (int)Math.sqrt(ce.numAccessed);
+ }
+ }
}
- }
+ entry = new CacheEntry();
+ cache.put(text, entry);
+ }
+ else
+ {
+ entry.numAccessed++;
+ }
+ }
- // this is a threshold to prevent caching of TermDocs
- // that are read only irregularly.
- if (entry.numAccessed < 10) {
- if (log.isDebugEnabled()) {
- log.debug("#{} TermDocs({},{})",
- new Object[]{new Integer(entry.numAccessed),
- field, text});
- }
- return reader.termDocs(t);
- }
+ // this is a threshold to prevent caching of TermDocs
+ // that are read only irregularly.
+ if (entry.numAccessed < 10)
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("#{} TermDocs({},{})", new Object[]{new Integer(entry.numAccessed), field, text});
+ }
+ return reader.termDocs(t);
+ }
- if (entry.bits == null) {
- // collect bits
- BitSet bits = null;
- TermDocs tDocs = reader.termDocs(t);
- try {
- while (tDocs.next()) {
- if (bits == null) {
- bits = new BitSet(reader.maxDoc());
- }
- bits.set(tDocs.doc());
- }
- } finally {
- tDocs.close();
+ if (entry.bits == null)
+ {
+ // collect bits
+ BitSet bits = null;
+ TermDocs tDocs = reader.termDocs(t);
+ try
+ {
+ while (tDocs.next())
+ {
+ if (bits == null)
+ {
+ bits = new BitSet(reader.maxDoc());
+ }
+ bits.set(tDocs.doc());
}
- if (bits != null) {
- entry.bits = bits;
- }
- }
+ }
+ finally
+ {
+ tDocs.close();
+ }
+ if (bits != null)
+ {
+ entry.bits = bits;
+ }
+ }
- if (entry.bits == null) {
- // none collected
- unknownValues.put(text, text);
- return EmptyTermDocs.INSTANCE;
- } else {
- if (log.isDebugEnabled()) {
- log.debug("CachedTermDocs({},{},{}/{})", new Object[]{
- field, text, new Integer(entry.bits.cardinality()),
- new Integer(reader.maxDoc())});
- }
- return new CachedTermDocs(entry.bits);
- }
- }
+ if (entry.bits == null)
+ {
+ // none collected
+ unknownValues.put(text, text);
+ return EmptyTermDocs.INSTANCE;
+ }
+ else
+ {
+ if (log.isDebugEnabled())
+ {
+ log.debug("CachedTermDocs({},{},{}/{})", new Object[]{field, text, new Integer(entry.bits.cardinality()),
+ new Integer(reader.maxDoc())});
+ }
+ return new CachedTermDocs(entry.bits);
+ }
+ }
- /**
- * Implements a {@link TermDocs} base on a {@link BitSet}.
- */
- private static final class CachedTermDocs implements TermDocs {
+ /**
+ * Implements a {@link TermDocs} base on a {@link BitSet}.
+ */
+ private static final class CachedTermDocs implements TermDocs
+ {
- /**
- * The cached docs for this term.
- */
- private final BitSet docs;
+ /**
+ * The cached docs for this term.
+ */
+ private final BitSet docs;
- /**
- * The current position into the {@link #docs}.
- */
- private int position = -1;
+ /**
+ * The current position into the {@link #docs}.
+ */
+ private int position = -1;
- /**
- * <code>true</code> if there are potentially more docs.
- */
- private boolean moreDocs = true;
+ /**
+ * <code>true</code> if there are potentially more docs.
+ */
+ private boolean moreDocs = true;
- public CachedTermDocs(BitSet docs) {
- this.docs = docs;
- }
+ public CachedTermDocs(BitSet docs)
+ {
+ this.docs = docs;
+ }
- /**
- * @throws UnsupportedOperationException always.
- */
- public void seek(Term term) throws IOException {
- throw new UnsupportedOperationException();
- }
+ /**
+ * @throws UnsupportedOperationException always.
+ */
+ public void seek(Term term) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
- /**
- * @throws UnsupportedOperationException always.
- */
- public void seek(TermEnum termEnum) throws IOException {
- throw new UnsupportedOperationException();
- }
+ /**
+ * @throws UnsupportedOperationException always.
+ */
+ public void seek(TermEnum termEnum) throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
- return position;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int doc()
+ {
+ return position;
+ }
- /**
- * {@inheritDoc}
- */
- public int freq() {
- return 1;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int freq()
+ {
+ return 1;
+ }
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
- if (moreDocs) {
- position = docs.nextSetBit(position + 1);
- moreDocs = position != -1;
- }
- return moreDocs;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean next() throws IOException
+ {
+ if (moreDocs)
+ {
+ position = docs.nextSetBit(position + 1);
+ moreDocs = position != -1;
+ }
+ return moreDocs;
+ }
- /**
- * {@inheritDoc}
- */
- public int read(int[] docs, int[] freqs) throws IOException {
- int count;
- for (count = 0; count < docs.length && next(); count++) {
- docs[count] = doc();
- freqs[count] = 1;
- }
- return count;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int read(int[] docs, int[] freqs) throws IOException
+ {
+ int count;
+ for (count = 0; count < docs.length && next(); count++)
+ {
+ docs[count] = doc();
+ freqs[count] = 1;
+ }
+ return count;
+ }
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
- if (moreDocs) {
- position = docs.nextSetBit(target);
- moreDocs = position != -1;
- }
- return moreDocs;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean skipTo(int target) throws IOException
+ {
+ if (moreDocs)
+ {
+ position = docs.nextSetBit(target);
+ moreDocs = position != -1;
+ }
+ return moreDocs;
+ }
- /**
- * {@inheritDoc}
- */
- public void close() throws IOException {
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void close() throws IOException
+ {
+ }
+ }
- private static final class CacheEntry implements Comparable {
+ private static final class CacheEntry implements Comparable
+ {
- private volatile int numAccessed = 1;
+ private volatile int numAccessed = 1;
- private volatile BitSet bits;
+ private volatile BitSet bits;
- public int compareTo(Object o) {
- CacheEntry other = (CacheEntry) o;
- return (numAccessed < other.numAccessed ? -1 : (numAccessed == other.numAccessed ? 0 : 1));
- }
- }
+ public int compareTo(Object o)
+ {
+ CacheEntry other = (CacheEntry)o;
+ return (numAccessed < other.numAccessed ? -1 : (numAccessed == other.numAccessed ? 0 : 1));
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/TextExtractorJob.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,6 +16,13 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
+import EDU.oswego.cs.dl.util.concurrent.Callable;
+import EDU.oswego.cs.dl.util.concurrent.FutureResult;
+
+import org.exoplatform.services.document.DocumentReader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
@@ -28,210 +35,238 @@
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
-import org.apache.poi.util.IOUtils;
-import org.exoplatform.services.document.DocumentReader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import EDU.oswego.cs.dl.util.concurrent.Callable;
-import EDU.oswego.cs.dl.util.concurrent.FutureResult;
-
/**
* <code>TextExtractorJob</code> implements a future result and is runnable
* in a background thread.
*/
-public class TextExtractorJob extends FutureResult implements Runnable {
+public class TextExtractorJob extends FutureResult implements Runnable
+{
- /**
- * UTF-8 encoding.
- */
- private static final String ENCODING_UTF8 = "UTF-8";
+ /**
+ * UTF-8 encoding.
+ */
+ private static final String ENCODING_UTF8 = "UTF-8";
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(TextExtractorJob.class);
+ /**
+ * The logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.TextExtractorJob");
- /**
- * The command of the future result.
- */
- private final Runnable cmd;
+ /**
+ * The command of the future result.
+ */
+ private final Runnable cmd;
- /**
- * The mime type of the resource to extract text from.
- */
- private final String type;
+ /**
+ * The mime type of the resource to extract text from.
+ */
+ private final String type;
- /**
- * Set to <code>true</code> if this job timed out.
- */
- private transient boolean timedOut = false;
+ /**
+ * Set to <code>true</code> if this job timed out.
+ */
+ private transient boolean timedOut = false;
- /**
- * <code>true</code> if this extractor job has been flaged as discarded.
- */
- private transient boolean discarded = false;
+ /**
+ * <code>true</code> if this extractor job has been flaged as discarded.
+ */
+ private transient boolean discarded = false;
- /**
- * Creates a new <code>TextExtractorJob</code> with the given
- * <code>extractor</code> on the <code>stream</code>.
- *
- * @param extractor the text extractor
- * @param stream the stream of the binary property.
- * @param type the mime-type of the binary content.
- * @param encoding the encoding of the binary content. May be
- * <code>null</code>.
- */
- public TextExtractorJob(final DocumentReader extractor,
- final InputStream stream,
- final String type,
- final String encoding) {
- this.type = type;
- this.cmd = setter(new Callable() {
- public Object call() throws Exception {
- Reader r = new StringReader(extractor.getContentAsText(stream, encoding));
- if (r != null) {
- if (discarded) {
- r.close();
- r = null;
- } else if (timedOut) {
- // spool a temp file to save memory
- r = getSwappedOutReader(r);
- }
- }
- return r;
+ /**
+ * Creates a new <code>TextExtractorJob</code> with the given
+ * <code>extractor</code> on the <code>stream</code>.
+ *
+ * @param extractor the text extractor
+ * @param stream the stream of the binary property.
+ * @param type the mime-type of the binary content.
+ * @param encoding the encoding of the binary content. May be
+ * <code>null</code>.
+ */
+ public TextExtractorJob(final DocumentReader extractor, final InputStream stream, final String type,
+ final String encoding)
+ {
+ this.type = type;
+ this.cmd = setter(new Callable()
+ {
+ public Object call() throws Exception
+ {
+ Reader r = new StringReader(extractor.getContentAsText(stream, encoding));
+ if (r != null)
+ {
+ if (discarded)
+ {
+ r.close();
+ r = null;
+ }
+ else if (timedOut)
+ {
+ // spool a temp file to save memory
+ r = getSwappedOutReader(r);
+ }
}
- });
- }
+ return r;
+ }
+ });
+ }
- /**
- * Returns the reader with the extracted text from the input stream passed
- * to the constructor of this <code>TextExtractorJob</code>. The caller of
- * this method is responsible for closing the returned reader. Returns
- * <code>null</code> if a <code>timeout</code>occurs while waiting for the
- * text extractor to get the reader.
- *
- * @return the Reader with the extracted text. Returns <code>null</code> if
- * a timeout or an exception occured extracting the text.
- */
- public Reader getReader(long timeout) {
- Reader reader = null;
- try {
- reader = (Reader) timedGet(timeout);
- } catch (InterruptedException e) {
- // also covers TimeoutException
- // text not extracted within timeout or interrupted
- if (timeout > 0) {
- log.debug("Text extraction for {} timed out (>{}ms).",
- type, new Long(timeout));
- timedOut = true;
- }
- } catch (InvocationTargetException e) {
- // extraction failed
- log.warn("Exception while indexing binary property: " + e.getCause());
- log.debug("Dump: ", e.getCause());
- }
- return reader;
- }
+ /**
+ * Returns the reader with the extracted text from the input stream passed
+ * to the constructor of this <code>TextExtractorJob</code>. The caller of
+ * this method is responsible for closing the returned reader. Returns
+ * <code>null</code> if a <code>timeout</code>occurs while waiting for the
+ * text extractor to get the reader.
+ *
+ * @return the Reader with the extracted text. Returns <code>null</code> if
+ * a timeout or an exception occured extracting the text.
+ */
+ public Reader getReader(long timeout)
+ {
+ Reader reader = null;
+ try
+ {
+ reader = (Reader)timedGet(timeout);
+ }
+ catch (InterruptedException e)
+ {
+ // also covers TimeoutException
+ // text not extracted within timeout or interrupted
+ if (timeout > 0)
+ {
+ log.debug("Text extraction for {} timed out (>{}ms).", type, new Long(timeout));
+ timedOut = true;
+ }
+ }
+ catch (InvocationTargetException e)
+ {
+ // extraction failed
+ log.warn("Exception while indexing binary property: " + e.getCause());
+ log.debug("Dump: ", e.getCause());
+ }
+ return reader;
+ }
- /**
- * Discards this extractor job. If the reader within this job is ready at
- * the time of this call, it is closed. If the reader is not yet ready this
- * job will be flaged as discarded and any later call to
- * {@link #getReader(long)} will return <code>null</code>. The reader that
- * is about to be constructed by a background thread will be closed
- * automatically as soon as it becomes ready.
- */
- void discard() {
- discarded = true;
- Reader r = (Reader) peek();
- if (r != null) {
- try {
- r.close();
- } catch (IOException e) {
- log.warn("Exception when trying to discard extractor job: " + e);
- }
- }
- }
+ /**
+ * Discards this extractor job. If the reader within this job is ready at
+ * the time of this call, it is closed. If the reader is not yet ready this
+ * job will be flaged as discarded and any later call to
+ * {@link #getReader(long)} will return <code>null</code>. The reader that
+ * is about to be constructed by a background thread will be closed
+ * automatically as soon as it becomes ready.
+ */
+ void discard()
+ {
+ discarded = true;
+ Reader r = (Reader)peek();
+ if (r != null)
+ {
+ try
+ {
+ r.close();
+ }
+ catch (IOException e)
+ {
+ log.warn("Exception when trying to discard extractor job: " + e);
+ }
+ }
+ }
- /**
- * @return a String description for this job with the mime type.
- */
- public String toString() {
- return "TextExtractorJob for " + type;
- }
+ /**
+ * @return a String description for this job with the mime type.
+ */
+ public String toString()
+ {
+ return "TextExtractorJob for " + type;
+ }
- //----------------------------< Runnable >----------------------------------
+ //----------------------------< Runnable >----------------------------------
- /**
- * Runs the actual text extraction.
- */
- public void run() {
- // forward to command
- cmd.run();
- }
+ /**
+ * Runs the actual text extraction.
+ */
+ public void run()
+ {
+ // forward to command
+ cmd.run();
+ }
- //----------------------------< internal >----------------------------------
+ //----------------------------< internal >----------------------------------
- /**
- * Returns a <code>Reader</code> for <code>r</code> using a temp file.
- *
- * @param r the reader to swap out into a temp file.
- * @return a reader to the temp file.
- */
- private Reader getSwappedOutReader(Reader r) {
- final File temp;
- try {
- temp = File.createTempFile("extractor", null);
- } catch (IOException e) {
- // unable to create temp file
- // return reader as is
- return r;
- }
- Writer out;
- try {
- out = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(temp), ENCODING_UTF8));
- } catch (IOException e) {
- // should never happend actually
- if (!temp.delete()) {
- temp.deleteOnExit();
- }
- return r;
- }
+ /**
+ * Returns a <code>Reader</code> for <code>r</code> using a temp file.
+ *
+ * @param r the reader to swap out into a temp file.
+ * @return a reader to the temp file.
+ */
+ private Reader getSwappedOutReader(Reader r)
+ {
+ final File temp;
+ try
+ {
+ temp = File.createTempFile("extractor", null);
+ }
+ catch (IOException e)
+ {
+ // unable to create temp file
+ // return reader as is
+ return r;
+ }
+ Writer out;
+ try
+ {
+ out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temp), ENCODING_UTF8));
+ }
+ catch (IOException e)
+ {
+ // should never happend actually
+ if (!temp.delete())
+ {
+ temp.deleteOnExit();
+ }
+ return r;
+ }
- // spool into temp file
- InputStream in = null;
- try {
- try {
- //IOUtils.copy(r, out);
- out.close();
- } finally {
- r.close();
+ // spool into temp file
+ InputStream in = null;
+ try
+ {
+ try
+ {
+ //IOUtils.copy(r, out);
+ out.close();
+ }
+ finally
+ {
+ r.close();
+ }
+ //in = new LazyFileInputStream(temp);
+
+ return new InputStreamReader(in, ENCODING_UTF8)
+ {
+ public void close() throws IOException
+ {
+ super.close();
+ // delete file
+ if (!temp.delete())
+ {
+ temp.deleteOnExit();
+ }
}
- //in = new LazyFileInputStream(temp);
+ };
+ }
+ catch (IOException e)
+ {
+ // do some clean up
+ //IOUtils.closeQuietly(out);
+ //IOUtils.closeQuietly(in);
+ //out.close();
+ //in.close();
- return new InputStreamReader(in, ENCODING_UTF8) {
- public void close() throws IOException {
- super.close();
- // delete file
- if (!temp.delete()) {
- temp.deleteOnExit();
- }
- }
- };
- } catch (IOException e) {
- // do some clean up
- //IOUtils.closeQuietly(out);
- //IOUtils.closeQuietly(in);
- //out.close();
- //in.close();
-
- if (!temp.delete()) {
- temp.deleteOnExit();
- }
- // use empty string reader as fallback
- return new StringReader("");
- }
- }
+ if (!temp.delete())
+ {
+ temp.deleteOnExit();
+ }
+ // use empty string reader as fallback
+ return new StringReader("");
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/Util.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,16 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
-import java.util.regex.Pattern;
-
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Value;
-import javax.jcr.ValueFormatException;
-
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Fieldable;
import org.apache.lucene.index.IndexReader;
@@ -38,321 +28,388 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.Iterator;
+import java.util.regex.Pattern;
+
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+
/**
* <code>Util</code> provides various static utility methods.
*/
-public class Util {
+public class Util
+{
- /**
- * The logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(Util.class);
+ /**
+ * The logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.Util");
- /**
- * Disposes the document <code>old</code>. Closes any potentially open
- * readers held by the document.
- *
- * @param old the document to dispose.
- */
- public static void disposeDocument(Document old) {
- for (Iterator it = old.getFields().iterator(); it.hasNext(); ) {
- Fieldable f = (Fieldable) it.next();
- try {
- if (f.readerValue() != null) {
- f.readerValue().close();
- } else if (f instanceof LazyTextExtractorField) {
- LazyTextExtractorField field = (LazyTextExtractorField) f;
- field.dispose();
- }
- } catch (IOException ex) {
- log.warn("Exception while disposing index document: " + ex);
+ /**
+ * Disposes the document <code>old</code>. Closes any potentially open
+ * readers held by the document.
+ *
+ * @param old the document to dispose.
+ */
+ public static void disposeDocument(Document old)
+ {
+ for (Iterator it = old.getFields().iterator(); it.hasNext();)
+ {
+ Fieldable f = (Fieldable)it.next();
+ try
+ {
+ if (f.readerValue() != null)
+ {
+ f.readerValue().close();
}
- }
- }
+ else if (f instanceof LazyTextExtractorField)
+ {
+ LazyTextExtractorField field = (LazyTextExtractorField)f;
+ field.dispose();
+ }
+ }
+ catch (IOException ex)
+ {
+ log.warn("Exception while disposing index document: " + ex);
+ }
+ }
+ }
- /**
- * Returns <code>true</code> if the document is ready to be added to the
- * index. That is all text extractors have finished their work.
- *
- * @param doc the document to check.
- * @return <code>true</code> if the document is ready; <code>false</code>
- * otherwise.
- */
- public static boolean isDocumentReady(Document doc) {
- for (Iterator it = doc.getFields().iterator(); it.hasNext(); ) {
- Fieldable f = (Fieldable) it.next();
- if (f instanceof LazyTextExtractorField) {
- LazyTextExtractorField field = (LazyTextExtractorField) f;
- if (!field.isExtractorFinished()) {
- return false;
- }
+ /**
+ * Returns <code>true</code> if the document is ready to be added to the
+ * index. That is all text extractors have finished their work.
+ *
+ * @param doc the document to check.
+ * @return <code>true</code> if the document is ready; <code>false</code>
+ * otherwise.
+ */
+ public static boolean isDocumentReady(Document doc)
+ {
+ for (Iterator it = doc.getFields().iterator(); it.hasNext();)
+ {
+ Fieldable f = (Fieldable)it.next();
+ if (f instanceof LazyTextExtractorField)
+ {
+ LazyTextExtractorField field = (LazyTextExtractorField)f;
+ if (!field.isExtractorFinished())
+ {
+ return false;
}
- }
- return true;
- }
+ }
+ }
+ return true;
+ }
- /**
- * Depending on the index format this method returns a query that matches
- * all nodes that have a property with a given <code>name</code>.
- *
- * @param name the property name.
- * @param version the index format version.
- * @return Query that matches all nodes that have a property with the given
- * <code>name</code>.
- */
- public static Query createMatchAllQuery(String name, IndexFormatVersion version) {
- if (version.getVersion() >= IndexFormatVersion.V2.getVersion()) {
- // new index format style
- return new JcrTermQuery(new Term(FieldNames.PROPERTIES_SET, name));
- } else {
- return new MatchAllQuery(name);
- }
- }
+ /**
+ * Depending on the index format this method returns a query that matches
+ * all nodes that have a property with a given <code>name</code>.
+ *
+ * @param name the property name.
+ * @param version the index format version.
+ * @return Query that matches all nodes that have a property with the given
+ * <code>name</code>.
+ */
+ public static Query createMatchAllQuery(String name, IndexFormatVersion version)
+ {
+ if (version.getVersion() >= IndexFormatVersion.V2.getVersion())
+ {
+ // new index format style
+ return new JcrTermQuery(new Term(FieldNames.PROPERTIES_SET, name));
+ }
+ else
+ {
+ return new MatchAllQuery(name);
+ }
+ }
- /**
- * Creates an {@link IOException} with <code>t</code> as its cause.
- *
- * @param t the cause.
- */
- public static IOException createIOException(Throwable t) {
- IOException ex = new IOException(t.getMessage());
- ex.initCause(t);
- return ex;
- }
+ /**
+ * Creates an {@link IOException} with <code>t</code> as its cause.
+ *
+ * @param t the cause.
+ */
+ public static IOException createIOException(Throwable t)
+ {
+ IOException ex = new IOException(t.getMessage());
+ ex.initCause(t);
+ return ex;
+ }
- /**
- * Depending on the type of the <code>reader</code> this method either
- * closes or releases the reader. The reader is released if it implements
- * {@link ReleaseableIndexReader}.
- *
- * @param reader the index reader to close or release.
- * @throws IOException if an error occurs while closing or releasing the
- * index reader.
- */
- public static void closeOrRelease(IndexReader reader) throws IOException {
- if (reader instanceof ReleaseableIndexReader) {
- ((ReleaseableIndexReader) reader).release();
- } else {
- reader.close();
- }
- }
+ /**
+ * Depending on the type of the <code>reader</code> this method either
+ * closes or releases the reader. The reader is released if it implements
+ * {@link ReleaseableIndexReader}.
+ *
+ * @param reader the index reader to close or release.
+ * @throws IOException if an error occurs while closing or releasing the
+ * index reader.
+ */
+ public static void closeOrRelease(IndexReader reader) throws IOException
+ {
+ if (reader instanceof ReleaseableIndexReader)
+ {
+ ((ReleaseableIndexReader)reader).release();
+ }
+ else
+ {
+ reader.close();
+ }
+ }
- /**
- * Returns a comparable for the internal <code>value</code>.
- *
- * @param value an internal value.
- * @return a comparable for the given <code>value</code>.
- * @throws IOException
- * @throws ValueFormatException
- * @throws IllegalStateException
- * @throws UnsupportedEncodingException
- * @throws IllegalNameException
- */
- public static Comparable getComparable(ValueData value, int type) throws UnsupportedEncodingException, IllegalStateException, ValueFormatException, IOException, IllegalNameException {
- switch (type) {
- case PropertyType.BINARY:
- return null;
- case PropertyType.BOOLEAN:
- return ComparableBoolean.valueOf(ValueDataConvertor.readBoolean(value));
- case PropertyType.DATE:
- return new Long(ValueDataConvertor.readDate(value).getTimeInMillis());
- case PropertyType.DOUBLE:
- return new Double(ValueDataConvertor.readDouble(value));
- case PropertyType.LONG:
- return new Long(ValueDataConvertor.readLong(value));
- case PropertyType.NAME:
- return new QPathEntry(ValueDataConvertor.readQName(value),1);
- case PropertyType.PATH:
- //return ValueDataConvertor.r;
- case PropertyType.REFERENCE:
- case PropertyType.STRING:
- return ValueDataConvertor.readString(value);
+ /**
+ * Returns a comparable for the internal <code>value</code>.
+ *
+ * @param value an internal value.
+ * @return a comparable for the given <code>value</code>.
+ * @throws IOException
+ * @throws ValueFormatException
+ * @throws IllegalStateException
+ * @throws UnsupportedEncodingException
+ * @throws IllegalNameException
+ */
+ public static Comparable getComparable(ValueData value, int type) throws UnsupportedEncodingException,
+ IllegalStateException, ValueFormatException, IOException, IllegalNameException
+ {
+ switch (type)
+ {
+ case PropertyType.BINARY :
+ return null;
+ case PropertyType.BOOLEAN :
+ return ComparableBoolean.valueOf(ValueDataConvertor.readBoolean(value));
+ case PropertyType.DATE :
+ return new Long(ValueDataConvertor.readDate(value).getTimeInMillis());
+ case PropertyType.DOUBLE :
+ return new Double(ValueDataConvertor.readDouble(value));
+ case PropertyType.LONG :
+ return new Long(ValueDataConvertor.readLong(value));
+ case PropertyType.NAME :
+ return new QPathEntry(ValueDataConvertor.readQName(value), 1);
+ case PropertyType.PATH :
+ //return ValueDataConvertor.r;
+ case PropertyType.REFERENCE :
+ case PropertyType.STRING :
+ return ValueDataConvertor.readString(value);
// TODO: JSR 283 now node types
- default:
- return null;
- }
- }
+ default :
+ return null;
+ }
+ }
- /**
- * Returns a comparable for the internal <code>value</code>.
- *
- * @param value an internal value.
- * @return a comparable for the given <code>value</code>.
- * @throws ValueFormatException if the given <code>value</code> cannot be
- * converted into a comparable (i.e.
- * unsupported type).
- * @throws RepositoryException if an error occurs while converting the
- * value.
- */
- public static Comparable getComparable(Value value)
- throws ValueFormatException, RepositoryException {
- switch (value.getType()) {
- case PropertyType.BOOLEAN:
- return ComparableBoolean.valueOf(value.getBoolean());
- case PropertyType.DATE:
- return new Long(value.getDate().getTimeInMillis());
- case PropertyType.DOUBLE:
- return new Double(value.getDouble());
- case PropertyType.LONG:
- return new Long(value.getLong());
- case PropertyType.NAME:
- case PropertyType.PATH:
- case PropertyType.REFERENCE:
- case PropertyType.STRING:
- return value.getString();
- // TODO: JSR 283 now node types
- default:
- throw new RepositoryException("Unsupported type: "
- + PropertyType.nameFromValue(value.getType()));
- }
- }
+ /**
+ * Returns a comparable for the internal <code>value</code>.
+ *
+ * @param value an internal value.
+ * @return a comparable for the given <code>value</code>.
+ * @throws ValueFormatException if the given <code>value</code> cannot be
+ * converted into a comparable (i.e.
+ * unsupported type).
+ * @throws RepositoryException if an error occurs while converting the
+ * value.
+ */
+ public static Comparable getComparable(Value value) throws ValueFormatException, RepositoryException
+ {
+ switch (value.getType())
+ {
+ case PropertyType.BOOLEAN :
+ return ComparableBoolean.valueOf(value.getBoolean());
+ case PropertyType.DATE :
+ return new Long(value.getDate().getTimeInMillis());
+ case PropertyType.DOUBLE :
+ return new Double(value.getDouble());
+ case PropertyType.LONG :
+ return new Long(value.getLong());
+ case PropertyType.NAME :
+ case PropertyType.PATH :
+ case PropertyType.REFERENCE :
+ case PropertyType.STRING :
+ return value.getString();
+ // TODO: JSR 283 now node types
+ default :
+ throw new RepositoryException("Unsupported type: " + PropertyType.nameFromValue(value.getType()));
+ }
+ }
- /**
- * Compares values <code>c1</code> and <code>c2</code>. If the
- * values have differing types, then the order is defined on
- * the type itself by calling <code>compareTo()</code> on the respective
- * type class names.
- *
- * @param c1 the first value.
- * @param c2 the second value.
- * @return a negative integer if <code>c1</code> should come before
- * <code>c2</code><br> a positive integer if <code>c1</code>
- * should come after <code>c2</code><br> <code>0</code> if they
- * are equal.
- */
- public static int compare(Comparable c1, Comparable c2) {
- if (c1 == c2) {
- return 0;
- } else if (c1 == null) {
- return -1;
- } else if (c2 == null) {
- return 1;
- } else if (c1.getClass() == c2.getClass()) {
- return c1.compareTo(c2);
- } else {
- // differing types -> compare class names
- String name1 = c1.getClass().getName();
- String name2 = c2.getClass().getName();
- return name1.compareTo(name2);
- }
- }
+ /**
+ * Compares values <code>c1</code> and <code>c2</code>. If the
+ * values have differing types, then the order is defined on
+ * the type itself by calling <code>compareTo()</code> on the respective
+ * type class names.
+ *
+ * @param c1 the first value.
+ * @param c2 the second value.
+ * @return a negative integer if <code>c1</code> should come before
+ * <code>c2</code><br> a positive integer if <code>c1</code>
+ * should come after <code>c2</code><br> <code>0</code> if they
+ * are equal.
+ */
+ public static int compare(Comparable c1, Comparable c2)
+ {
+ if (c1 == c2)
+ {
+ return 0;
+ }
+ else if (c1 == null)
+ {
+ return -1;
+ }
+ else if (c2 == null)
+ {
+ return 1;
+ }
+ else if (c1.getClass() == c2.getClass())
+ {
+ return c1.compareTo(c2);
+ }
+ else
+ {
+ // differing types -> compare class names
+ String name1 = c1.getClass().getName();
+ String name2 = c2.getClass().getName();
+ return name1.compareTo(name2);
+ }
+ }
- /**
- * Compares the two values. If the values have differing types, then an
- * attempt is made to convert the second value into the type of the first
- * value.
- * <p/>
- * Comparison of binary values is not supported.
- *
- * @param v1 the first value.
- * @param v2 the second value.
- * @return result of the comparison as specified in
- * {@link Comparable#compareTo(Object)}.
- * @throws ValueFormatException if the given <code>value</code> cannot be
- * converted into a comparable (i.e.
- * unsupported type).
- * @throws RepositoryException if an error occurs while converting the
- * value.
- */
- public static int compare(Value v1, Value v2)
- throws ValueFormatException, RepositoryException {
- Comparable c1 = getComparable(v1);
- Comparable c2;
- switch (v1.getType()) {
- case PropertyType.BOOLEAN:
- c2 = ComparableBoolean.valueOf(v2.getBoolean());
- break;
- case PropertyType.DATE:
- c2 = new Long(v2.getDate().getTimeInMillis());
- break;
- case PropertyType.DOUBLE:
- c2 = new Double(v2.getDouble());
- break;
- case PropertyType.LONG:
- c2 = new Long(v2.getLong());
- break;
- case PropertyType.NAME:
- case PropertyType.PATH:
- case PropertyType.REFERENCE:
- case PropertyType.STRING:
- c2 = v2.getString();
- break;
- // TODO: JSR 283 now node types
- default:
- throw new RepositoryException("Unsupported type: "
- + PropertyType.nameFromValue(v2.getType()));
- }
- return compare(c1, c2);
- }
+ /**
+ * Compares the two values. If the values have differing types, then an
+ * attempt is made to convert the second value into the type of the first
+ * value.
+ * <p/>
+ * Comparison of binary values is not supported.
+ *
+ * @param v1 the first value.
+ * @param v2 the second value.
+ * @return result of the comparison as specified in
+ * {@link Comparable#compareTo(Object)}.
+ * @throws ValueFormatException if the given <code>value</code> cannot be
+ * converted into a comparable (i.e.
+ * unsupported type).
+ * @throws RepositoryException if an error occurs while converting the
+ * value.
+ */
+ public static int compare(Value v1, Value v2) throws ValueFormatException, RepositoryException
+ {
+ Comparable c1 = getComparable(v1);
+ Comparable c2;
+ switch (v1.getType())
+ {
+ case PropertyType.BOOLEAN :
+ c2 = ComparableBoolean.valueOf(v2.getBoolean());
+ break;
+ case PropertyType.DATE :
+ c2 = new Long(v2.getDate().getTimeInMillis());
+ break;
+ case PropertyType.DOUBLE :
+ c2 = new Double(v2.getDouble());
+ break;
+ case PropertyType.LONG :
+ c2 = new Long(v2.getLong());
+ break;
+ case PropertyType.NAME :
+ case PropertyType.PATH :
+ case PropertyType.REFERENCE :
+ case PropertyType.STRING :
+ c2 = v2.getString();
+ break;
+ // TODO: JSR 283 now node types
+ default :
+ throw new RepositoryException("Unsupported type: " + PropertyType.nameFromValue(v2.getType()));
+ }
+ return compare(c1, c2);
+ }
- /**
- * Creates a regexp from <code>likePattern</code>.
- *
- * @param likePattern the pattern.
- * @return the regular expression <code>Pattern</code>.
- */
- public static Pattern createRegexp(String likePattern) {
- // - escape all non alphabetic characters
- // - escape constructs like \<alphabetic char> into \\<alphabetic char>
- // - replace non escaped _ % into . and .*
- StringBuffer regexp = new StringBuffer();
- boolean escaped = false;
- for (int i = 0; i < likePattern.length(); i++) {
- if (likePattern.charAt(i) == '\\') {
- if (escaped) {
- regexp.append("\\\\");
- escaped = false;
- } else {
- escaped = true;
- }
- } else {
- if (Character.isLetterOrDigit(likePattern.charAt(i))) {
- if (escaped) {
- regexp.append("\\\\").append(likePattern.charAt(i));
- escaped = false;
- } else {
- regexp.append(likePattern.charAt(i));
- }
- } else {
- if (escaped) {
+ /**
+ * Creates a regexp from <code>likePattern</code>.
+ *
+ * @param likePattern the pattern.
+ * @return the regular expression <code>Pattern</code>.
+ */
+ public static Pattern createRegexp(String likePattern)
+ {
+ // - escape all non alphabetic characters
+ // - escape constructs like \<alphabetic char> into \\<alphabetic char>
+ // - replace non escaped _ % into . and .*
+ StringBuffer regexp = new StringBuffer();
+ boolean escaped = false;
+ for (int i = 0; i < likePattern.length(); i++)
+ {
+ if (likePattern.charAt(i) == '\\')
+ {
+ if (escaped)
+ {
+ regexp.append("\\\\");
+ escaped = false;
+ }
+ else
+ {
+ escaped = true;
+ }
+ }
+ else
+ {
+ if (Character.isLetterOrDigit(likePattern.charAt(i)))
+ {
+ if (escaped)
+ {
+ regexp.append("\\\\").append(likePattern.charAt(i));
+ escaped = false;
+ }
+ else
+ {
+ regexp.append(likePattern.charAt(i));
+ }
+ }
+ else
+ {
+ if (escaped)
+ {
+ regexp.append('\\').append(likePattern.charAt(i));
+ escaped = false;
+ }
+ else
+ {
+ switch (likePattern.charAt(i))
+ {
+ case '_' :
+ regexp.append('.');
+ break;
+ case '%' :
+ regexp.append(".*");
+ break;
+ default :
regexp.append('\\').append(likePattern.charAt(i));
- escaped = false;
- } else {
- switch (likePattern.charAt(i)) {
- case '_':
- regexp.append('.');
- break;
- case '%':
- regexp.append(".*");
- break;
- default:
- regexp.append('\\').append(likePattern.charAt(i));
- }
- }
- }
+ }
+ }
}
- }
- return Pattern.compile(regexp.toString(), Pattern.DOTALL);
- }
+ }
+ }
+ return Pattern.compile(regexp.toString(), Pattern.DOTALL);
+ }
- /**
- * Returns length of the internal value.
- *
- * @param value a value.
- * @param propType
- * @return the length of the internal value or <code>-1</code> if the length
- * cannot be determined.
- */
- public static long getLength(ValueData value, int propType) {
- // TODO: support new JSR 283 property types
- if (propType == PropertyType.BINARY) {
- return value.getLength();
- } else
- if (propType == PropertyType.NAME
- || propType == PropertyType.PATH) {
- return -1;
- } else {
- return value.toString().length();
- }
- }
+ /**
+ * Returns length of the internal value.
+ *
+ * @param value a value.
+ * @param propType
+ * @return the length of the internal value or <code>-1</code> if the length
+ * cannot be determined.
+ */
+ public static long getLength(ValueData value, int propType)
+ {
+ // TODO: support new JSR 283 property types
+ if (propType == PropertyType.BINARY)
+ {
+ return value.getLength();
+ }
+ else if (propType == PropertyType.NAME || propType == PropertyType.PATH)
+ {
+ return -1;
+ }
+ else
+ {
+ return value.toString().length();
+ }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WeightedHighlighter.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WeightedHighlighter.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WeightedHighlighter.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -44,7 +44,7 @@
/**
* The logger instance for this class.
*/
- private static final Logger log = LoggerFactory.getLogger(WeightedHighlighter.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.WeightedHighlighter");
/**
* Punctuation characters that mark the end of a sentence.
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WildcardQuery.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WildcardQuery.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/WildcardQuery.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,12 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene;
-import java.io.IOException;
-import java.util.BitSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermDocs;
@@ -38,6 +32,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
/**
* Implements a wildcard query on a lucene field with an embedded property name
* and a pattern.
@@ -48,325 +48,369 @@
* <li><code>_</code> : matches exactly one character</li>
* </ul>
*/
-public class WildcardQuery extends Query implements Transformable {
+public class WildcardQuery extends Query implements Transformable
+{
- /**
- * Logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(WildcardQuery.class);
+ /**
+ * Logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.WildcardQuery");
- /**
- * Name of the field to search.
- */
- private final String field;
+ /**
+ * Name of the field to search.
+ */
+ private final String field;
- /**
- * Name of the property to search.
- */
- private final String propName;
+ /**
+ * Name of the property to search.
+ */
+ private final String propName;
- /**
- * The wildcard pattern.
- */
- private final String pattern;
+ /**
+ * The wildcard pattern.
+ */
+ private final String pattern;
- /**
- * How property values are tranformed before they are matched using the
- * provided pattern.
- */
- private int transform = TRANSFORM_NONE;
+ /**
+ * How property values are tranformed before they are matched using the
+ * provided pattern.
+ */
+ private int transform = TRANSFORM_NONE;
- /**
- * The standard multi term query to execute wildcard queries. This is only
- * set if the pattern matches less than {@link org.apache.lucene.search.BooleanQuery#maxClauseCount}.
- */
- private Query multiTermQuery;
+ /**
+ * The standard multi term query to execute wildcard queries. This is only
+ * set if the pattern matches less than {@link org.apache.lucene.search.BooleanQuery#maxClauseCount}.
+ */
+ private Query multiTermQuery;
- /**
- * Creates a new <code>WildcardQuery</code>.
- *
- * @param field the name of the field to search.
- * @param propName name of the property to search.
- * @param pattern the wildcard pattern.
- * @param transform how property values are transformed before they are
- * matched using the <code>pattern</code>.
- */
- public WildcardQuery(String field, String propName, String pattern, int transform) {
- this.field = field.intern();
- this.propName = propName;
- this.pattern = pattern;
- this.transform = transform;
- }
+ /**
+ * Creates a new <code>WildcardQuery</code>.
+ *
+ * @param field the name of the field to search.
+ * @param propName name of the property to search.
+ * @param pattern the wildcard pattern.
+ * @param transform how property values are transformed before they are
+ * matched using the <code>pattern</code>.
+ */
+ public WildcardQuery(String field, String propName, String pattern, int transform)
+ {
+ this.field = field.intern();
+ this.propName = propName;
+ this.pattern = pattern;
+ this.transform = transform;
+ }
- /**
- * Creates a new <code>WildcardQuery</code>.
- *
- * @param field the name of the field to search.
- * @param propName name of the property to search.
- * @param pattern the wildcard pattern.
- */
- public WildcardQuery(String field, String propName, String pattern) {
- this(field, propName, pattern, TRANSFORM_NONE);
- }
+ /**
+ * Creates a new <code>WildcardQuery</code>.
+ *
+ * @param field the name of the field to search.
+ * @param propName name of the property to search.
+ * @param pattern the wildcard pattern.
+ */
+ public WildcardQuery(String field, String propName, String pattern)
+ {
+ this(field, propName, pattern, TRANSFORM_NONE);
+ }
- /**
- * {@inheritDoc}
- */
- public void setTransformation(int transformation) {
- this.transform = transformation;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void setTransformation(int transformation)
+ {
+ this.transform = transformation;
+ }
- /**
- * Either rewrites this query to a lucene MultiTermQuery or in case of
- * a TooManyClauses exception to a custom jackrabbit query implementation
- * that uses a BitSet to collect all hits.
- *
- * @param reader the index reader to use for the search.
- * @return the rewritten query.
- * @throws IOException if an error occurs while reading from the index.
- */
- public Query rewrite(IndexReader reader) throws IOException {
- Query stdWildcardQuery = new MultiTermQuery(new Term(field, pattern)) {
- protected FilteredTermEnum getEnum(IndexReader reader) throws IOException {
- return new WildcardTermEnum(reader, field, propName, pattern, transform);
- }
- };
- try {
- multiTermQuery = stdWildcardQuery.rewrite(reader);
- return multiTermQuery;
- } catch (BooleanQuery.TooManyClauses e) {
- // MultiTermQuery not possible
- log.debug("Too many terms to enumerate, using custom WildcardQuery.");
- return this;
- }
- }
+ /**
+ * Either rewrites this query to a lucene MultiTermQuery or in case of
+ * a TooManyClauses exception to a custom jackrabbit query implementation
+ * that uses a BitSet to collect all hits.
+ *
+ * @param reader the index reader to use for the search.
+ * @return the rewritten query.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ public Query rewrite(IndexReader reader) throws IOException
+ {
+ Query stdWildcardQuery = new MultiTermQuery(new Term(field, pattern))
+ {
+ protected FilteredTermEnum getEnum(IndexReader reader) throws IOException
+ {
+ return new WildcardTermEnum(reader, field, propName, pattern, transform);
+ }
+ };
+ try
+ {
+ multiTermQuery = stdWildcardQuery.rewrite(reader);
+ return multiTermQuery;
+ }
+ catch (BooleanQuery.TooManyClauses e)
+ {
+ // MultiTermQuery not possible
+ log.debug("Too many terms to enumerate, using custom WildcardQuery.");
+ return this;
+ }
+ }
- /**
- * Creates the <code>Weight</code> for this query.
- *
- * @param searcher the searcher to use for the <code>Weight</code>.
- * @return the <code>Weigth</code> for this query.
- */
- protected Weight createWeight(Searcher searcher) {
- return new WildcardQueryWeight(searcher);
- }
+ /**
+ * Creates the <code>Weight</code> for this query.
+ *
+ * @param searcher the searcher to use for the <code>Weight</code>.
+ * @return the <code>Weigth</code> for this query.
+ */
+ protected Weight createWeight(Searcher searcher)
+ {
+ return new WildcardQueryWeight(searcher);
+ }
- /**
- * Returns a string representation of this query.
- *
- * @param field the field name for which to create a string representation.
- * @return a string representation of this query.
- */
- public String toString(String field) {
- return propName + ":" + pattern;
- }
+ /**
+ * Returns a string representation of this query.
+ *
+ * @param field the field name for which to create a string representation.
+ * @return a string representation of this query.
+ */
+ public String toString(String field)
+ {
+ return propName + ":" + pattern;
+ }
- /**
- * {@inheritDoc}
- */
- public void extractTerms(Set terms) {
- if (multiTermQuery != null) {
- multiTermQuery.extractTerms(terms);
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void extractTerms(Set terms)
+ {
+ if (multiTermQuery != null)
+ {
+ multiTermQuery.extractTerms(terms);
+ }
+ }
- /**
- * The <code>Weight</code> implementation for this <code>WildcardQuery</code>.
- */
- private class WildcardQueryWeight extends AbstractWeight {
+ /**
+ * The <code>Weight</code> implementation for this <code>WildcardQuery</code>.
+ */
+ private class WildcardQueryWeight extends AbstractWeight
+ {
- /**
- * Creates a new <code>WildcardQueryWeight</code> instance using
- * <code>searcher</code>.
- *
- * @param searcher a <code>Searcher</code> instance.
- */
- public WildcardQueryWeight(Searcher searcher) {
- super(searcher);
- }
+ /**
+ * Creates a new <code>WildcardQueryWeight</code> instance using
+ * <code>searcher</code>.
+ *
+ * @param searcher a <code>Searcher</code> instance.
+ */
+ public WildcardQueryWeight(Searcher searcher)
+ {
+ super(searcher);
+ }
- /**
- * Creates a {@link WildcardQueryScorer} instance.
- *
- * @param reader index reader
- * @return a {@link WildcardQueryScorer} instance
- */
- protected Scorer createScorer(IndexReader reader) {
- return new WildcardQueryScorer(searcher.getSimilarity(), reader);
- }
+ /**
+ * Creates a {@link WildcardQueryScorer} instance.
+ *
+ * @param reader index reader
+ * @return a {@link WildcardQueryScorer} instance
+ */
+ protected Scorer createScorer(IndexReader reader)
+ {
+ return new WildcardQueryScorer(searcher.getSimilarity(), reader);
+ }
- /**
- * Returns this <code>WildcardQuery</code>.
- *
- * @return this <code>WildcardQuery</code>.
- */
- public Query getQuery() {
- return WildcardQuery.this;
- }
+ /**
+ * Returns this <code>WildcardQuery</code>.
+ *
+ * @return this <code>WildcardQuery</code>.
+ */
+ public Query getQuery()
+ {
+ return WildcardQuery.this;
+ }
- /**
- * {@inheritDoc}
- */
- public float getValue() {
- return 1.0f;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public float getValue()
+ {
+ return 1.0f;
+ }
- /**
- * {@inheritDoc}
- */
- public float sumOfSquaredWeights() throws IOException {
- return 1.0f;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public float sumOfSquaredWeights() throws IOException
+ {
+ return 1.0f;
+ }
- /**
- * {@inheritDoc}
- */
- public void normalize(float norm) {
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void normalize(float norm)
+ {
+ }
- /**
- * {@inheritDoc}
- */
- public Explanation explain(IndexReader reader, int doc) throws IOException {
- return new Explanation();
- }
- }
+ /**
+ * {@inheritDoc}
+ */
+ public Explanation explain(IndexReader reader, int doc) throws IOException
+ {
+ return new Explanation();
+ }
+ }
- /**
- * Implements a <code>Scorer</code> for this <code>WildcardQuery</code>.
- */
- private final class WildcardQueryScorer extends Scorer {
+ /**
+ * Implements a <code>Scorer</code> for this <code>WildcardQuery</code>.
+ */
+ private final class WildcardQueryScorer extends Scorer
+ {
- /**
- * The index reader to use for calculating the matching documents.
- */
- private final IndexReader reader;
+ /**
+ * The index reader to use for calculating the matching documents.
+ */
+ private final IndexReader reader;
- /**
- * The documents ids that match this wildcard query.
- */
- private final BitSet hits;
+ /**
+ * The documents ids that match this wildcard query.
+ */
+ private final BitSet hits;
- /**
- * Set to <code>true</code> when the hits have been calculated.
- */
- private boolean hitsCalculated = false;
+ /**
+ * Set to <code>true</code> when the hits have been calculated.
+ */
+ private boolean hitsCalculated = false;
- /**
- * The next document id to return
- */
- private int nextDoc = -1;
+ /**
+ * The next document id to return
+ */
+ private int nextDoc = -1;
- /**
- * The cache key to use to store the results.
- */
- private final String cacheKey;
+ /**
+ * The cache key to use to store the results.
+ */
+ private final String cacheKey;
- /**
- * The map to store the results.
- */
- private final Map resultMap;
+ /**
+ * The map to store the results.
+ */
+ private final Map resultMap;
- /**
- * Creates a new WildcardQueryScorer.
- *
- * @param similarity the similarity implementation.
- * @param reader the index reader to use.
- */
- WildcardQueryScorer(Similarity similarity, IndexReader reader) {
- super(similarity);
- this.reader = reader;
- this.cacheKey = field + '\uFFFF' + propName + '\uFFFF' + transform + '\uFFFF' + pattern;
- // check cache
- PerQueryCache cache = PerQueryCache.getInstance();
- Map m = (Map) cache.get(WildcardQueryScorer.class, reader);
- if (m == null) {
- m = new HashMap();
- cache.put(WildcardQueryScorer.class, reader, m);
- }
- resultMap = m;
+ /**
+ * Creates a new WildcardQueryScorer.
+ *
+ * @param similarity the similarity implementation.
+ * @param reader the index reader to use.
+ */
+ WildcardQueryScorer(Similarity similarity, IndexReader reader)
+ {
+ super(similarity);
+ this.reader = reader;
+ this.cacheKey = field + '\uFFFF' + propName + '\uFFFF' + transform + '\uFFFF' + pattern;
+ // check cache
+ PerQueryCache cache = PerQueryCache.getInstance();
+ Map m = (Map)cache.get(WildcardQueryScorer.class, reader);
+ if (m == null)
+ {
+ m = new HashMap();
+ cache.put(WildcardQueryScorer.class, reader, m);
+ }
+ resultMap = m;
- BitSet result = (BitSet) resultMap.get(cacheKey);
- if (result == null) {
- result = new BitSet(reader.maxDoc());
- } else {
- hitsCalculated = true;
- }
- hits = result;
- }
+ BitSet result = (BitSet)resultMap.get(cacheKey);
+ if (result == null)
+ {
+ result = new BitSet(reader.maxDoc());
+ }
+ else
+ {
+ hitsCalculated = true;
+ }
+ hits = result;
+ }
- /**
- * {@inheritDoc}
- */
- public boolean next() throws IOException {
- calculateHits();
- nextDoc = hits.nextSetBit(nextDoc + 1);
- return nextDoc > -1;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean next() throws IOException
+ {
+ calculateHits();
+ nextDoc = hits.nextSetBit(nextDoc + 1);
+ return nextDoc > -1;
+ }
- /**
- * {@inheritDoc}
- */
- public int doc() {
- return nextDoc;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int doc()
+ {
+ return nextDoc;
+ }
- /**
- * {@inheritDoc}
- */
- public float score() {
- return 1.0f;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public float score()
+ {
+ return 1.0f;
+ }
- /**
- * {@inheritDoc}
- */
- public boolean skipTo(int target) throws IOException {
- calculateHits();
- nextDoc = hits.nextSetBit(target);
- return nextDoc > -1;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public boolean skipTo(int target) throws IOException
+ {
+ calculateHits();
+ nextDoc = hits.nextSetBit(target);
+ return nextDoc > -1;
+ }
- /**
- * Returns an empty Explanation object.
- * @return an empty Explanation object.
- */
- public Explanation explain(int doc) {
- return new Explanation();
- }
+ /**
+ * Returns an empty Explanation object.
+ * @return an empty Explanation object.
+ */
+ public Explanation explain(int doc)
+ {
+ return new Explanation();
+ }
- /**
- * Calculates the ids of the documents matching this wildcard query.
- * @throws IOException if an error occurs while reading from the index.
- */
- private void calculateHits() throws IOException {
- if (hitsCalculated) {
- return;
+ /**
+ * Calculates the ids of the documents matching this wildcard query.
+ * @throws IOException if an error occurs while reading from the index.
+ */
+ private void calculateHits() throws IOException
+ {
+ if (hitsCalculated)
+ {
+ return;
+ }
+ TermEnum terms = new WildcardTermEnum(reader, field, propName, pattern, transform);
+ try
+ {
+ // use unpositioned TermDocs
+ TermDocs docs = reader.termDocs();
+ try
+ {
+ while (terms.term() != null)
+ {
+ docs.seek(terms);
+ while (docs.next())
+ {
+ hits.set(docs.doc());
+ }
+ if (!terms.next())
+ {
+ break;
+ }
+ }
}
- TermEnum terms = new WildcardTermEnum(reader, field, propName, pattern, transform);
- try {
- // use unpositioned TermDocs
- TermDocs docs = reader.termDocs();
- try {
- while (terms.term() != null) {
- docs.seek(terms);
- while (docs.next()) {
- hits.set(docs.doc());
- }
- if (!terms.next()) {
- break;
- }
- }
- } finally {
- docs.close();
- }
- } finally {
- terms.close();
+ finally
+ {
+ docs.close();
}
- hitsCalculated = true;
- // put to cache
- resultMap.put(cacheKey, hits);
- }
+ }
+ finally
+ {
+ terms.close();
+ }
+ hitsCalculated = true;
+ // put to cache
+ resultMap.put(cacheKey, hits);
+ }
- }
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/hits/AdaptingHits.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/hits/AdaptingHits.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/hits/AdaptingHits.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,109 +16,123 @@
*/
package org.exoplatform.services.jcr.impl.core.query.lucene.hits;
-import java.io.IOException;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.IOException;
+
/**
* This is an implementation of Hits which starts with marking hits in an
* ArrayHits instance and switches to a BitSetHits instance if at least the
* threshold of 8kb for the ArrayHits is reached and a BitSetHits instance
* would consume less memory.
*/
-public class AdaptingHits implements Hits {
+public class AdaptingHits implements Hits
+{
- /**
- * Logger instance for this class.
- */
- private static final Logger log = LoggerFactory.getLogger(AdaptingHits.class);
+ /**
+ * Logger instance for this class.
+ */
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.AdaptingHits");
- /**
- * The lower threshold before a conversion is tried
- */
- private static final int DEFAULT_THRESHOLD = 2048;
+ /**
+ * The lower threshold before a conversion is tried
+ */
+ private static final int DEFAULT_THRESHOLD = 2048;
- /**
- * Internal hits instance
- */
- private Hits hits;
+ /**
+ * Internal hits instance
+ */
+ private Hits hits;
- /**
- * The maximum doc number in hits. Used to calculate the expected
- * BitSetHits memory footprint.
- */
- private int maxDoc;
+ /**
+ * The maximum doc number in hits. Used to calculate the expected
+ * BitSetHits memory footprint.
+ */
+ private int maxDoc;
- /**
- * The total number of hits. Used to calculate the memory footprint of the
- * initial ArrayHits instance.
- */
- private int docCount;
+ /**
+ * The total number of hits. Used to calculate the memory footprint of the
+ * initial ArrayHits instance.
+ */
+ private int docCount;
- private int threshold;
+ private int threshold;
- public AdaptingHits() {
- this(DEFAULT_THRESHOLD);
- }
+ public AdaptingHits()
+ {
+ this(DEFAULT_THRESHOLD);
+ }
- public AdaptingHits(int threshold) {
- this.threshold = threshold;
- hits = new ArrayHits();
- maxDoc = 0;
- }
+ public AdaptingHits(int threshold)
+ {
+ this.threshold = threshold;
+ hits = new ArrayHits();
+ maxDoc = 0;
+ }
- /**
- * {@inheritDoc}
- */
- public int next() throws IOException {
- // delegate to the internal Hits instance
- return hits.next();
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int next() throws IOException
+ {
+ // delegate to the internal Hits instance
+ return hits.next();
+ }
- /**
- * {@inheritDoc}
- */
- public void set(int doc) {
- hits.set(doc);
- docCount++;
- if (doc > maxDoc) {
- maxDoc = doc;
- }
+ /**
+ * {@inheritDoc}
+ */
+ public void set(int doc)
+ {
+ hits.set(doc);
+ docCount++;
+ if (doc > maxDoc)
+ {
+ maxDoc = doc;
+ }
- if (docCount > threshold && (hits instanceof ArrayHits)) {
- int intArraySize = docCount * 4;
- int bitSetSize = maxDoc / 8;
- if (bitSetSize < intArraySize) {
- log.debug("BitSet is smaller than int[]: "
- + bitSetSize + " vs " + intArraySize);
- BitSetHits bitSetHits = new BitSetHits();
- int i = 0;
- while (i > -1) {
- try {
- i = hits.next();
- if (i > -1) {
- bitSetHits.set(i);
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- hits = bitSetHits;
+ if (docCount > threshold && (hits instanceof ArrayHits))
+ {
+ int intArraySize = docCount * 4;
+ int bitSetSize = maxDoc / 8;
+ if (bitSetSize < intArraySize)
+ {
+ log.debug("BitSet is smaller than int[]: " + bitSetSize + " vs " + intArraySize);
+ BitSetHits bitSetHits = new BitSetHits();
+ int i = 0;
+ while (i > -1)
+ {
+ try
+ {
+ i = hits.next();
+ if (i > -1)
+ {
+ bitSetHits.set(i);
+ }
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
}
- }
- }
+ hits = bitSetHits;
+ }
+ }
+ }
- /**
- * {@inheritDoc}
- */
- public int skipTo(int target) throws IOException {
- // delegate to the internal Hits instance
- return hits.skipTo(target);
- }
+ /**
+ * {@inheritDoc}
+ */
+ public int skipTo(int target) throws IOException
+ {
+ // delegate to the internal Hits instance
+ return hits.skipTo(target);
+ }
- Hits getInternalHits() {
- return hits;
- }
+ Hits getInternalHits()
+ {
+ return hits;
+ }
}
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/lucene/spell/LuceneSpellChecker.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -53,7 +53,7 @@
/**
* Logger instance for this class.
*/
- private static final Log log = ExoLogger.getLogger(LuceneSpellChecker.class);
+ private static final Log log = ExoLogger.getLogger("exo.jcr.component.core.LuceneSpellChecker");
public static final class FiveSecondsRefreshInterval extends LuceneSpellChecker
{
Modified: jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/sql/JCRSQLQueryBuilder.java
===================================================================
--- jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/sql/JCRSQLQueryBuilder.java 2010-03-25 15:08:47 UTC (rev 2136)
+++ jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/query/sql/JCRSQLQueryBuilder.java 2010-03-25 15:31:56 UTC (rev 2137)
@@ -16,21 +16,6 @@
*/
package org.exoplatform.services.jcr.impl.core.query.sql;
-import java.io.StringReader;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import javax.jcr.NamespaceException;
-import javax.jcr.RepositoryException;
-import javax.jcr.query.InvalidQueryException;
-
import org.apache.commons.collections.map.ReferenceMap;
import org.exoplatform.commons.utils.ISO8601;
import org.exoplatform.services.jcr.datamodel.InternalQName;
@@ -53,10 +38,24 @@
import org.exoplatform.services.jcr.impl.core.query.QueryRootNode;
import org.exoplatform.services.jcr.impl.core.query.RelationQueryNode;
import org.exoplatform.services.jcr.impl.core.query.TextsearchQueryNode;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.StringReader;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+import javax.jcr.NamespaceException;
+import javax.jcr.RepositoryException;
+import javax.jcr.query.InvalidQueryException;
+
/**
* Implements the query builder for the JCR SQL syntax.
*/
@@ -66,7 +65,7 @@
/**
* logger instance for this class
*/
- private static final Logger log = LoggerFactory.getLogger(JCRSQLQueryBuilder.class);
+ private static final Logger log = LoggerFactory.getLogger("exo.jcr.component.core.JCRSQLQueryBuilder");
/**
* DateFormat pattern for type
@@ -180,7 +179,7 @@
{
t.printStackTrace();
// javacc parser may also throw an error in some cases
- throw new InvalidQueryException(t.getMessage(),t);
+ throw new InvalidQueryException(t.getMessage(), t);
}
}
@@ -773,7 +772,6 @@
throw new IllegalArgumentException(e.toString());
}
-
if (node == null)
{
throw new IllegalArgumentException("Unknown type for literal: " + literal.getType());
14 years, 2 months
exo-jcr SVN: r2136 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-03-25 11:08:47 -0400 (Thu, 25 Mar 2010)
New Revision: 2136
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
Log:
EXOJCR-549 : The implementation backup/restore whole repository in HTTPBackupAgent.
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:59:27 UTC (rev 2135)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 15:08:47 UTC (rev 2136)
@@ -1209,7 +1209,7 @@
}
/**
- * Will be returned the list short info of current and completed backups.
+ * Will be returned the list short info of current and completed repository backups.
*
* @param repository
* String, the repository name
14 years, 2 months
exo-jcr SVN: r2135 - in jcr/trunk/exo.jcr.component.ext/src: test/java/org/exoplatform/services/jcr/ext/backup/server and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-25 10:59:27 -0400 (Thu, 25 Mar 2010)
New Revision: 2135
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
Log:
EXOJCR-549: fix bugs
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:37:44 UTC (rev 2134)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:59:27 UTC (rev 2135)
@@ -119,6 +119,11 @@
public static final String STOP_BACKUP = "/stop";
/**
+ * Stop repository backup operations.
+ */
+ public static final String STOP_BACKUP_REPOSITORY = "stop-repository";
+
+ /**
* The current and completed backups info operation.
*/
public static final String CURRENT_AND_COMPLETED_BACKUPS_INFO = "/info/backup";
@@ -134,6 +139,11 @@
public static final String CURRENT_BACKUPS_INFO = "/info/backup/current";
/**
+ * The current repository backups info operations.
+ */
+ public static final String CURRENT_BACKUPS_REPOSITORY_INFO = "/info/backup-repository/current";
+
+ /**
* The current or completed backup info operations.
*/
public static final String CURRENT_OR_COMPLETED_BACKUP_INFO = "/info/backup";
@@ -156,7 +166,7 @@
/**
* The completed repository backups info operations.
*/
- public static final String COMPLETED_BACKUPS_REPOSITORY_INFO = "/info/backup/repository/completed";
+ public static final String COMPLETED_BACKUPS_REPOSITORY_INFO = "/info/backup-repository/completed";
/**
* The backup service info operations.
@@ -731,7 +741,6 @@
if (backupId.equals(chainLog.getBackupId()))
{
shortInfo = new ShortInfo(ShortInfo.COMPLETED, chainLog);
- System.out.println();
break;
}
@@ -760,6 +769,64 @@
}
/**
+ * The repository backup stop by 'id'.
+ *
+ * @param backupId
+ * String, the identifier to backup
+ * @return Response return the response
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/stop-repository/{id}")
+ public Response stopRepository(@PathParam("id") String backupId)
+ {
+ String failMessage;
+ Response.Status status;
+ Throwable exception;
+
+ try
+ {
+ RepositoryBackupChain bch = backupManager.findRepositoryBackupId(backupId);
+
+ if (bch != null)
+ backupManager.stopBackup(bch);
+ else
+ throw new BackupNotFoundException("No active repository backup with id '" + backupId + "'");
+
+ ShortInfo shortInfo = null;
+ for (RepositoryBackupChainLog chainLog : backupManager.getRepositoryBackupsLogs())
+ if (backupId.equals(chainLog.getBackupId()))
+ {
+ shortInfo = new ShortInfo(ShortInfo.COMPLETED, chainLog);
+ break;
+ }
+
+ if (shortInfo == null)
+ throw new BackupNotFoundException("No completed backup with id '" + backupId + "'");
+
+ return Response.ok(shortInfo).cacheControl(noCache).build();
+ }
+ catch (BackupNotFoundException e)
+ {
+ exception = e;
+ status = Response.Status.NOT_FOUND;
+ failMessage = e.getMessage();
+ }
+ catch (Throwable e)
+ {
+ exception = e;
+ status = Response.Status.INTERNAL_SERVER_ERROR;
+ failMessage = e.getMessage();
+ }
+
+ log.error("Can not stop repository backup ", exception);
+
+ return Response.status(status).entity("Can not stop repository backup : " + failMessage).type(
+ MediaType.TEXT_PLAIN).cacheControl(noCache).build();
+ }
+
+ /**
* Will be returned the backup service info.
*
* @return Response return the response
@@ -943,16 +1010,17 @@
return Response.ok(info).cacheControl(noCache).build();
}
- return Response.status(Response.Status.NOT_FOUND).entity("No current or completed repository backup with 'id' " + id)
- .type(MediaType.TEXT_PLAIN).cacheControl(noCache).build();
+ return Response.status(Response.Status.NOT_FOUND).entity(
+ "No current or completed repository backup with 'id' " + id).type(MediaType.TEXT_PLAIN).cacheControl(
+ noCache).build();
}
catch (Throwable e)
{
log.error("Can not get information about current or completed repository backup with 'id' " + id, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about current or completed repository backup with 'id' " + id + " : " + e.getMessage()).type(
- MediaType.TEXT_PLAIN).cacheControl(noCache).build();
+ "Can not get information about current or completed repository backup with 'id' " + id + " : "
+ + e.getMessage()).type(MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
}
@@ -1061,8 +1129,8 @@
@GET
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("administrators")
- @Path("/info/backup/repository/completed")
- public Response infoBackupRepositoryCompleted()
+ @Path("/info/backup-repository/completed")
+ public Response infoRepositoryBackupCompleted()
{
try
{
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java 2010-03-25 14:37:44 UTC (rev 2134)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java 2010-03-25 14:59:27 UTC (rev 2135)
@@ -188,37 +188,80 @@
Thread.sleep(5000);
}
- public void testRepositoryStart() throws Exception
+ public void testRepositoryStartBackup() throws Exception
{
// login to workspace '/db6/ws2'
- Session session_db6_ws2 = repositoryService.getRepository("db6").login(credentials, "ws2");
- assertNotNull(session_db6_ws2);
+ // Start repository backup
+ {
+ Session session_db6_ws2 = repositoryService.getRepository("db6").login(credentials, "ws2");
+ assertNotNull(session_db6_ws2);
- session_db6_ws2.getRootNode().addNode("NODE_NAME_TO_TEST");
- session_db6_ws2.save();
+ session_db6_ws2.getRootNode().addNode("NODE_NAME_TO_TEST");
+ session_db6_ws2.save();
- File f = new File("target/temp/backup/" + System.currentTimeMillis());
- f.mkdirs();
+ File f = new File("target/temp/backup/" + System.currentTimeMillis());
+ f.mkdirs();
- BackupConfigBean configBean = new BackupConfigBean(BackupManager.FULL_AND_INCREMENTAL, f.getPath(), 10000l);
+ BackupConfigBean configBean = new BackupConfigBean(BackupManager.FULL_AND_INCREMENTAL, f.getPath(), 10000l);
- JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
- JsonValue json = generatorImpl.createJsonObject(configBean);
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json = generatorImpl.createJsonObject(configBean);
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.putSingle("Content-Type", "application/json; charset=UTF-8");
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("POST", new URI(HTTP_BACKUP_AGENT_PATH
+ + HTTPBackupAgent.Constants.OperationType.START_BACKUP + "/db6"), new URI(""), new ByteArrayInputStream(
+ json.toString().getBytes("UTF-8")), new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ Thread.sleep(10000);
+ }
+
+ // Get repository backup id for backup on workspace /db6/ws2
+ String id = null;
+
+ {
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+ + HTTPBackupAgent.Constants.OperationType.CURRENT_BACKUPS_REPOSITORY_INFO), new URI(""), null,
+ new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ ShortInfoList infoList = (ShortInfoList)getObject(ShortInfoList.class, responseWriter.getBody());
+ List<ShortInfo> list = new ArrayList<ShortInfo>(infoList.getBackups());
+
+ assertEquals(1, list.size());
+
+ ShortInfo info = list.get(0);
+
+ assertEquals(info.getRepositoryName(), "db6");
+
+ id = info.getBackupId();
+ }
+
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
- headers.putSingle("Content-Type", "application/json; charset=UTF-8");
ContainerRequestUserRole creq =
- new ContainerRequestUserRole("POST", new URI(HTTP_BACKUP_AGENT_PATH
- + HTTPBackupAgent.Constants.OperationType.START_BACKUP + "/db6"), new URI(""), new ByteArrayInputStream(
- json.toString().getBytes("UTF-8")), new InputHeadersMap(headers));
+ new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+ + HTTPBackupAgent.Constants.OperationType.STOP_BACKUP_REPOSITORY + "/" + id), new URI(""), null,
+ new InputHeadersMap(headers));
ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
ContainerResponse cres = new ContainerResponse(responseWriter);
handler.handleRequest(creq, cres);
assertEquals(200, cres.getStatus());
-
- Thread.sleep(5000);
}
public void testInfoBackup() throws Exception
14 years, 2 months
exo-jcr SVN: r2134 - in jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server: bean/response and 1 other directory.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-03-25 10:37:44 -0400 (Thu, 25 Mar 2010)
New Revision: 2134
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java
Log:
EXOJCR-549 : The implementation backup/restore whole repository in HTTPBackupAgent.
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:32:04 UTC (rev 2133)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:37:44 UTC (rev 2134)
@@ -931,9 +931,9 @@
return Response.ok(info).cacheControl(noCache).build();
}
- BackupChainLog completed = null;
+ RepositoryBackupChainLog completed = null;
- for (BackupChainLog chainLog : backupManager.getBackupsLogs())
+ for (RepositoryBackupChainLog chainLog : backupManager.getRepositoryBackupsLogs())
if (id.equals(chainLog.getBackupId()))
completed = chainLog;
@@ -943,15 +943,15 @@
return Response.ok(info).cacheControl(noCache).build();
}
- return Response.status(Response.Status.NOT_FOUND).entity("No current or completed backup with 'id' " + id)
+ return Response.status(Response.Status.NOT_FOUND).entity("No current or completed repository backup with 'id' " + id)
.type(MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
catch (Throwable e)
{
- log.error("Can not get information about current or completed backup with 'id' " + id, e);
+ log.error("Can not get information about current or completed repository backup with 'id' " + id, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about current or completed backup with 'id' " + id + " : " + e.getMessage()).type(
+ "Can not get information about current or completed repository backup with 'id' " + id + " : " + e.getMessage()).type(
MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java 2010-03-25 14:32:04 UTC (rev 2133)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java 2010-03-25 14:37:44 UTC (rev 2134)
@@ -92,6 +92,20 @@
super(type, chainLog);
this.backupConfig = new BackupConfigBean(chainLog.getBackupConfig());
}
+
+ /**
+ * DetailedInfo constructor.
+ *
+ * @param type
+ * int, the type of detailed info (current or completed)
+ * @param chainLog
+ * RepositoryBackupChainLog
+ */
+ public DetailedInfo(int type, RepositoryBackupChainLog chainLog)
+ {
+ super(type, chainLog);
+ this.backupConfig = new BackupConfigBean(chainLog.getBackupConfig());
+ }
/**
* DetailedInfo constructor.
14 years, 2 months
exo-jcr SVN: r2133 - jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-25 10:32:04 -0400 (Thu, 25 Mar 2010)
New Revision: 2133
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
Log:
EXOJCR-549: fix bug
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:29:25 UTC (rev 2132)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:32:04 UTC (rev 2133)
@@ -855,8 +855,8 @@
log.error("Can not get information about current or completed reposioty backups", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about current or completed repository backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
- .cacheControl(noCache).build();
+ "Can not get information about current or completed repository backups" + e.getMessage()).type(
+ MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
}
@@ -907,7 +907,7 @@
MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
}
-
+
/**
* Will be returned the detailed info of current or completed repository backup by 'id'.
*
@@ -987,7 +987,7 @@
noCache).build();
}
}
-
+
/**
* Will be returned the list short info of current backups .
*
@@ -1069,7 +1069,7 @@
List<ShortInfo> completedList = new ArrayList<ShortInfo>();
for (RepositoryBackupChainLog chainLog : backupManager.getRepositoryBackupsLogs())
- if (backupManager.findBackup(chainLog.getBackupId()) == null)
+ if (backupManager.findRepositoryBackupId(chainLog.getBackupId()) == null)
completedList.add(new ShortInfo(ShortInfo.COMPLETED, chainLog));
ShortInfoList list = new ShortInfoList(completedList);
14 years, 2 months
exo-jcr SVN: r2131 - in jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup: impl and 2 other directories.
by do-not-reply@jboss.org
Author: areshetnyak
Date: 2010-03-25 10:29:09 -0400 (Thu, 25 Mar 2010)
New Revision: 2131
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java
Log:
EXOJCR-549 : The implementation backup/restore whole repository in HTTPBackupAgent.
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java 2010-03-25 14:27:01 UTC (rev 2130)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java 2010-03-25 14:29:09 UTC (rev 2131)
@@ -349,5 +349,15 @@
* return the current backup to repository
*/
RepositoryBackupChain findRepositoryBackup(String repository);
+
+ /**
+ * Finding current backup by id.
+ *
+ * @param reposytore
+ * String, the repository name
+ * @return RepositoryBackupChain
+ * return the current backup to repository
+ */
+ RepositoryBackupChain findRepositoryBackupId(String id);
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-03-25 14:27:01 UTC (rev 2130)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-03-25 14:29:09 UTC (rev 2131)
@@ -1498,8 +1498,26 @@
return null;
}
+ /**
+ * {@inheritDoc}
+ */
public Set<RepositoryBackupChain> getCurrentRepositoryBackups()
{
return currentRepositoryBackups;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public RepositoryBackupChain findRepositoryBackupId(String backupId)
+ {
+ Iterator<RepositoryBackupChain> it = currentRepositoryBackups.iterator();
+ while (it.hasNext())
+ {
+ RepositoryBackupChain chain = it.next();
+ if (backupId.equals(chain.getBackupId()))
+ return chain;
+ }
+ return null;
+ }
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:27:01 UTC (rev 2130)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:29:09 UTC (rev 2131)
@@ -825,14 +825,14 @@
}
/**
- * Will be returned the list short info of current and completed backups .
+ * Will be returned the list short info of current and completed repository backups .
*
* @return Response return the response
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@RolesAllowed("administrators")
- @Path("/info/backup/repository")
+ @Path("/info/backup-repository")
public Response infoBackupRepository()
{
try
@@ -843,7 +843,7 @@
list.add(new ShortInfo(ShortInfo.CURRENT, chain));
for (RepositoryBackupChainLog chainLog : backupManager.getRepositoryBackupsLogs())
- if (backupManager.findBackup(chainLog.getBackupId()) == null)
+ if (backupManager.findRepositoryBackupId(chainLog.getBackupId()) == null)
list.add(new ShortInfo(ShortInfo.COMPLETED, chainLog));
ShortInfoList shortInfoList = new ShortInfoList(list);
@@ -852,10 +852,10 @@
}
catch (Throwable e)
{
- log.error("Can not get information about current or completed backups", e);
+ log.error("Can not get information about current or completed reposioty backups", e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
- "Can not get information about current or completed backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
+ "Can not get information about current or completed repository backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
.cacheControl(noCache).build();
}
}
@@ -907,7 +907,55 @@
MediaType.TEXT_PLAIN).cacheControl(noCache).build();
}
}
+
+ /**
+ * Will be returned the detailed info of current or completed repository backup by 'id'.
+ *
+ * @param id
+ * String, the identifier to repository backup
+ * @return Response return the response
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/info/backup-repository/{id}")
+ public Response infoBackupRepositoryId(@PathParam("id") String id)
+ {
+ try
+ {
+ RepositoryBackupChain current = backupManager.findRepositoryBackupId(id);
+ if (current != null)
+ {
+ DetailedInfo info = new DetailedInfo(DetailedInfo.CURRENT, current);
+ return Response.ok(info).cacheControl(noCache).build();
+ }
+
+ BackupChainLog completed = null;
+
+ for (BackupChainLog chainLog : backupManager.getBackupsLogs())
+ if (id.equals(chainLog.getBackupId()))
+ completed = chainLog;
+
+ if (completed != null)
+ {
+ DetailedInfo info = new DetailedInfo(DetailedInfo.COMPLETED, completed);
+ return Response.ok(info).cacheControl(noCache).build();
+ }
+
+ return Response.status(Response.Status.NOT_FOUND).entity("No current or completed backup with 'id' " + id)
+ .type(MediaType.TEXT_PLAIN).cacheControl(noCache).build();
+ }
+ catch (Throwable e)
+ {
+ log.error("Can not get information about current or completed backup with 'id' " + id, e);
+
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "Can not get information about current or completed backup with 'id' " + id + " : " + e.getMessage()).type(
+ MediaType.TEXT_PLAIN).cacheControl(noCache).build();
+ }
+ }
+
/**
* Will be returned the list short info of current backups .
*
@@ -939,7 +987,39 @@
noCache).build();
}
}
+
+ /**
+ * Will be returned the list short info of current backups .
+ *
+ * @return Response return the response
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/info/backup-repository/current")
+ public Response infoRepositoryBackupCurrent()
+ {
+ try
+ {
+ List<ShortInfo> list = new ArrayList<ShortInfo>();
+ for (RepositoryBackupChain chain : backupManager.getCurrentRepositoryBackups())
+ list.add(new ShortInfo(ShortInfo.CURRENT, chain));
+
+ ShortInfoList shortInfoList = new ShortInfoList(list);
+
+ return Response.ok(shortInfoList).cacheControl(noCache).build();
+ }
+ catch (Throwable e)
+ {
+ log.error("Can not get information about current repositorty backups", e);
+
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "Can not get information about current backups" + e.getMessage()).type(MediaType.TEXT_PLAIN).cacheControl(
+ noCache).build();
+ }
+ }
+
/**
* Will be returned the list short info of completed backups .
*
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java 2010-03-25 14:27:01 UTC (rev 2130)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/DetailedInfo.java 2010-03-25 14:29:09 UTC (rev 2131)
@@ -20,6 +20,7 @@
import org.exoplatform.services.jcr.ext.backup.BackupChain;
import org.exoplatform.services.jcr.ext.backup.BackupChainLog;
+import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChain;
import org.exoplatform.services.jcr.ext.backup.RepositoryBackupChainLog;
import org.exoplatform.services.jcr.ext.backup.server.bean.BackupConfigBean;
@@ -63,6 +64,20 @@
super(type, chain);
this.backupConfig = new BackupConfigBean(chain.getBackupConfig());
}
+
+ /**
+ * DetailedInfo constructor.
+ *
+ * @param type
+ * int, the type of detailed info (current or completed)
+ * @param chain
+ * backupChain
+ */
+ public DetailedInfo(int type, RepositoryBackupChain chain)
+ {
+ super(type, chain);
+ this.backupConfig = new BackupConfigBean(chain.getBackupConfig());
+ }
/**
* DetailedInfo constructor.
14 years, 2 months
exo-jcr SVN: r2130 - in jcr/trunk/exo.jcr.component.ext/src: test/java/org/exoplatform/services/jcr/ext/backup/server and 1 other directory.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-25 10:27:01 -0400 (Thu, 25 Mar 2010)
New Revision: 2130
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
Log:
EXOJCR-549: add infoBackupRepositoryCompleted() method
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:12:58 UTC (rev 2129)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:27:01 UTC (rev 2130)
@@ -154,6 +154,11 @@
public static final String COMPLETED_BACKUPS_INFO = "/info/backup/completed";
/**
+ * The completed repository backups info operations.
+ */
+ public static final String COMPLETED_BACKUPS_REPOSITORY_INFO = "/info/backup/repository/completed";
+
+ /**
* The backup service info operations.
*/
public static final String BACKUP_SERVICE_INFO = "/info";
@@ -969,6 +974,39 @@
}
/**
+ * Will be returned the list short info of completed backups .
+ *
+ * @return Response return the response
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/info/backup/repository/completed")
+ public Response infoBackupRepositoryCompleted()
+ {
+ try
+ {
+ List<ShortInfo> completedList = new ArrayList<ShortInfo>();
+
+ for (RepositoryBackupChainLog chainLog : backupManager.getRepositoryBackupsLogs())
+ if (backupManager.findBackup(chainLog.getBackupId()) == null)
+ completedList.add(new ShortInfo(ShortInfo.COMPLETED, chainLog));
+
+ ShortInfoList list = new ShortInfoList(completedList);
+
+ return Response.ok(list).cacheControl(noCache).build();
+ }
+ catch (Throwable e)
+ {
+ log.error("Can not get information about completed backups", e);
+
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "Can not get information about completed backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
+ .cacheControl(noCache).build();
+ }
+ }
+
+ /**
* Will be returned the list short info of current and completed backups. Filtered by specific
* workspace.
*
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java 2010-03-25 14:12:58 UTC (rev 2129)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java 2010-03-25 14:27:01 UTC (rev 2130)
@@ -726,7 +726,7 @@
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
ContainerRequestUserRole creq =
new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
- + HTTPBackupAgent.Constants.OperationType.COMPLETED_BACKUPS_INFO), new URI(""), null,
+ + HTTPBackupAgent.Constants.OperationType.COMPLETED_BACKUPS_REPOSITORY_INFO), new URI(""), null,
new InputHeadersMap(headers));
ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
14 years, 2 months
exo-jcr SVN: r2129 - in ws/trunk: exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet and 7 other directories.
by do-not-reply@jboss.org
Author: dkatayev
Date: 2010-03-25 10:12:58 -0400 (Thu, 25 Mar 2010)
New Revision: 2129
Modified:
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/AuthorizationModule.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/ContentEncodingModule.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/ContentMD5Module.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Cookie.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Cookie2.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/CookieModule.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultAuthHandler.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultModule.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPResponse.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpOutputStream.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RedirectionModule.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RespInputStream.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Response.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RetryModule.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/SocksClient.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/StreamDemultiplexor.java
ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/TransferEncodingModule.java
ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AnonymousUserContextRedirectionFilter.java
ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/PortalContainerInitializedFilter.java
ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ConstructorDescriptorImpl.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ContainerResponse.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestFilterComponentPlugin.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResponseFilterComponentPlugin.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/MethodInvokerFilterComponentPlugin.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/DOMSourceEntityProvider.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/EntityProviderComponentPlugin.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBContextComponentPlugin.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBContextResolver.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBElementEntityProvider.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBObjectEntityProvider.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java
ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/servlet/RestServlet.java
ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/provider/HierarchicalPropertyEntityProvider.java
ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/proxy/BaseConnector.java
Log:
EXOJCR-605 Logging category now consists of 'package name' + 'simple classname'
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/AuthorizationModule.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/AuthorizationModule.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/AuthorizationModule.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -81,7 +81,7 @@
private Response saved_resp;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.AuthorizationModule");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.AuthorizationModule");
// Constructors
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/ContentEncodingModule.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/ContentEncodingModule.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/ContentEncodingModule.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -49,7 +49,7 @@
class ContentEncodingModule implements HTTPClientModule
{
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.ContentEncodingModule");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.ContentEncodingModule");
// Methods
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/ContentMD5Module.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/ContentMD5Module.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/ContentMD5Module.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -50,7 +50,7 @@
class ContentMD5Module implements HTTPClientModule
{
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.ContentMD5Module");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.ContentMD5Module");
// Constructors
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Cookie.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Cookie.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Cookie.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -70,7 +70,7 @@
/** Make this compatible with V0.3-2 */
private static final long serialVersionUID = 8599975325569296615L;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.Cookie");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.Cookie");
protected String name;
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Cookie2.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Cookie2.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Cookie2.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -54,7 +54,7 @@
/** Make this compatible with V0.3-2 */
private static final long serialVersionUID = 2208203902820875917L;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.Cookie2");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.Cookie2");
protected int version;
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/CookieModule.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/CookieModule.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/CookieModule.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -113,7 +113,7 @@
/** the cookie policy handler */
private static CookiePolicyHandler cookie_handler = new DefaultCookiePolicyHandler();
- private static final Log log = ExoLogger.getLogger("ws.commons.httpClient.CookieModule");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.CookieModule");
// read in cookies from disk at startup
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultAuthHandler.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultAuthHandler.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultAuthHandler.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -92,7 +92,7 @@
private static boolean prompterSet = false;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.DefaultAuthHandler");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.DefaultAuthHandler");
/**
* For Digest authentication we need to set the uri, response and opaque
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultModule.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultModule.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/DefaultModule.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -49,7 +49,7 @@
/** number of times the request will be retried */
private int req_timeout_retries;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.DefaultModule");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.DefaultModule");
// Constructors
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPConnection.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -303,7 +303,7 @@
/** controls whether modules are allowed to interact with user */
private boolean allowUI;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.HTTPConnection");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.HTTPConnection");
static
{
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPResponse.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPResponse.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HTTPResponse.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -113,7 +113,7 @@
/** the method used in the request */
private String method = null;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.HTTPResponse");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.HTTPResponse");
// Constructors
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpOutputStream.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpOutputStream.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpOutputStream.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -125,7 +125,7 @@
/** just ignore all the data if told to do so */
private boolean ignore = false;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.HttpOutputStream");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.HttpOutputStream");
// Constructors
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/HttpURLConnection.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -143,7 +143,7 @@
/** the output stream used for POST and PUT */
private OutputStream output_stream;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.HttpURLConnection");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.HttpURLConnection");
static
{
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RedirectionModule.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RedirectionModule.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RedirectionModule.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -65,7 +65,7 @@
/** used for deferred redirection retries */
private Request saved_req;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.RedirectionModule");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.RedirectionModule");
// Constructors
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RespInputStream.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RespInputStream.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RespInputStream.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -82,7 +82,7 @@
/** the total number of bytes of entity data read from the demux so far */
int count = 0;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.RespInputStream");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.RespInputStream");
static
{
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Response.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Response.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/Response.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -143,7 +143,7 @@
/** should the request be retried by the application? */
boolean retry = false;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.Response");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.Response");
static
{
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RetryModule.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RetryModule.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/RetryModule.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -54,7 +54,7 @@
class RetryModule implements HTTPClientModule, GlobalConstants
{
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.RetryModule");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.RetryModule");
// Constructors
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/SocksClient.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/SocksClient.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/SocksClient.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -77,7 +77,7 @@
/** socks version 5 address types */
private final static byte IP_V4 = 1, DMNAME = 3, IP_V6 = 4;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.SocksClient");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.SocksClient");
// Constructors
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/StreamDemultiplexor.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/StreamDemultiplexor.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/StreamDemultiplexor.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -82,7 +82,7 @@
/** the currently set timeout for the socket */
private int cur_timeout = 0;
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.StreamDemultiplexor");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.StreamDemultiplexor");
static
{
Modified: ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/TransferEncodingModule.java
===================================================================
--- ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/TransferEncodingModule.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.commons/src/main/java/org/exoplatform/common/http/client/TransferEncodingModule.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -49,7 +49,7 @@
class TransferEncodingModule implements HTTPClientModule
{
- private static final Log log = ExoLogger.getLogger("ws.commons.httpclient.TransferEncodingModule");
+ private static final Log log = ExoLogger.getLogger("exo.ws.commons.TransferEncodingModule");
// Methods
Modified: ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AnonymousUserContextRedirectionFilter.java
===================================================================
--- ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AnonymousUserContextRedirectionFilter.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AnonymousUserContextRedirectionFilter.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -58,7 +58,7 @@
/**
* Logger.
*/
- private final static Log LOG = ExoLogger.getLogger("ws.AnonymousUserContextRedirectionFilter");
+ private final static Log LOG = ExoLogger.getLogger("exo.ws.frameworks.servlet.AnonymousUserContextRedirectionFilter");
/**
* The name of context.
Modified: ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/PortalContainerInitializedFilter.java
===================================================================
--- ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/PortalContainerInitializedFilter.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/PortalContainerInitializedFilter.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -44,7 +44,7 @@
public class PortalContainerInitializedFilter extends AbstractFilter
{
- private static final Log LOG = ExoLogger.getLogger("PortatContainerInitializedFilter");
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.frameworks.servlet.PortatContainerInitializedFilter");
/**
* initializes PortalContainer instance.
Modified: ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java
===================================================================
--- ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -49,7 +49,7 @@
public class StandaloneContainerInitializedListener implements ServletContextListener
{
- private static final Log LOG = ExoLogger.getLogger(StandaloneContainerInitializedListener.class);
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.frameworks.servlet.StandaloneContainerInitializedListener");
private static final String CONF_URL_PARAMETER = "org.exoplatform.container.standalone.config";
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ConstructorDescriptorImpl.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ConstructorDescriptorImpl.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ConstructorDescriptorImpl.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -58,7 +58,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(ConstructorDescriptorImpl.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.ConstructorDescriptorImpl");
/**
* ConstructorDescriptor comparator.
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ContainerResponse.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ContainerResponse.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ContainerResponse.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -48,7 +48,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(ContainerResponse.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.ContainerResponse");
/**
* See {@link ContainerResponseWriter}.
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/FieldInjectorImpl.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -51,7 +51,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(FieldInjectorImpl.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.FieldInjectorImpl");
/**
* All annotations including JAX-RS annotation.
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ProviderBinder.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -82,7 +82,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(ProviderBinder.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.ProviderBinder");
/**
* Providers instance.
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestDispatcher.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -64,7 +64,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(RequestDispatcher.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.RequestDispatcher");
/**
* See {@link ResourceBinder}.
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestFilterComponentPlugin.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestFilterComponentPlugin.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestFilterComponentPlugin.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -44,7 +44,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(RequestFilterComponentPlugin.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.RequestFilterComponentPlugin");
/**
* See {@link RequestFilter}.
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/RequestHandlerImpl.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -63,7 +63,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(RequestHandlerImpl.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.RequestHandlerImpl");
/**
* Application properties. Properties from this map will be copied to ApplicationContext
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResourceBinder.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -66,7 +66,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger("ws.rest.core.ResourceBinder");
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.ResourceBinder");
private static final Comparator<ObjectFactory<AbstractResourceDescriptor>> RESOURCE_COMPARATOR =
new ResourceComparator();
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResponseFilterComponentPlugin.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResponseFilterComponentPlugin.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/ResponseFilterComponentPlugin.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -42,7 +42,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(RequestFilterComponentPlugin.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.RequestFilterComponentPlugin");
/**
* See {@link ResponseFilter}.
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/DefaultMethodInvoker.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -54,7 +54,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(DefaultMethodInvoker.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.DefaultMethodInvoker");
/**
* {@inheritDoc}
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/MethodInvokerFilterComponentPlugin.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/MethodInvokerFilterComponentPlugin.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/method/MethodInvokerFilterComponentPlugin.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -43,7 +43,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(MethodInvokerFilterComponentPlugin.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.MethodInvokerFilterComponentPlugin");
/**
* List of {@link MethodInvokerFilter}.
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/DOMSourceEntityProvider.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/DOMSourceEntityProvider.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/DOMSourceEntityProvider.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -58,7 +58,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(DOMSourceEntityProvider.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.DOMSourceEntityProvider");
/**
* {@inheritDoc}
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/EntityProviderComponentPlugin.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/EntityProviderComponentPlugin.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/EntityProviderComponentPlugin.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -40,7 +40,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(EntityProviderComponentPlugin.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.EntityProviderComponentPlugin");
/**
* See {@link EntityProvider}.
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBContextComponentPlugin.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBContextComponentPlugin.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBContextComponentPlugin.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -41,7 +41,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(JAXBContextComponentPlugin.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.JAXBContextComponentPlugin");
/**
* Set of classes that will be bounded.
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBContextResolver.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBContextResolver.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBContextResolver.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -49,7 +49,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(JAXBContextResolver.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.JAXBContextResolver");
/**
* JAXBContext cache.
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBElementEntityProvider.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBElementEntityProvider.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBElementEntityProvider.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -57,7 +57,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(JAXBElementEntityProvider.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.JAXBElementEntityProvider");
/**
* @see Providers
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBObjectEntityProvider.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBObjectEntityProvider.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/provider/JAXBObjectEntityProvider.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -56,7 +56,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(JAXBObjectEntityProvider.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.JAXBObjectEntityProvider");
/**
* @see Providers
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/impl/resource/AbstractResourceDescriptorImpl.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -77,7 +77,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(AbstractResourceDescriptorImpl.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.AbstractResourceDescriptorImpl");
/**
* @see PathValue
Modified: ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/servlet/RestServlet.java
===================================================================
--- ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/servlet/RestServlet.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.core/src/main/java/org/exoplatform/services/rest/servlet/RestServlet.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -52,7 +52,7 @@
public class RestServlet extends AbstractHttpServlet implements Connector
{
- private static final Log LOG = ExoLogger.getLogger(RestServlet.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.core.RestServlet");
/**
* Generated by Eclipse.
Modified: ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/provider/HierarchicalPropertyEntityProvider.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/provider/HierarchicalPropertyEntityProvider.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/provider/HierarchicalPropertyEntityProvider.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -59,7 +59,7 @@
/**
* Logger.
*/
- private static final Log LOG = ExoLogger.getLogger(HierarchicalPropertyEntityProvider.class.getName());
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.ext.HierarchicalPropertyEntityProvider");
/**
* {@inheritDoc}
Modified: ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/proxy/BaseConnector.java
===================================================================
--- ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/proxy/BaseConnector.java 2010-03-25 14:04:36 UTC (rev 2128)
+++ ws/trunk/exo.ws.rest.ext/src/main/java/org/exoplatform/services/rest/ext/proxy/BaseConnector.java 2010-03-25 14:12:58 UTC (rev 2129)
@@ -58,7 +58,7 @@
NVPair[] headers;
/** Logger. */
- private static final Log LOG = ExoLogger.getLogger(BaseConnector.class);
+ private static final Log LOG = ExoLogger.getLogger("exo.ws.rest.ext.BaseConnector");
/**
* {@inheritDoc}
14 years, 2 months
exo-jcr SVN: r2128 - in jcr/trunk/exo.jcr.component.ext/src: main/java/org/exoplatform/services/jcr/ext/backup/impl and 3 other directories.
by do-not-reply@jboss.org
Author: tolusha
Date: 2010-03-25 10:04:36 -0400 (Thu, 25 Mar 2010)
New Revision: 2128
Modified:
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/ShortInfo.java
jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
Log:
EXOJCR-549: fix bubs
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java 2010-03-25 13:46:47 UTC (rev 2127)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupChainLog.java 2010-03-25 14:04:36 UTC (rev 2128)
@@ -55,7 +55,7 @@
protected static Log logger = ExoLogger.getLogger("ext.BackupChainLog");
- private static final String PREFIX = "backup-";
+ public static final String PREFIX = "backup-";
private static final String SUFFIX = ".xml";
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java 2010-03-25 13:46:47 UTC (rev 2127)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/BackupManager.java 2010-03-25 14:04:36 UTC (rev 2128)
@@ -60,7 +60,7 @@
* return the set of current backups
*/
Set<BackupChain> getCurrentBackups();
-
+
/**
* Getting current repository backups.
*
@@ -88,7 +88,7 @@
* return the job to restore
*/
JobWorkspaceRestore getLastRestore(String repositoryName, String workspaceName);
-
+
/**
* Getting list of repository restores.
*
@@ -116,6 +116,14 @@
BackupChainLog[] getBackupsLogs();
/**
+ * Getting all repository backup logs.
+ *
+ * @return RepositoryBackupChainLog[]
+ * return the all repository backup logs
+ */
+ RepositoryBackupChainLog[] getRepositoryBackupsLogs();
+
+ /**
* Starting backup.
*
* @param config
@@ -258,7 +266,7 @@
* return the default incremental job period
*/
long getDefaultIncrementalJobPeriod();
-
+
/**
* Starting repository backup.
*
@@ -275,9 +283,9 @@
* @throws RepositoryConfigurationException
* will be generate the exception RepositoryConfigurationException
*/
- RepositoryBackupChain startBackup(RepositoryBackupConfig config) throws BackupOperationException, BackupConfigurationException,
- RepositoryException, RepositoryConfigurationException;
-
+ RepositoryBackupChain startBackup(RepositoryBackupConfig config) throws BackupOperationException,
+ BackupConfigurationException, RepositoryException, RepositoryConfigurationException;
+
/**
* Stop backup.
*
@@ -285,7 +293,7 @@
* RepositoryBackupChain, the repositroy backup chain
*/
void stopBackup(RepositoryBackupChain backup);
-
+
/**
* Repository restore from backup.
*
@@ -306,10 +314,10 @@
* @throws RepositoryConfigurationException
* will be generate the exception RepositoryConfigurationException
*/
- void restore(RepositoryBackupChainLog log, RepositoryEntry repositoryEntry, Map<String, String> workspaceNamesCorrespondMap, boolean asynchronous)
- throws BackupOperationException, BackupConfigurationException, RepositoryException,
- RepositoryConfigurationException;
-
+ void restore(RepositoryBackupChainLog log, RepositoryEntry repositoryEntry,
+ Map<String, String> workspaceNamesCorrespondMap, boolean asynchronous) throws BackupOperationException,
+ BackupConfigurationException, RepositoryException, RepositoryConfigurationException;
+
/**
* Repository restore from backup.
*
@@ -341,5 +349,5 @@
* return the current backup to repository
*/
RepositoryBackupChain findRepositoryBackup(String repository);
-
+
}
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-03-25 13:46:47 UTC (rev 2127)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/BackupManagerImpl.java 2010-03-25 14:04:36 UTC (rev 2128)
@@ -246,15 +246,24 @@
}
}
- class LogsFilter implements FileFilter
+ class BackupLogsFilter implements FileFilter
{
public boolean accept(File pathname)
{
- return pathname.getName().endsWith(".xml");
+ return pathname.getName().endsWith(".xml") && pathname.getName().startsWith(BackupChainLog.PREFIX);
}
}
+ class RepositoryBackupLogsFilter implements FileFilter
+ {
+
+ public boolean accept(File pathname)
+ {
+ return pathname.getName().endsWith(".xml") && pathname.getName().startsWith(RepositoryBackupChainLog.PREFIX);
+ }
+ }
+
class TaskFilter implements FileFilter
{
@@ -425,7 +434,7 @@
*/
public BackupChainLog[] getBackupsLogs()
{
- File[] cfs = logsDirectory.listFiles(new LogsFilter());
+ File[] cfs = logsDirectory.listFiles(new BackupLogsFilter());
List<BackupChainLog> logs = new ArrayList<BackupChainLog>();
for (int i = 0; i < cfs.length; i++)
{
@@ -447,6 +456,32 @@
}
/**
+ * {@inheritDoc}
+ */
+ public RepositoryBackupChainLog[] getRepositoryBackupsLogs()
+ {
+ File[] cfs = logsDirectory.listFiles(new RepositoryBackupLogsFilter());
+ List<RepositoryBackupChainLog> logs = new ArrayList<RepositoryBackupChainLog>();
+ for (int i = 0; i < cfs.length; i++)
+ {
+ File cf = cfs[i];
+
+ try
+ {
+ if (!isCurrentBackup(cf))
+ logs.add(new RepositoryBackupChainLog(cf));
+ }
+ catch (BackupOperationException e)
+ {
+ log.warn("Log file " + cf.getAbsolutePath() + " is bussy or corrupted. Skipped. " + e, e);
+ }
+ }
+ RepositoryBackupChainLog[] ls = new RepositoryBackupChainLog[logs.size()];
+ logs.toArray(ls);
+ return ls;
+ }
+
+ /**
* isCurrentBackup.
*
* @param log
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 13:46:47 UTC (rev 2127)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgent.java 2010-03-25 14:04:36 UTC (rev 2128)
@@ -651,8 +651,8 @@
// search necessary restore
JobRepositoryRestore restore = backupManager.getLastRepositoryRestore(rEntry.getName());
ShortInfo info =
- new ShortInfo(ShortInfo.RESTORE, restore.getRepositoryBackupChainLog(), restore.getStartTime(),
- restore.getEndTime(), restore.getStateRestore(), restore.getRepositoryName());
+ new ShortInfo(ShortInfo.RESTORE, restore.getRepositoryBackupChainLog(), restore.getStartTime(), restore
+ .getEndTime(), restore.getStateRestore(), restore.getRepositoryName());
return Response.ok(info).cacheControl(noCache).build();
}
@@ -820,6 +820,42 @@
}
/**
+ * Will be returned the list short info of current and completed backups .
+ *
+ * @return Response return the response
+ */
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @RolesAllowed("administrators")
+ @Path("/info/backup/repository")
+ public Response infoBackupRepository()
+ {
+ try
+ {
+ List<ShortInfo> list = new ArrayList<ShortInfo>();
+
+ for (RepositoryBackupChain chain : backupManager.getCurrentRepositoryBackups())
+ list.add(new ShortInfo(ShortInfo.CURRENT, chain));
+
+ for (RepositoryBackupChainLog chainLog : backupManager.getRepositoryBackupsLogs())
+ if (backupManager.findBackup(chainLog.getBackupId()) == null)
+ list.add(new ShortInfo(ShortInfo.COMPLETED, chainLog));
+
+ ShortInfoList shortInfoList = new ShortInfoList(list);
+
+ return Response.ok(shortInfoList).cacheControl(noCache).build();
+ }
+ catch (Throwable e)
+ {
+ log.error("Can not get information about current or completed backups", e);
+
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(
+ "Can not get information about current or completed backups" + e.getMessage()).type(MediaType.TEXT_PLAIN)
+ .cacheControl(noCache).build();
+ }
+ }
+
+ /**
* Will be returned the detailed info of current or completed backup by 'id'.
*
* @param id
@@ -1278,7 +1314,7 @@
private boolean isRepositoryExist(String repositoryName) throws RepositoryException,
RepositoryConfigurationException
{
- try
+ try
{
return repositoryService.getRepository(repositoryName) != null;
}
@@ -1286,7 +1322,7 @@
{
return false;
}
-
+
}
/**
@@ -1331,7 +1367,7 @@
+ "' is already restoring.");
}
}
-
+
/**
* validateOneRepositoryRestoreInstants.
*
@@ -1422,7 +1458,7 @@
return null;
}
-
+
/**
* getRepositoryBackupLogbyId.
*
Modified: jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/ShortInfo.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/ShortInfo.java 2010-03-25 13:46:47 UTC (rev 2127)
+++ jcr/trunk/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/server/bean/response/ShortInfo.java 2010-03-25 14:04:36 UTC (rev 2128)
@@ -180,6 +180,30 @@
/**
* ShortInfo constructor.
*
+ * @param type
+ * int, the tupe of short info
+ * @param chainLog
+ * BackupChainLog, the backup chain log for completed backup.
+ */
+ public ShortInfo(int type, RepositoryBackupChainLog chainLog)
+ {
+ this.type = type;
+ this.backupType = chainLog.getBackupConfig().getBackupType();
+ this.backupId = chainLog.getBackupId();
+ this.repositoryName = chainLog.getBackupConfig().getRepository();
+ this.workspaceName = "";
+
+ // do not use
+ this.state = 0;
+
+ DateFormat df = new SimpleDateFormat(HTTPBackupAgent.Constants.DATE_FORMAT_RFC_1123);
+ this.startedTime = df.format(chainLog.getStartedTime().getTime());
+ this.finishedTime = df.format(chainLog.getFinishedTime().getTime());;
+ }
+
+ /**
+ * ShortInfo constructor.
+ *
* For restore.
*
* @param type
Modified: jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java
===================================================================
--- jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java 2010-03-25 13:46:47 UTC (rev 2127)
+++ jcr/trunk/exo.jcr.component.ext/src/test/java/org/exoplatform/services/jcr/ext/backup/server/HTTPBackupAgentTest.java 2010-03-25 14:04:36 UTC (rev 2128)
@@ -188,6 +188,39 @@
Thread.sleep(5000);
}
+ public void testRepositoryStart() throws Exception
+ {
+ // login to workspace '/db6/ws2'
+ Session session_db6_ws2 = repositoryService.getRepository("db6").login(credentials, "ws2");
+ assertNotNull(session_db6_ws2);
+
+ session_db6_ws2.getRootNode().addNode("NODE_NAME_TO_TEST");
+ session_db6_ws2.save();
+
+ File f = new File("target/temp/backup/" + System.currentTimeMillis());
+ f.mkdirs();
+
+ BackupConfigBean configBean = new BackupConfigBean(BackupManager.FULL_AND_INCREMENTAL, f.getPath(), 10000l);
+
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json = generatorImpl.createJsonObject(configBean);
+
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.putSingle("Content-Type", "application/json; charset=UTF-8");
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("POST", new URI(HTTP_BACKUP_AGENT_PATH
+ + HTTPBackupAgent.Constants.OperationType.START_BACKUP + "/db6"), new URI(""), new ByteArrayInputStream(
+ json.toString().getBytes("UTF-8")), new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ Thread.sleep(5000);
+ }
+
public void testInfoBackup() throws Exception
{
MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
@@ -684,6 +717,156 @@
}
}
+ public void testRestoreRepository() throws Exception
+ {
+ // Get backup id for backup on workspace /db6/ws2
+ String id = null;
+
+ {
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+ + HTTPBackupAgent.Constants.OperationType.COMPLETED_BACKUPS_INFO), new URI(""), null,
+ new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ ShortInfoList infoList = (ShortInfoList)getObject(ShortInfoList.class, responseWriter.getBody());
+ List<ShortInfo> list = new ArrayList<ShortInfo>(infoList.getBackups());
+
+ assertEquals(1, list.size());
+
+ ShortInfo info = list.get(0);
+
+ assertEquals(info.getRepositoryName(), "db6");
+ assertEquals(info.getWorkspaceName(), "ws2");
+
+ id = info.getBackupId();
+ }
+
+ // Getting default WorkspaceEntry
+ WorkspaceEntry defEntry;
+ {
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+ + HTTPBackupAgent.Constants.OperationType.GET_DEFAULT_WORKSPACE_CONFIG), new URI(""), null,
+ new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+ defEntry = (WorkspaceEntry)getObject(WorkspaceEntry.class, responseWriter.getBody());
+ }
+
+ WorkspaceEntry wEntry = makeWorkspaceEntry(defEntry, "db6", "ws3", "jdbcjcr24");
+
+ // Check the workspace /db6/ws3 not exists.
+ try
+ {
+ Session sessin_ws3 = repositoryService.getRepository("db6").login(credentials, "ws3");
+ fail("The workspace /db6/ws3 should not exists.");
+ }
+ catch (Exception e)
+ {
+ // ok
+ }
+
+ // Restore
+ {
+ // Create JSON to WorkspaceEntry
+ JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
+ JsonValue json = generatorImpl.createJsonObject(wEntry);
+
+ // Execute restore
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ headers.putSingle("Content-Type", "application/json; charset=UTF-8");
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("POST", new URI(HTTP_BACKUP_AGENT_PATH
+ + HTTPBackupAgent.Constants.OperationType.RESTORE + "/" + "db6" + "/" + id), new URI(""),
+ new ByteArrayInputStream(json.toString().getBytes("UTF-8")), new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+ }
+
+ Thread.sleep(2000);
+
+ // Get restore info to workspace /db6/ws3
+ {
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+ + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORE_INFO_ON_WS + "/" + "db6" + "/" + "ws3"),
+ new URI(""), null, new InputHeadersMap(headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ DetailedInfo info = (DetailedInfo)getObject(DetailedInfo.class, responseWriter.getBody());
+
+ assertNotNull(info);
+ assertEquals(BackupManager.FULL_AND_INCREMENTAL, info.getBackupType().intValue());
+ assertNotNull(info.getStartedTime());
+ assertNotNull(info.getFinishedTime());
+ assertEquals(ShortInfo.RESTORE, info.getType().intValue());
+ assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, info.getState().intValue());
+ assertEquals("db6", info.getRepositoryName());
+ assertEquals("ws3", info.getWorkspaceName());
+ assertNotNull(info.getBackupConfig());
+
+ Session sessin_ws3 = repositoryService.getRepository("db6").login(credentials, "ws3");
+ assertNotNull(sessin_ws3);
+ assertNotNull(sessin_ws3.getRootNode());
+ }
+
+ // Get restores info
+ {
+ MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ ContainerRequestUserRole creq =
+ new ContainerRequestUserRole("GET", new URI(HTTP_BACKUP_AGENT_PATH
+ + HTTPBackupAgent.Constants.OperationType.CURRENT_RESTORES), new URI(""), null, new InputHeadersMap(
+ headers));
+
+ ByteArrayContainerResponseWriter responseWriter = new ByteArrayContainerResponseWriter();
+ ContainerResponse cres = new ContainerResponse(responseWriter);
+ handler.handleRequest(creq, cres);
+
+ assertEquals(200, cres.getStatus());
+
+ ShortInfoList infoList = (ShortInfoList)getObject(ShortInfoList.class, responseWriter.getBody());
+ assertNotNull(infoList);
+
+ ShortInfo info = new ArrayList<ShortInfo>(infoList.getBackups()).get(0);
+
+ assertNotNull(info);
+ assertEquals(BackupManager.FULL_AND_INCREMENTAL, info.getBackupType().intValue());
+ assertNotNull(info.getStartedTime());
+ assertNotNull(info.getFinishedTime());
+ assertEquals(ShortInfo.RESTORE, info.getType().intValue());
+ assertEquals(JobWorkspaceRestore.RESTORE_SUCCESSFUL, info.getState().intValue());
+ assertEquals("db6", info.getRepositoryName());
+ assertEquals("ws3", info.getWorkspaceName());
+ assertNotNull(info.getBackupId());
+
+ Session sessin_ws3 = repositoryService.getRepository("db6").login(credentials, "ws3");
+ assertNotNull(sessin_ws3);
+ assertNotNull(sessin_ws3.getRootNode());
+ }
+ }
+
protected WorkspaceEntry makeWorkspaceEntry(WorkspaceEntry defWEntry, String repoNmae, String wsName,
String sourceName)
{
14 years, 2 months