Browse Source

[MRM-46] introduce modello configuration, change indexer API to use a File for the index path, introduce a core module for moving the main application logic to

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@412683 13f79535-47bb-0310-9956-ffa450edef68
tags/archiva-0.9-alpha-1
Brett Porter 18 years ago
parent
commit
86db5311d4
30 changed files with 265 additions and 302 deletions
  1. 1
    1
      maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexCli.java
  2. 1
    1
      maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexSearcherCli.java
  3. 40
    0
      maven-repository-configuration/pom.xml
  4. 82
    0
      maven-repository-configuration/src/main/mdo/configuration.mdo
  5. 20
    0
      maven-repository-core/pom.xml
  6. 7
    9
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndex.java
  7. 2
    1
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndex.java
  8. 1
    1
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexSearcher.java
  9. 5
    12
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexingFactory.java
  10. 2
    2
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java
  11. 2
    1
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java
  12. 1
    1
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/PomRepositoryIndex.java
  13. 2
    1
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java
  14. 5
    3
      maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexingFactory.java
  15. 5
    5
      maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java
  16. 5
    5
      maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/EclipseRepositoryIndexTest.java
  17. 2
    2
      maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/MetadataRepositoryIndexingTest.java
  18. 4
    4
      maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/PomRepositoryIndexingTest.java
  19. 2
    2
      maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayerTest.java
  20. 2
    2
      maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java
  21. 1
    1
      maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java
  22. 4
    0
      maven-repository-webapp/pom.xml
  23. 6
    2
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BaseAction.java
  24. 11
    7
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java
  25. 13
    9
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java
  26. 27
    54
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java
  27. 0
    99
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java
  28. 3
    32
      maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererScheduler.java
  29. 0
    41
      maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml
  30. 9
    4
      pom.xml

+ 1
- 1
maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexCli.java View File

@@ -69,7 +69,7 @@ public class IndexCli
List artifacts = discoverer.discoverArtifacts( repository, null, false );

ArtifactRepositoryIndex index =
indexFactory.createArtifactRepositoryIndex( new File( args[0], ".index" ).getAbsolutePath(), repository );
indexFactory.createArtifactRepositoryIndex( new File( args[0], ".index" ), repository );

long time = System.currentTimeMillis();
try

+ 1
- 1
maven-repository-application/src/main/java/org/apache/maven/repository/manager/cli/IndexSearcherCli.java View File

@@ -65,7 +65,7 @@ public class IndexSearcherCli
layout, null, null );

ArtifactRepositoryIndex index =
indexFactory.createArtifactRepositoryIndex( new File( args[0], ".index" ).getAbsolutePath(), repository );
indexFactory.createArtifactRepositoryIndex( new File( args[0], ".index" ), repository );

RepositoryIndexSearcher searcher = (RepositoryIndexSearcher) embedder.lookup( RepositoryIndexSearcher.ROLE );


+ 40
- 0
maven-repository-configuration/pom.xml View File

@@ -0,0 +1,40 @@
<?xml version="1.0"?>
<project>
<parent>
<artifactId>maven-repository-manager</artifactId>
<groupId>org.apache.maven.repository</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-configuration</artifactId>
<name>Maven Repository Manager Configuration</name>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
<version>1.0-alpha-8</version>
<executions>
<execution>
<goals>
<goal>xpp3-writer</goal>
<goal>java</goal>
<goal>xpp3-reader</goal>
</goals>
</execution>
</executions>
<configuration>
<version>1.0.0</version>
<model>src/main/mdo/configuration.mdo</model>
</configuration>
</plugin>
</plugins>
</build>
</project>

+ 82
- 0
maven-repository-configuration/src/main/mdo/configuration.mdo View File

@@ -0,0 +1,82 @@
<model>
<id>configuration</id>
<name>Configuration</name>
<description>
Configuration for the Maven Repository Manager.
</description>
<defaults>
<default>
<key>package</key>
<value>org.apache.maven.repository.configuration</value>
</default>
</defaults>
<!-- TODO! break out subtypes such as <discovery> and create a list of blacklist -->
<classes>
<class rootElement="true" xml.tagName="configuration">
<name>Configuration</name>
<version>1.0.0</version>
<fields>
<field>
<name>repositoryDirectory</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The location of the repository to monitor.
</description>
</field>
<field>
<name>repositoryLayout</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The layout of the repository. Valid values are "default" and "legacy".
</description>
<!-- TODO: should be able to detect this from the repository (perhaps by metadata at the root) -->
<defaultValue>default</defaultValue>
</field>
<field>
<name>indexPath</name>
<version>1.0.0</version>
<type>String</type>
<description>
The location of the Lucene index to use for the repository. The default is the .index subdirectory of
the repository.
</description>
</field>
<field>
<name>minimalIndexPath</name>
<version>1.0.0</version>
<type>String</type>
<description>
The location of the reduced Lucene index to use for the repository. The default is the .small-index
subdirectory of the repository.
</description>
</field>
<field>
<name>discoveryCronExpression</name>
<version>1.0.0</version>
<type>String</type>
<description>When to run the discovery mechanism.</description>
<defaultValue>0 0 8 * * ?</defaultValue>
</field>
<field>
<name>discoverSnapshots</name>
<version>1.0.0</version>
<type>boolean</type>
<description>Whether to include snapshot versions in the discovery process</description>
<defaultValue>false</defaultValue>
</field>
<field>
<name>discoveryBlackListPatterns</name>
<version>1.0.0</version>
<type>String</type>
<description>Blacklisted patterns in the discovery process</description>
</field>
</fields>
</class>
</classes>
</model>



+ 20
- 0
maven-repository-core/pom.xml View File

@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<project>
<parent>
<artifactId>maven-repository-manager</artifactId>
<groupId>org.apache.maven.repository</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-core</artifactId>
<name>Maven Repository Manager Core</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

+ 7
- 9
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/AbstractRepositoryIndex.java View File

@@ -41,7 +41,7 @@ public abstract class AbstractRepositoryIndex
implements RepositoryIndex
{
// TODO: can this be derived from the repository? -- probably a sensible default, but still should be configurable, but this could just be on the call to open()
private String indexPath;
private File indexPath;

private boolean indexOpen;

@@ -58,7 +58,7 @@ public abstract class AbstractRepositoryIndex
* @param indexPath
* @param repository
*/
protected AbstractRepositoryIndex( String indexPath, ArtifactRepository repository )
protected AbstractRepositoryIndex( File indexPath, ArtifactRepository repository )
{
this.repository = repository;
this.indexPath = indexPath;
@@ -144,7 +144,7 @@ public abstract class AbstractRepositoryIndex
/**
* @see org.apache.maven.repository.indexing.RepositoryIndex#getIndexPath()
*/
public String getIndexPath()
public File getIndexPath()
{
return indexPath;
}
@@ -244,19 +244,17 @@ public abstract class AbstractRepositoryIndex
protected boolean indexExists()
throws RepositoryIndexException
{
File indexDir = new File( indexPath );

if ( IndexReader.indexExists( indexDir ) )
if ( IndexReader.indexExists( indexPath ) )
{
return true;
}
else if ( !indexDir.exists() )
else if ( !indexPath.exists() )
{
return false;
}
else if ( indexDir.isDirectory() )
else if ( indexPath.isDirectory() )
{
if ( indexDir.listFiles().length > 1 )
if ( indexPath.listFiles().length > 1 )
{
throw new RepositoryIndexException( indexPath + " is not a valid index directory." );
}

+ 2
- 1
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndex.java View File

@@ -22,6 +22,7 @@ import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.repository.digest.Digester;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
@@ -48,7 +49,7 @@ public class ArtifactRepositoryIndex
* @param repository the repository where the indexed artifacts are located
* @param digester the digester object to generate the checksum strings
*/
public ArtifactRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester )
public ArtifactRepositoryIndex( File indexPath, ArtifactRepository repository, Digester digester )
{
super( indexPath, repository );
this.digester = digester;

+ 1
- 1
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexSearcher.java View File

@@ -78,7 +78,7 @@ public class DefaultRepositoryIndexSearcher
IndexSearcher searcher;
try
{
searcher = new IndexSearcher( index.getIndexPath() );
searcher = new IndexSearcher( index.getIndexPath().getAbsolutePath() );
}
catch ( IOException e )
{

+ 5
- 12
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/DefaultRepositoryIndexingFactory.java View File

@@ -20,6 +20,8 @@ import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.repository.digest.Digester;

import java.io.File;

/**
* @author Edwin Punzalan
* @plexus.component role="org.apache.maven.repository.indexing.RepositoryIndexingFactory"
@@ -37,28 +39,19 @@ public class DefaultRepositoryIndexingFactory
*/
private ArtifactFactory artifactFactory;

/**
* @see RepositoryIndexingFactory#createArtifactRepositoryIndex(String, org.apache.maven.artifact.repository.ArtifactRepository)
*/
public ArtifactRepositoryIndex createArtifactRepositoryIndex( String indexPath, ArtifactRepository repository )
public ArtifactRepositoryIndex createArtifactRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
return new ArtifactRepositoryIndex( indexPath, repository, digester );
}

/**
* @see RepositoryIndexingFactory#createPomRepositoryIndex(String, org.apache.maven.artifact.repository.ArtifactRepository)
*/
public PomRepositoryIndex createPomRepositoryIndex( String indexPath, ArtifactRepository repository )
public PomRepositoryIndex createPomRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
return new PomRepositoryIndex( indexPath, repository, digester, artifactFactory );
}

/**
* @see RepositoryIndexingFactory#createMetadataRepositoryIndex(String, org.apache.maven.artifact.repository.ArtifactRepository)
*/
public MetadataRepositoryIndex createMetadataRepositoryIndex( String indexPath, ArtifactRepository repository )
public MetadataRepositoryIndex createMetadataRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
return new MetadataRepositoryIndex( indexPath, repository );

+ 2
- 2
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/EclipseRepositoryIndex.java View File

@@ -68,7 +68,7 @@ public class EclipseRepositoryIndex
* @param repository the repository where the indexed artifacts are located
* @param digester the digester object to generate the checksum strings
*/
public EclipseRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester )
public EclipseRepositoryIndex( File indexPath, ArtifactRepository repository, Digester digester )
{
super( indexPath, repository );

@@ -169,7 +169,7 @@ public class EclipseRepositoryIndex
public File getCompressedCopy()
throws IOException
{
File indexPath = new File( getIndexPath() );
File indexPath = getIndexPath();
String name = indexPath.getName();

File outputFile = new File( indexPath.getParent(), name + ".zip" );

+ 2
- 1
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java View File

@@ -24,6 +24,7 @@ import org.apache.maven.artifact.repository.metadata.Plugin;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.artifact.repository.metadata.Versioning;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
@@ -40,7 +41,7 @@ public class MetadataRepositoryIndex
* @param indexPath the path to the index
* @param repository the repository where the metadata to be indexed is located
*/
public MetadataRepositoryIndex( String indexPath, ArtifactRepository repository )
public MetadataRepositoryIndex( File indexPath, ArtifactRepository repository )
{
super( indexPath, repository );
}

+ 1
- 1
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/PomRepositoryIndex.java View File

@@ -56,7 +56,7 @@ public class PomRepositoryIndex
* @param digester the digester to be used for generating checksums
* @param artifactFactory the factory for building artifact objects
*/
public PomRepositoryIndex( String indexPath, ArtifactRepository repository, Digester digester,
public PomRepositoryIndex( File indexPath, ArtifactRepository repository, Digester digester,
ArtifactFactory artifactFactory )
{
super( indexPath, repository );

+ 2
- 1
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndex.java View File

@@ -19,6 +19,7 @@ package org.apache.maven.repository.indexing;
import org.apache.lucene.analysis.Analyzer;
import org.apache.maven.artifact.repository.ArtifactRepository;

import java.io.File;
import java.util.Arrays;
import java.util.List;

@@ -113,7 +114,7 @@ public interface RepositoryIndex
*
* @return the path where the index resides
*/
String getIndexPath();
File getIndexPath();

/**
* Tests an index field if it is a keyword field

+ 5
- 3
maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryIndexingFactory.java View File

@@ -18,6 +18,8 @@ package org.apache.maven.repository.indexing;

import org.apache.maven.artifact.repository.ArtifactRepository;

import java.io.File;


/**
* @author Edwin Punzalan
@@ -34,7 +36,7 @@ public interface RepositoryIndexingFactory
* @return the ArtifactRepositoryIndex instance
* @throws RepositoryIndexException
*/
ArtifactRepositoryIndex createArtifactRepositoryIndex( String indexPath, ArtifactRepository repository )
ArtifactRepositoryIndex createArtifactRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException;

/**
@@ -45,7 +47,7 @@ public interface RepositoryIndexingFactory
* @return the PomRepositoryIndex instance
* @throws RepositoryIndexException
*/
PomRepositoryIndex createPomRepositoryIndex( String indexPath, ArtifactRepository repository )
PomRepositoryIndex createPomRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException;

/**
@@ -56,7 +58,7 @@ public interface RepositoryIndexingFactory
* @return the MetadataRepositoryIndex instance
* @throws RepositoryIndexException
*/
MetadataRepositoryIndex createMetadataRepositoryIndex( String indexPath, ArtifactRepository repository )
MetadataRepositoryIndex createMetadataRepositoryIndex( File indexPath, ArtifactRepository repository )
throws RepositoryIndexException;

}

+ 5
- 5
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/ArtifactRepositoryIndexingTest.java View File

@@ -43,7 +43,7 @@ public class ArtifactRepositoryIndexingTest

private ArtifactRepository repository;

private String indexPath;
private File indexPath;

private Digester digester;

@@ -59,7 +59,7 @@ public class ArtifactRepositoryIndexingTest
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
digester = new DefaultDigester();

indexPath = "target/index";
indexPath = getTestFile( "target/index" );
FileUtils.deleteDirectory( indexPath );
}

@@ -77,7 +77,7 @@ public class ArtifactRepositoryIndexingTest

try
{
String notIndexDir = new File( "pom.xml" ).getAbsolutePath();
File notIndexDir = new File( "pom.xml" );
ArtifactRepositoryIndex indexer = factory.createArtifactRepositoryIndex( notIndexDir, repository );
indexer.indexArtifact( artifact );
fail( "Must throw exception on non-directory index directory" );
@@ -89,7 +89,7 @@ public class ArtifactRepositoryIndexingTest

try
{
String notIndexDir = new File( "" ).getAbsolutePath();
File notIndexDir = new File( "" );
ArtifactRepositoryIndex indexer = factory.createArtifactRepositoryIndex( notIndexDir, repository );
indexer.indexArtifact( artifact );
fail( "Must throw an exception on a non-index directory" );
@@ -433,7 +433,7 @@ public class ArtifactRepositoryIndexingTest
assertTrue( true );
}

indexer = factory.createArtifactRepositoryIndex( "target/index/sample", repository );
indexer = factory.createArtifactRepositoryIndex( getTestFile( "target/index/sample" ), repository );

try
{

+ 5
- 5
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/EclipseRepositoryIndexTest.java View File

@@ -43,7 +43,7 @@ public class EclipseRepositoryIndexTest

private ArtifactRepository repository;

private String indexPath;
private File indexPath;

private Digester digester;

@@ -63,7 +63,7 @@ public class EclipseRepositoryIndexTest
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
digester = new DefaultDigester();

indexPath = "target/index";
indexPath = getTestFile( "target/index" );
FileUtils.deleteDirectory( indexPath );
}

@@ -125,7 +125,7 @@ public class EclipseRepositoryIndexTest

try
{
String notIndexDir = new File( "pom.xml" ).getAbsolutePath();
File notIndexDir = new File( "pom.xml" );
EclipseRepositoryIndex indexer = new EclipseRepositoryIndex( notIndexDir, repository, digester );
indexer.indexArtifact( artifact );
fail( "Must throw exception on non-directory index directory" );
@@ -137,7 +137,7 @@ public class EclipseRepositoryIndexTest

try
{
String notIndexDir = new File( "" ).getAbsolutePath();
File notIndexDir = new File( "" );
EclipseRepositoryIndex indexer = new EclipseRepositoryIndex( notIndexDir, repository, digester );
indexer.indexArtifact( artifact );
fail( "Must throw an exception on a non-index directory" );
@@ -169,7 +169,7 @@ public class EclipseRepositoryIndexTest
{
EclipseRepositoryIndex index = createTestIndex();

IndexSearcher searcher = new IndexSearcher( index.getIndexPath() );
IndexSearcher searcher = new IndexSearcher( index.getIndexPath().getAbsolutePath() );
try
{
QueryParser parser = new QueryParser( "j", index.getAnalyzer() );

+ 2
- 2
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/MetadataRepositoryIndexingTest.java View File

@@ -52,7 +52,7 @@ public class MetadataRepositoryIndexingTest
{
private ArtifactRepository repository;
private String indexPath;
private File indexPath;
private ArtifactFactory artifactFactory;
@@ -71,7 +71,7 @@ public class MetadataRepositoryIndexingTest
ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
indexPath = "target/index";
indexPath = getTestFile( "target/index" );
FileUtils.deleteDirectory( indexPath );
}

+ 4
- 4
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/PomRepositoryIndexingTest.java View File

@@ -48,7 +48,7 @@ public class PomRepositoryIndexingTest

private ArtifactFactory artifactFactory;

private String indexPath;
private File indexPath;

private Digester digester;

@@ -64,7 +64,7 @@ public class PomRepositoryIndexingTest
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
digester = new DefaultDigester();

indexPath = "target/index";
indexPath = getTestFile( "target/index" );
FileUtils.deleteDirectory( indexPath );
}

@@ -77,7 +77,7 @@ public class PomRepositoryIndexingTest

try
{
String notIndexDir = new File( "pom.xml" ).getAbsolutePath();
File notIndexDir = new File( "pom.xml" );
PomRepositoryIndex indexer = factory.createPomRepositoryIndex( notIndexDir, repository );
indexer.indexPom( pom );
fail( "Must throw exception on non-directory index directory" );
@@ -89,7 +89,7 @@ public class PomRepositoryIndexingTest

try
{
String notIndexDir = new File( "" ).getAbsolutePath();
File notIndexDir = new File( "" );
PomRepositoryIndex indexer = factory.createPomRepositoryIndex( notIndexDir, repository );
indexer.indexPom( pom );
fail( "Must throw an exception on a non-index directory" );

+ 2
- 2
maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/RepositoryIndexSearchLayerTest.java View File

@@ -54,7 +54,7 @@ public class RepositoryIndexSearchLayerTest
private ArtifactFactory artifactFactory;
private String indexPath;
private File indexPath;
/**
* Setup method
@@ -71,7 +71,7 @@ public class RepositoryIndexSearchLayerTest
ArtifactRepositoryFactory repoFactory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE );
repository = repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
indexPath = "target/index";
indexPath = getTestFile( "target/index" );
FileUtils.deleteDirectory( indexPath );
}

+ 2
- 2
maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java View File

@@ -68,8 +68,8 @@ public class DuplicateArtifactFileReportProcessor
{
if ( artifact.getFile() != null )
{
//@todo remove hard-coded value; current value enables tests to pass
String indexPath = new File( "target/.index" ).getAbsolutePath();
//@todo remove hard-coded value; current value enables tests to pass!
File indexPath = new File( "target/.index" );

RepositoryIndex index;
try

+ 1
- 1
maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java View File

@@ -41,7 +41,7 @@ public class DuplicateArtifactFileReportProcessorTest

private ArtifactFactory artifactFactory;

private String indexPath = new File( "target/.index" ).getAbsolutePath();
private File indexPath = getTestFile( "target/.index" );

protected void setUp()
throws Exception

+ 4
- 0
maven-repository-webapp/pom.xml View File

@@ -50,6 +50,10 @@
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-configuration</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-artifact-applet</artifactId>

+ 6
- 2
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BaseAction.java View File

@@ -17,9 +17,12 @@ package org.apache.maven.repository.manager.web.action;
*/
import com.opensymphony.xwork.Action;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.manager.web.execution.DiscovererExecution;
import org.apache.maven.repository.manager.web.job.DiscovererScheduler;
import java.io.File;
/**
* This is the Action class of index.jsp, which is the initial page of the web application.
* It invokes the DiscovererScheduler to set the DiscoverJob in the scheduler.
@@ -48,8 +51,9 @@ public class BaseAction
{
try
{
execution.executeDiscovererIfIndexDoesNotExist();
discovererScheduler.setSchedule();
Configuration configuration = new Configuration(); // TODO!
execution.executeDiscovererIfIndexDoesNotExist( new File( configuration.getIndexPath() ) );
discovererScheduler.setSchedule( configuration.getDiscoveryCronExpression() );
}
catch ( Exception e )
{

+ 11
- 7
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/GeneralSearchAction.java View File

@@ -19,16 +19,18 @@ package org.apache.maven.repository.manager.web.action;
import com.opensymphony.xwork.Action;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.apache.maven.repository.manager.web.job.Configuration;
import java.io.File;
import java.net.MalformedURLException;
import java.util.List;
import java.util.Map;
/**
* Searches for searchString in all indexed fields.
@@ -58,24 +60,26 @@ public class GeneralSearchAction
private ArtifactRepositoryFactory repositoryFactory;
/**
* @plexus.requirement
* @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
*/
private Configuration configuration;
private Map repositoryLayouts;
public String execute()
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException
{
if ( searchString != null && searchString.length() != 0 )
{
String indexPath = configuration.getIndexDirectory();
// TODO: reduce the amount of lookup?
Configuration configuration = new Configuration(); // TODO!
File indexPath = new File( configuration.getIndexPath() );
// TODO: [!] repository should only have been instantiated once
File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
String repoDir = repositoryDirectory.toURL().toString();
ArtifactRepositoryLayout layout =
(ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
ArtifactRepository repository =
repositoryFactory.createArtifactRepository( "test", repoDir, configuration.getLayout(), null, null );
repositoryFactory.createArtifactRepository( "test", repoDir, layout, null, null );
ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );

+ 13
- 9
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/PackageSearchAction.java View File

@@ -19,6 +19,8 @@ package org.apache.maven.repository.manager.web.action;
import com.opensymphony.xwork.Action;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndexException;
@@ -26,11 +28,11 @@ import org.apache.maven.repository.indexing.RepositoryIndexSearchException;
import org.apache.maven.repository.indexing.RepositoryIndexSearchLayer;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.apache.maven.repository.indexing.query.SinglePhraseQuery;
import org.apache.maven.repository.manager.web.job.Configuration;

import java.io.File;
import java.net.MalformedURLException;
import java.util.List;
import java.util.Map;

/**
* Search by package name.
@@ -53,19 +55,19 @@ public class PackageSearchAction
private RepositoryIndexingFactory factory;

/**
* @plexus.requirement
* @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
*/
private ArtifactRepositoryFactory repositoryFactory;
private Map repositoryLayouts;

/**
* @plexus.requirement
*/
private RepositoryIndexSearchLayer searchLayer;
private ArtifactRepositoryFactory repositoryFactory;

/**
* @plexus.requirement
*/
private Configuration configuration;
private RepositoryIndexSearchLayer searchLayer;

public String execute()
throws MalformedURLException, RepositoryIndexException, RepositoryIndexSearchException
@@ -87,15 +89,17 @@ public class PackageSearchAction
return ERROR;
}

// TODO: better config [!]
String indexPath = configuration.getIndexDirectory();
// TODO: better config - share with general [!]
Configuration configuration = new Configuration();
File indexPath = new File( configuration.getIndexPath() );

// TODO: reduce the amount of lookup?
File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
String repoDir = repositoryDirectory.toURL().toString();

ArtifactRepositoryLayout layout =
(ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
ArtifactRepository repository =
repositoryFactory.createArtifactRepository( "repository", repoDir, configuration.getLayout(), null, null );
repositoryFactory.createArtifactRepository( "repository", repoDir, layout, null, null );

ArtifactRepositoryIndex index = factory.createArtifactRepositoryIndex( indexPath, repository );


+ 27
- 54
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java View File

@@ -24,6 +24,7 @@ import org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
import org.apache.maven.model.Model;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.discovery.ArtifactDiscoverer;
import org.apache.maven.repository.discovery.MetadataDiscoverer;
import org.apache.maven.repository.indexing.ArtifactRepositoryIndex;
@@ -31,7 +32,6 @@ import org.apache.maven.repository.indexing.MetadataRepositoryIndex;
import org.apache.maven.repository.indexing.PomRepositoryIndex;
import org.apache.maven.repository.indexing.RepositoryIndexException;
import org.apache.maven.repository.indexing.RepositoryIndexingFactory;
import org.apache.maven.repository.manager.web.job.Configuration;
import org.codehaus.plexus.logging.AbstractLogEnabled;

import java.io.File;
@@ -39,7 +39,6 @@ import java.net.MalformedURLException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;

/**
* This is the class that executes the discoverer and indexer.
@@ -50,10 +49,6 @@ import java.util.Properties;
public class DiscovererExecution
extends AbstractLogEnabled
{
/**
* @plexus.requirement
*/
private Configuration config;

/**
* @plexus.requirement role="org.apache.maven.repository.discovery.ArtifactDiscoverer"
@@ -75,19 +70,21 @@ public class DiscovererExecution
*/
private ArtifactRepositoryFactory repoFactory;

/**
* @plexus.requirement role="org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout"
*/
private Map repositoryLayouts;

/**
* Executes discoverer and indexer if an index does not exist yet
*
* @param indexDir
* @throws MalformedURLException
* @throws RepositoryIndexException
*/
public void executeDiscovererIfIndexDoesNotExist()
public void executeDiscovererIfIndexDoesNotExist( File indexDir )
throws MalformedURLException, RepositoryIndexException
{
Properties props = config.getProperties();
String indexPath = props.getProperty( "index.path" );

File indexDir = new File( indexPath );
boolean isExisting = false;

if ( IndexReader.indexExists( indexDir ) )
@@ -107,27 +104,26 @@ public class DiscovererExecution
public void executeDiscoverer()
throws MalformedURLException, RepositoryIndexException
{
Properties props = config.getProperties();
String indexPath = props.getProperty( "index.path" );
String blacklistedPatterns = props.getProperty( "blacklist.patterns" );
boolean includeSnapshots = Boolean.valueOf( props.getProperty( "include.snapshots" ) ).booleanValue();
boolean convertSnapshots = Boolean.valueOf( props.getProperty( "convert.snapshots" ) ).booleanValue();
Configuration configuration = new Configuration(); // TODO!
File indexPath = new File( configuration.getIndexPath() );
String blacklistedPatterns = configuration.getDiscoveryBlackListPatterns();
boolean includeSnapshots = configuration.isDiscoverSnapshots();

ArtifactRepository defaultRepository = getDefaultRepository();
ArtifactRepository defaultRepository = getDefaultRepository( configuration );

getLogger().info( "[DiscovererExecution] Started discovery and indexing.." );
String layoutProperty = props.getProperty( "layout" );
String layoutProperty = configuration.getRepositoryLayout();
ArtifactDiscoverer discoverer = (ArtifactDiscoverer) artifactDiscoverers.get( layoutProperty );
List artifacts = discoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, includeSnapshots );
indexArtifact( artifacts, indexPath, defaultRepository );

List models = discoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, convertSnapshots );
List models = discoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, includeSnapshots );
indexPom( models, indexPath, defaultRepository );

MetadataDiscoverer metadataDiscoverer = (MetadataDiscoverer) metadataDiscoverers.get( layoutProperty );
List metadataList =
metadataDiscoverer.discoverMetadata( new File( defaultRepository.getBasedir() ), blacklistedPatterns );
indexMetadata( metadataList, indexPath, new File( defaultRepository.getBasedir() ), config.getLayout() );
indexMetadata( metadataList, indexPath, defaultRepository );
getLogger().info( "[DiscovererExecution] Finished discovery and indexing." );
}

@@ -138,7 +134,7 @@ public class DiscovererExecution
* @param indexPath the path to the index file
* @param repository the repository where the artifacts are located
*/
protected void indexArtifact( List artifacts, String indexPath, ArtifactRepository repository )
protected void indexArtifact( List artifacts, File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
ArtifactRepositoryIndex artifactIndex = indexFactory.createArtifactRepositoryIndex( indexPath, repository );
@@ -158,18 +154,12 @@ public class DiscovererExecution
/**
* Index the metadata in the list
*
* @param metadataList the metadata to be indexed
* @param indexPath the path to the index file
* @param repositoryBase the repository where the metadata are located
* @param metadataList the metadata to be indexed
* @param indexPath the path to the index file
*/
protected void indexMetadata( List metadataList, String indexPath, File repositoryBase,
ArtifactRepositoryLayout layout )
protected void indexMetadata( List metadataList, File indexPath, ArtifactRepository repository )
throws RepositoryIndexException, MalformedURLException
{
String repoDir = repositoryBase.toURL().toString();
ArtifactRepository repository =
repoFactory.createArtifactRepository( "repository", repoDir, layout, null, null );

MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository );
for ( Iterator iter = metadataList.iterator(); iter.hasNext(); )
{
@@ -191,7 +181,7 @@ public class DiscovererExecution
* @param indexPath the path to the index
* @param repository the artifact repository where the poms were discovered
*/
protected void indexPom( List models, String indexPath, ArtifactRepository repository )
protected void indexPom( List models, File indexPath, ArtifactRepository repository )
throws RepositoryIndexException
{
PomRepositoryIndex pomIndex = indexFactory.createPomRepositoryIndex( indexPath, repository );
@@ -214,33 +204,16 @@ public class DiscovererExecution
* @return an ArtifactRepository instance
* @throws java.net.MalformedURLException
*/
protected ArtifactRepository getDefaultRepository()
protected ArtifactRepository getDefaultRepository( Configuration configuration )
throws MalformedURLException
{
File repositoryDirectory = new File( config.getRepositoryDirectory() );
// TODO! share with general search action, should only instantiate once
File repositoryDirectory = new File( configuration.getRepositoryDirectory() );
String repoDir = repositoryDirectory.toURL().toString();
ArtifactRepositoryFactory repoFactory = new DefaultArtifactRepositoryFactory();

return repoFactory.createArtifactRepository( "test", repoDir, config.getLayout(), null, null );
}

/**
* Method that sets the configuration object
*
* @param config
*/
public void setConfiguration( Configuration config )
{
this.config = config;
}

/**
* Returns the cofiguration
*
* @return a Configuration object that contains the configuration values
*/
public Configuration getConfiguration()
{
return config;
ArtifactRepositoryLayout layout =
(ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() );
return repoFactory.createArtifactRepository( "test", repoDir, layout, null, null );
}
}

+ 0
- 99
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java View File

@@ -1,99 +0,0 @@
package org.apache.maven.repository.manager.web.job;
/*
* Copyright 2005-2006 The Apache Software Foundation.
*
* Licensed 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.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.artifact.repository.layout.LegacyRepositoryLayout;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import java.util.Properties;
/**
* This class contains the configuration values to be used by the scheduler
*
* @todo should not need to be initializable [!] Should have individual configuration items, and they could well be configured on the job itself, not in this class
*/
public class Configuration
implements Initializable
{
private Properties props;
/**
* @throws InitializationException
*/
public void initialize()
throws InitializationException
{
}
/**
* Set the properties object
*
* @param properties
*/
public void setProperties( Properties properties )
{
this.props = properties;
}
/**
* Returns the properties object
*
* @return a Properties object that contains the configuration values
*/
public Properties getProperties()
{
return props;
}
public ArtifactRepositoryLayout getLayout()
{
// TODO: lookup from map [!]
ArtifactRepositoryLayout layout;
if ( "legacy".equals( props.getProperty( "layout" ) ) )
{
layout = new LegacyRepositoryLayout();
}
else
{
layout = new DefaultRepositoryLayout();
}
return layout;
}
public String getIndexDirectory()
{
return props.getProperty( "index.path" );
}
public String getRepositoryDirectory()
{
String repositoryDir = "";
if ( "default".equals( props.getProperty( "layout" ) ) )
{
repositoryDir = props.getProperty( "default.repository.dir" );
}
else if ( "legacy".equals( props.getProperty( "layout" ) ) )
{
repositoryDir = props.getProperty( "legacy.repository.dir" );
}
return repositoryDir;
}
}

+ 3
- 32
maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererScheduler.java View File

@@ -26,7 +26,6 @@ import org.quartz.JobDetail;
import org.quartz.SchedulerException;
import java.text.ParseException;
import java.util.Properties;
/**
* This class sets the job to be executed in the plexus-quartz scheduler
@@ -36,11 +35,6 @@ import java.util.Properties;
public class DiscovererScheduler
extends AbstractLogEnabled
{
/**
* @plexus.requirement
*/
private Configuration config;
/**
* @plexus.requirement
*/
@@ -54,43 +48,20 @@ public class DiscovererScheduler
/**
* Method that sets the schedule in the plexus-quartz scheduler
*
* @param cronExpression
* @throws ParseException
* @throws SchedulerException
*/
public void setSchedule()
public void setSchedule( String cronExpression )
throws ParseException, SchedulerException
{
Properties props = config.getProperties();
JobDetail jobDetail = new JobDetail( "discovererJob", "DISCOVERER", DiscovererJob.class );
JobDataMap dataMap = new JobDataMap();
dataMap.put( AbstractJob.LOGGER, getLogger() );
dataMap.put( DiscovererJob.MAP_DISCOVERER_EXECUTION, execution );
jobDetail.setJobDataMap( dataMap );
CronTrigger trigger =
new CronTrigger( "DiscovererTrigger", "DISCOVERER", props.getProperty( "cron.expression" ) );
CronTrigger trigger = new CronTrigger( "DiscovererTrigger", "DISCOVERER", cronExpression );
scheduler.scheduleJob( jobDetail, trigger );
}
/**
* Method that sets the configuration object
*
* @param config
*/
public void setConfiguration( Configuration config )
{
this.config = config;
}
/**
* Returns the cofiguration
*
* @return a Configuration object that contains the configuration values
*/
public Configuration getConfiguration()
{
return config;
}
}

+ 0
- 41
maven-repository-webapp/src/main/webapp/WEB-INF/plexus.xml View File

@@ -41,47 +41,6 @@
<implementation>org.codehaus.plexus.xwork.PlexusObjectFactory</implementation>
</component>

<component>
<role>org.apache.maven.repository.manager.web.job.Configuration</role>
<implementation>org.apache.maven.repository.manager.web.job.Configuration</implementation>
<configuration>
<properties>
<property>
<name>layout</name>
<value>default</value>
</property>
<property>
<name>default.repository.dir</name>
<value>C:/TEST_REPOS/.m2/repository/</value>
</property>
<property>
<name>legacy.repository.dir</name>
<value>C:/TEST_REPOS/.maven/repository/</value>
</property>
<property>
<name>index.path</name>
<value>C:/INDEX</value>
</property>
<property>
<name>cron.expression</name>
<value>0 0 8 * * ?</value>
</property>
<property>
<name>blacklist.patterns</name>
<value>null</value>
</property>
<property>
<name>include.snapshots</name>
<value>true</value>
</property>
<property>
<name>convert.snapshots</name>
<value>true</value>
</property>
</properties>
</configuration>
</component>

<!--
| Logger manager
-->

+ 9
- 4
pom.xml View File

@@ -14,9 +14,7 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven</groupId>
@@ -120,6 +118,8 @@
<module>maven-repository-webapp</module>
<module>maven-repository-proxy</module>
<module>maven-repository-manager-site</module>
<module>maven-repository-core</module>
<module>maven-repository-configuration</module>
</modules>
<dependencies>
<dependency>
@@ -211,6 +211,11 @@
<artifactId>maven-repository-artifact-applet</artifactId>
<version>${pom.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.repository</groupId>
<artifactId>maven-repository-configuration</artifactId>
<version>${pom.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<reporting>
@@ -329,4 +334,4 @@
</build>
</profile>
</profiles>
</project>
</project>

Loading…
Cancel
Save