Copied: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndex.java (from r521491, maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryArtifactIndex.java) URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndex.java?view=diff&rev=525176&p1=maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryArtifactIndex.java&r1=521491&p2=maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndex.java&r2=525176 ============================================================================== --- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryArtifactIndex.java (original) +++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndex.java Tue Apr 3 08:21:33 2007 @@ -19,220 +19,168 @@ * under the License. */ -import org.apache.lucene.analysis.Analyzer; -import org.apache.lucene.analysis.CharTokenizer; -import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; import org.apache.lucene.index.IndexModifier; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.Term; import org.apache.lucene.index.TermEnum; -import org.apache.lucene.search.BooleanClause; -import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Hits; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.MatchAllDocsQuery; -import org.apache.lucene.search.TermQuery; -import org.apache.maven.archiva.indexer.RepositoryArtifactIndex; +import org.apache.maven.archiva.indexer.RepositoryContentIndex; import org.apache.maven.archiva.indexer.RepositoryIndexException; import org.apache.maven.archiva.indexer.RepositoryIndexSearchException; import org.apache.maven.archiva.indexer.query.Query; -import org.apache.maven.archiva.indexer.record.MinimalIndexRecordFields; -import org.apache.maven.archiva.indexer.record.RepositoryIndexRecord; -import org.apache.maven.archiva.indexer.record.RepositoryIndexRecordFactory; -import org.apache.maven.archiva.indexer.record.StandardIndexRecordFields; -import org.apache.maven.artifact.Artifact; import java.io.File; import java.io.IOException; -import java.io.Reader; import java.text.ParseException; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; -import java.util.LinkedHashSet; import java.util.List; -import java.util.Set; /** * Lucene implementation of a repository index. * * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a> */ -public class LuceneRepositoryArtifactIndex - implements RepositoryArtifactIndex +public class LuceneRepositoryContentIndex implements RepositoryContentIndex { /** + * The max field length for a field in a document. + */ + private static final int MAX_FIELD_LENGTH = 40000; + + /** * The location of the index on the file system. */ private File indexLocation; - + /** - * Convert repository records to Lucene documents. + * The Lucene Index Handlers */ - private LuceneIndexRecordConverter converter; - - private static final String FLD_PK = "pk"; - - private static Analyzer luceneAnalyzer = new LuceneAnalyzer(); + private LuceneIndexHandlers indexHandlers; - private static long lastUpdatedTime = 0; - - public LuceneRepositoryArtifactIndex( File indexPath, LuceneIndexRecordConverter converter ) + public LuceneRepositoryContentIndex( File indexDir, LuceneIndexHandlers handlers ) { - this.indexLocation = indexPath; - this.converter = converter; + this.indexLocation = indexDir; + this.indexHandlers = handlers; } - public void indexRecords( Collection records ) - throws RepositoryIndexException + public void indexRecords( Collection records ) throws RepositoryIndexException { deleteRecords( records ); addRecords( records ); } - - private void addRecords( Collection records ) - throws RepositoryIndexException + + public void modifyRecords( Collection records ) throws RepositoryIndexException { - IndexWriter indexWriter; + IndexModifier indexModifier = null; try { - indexWriter = new IndexWriter( indexLocation, getAnalyzer(), !exists() ); - } - catch ( IOException e ) - { - throw new RepositoryIndexException( "Unable to open index", e ); - } + indexModifier = new IndexModifier( indexLocation, indexHandlers.getAnalyzer(), !exists() ); + indexModifier.setMaxFieldLength( MAX_FIELD_LENGTH ); - try - { for ( Iterator i = records.iterator(); i.hasNext(); ) { - RepositoryIndexRecord record = (RepositoryIndexRecord) i.next(); + LuceneRepositoryContentRecord record = (LuceneRepositoryContentRecord) i.next(); if ( record != null ) { - Document document = converter.convert( record ); - document.add( - new Field( FLD_PK, record.getPrimaryKey(), Field.Store.NO, Field.Index.UN_TOKENIZED ) ); + Term term = new Term( LuceneDocumentMaker.PRIMARY_KEY, record.getPrimaryKey() ); - indexWriter.addDocument( document ); + indexModifier.deleteDocuments( term ); + + Document document = indexHandlers.getConverter().convert( record ); + + indexModifier.addDocument( document ); } } - - indexWriter.optimize(); + indexModifier.optimize(); } catch ( IOException e ) { - throw new RepositoryIndexException( "Failed to add an index document", e ); + throw new RepositoryIndexException( "Error updating index: " + e.getMessage(), e ); } finally { - closeQuietly( indexWriter ); - lastUpdatedTime = System.currentTimeMillis(); + closeQuietly( indexModifier ); } } - public static Analyzer getAnalyzer() + public void modifyRecord( LuceneRepositoryContentRecord record ) throws RepositoryIndexException { - return luceneAnalyzer; + IndexModifier indexModifier = null; + try + { + indexModifier = new IndexModifier( indexLocation, indexHandlers.getAnalyzer(), !exists() ); + indexModifier.setMaxFieldLength( MAX_FIELD_LENGTH ); + + if ( record != null ) + { + Term term = new Term( LuceneDocumentMaker.PRIMARY_KEY, record.getPrimaryKey() ); + + indexModifier.deleteDocuments( term ); + + Document document = indexHandlers.getConverter().convert( record ); + + indexModifier.addDocument( document ); + } + indexModifier.optimize(); + } + catch ( IOException e ) + { + throw new RepositoryIndexException( "Error updating index: " + e.getMessage(), e ); + } + finally + { + closeQuietly( indexModifier ); + } } - private static class LuceneAnalyzer - extends Analyzer + private void addRecords( Collection records ) throws RepositoryIndexException { - private static final Analyzer STANDARD = new StandardAnalyzer(); + IndexWriter indexWriter; + try + { + indexWriter = new IndexWriter( indexLocation, indexHandlers.getAnalyzer(), !exists() ); + indexWriter.setMaxFieldLength( MAX_FIELD_LENGTH ); + } + catch ( IOException e ) + { + throw new RepositoryIndexException( "Unable to open index", e ); + } - public TokenStream tokenStream( String field, final Reader reader ) + try { - // do not tokenize field called 'element' - if ( StandardIndexRecordFields.DEPENDENCIES.equals( field ) ) - { - return new CharTokenizer( reader ) - { - protected boolean isTokenChar( char c ) - { - return c != '\n'; - } - }; - } - else if ( StandardIndexRecordFields.FILES.equals( field ) ) - { - return new CharTokenizer( reader ) - { - protected boolean isTokenChar( char c ) - { - return c != '\n' && c != '/'; - } - }; - } - else - if ( StandardIndexRecordFields.CLASSES.equals( field ) || MinimalIndexRecordFields.CLASSES.equals( field ) ) + for ( Iterator i = records.iterator(); i.hasNext(); ) { - return new CharTokenizer( reader ) - { - protected boolean isTokenChar( char c ) - { - return c != '\n' && c != '.'; - } + LuceneRepositoryContentRecord record = (LuceneRepositoryContentRecord) i.next(); - protected char normalize( char c ) - { - return Character.toLowerCase( c ); - } - }; - } - else if ( StandardIndexRecordFields.GROUPID.equals( field ) ) - { - return new CharTokenizer( reader ) + if ( record != null ) { - protected boolean isTokenChar( char c ) - { - return c != '.'; - } + Document document = indexHandlers.getConverter().convert( record ); - protected char normalize( char c ) - { - return Character.toLowerCase( c ); - } - }; - } - else if ( StandardIndexRecordFields.VERSION.equals( field ) || - StandardIndexRecordFields.BASE_VERSION.equals( field ) ) - { - return new CharTokenizer( reader ) - { - protected boolean isTokenChar( char c ) - { - return c != '-'; - } - }; - } - else if ( StandardIndexRecordFields.FILENAME.equals( field ) || - MinimalIndexRecordFields.FILENAME.equals( field ) ) - { - return new CharTokenizer( reader ) - { - protected boolean isTokenChar( char c ) - { - return c != '-' && c != '.' && c != '/'; - } - }; - } - else - { - // use standard analyzer - return STANDARD.tokenStream( field, reader ); + indexWriter.addDocument( document ); + } } + + indexWriter.optimize(); + } + catch ( IOException e ) + { + throw new RepositoryIndexException( "Failed to add an index document", e ); + } + finally + { + closeQuietly( indexWriter ); } } - public void deleteRecords( Collection records ) - throws RepositoryIndexException + public void deleteRecords( Collection records ) throws RepositoryIndexException { if ( exists() ) { @@ -243,11 +191,11 @@ for ( Iterator i = records.iterator(); i.hasNext(); ) { - RepositoryIndexRecord record = (RepositoryIndexRecord) i.next(); + LuceneRepositoryContentRecord record = (LuceneRepositoryContentRecord) i.next(); if ( record != null ) { - Term term = new Term( FLD_PK, record.getPrimaryKey() ); + Term term = new Term( LuceneDocumentMaker.PRIMARY_KEY, record.getPrimaryKey() ); indexReader.deleteDocuments( term ); } @@ -264,20 +212,17 @@ } } - public Collection getAllRecords() - throws RepositoryIndexSearchException + public Collection getAllRecords() throws RepositoryIndexSearchException { return search( new LuceneQuery( new MatchAllDocsQuery() ) ); } - public Collection getAllRecordKeys() - throws RepositoryIndexException + public Collection getAllRecordKeys() throws RepositoryIndexException { - return getAllFieldValues( FLD_PK ); + return getAllFieldValues( LuceneDocumentMaker.PRIMARY_KEY ); } - private List getAllFieldValues( String fieldName ) - throws RepositoryIndexException + private List getAllFieldValues( String fieldName ) throws RepositoryIndexException { List keys = new ArrayList(); @@ -313,147 +258,65 @@ return keys; } - public void indexArtifacts( List artifacts, RepositoryIndexRecordFactory factory ) - throws RepositoryIndexException - { - IndexModifier indexModifier = null; - try - { - indexModifier = new IndexModifier( indexLocation, getAnalyzer(), !exists() ); - - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) - { - Artifact artifact = (Artifact) i.next(); - RepositoryIndexRecord record = factory.createRecord( artifact ); - - if ( record != null ) - { - Term term = new Term( FLD_PK, record.getPrimaryKey() ); - - indexModifier.deleteDocuments( term ); - - Document document = converter.convert( record ); - document.add( - new Field( FLD_PK, record.getPrimaryKey(), Field.Store.NO, Field.Index.UN_TOKENIZED ) ); - - indexModifier.addDocument( document ); - } - } - indexModifier.optimize(); - } - catch ( IOException e ) - { - throw new RepositoryIndexException( "Error updating index: " + e.getMessage(), e ); - } - finally - { - closeQuietly( indexModifier ); - lastUpdatedTime = System.currentTimeMillis(); - } - } - - public void indexArtifact( Artifact artifact, RepositoryIndexRecordFactory factory ) - throws RepositoryIndexException - { - IndexModifier indexModifier = null; - try - { - indexModifier = new IndexModifier( indexLocation, getAnalyzer(), !exists() ); - - RepositoryIndexRecord record = factory.createRecord( artifact ); - - if ( record != null ) - { - Term term = new Term( FLD_PK, record.getPrimaryKey() ); - - indexModifier.deleteDocuments( term ); - - Document document = converter.convert( record ); - document.add( new Field( FLD_PK, record.getPrimaryKey(), Field.Store.NO, Field.Index.UN_TOKENIZED ) ); - - indexModifier.addDocument( document ); - } - indexModifier.optimize(); - } - catch ( IOException e ) - { - throw new RepositoryIndexException( "Error updating index: " + e.getMessage(), e ); - } - finally - { - closeQuietly( indexModifier ); - lastUpdatedTime = System.currentTimeMillis(); - } - } - - public List getAllGroupIds() - throws RepositoryIndexException - { - return getAllFieldValues( StandardIndexRecordFields.GROUPID_EXACT ); - } - - public List getArtifactIds( String groupId ) - throws RepositoryIndexSearchException - { - return searchField( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ), - StandardIndexRecordFields.ARTIFACTID ); - } - - public List getVersions( String groupId, String artifactId ) - throws RepositoryIndexSearchException - { - BooleanQuery query = new BooleanQuery(); - query.add( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ), - BooleanClause.Occur.MUST ); - query.add( new TermQuery( new Term( StandardIndexRecordFields.ARTIFACTID_EXACT, artifactId ) ), - BooleanClause.Occur.MUST ); - - return searchField( query, StandardIndexRecordFields.VERSION ); - } +// public List getAllGroupIds() throws RepositoryIndexException +// { +// return getAllFieldValues( StandardIndexRecordFields.GROUPID_EXACT ); +// } +// +// public List getArtifactIds( String groupId ) throws RepositoryIndexSearchException +// { +// return searchField( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ), +// StandardIndexRecordFields.ARTIFACTID ); +// } +// +// public List getVersions( String groupId, String artifactId ) throws RepositoryIndexSearchException +// { +// BooleanQuery query = new BooleanQuery(); +// query.add( new TermQuery( new Term( StandardIndexRecordFields.GROUPID_EXACT, groupId ) ), +// BooleanClause.Occur.MUST ); +// query.add( new TermQuery( new Term( StandardIndexRecordFields.ARTIFACTID_EXACT, artifactId ) ), +// BooleanClause.Occur.MUST ); +// +// return searchField( query, StandardIndexRecordFields.VERSION ); +// } + +// private List searchField( org.apache.lucene.search.Query luceneQuery, String fieldName ) +// throws RepositoryIndexSearchException +// { +// Set results = new LinkedHashSet(); +// +// IndexSearcher searcher; +// try +// { +// searcher = new IndexSearcher( indexLocation.getAbsolutePath() ); +// } +// catch ( IOException e ) +// { +// throw new RepositoryIndexSearchException( "Unable to open index: " + e.getMessage(), e ); +// } +// +// try +// { +// Hits hits = searcher.search( luceneQuery ); +// for ( int i = 0; i < hits.length(); i++ ) +// { +// Document doc = hits.doc( i ); +// +// results.add( doc.get( fieldName ) ); +// } +// } +// catch ( IOException e ) +// { +// throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e ); +// } +// finally +// { +// closeQuietly( searcher ); +// } +// return new ArrayList( results ); +// } - public long getLastUpdatedTime() - { - return lastUpdatedTime; - } - - private List searchField( org.apache.lucene.search.Query luceneQuery, String fieldName ) - throws RepositoryIndexSearchException - { - Set results = new LinkedHashSet(); - - IndexSearcher searcher; - try - { - searcher = new IndexSearcher( indexLocation.getAbsolutePath() ); - } - catch ( IOException e ) - { - throw new RepositoryIndexSearchException( "Unable to open index: " + e.getMessage(), e ); - } - - try - { - Hits hits = searcher.search( luceneQuery ); - for ( int i = 0; i < hits.length(); i++ ) - { - Document doc = hits.doc( i ); - - results.add( doc.get( fieldName ) ); - } - } - catch ( IOException e ) - { - throw new RepositoryIndexSearchException( "Unable to search index: " + e.getMessage(), e ); - } - finally - { - closeQuietly( searcher ); - } - return new ArrayList( results ); - } - - public boolean exists() - throws RepositoryIndexException + public boolean exists() throws RepositoryIndexException { if ( IndexReader.indexExists( indexLocation ) ) { @@ -480,8 +343,7 @@ } } - public List search( Query query ) - throws RepositoryIndexSearchException + public List search( Query query ) throws RepositoryIndexSearchException { LuceneQuery lQuery = (LuceneQuery) query; @@ -505,7 +367,7 @@ { Document doc = hits.doc( i ); - records.add( converter.convert( doc ) ); + records.add( indexHandlers.getConverter().convert( doc ) ); } } catch ( IOException e ) @@ -523,7 +385,7 @@ return records; } - + private static void closeQuietly( IndexSearcher searcher ) { try @@ -539,8 +401,7 @@ } } - private static void closeQuietly( TermEnum terms ) - throws RepositoryIndexException + private static void closeQuietly( TermEnum terms ) throws RepositoryIndexException { if ( terms != null ) { @@ -555,8 +416,7 @@ } } - private static void closeQuietly( IndexWriter indexWriter ) - throws RepositoryIndexException + private static void closeQuietly( IndexWriter indexWriter ) throws RepositoryIndexException { try { @@ -600,5 +460,10 @@ { // ignore } + } + + public File getIndexDirectory() + { + return this.indexLocation; } }
Copied: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndexFactory.java (from r521491, maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryArtifactIndexFactory.java) URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndexFactory.java?view=diff&rev=525176&p1=maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryArtifactIndexFactory.java&r1=521491&p2=maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndexFactory.java&r2=525176 ============================================================================== --- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryArtifactIndexFactory.java (original) +++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentIndexFactory.java Tue Apr 3 08:21:33 2007 @@ -19,27 +19,81 @@ * under the License. */ -import org.apache.maven.archiva.indexer.RepositoryArtifactIndex; -import org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory; +import org.apache.maven.archiva.configuration.ArchivaConfiguration; +import org.apache.maven.archiva.configuration.RepositoryConfiguration; +import org.apache.maven.archiva.indexer.RepositoryContentIndex; +import org.apache.maven.archiva.indexer.RepositoryContentIndexFactory; +import org.apache.maven.archiva.indexer.bytecode.BytecodeHandlers; +import org.apache.maven.archiva.indexer.filecontent.FileContentHandlers; +import org.apache.maven.archiva.indexer.hashcodes.HashcodesHandlers; +import org.apache.maven.archiva.model.ArchivaRepository; import java.io.File; /** - * Factory for Lucene artifact index instances. + * Factory for Lucene repository content index instances. * * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a> - * @plexus.component role="org.apache.maven.archiva.indexer.RepositoryArtifactIndexFactory" role-hint="lucene" + * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a> + * + * @plexus.component role="org.apache.maven.archiva.indexer.RepositoryContentIndexFactory" role-hint="lucene" */ -public class LuceneRepositoryArtifactIndexFactory - implements RepositoryArtifactIndexFactory +public class LuceneRepositoryContentIndexFactory implements RepositoryContentIndexFactory { - public RepositoryArtifactIndex createStandardIndex( File indexPath ) + /** + * @plexus.requirement + */ + private ArchivaConfiguration configuration; + + public RepositoryContentIndex createBytecodeIndex( ArchivaRepository repository ) + { + File indexDir = toIndexDir( repository, "bytecode" ); + return new LuceneRepositoryContentIndex( indexDir, new BytecodeHandlers() ); + } + + public RepositoryContentIndex createFileContentIndex( ArchivaRepository repository ) + { + File indexDir = toIndexDir( repository, "filecontent" ); + return new LuceneRepositoryContentIndex( indexDir, new FileContentHandlers() ); + } + + public RepositoryContentIndex createHashcodeIndex( ArchivaRepository repository ) { - return new LuceneRepositoryArtifactIndex( indexPath, new LuceneStandardIndexRecordConverter() ); + File indexDir = toIndexDir( repository, "hashcodes" ); + return new LuceneRepositoryContentIndex( indexDir, new HashcodesHandlers() ); } - public RepositoryArtifactIndex createMinimalIndex( File indexPath ) + /** + * Obtain the index directory for the provided repository. + * + * @param repository the repository to obtain the index directory from. + * @param indexId the id of the index + * @return the directory to put the index into. + */ + private File toIndexDir( ArchivaRepository repository, String indexId ) { - return new LuceneRepositoryArtifactIndex( indexPath, new LuceneMinimalIndexRecordConverter() ); + if ( !repository.isManaged() ) + { + throw new IllegalArgumentException( "Only supports managed repositories." ); + } + + // Attempt to get the specified indexDir in the configuration first. + RepositoryConfiguration repoConfig = configuration.getConfiguration().findRepositoryById( repository.getId() ); + File indexDir; + + if ( repoConfig == null ) + { + // No configured index dir, use the repository path instead. + String repoPath = repository.getUrl().getPath(); + indexDir = new File( repoPath, ".index/" + indexId + "/" ); + } + else + { + // Use configured index dir. + String repoPath = repoConfig.getIndexDir(); + indexDir = new File( repoPath, "/" + indexId + "/" ); + } + + return indexDir; } } Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentRecord.java URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentRecord.java?view=auto&rev=525176 ============================================================================== --- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentRecord.java (added) +++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentRecord.java Tue Apr 3 08:21:33 2007 @@ -0,0 +1,35 @@ +package org.apache.maven.archiva.indexer.lucene; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * A repository content index record. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Brett Porter</a> + */ +public interface LuceneRepositoryContentRecord +{ + /** + * Get the primary key used to identify the record uniquely in the index. + * + * @return the primary key + */ + public String getPrimaryKey(); +} Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentRecord.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentRecord.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/LuceneRepositoryContentRecord.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/ClassnameTokenizer.java URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/ClassnameTokenizer.java?view=auto&rev=525176 ============================================================================== --- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/ClassnameTokenizer.java (added) +++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/ClassnameTokenizer.java Tue Apr 3 08:21:33 2007 @@ -0,0 +1,59 @@ +package org.apache.maven.archiva.indexer.lucene.analyzers; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.lucene.analysis.CharTokenizer; +import org.apache.maven.archiva.indexer.bytecode.BytecodeKeys; + +import java.io.Reader; + +/** + * Lucene Tokenizer for [EMAIL PROTECTED] BytecodeKeys#CLASSES} fields. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a> + * @version $Id$ + */ +public class ClassnameTokenizer extends CharTokenizer +{ + public ClassnameTokenizer( Reader reader ) + { + super( reader ); + } + + /** + * Determine Token Character. + * + * The field is a list of full classnames "com.foo.Object" seperated by + * newline characters. "\n". + * + * Identify newline "\n" and "." as the token delimiters. + */ + protected boolean isTokenChar( char c ) + { + return ( ( c != '\n' ) && ( c != '.' ) ); + } + + /* + protected char normalize( char c ) + { + return Character.toLowerCase( c ); + } + */ +} Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/ClassnameTokenizer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/ClassnameTokenizer.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/ClassnameTokenizer.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/FilenamesTokenizer.java URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/FilenamesTokenizer.java?view=auto&rev=525176 ============================================================================== --- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/FilenamesTokenizer.java (added) +++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/FilenamesTokenizer.java Tue Apr 3 08:21:33 2007 @@ -0,0 +1,52 @@ +package org.apache.maven.archiva.indexer.lucene.analyzers; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.lucene.analysis.CharTokenizer; +import org.apache.maven.archiva.indexer.bytecode.BytecodeKeys; + +import java.io.Reader; + +/** + * Lucene Tokenizer for [EMAIL PROTECTED] BytecodeKeys#FILES} fields. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a> + * @version $Id$ + */ +public class FilenamesTokenizer extends CharTokenizer +{ + public FilenamesTokenizer( Reader reader ) + { + super( reader ); + } + + /** + * Determine Token Character. + * + * The field is a list of full filenames "/home/archiva/foo/readme.txt" seperated by + * newline characters. "\n". + * + * Identify newline "\n" and "/" as the token delimiters. + */ + protected boolean isTokenChar( char c ) + { + return ( ( c != '\n' ) && ( c != '/' ) ); + } +} Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/FilenamesTokenizer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/FilenamesTokenizer.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/FilenamesTokenizer.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/GroupIdTokenizer.java URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/GroupIdTokenizer.java?view=auto&rev=525176 ============================================================================== --- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/GroupIdTokenizer.java (added) +++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/GroupIdTokenizer.java Tue Apr 3 08:21:33 2007 @@ -0,0 +1,52 @@ +package org.apache.maven.archiva.indexer.lucene.analyzers; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.lucene.analysis.CharTokenizer; +import org.apache.maven.archiva.indexer.ArtifactKeys; + +import java.io.Reader; + +/** + * Lucene Tokenizer for [EMAIL PROTECTED] ArtifactKeys#GROUPID} fields. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a> + * @version $Id$ + */ +public class GroupIdTokenizer extends CharTokenizer +{ + public GroupIdTokenizer( Reader reader ) + { + super( reader ); + } + + /** + * Determine Token Character. + * + * The field is a groupId "com.foo.project". + * + * Identify "." as the token delimiter. + */ + protected boolean isTokenChar( char c ) + { + return ( c != '.' ); + } + +} Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/GroupIdTokenizer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/GroupIdTokenizer.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/GroupIdTokenizer.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/VersionTokenizer.java URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/VersionTokenizer.java?view=auto&rev=525176 ============================================================================== --- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/VersionTokenizer.java (added) +++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/VersionTokenizer.java Tue Apr 3 08:21:33 2007 @@ -0,0 +1,51 @@ +package org.apache.maven.archiva.indexer.lucene.analyzers; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.lucene.analysis.CharTokenizer; +import org.apache.maven.archiva.indexer.ArtifactKeys; + +import java.io.Reader; + +/** + * Lucene Tokenizer for [EMAIL PROTECTED] ArtifactKeys#VERSION} fields. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Joakim Erdfelt</a> + * @version $Id$ + */ +public class VersionTokenizer extends CharTokenizer +{ + public VersionTokenizer( Reader reader ) + { + super( reader ); + } + + /** + * Determine Token Character. + * + * The field is a version id in the form "1.0-alpha-4-SNAPSHOT". + * + * Identify "-" as the token delimiter. + */ + protected boolean isTokenChar( char c ) + { + return ( c != '.' ) && ( c != '-' ); + } +} Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/VersionTokenizer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/VersionTokenizer.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/main/java/org/apache/maven/archiva/indexer/lucene/analyzers/VersionTokenizer.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/test/artifact-dumps/archiva-common-1.0.jar.txt URL: http://svn.apache.org/viewvc/maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/test/artifact-dumps/archiva-common-1.0.jar.txt?view=auto&rev=525176 ============================================================================== --- maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/test/artifact-dumps/archiva-common-1.0.jar.txt (added) +++ maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/test/artifact-dumps/archiva-common-1.0.jar.txt Tue Apr 3 08:21:33 2007 @@ -0,0 +1,56 @@ +FILENAME|archiva-common-1.0-SNAPSHOT.jar +SIZE|8516 +HASH_MD5|a5d0d280ce83133432d8fed8f2ce3474 +HASH_SHA1|c2635a1b38bd4520a6604664c04b2b3c32330864 +HASH_BYTECODE|2868f6661c55afda5a3b62859fbc8b1beb021b6e +JDK|1.4 +CLASS|org.apache.maven.archiva.common.ArchivaException +CLASS|org.apache.maven.archiva.common.utils.BaseFile +CLASS|org.apache.maven.archiva.common.utils.DateUtil +CLASS|org.apache.maven.archiva.common.utils.PathUtil +CLASS|org.apache.maven.archiva.common.utils.VersionUtil +METHOD|org.apache.maven.archiva.common.ArchivaException.<init>(Ljava/lang/String;Ljava/lang/Throwable;)V +METHOD|org.apache.maven.archiva.common.ArchivaException.<init>(Ljava/lang/String;)V +METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/io/File;)V +METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/io/File;Ljava/io/File;)V +METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/io/File;Ljava/lang/String;)V +METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/lang/String;)V +METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/lang/String;Ljava/io/File;)V +METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/lang/String;Ljava/lang/String;)V +METHOD|org.apache.maven.archiva.common.utils.BaseFile.<init>(Ljava/net/URI;)V +METHOD|org.apache.maven.archiva.common.utils.BaseFile.getBaseDir()Ljava/io/File; +METHOD|org.apache.maven.archiva.common.utils.BaseFile.getRelativePath()Ljava/lang/String; +METHOD|org.apache.maven.archiva.common.utils.BaseFile.setBaseDir(Ljava/io/File;)V +METHOD|org.apache.maven.archiva.common.utils.BaseFile.setBaseDir(Ljava/lang/String;)V +METHOD|org.apache.maven.archiva.common.utils.BaseFile.class$(Ljava/lang/String;)Ljava/lang/Class; +METHOD|org.apache.maven.archiva.common.utils.DateUtil.<init>()V +METHOD|org.apache.maven.archiva.common.utils.DateUtil.getDuration(J)Ljava/lang/String; +METHOD|org.apache.maven.archiva.common.utils.DateUtil.getDuration(JJ)Ljava/lang/String; +METHOD|org.apache.maven.archiva.common.utils.DateUtil.getDuration(Ljava/util/Date;Ljava/util/Date;)Ljava/lang/String; +METHOD|org.apache.maven.archiva.common.utils.DateUtil.getDuration(Ljava/util/Calendar;Ljava/util/Calendar;)Ljava/lang/String; +METHOD|org.apache.maven.archiva.common.utils.DateUtil.appendInterval(Ljava/lang/StringBuffer;ILjava/lang/String;)V +METHOD|org.apache.maven.archiva.common.utils.PathUtil.<init>()V +METHOD|org.apache.maven.archiva.common.utils.PathUtil.getRelative(Ljava/lang/String;Ljava/io/File;)Ljava/lang/String; +METHOD|org.apache.maven.archiva.common.utils.PathUtil.getRelative(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; +METHOD|org.apache.maven.archiva.common.utils.VersionUtil.<init>()V +METHOD|org.apache.maven.archiva.common.utils.VersionUtil.isSnapshot(Ljava/lang/String;)Z +METHOD|org.apache.maven.archiva.common.utils.VersionUtil.getBaseVersion(Ljava/lang/String;)Ljava/lang/String; +METHOD|org.apache.maven.archiva.common.utils.VersionUtil.<clinit>()V +FILE|META-INF/ +FILE|META-INF/MANIFEST.MF +FILE|META-INF/maven/ +FILE|META-INF/maven/org.apache.maven.archiva/ +FILE|META-INF/maven/org.apache.maven.archiva/archiva-common/ +FILE|META-INF/maven/org.apache.maven.archiva/archiva-common/pom.properties +FILE|META-INF/maven/org.apache.maven.archiva/archiva-common/pom.xml +FILE|org/ +FILE|org/apache/ +FILE|org/apache/maven/ +FILE|org/apache/maven/archiva/ +FILE|org/apache/maven/archiva/common/ +FILE|org/apache/maven/archiva/common/ArchivaException.class +FILE|org/apache/maven/archiva/common/utils/ +FILE|org/apache/maven/archiva/common/utils/BaseFile.class +FILE|org/apache/maven/archiva/common/utils/DateUtil.class +FILE|org/apache/maven/archiva/common/utils/PathUtil.class +FILE|org/apache/maven/archiva/common/utils/VersionUtil.class Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/test/artifact-dumps/archiva-common-1.0.jar.txt ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/archiva/branches/archiva-jpox-database-refactor/archiva-base/archiva-indexer/src/test/artifact-dumps/archiva-common-1.0.jar.txt ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision"