some webapp task completion

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@412341 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-06-07 09:22:10 +00:00
parent 9202e38f96
commit 7ccdd0eb09
6 changed files with 32 additions and 100 deletions

View File

@ -153,7 +153,7 @@ public class MetadataRepositoryIndex
{ {
doc.add( Field.Text( FLD_VERSION, "" ) ); doc.add( Field.Text( FLD_VERSION, "" ) );
} }
// TODO! do we need to add all these empty fields? // TODO: do we need to add all these empty fields?
doc.add( Field.Text( FLD_DOCTYPE, METADATA ) ); doc.add( Field.Text( FLD_DOCTYPE, METADATA ) );
doc.add( Field.Keyword( FLD_PACKAGING, "" ) ); doc.add( Field.Keyword( FLD_PACKAGING, "" ) );
doc.add( Field.Text( FLD_SHA1, "" ) ); doc.add( Field.Text( FLD_SHA1, "" ) );

View File

@ -140,7 +140,7 @@ public class PomRepositoryIndex
doc.add( Field.Text( FLD_PLUGINS_ALL, "" ) ); doc.add( Field.Text( FLD_PLUGINS_ALL, "" ) );
} }
doc.add( Field.UnIndexed( FLD_DOCTYPE, POM ) ); doc.add( Field.UnIndexed( FLD_DOCTYPE, POM ) );
// TODO! do we need to add all these empty fields? // TODO: do we need to add all these empty fields?
doc.add( Field.Text( FLD_PLUGINPREFIX, "" ) ); doc.add( Field.Text( FLD_PLUGINPREFIX, "" ) );
doc.add( Field.Text( FLD_LASTUPDATE, "" ) ); doc.add( Field.Text( FLD_LASTUPDATE, "" ) );
doc.add( Field.Text( FLD_NAME, "" ) ); doc.add( Field.Text( FLD_NAME, "" ) );

View File

@ -109,20 +109,6 @@ public class RepositoryBrowseAction
return SUCCESS; return SUCCESS;
} }
// TODO! is this method needed?
public String doEdit()
{
idx = idx + 1;
//set folder to "" if we are at the root directory
if ( idx == 1 )
{
folder = "";
}
return SUCCESS;
}
public Map getArtifactMap() public Map getArtifactMap()
{ {
return artifactMap; return artifactMap;

View File

@ -38,12 +38,14 @@ import java.io.File;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Properties; import java.util.Properties;
/** /**
* This is the class that executes the discoverer and indexer. * This is the class that executes the discoverer and indexer.
* *
* @plexus.component role="org.apache.maven.repository.manager.web.execution.DiscovererExecution" * @plexus.component role="org.apache.maven.repository.manager.web.execution.DiscovererExecution"
* @todo note that a legacy repository will fail due to lack of metadata discoverer
*/ */
public class DiscovererExecution public class DiscovererExecution
extends AbstractLogEnabled extends AbstractLogEnabled
@ -54,19 +56,14 @@ public class DiscovererExecution
private Configuration config; private Configuration config;
/** /**
* @plexus.requirement role-hint="default" * @plexus.requirement role="org.apache.maven.repository.discovery.ArtifactDiscoverer"
*/ */
private ArtifactDiscoverer defaultArtifactDiscoverer; private Map artifactDiscoverers;
/** /**
* @plexus.requirement role-hint="legacy" * @plexus.requirement role="org.apache.maven.repository.discovery.MetadataDiscoverer"
*/ */
private ArtifactDiscoverer legacyArtifactDiscoverer; private Map metadataDiscoverers;
/**
* @plexus.requirement role-hint="default"
*/
private MetadataDiscoverer defaultMetadataDiscoverer;
/** /**
* @plexus.requirement * @plexus.requirement
@ -78,18 +75,6 @@ public class DiscovererExecution
*/ */
private ArtifactRepositoryFactory repoFactory; private ArtifactRepositoryFactory repoFactory;
private ArtifactRepositoryLayout layout;
private String indexPath;
private String blacklistedPatterns;
private boolean includeSnapshots;
private boolean convertSnapshots;
private ArtifactRepository defaultRepository;
/** /**
* Executes discoverer and indexer if an index does not exist yet * Executes discoverer and indexer if an index does not exist yet
* *
@ -100,7 +85,7 @@ public class DiscovererExecution
throws MalformedURLException, RepositoryIndexException throws MalformedURLException, RepositoryIndexException
{ {
Properties props = config.getProperties(); Properties props = config.getProperties();
indexPath = props.getProperty( "index.path" ); String indexPath = props.getProperty( "index.path" );
File indexDir = new File( indexPath ); File indexDir = new File( indexPath );
boolean isExisting = false; boolean isExisting = false;
@ -123,68 +108,27 @@ public class DiscovererExecution
throws MalformedURLException, RepositoryIndexException throws MalformedURLException, RepositoryIndexException
{ {
Properties props = config.getProperties(); Properties props = config.getProperties();
indexPath = props.getProperty( "index.path" ); String indexPath = props.getProperty( "index.path" );
layout = config.getLayout(); String blacklistedPatterns = props.getProperty( "blacklist.patterns" );
blacklistedPatterns = props.getProperty( "blacklist.patterns" ); boolean includeSnapshots = Boolean.valueOf( props.getProperty( "include.snapshots" ) ).booleanValue();
includeSnapshots = Boolean.valueOf( props.getProperty( "include.snapshots" ) ).booleanValue(); boolean convertSnapshots = Boolean.valueOf( props.getProperty( "convert.snapshots" ) ).booleanValue();
convertSnapshots = Boolean.valueOf( props.getProperty( "convert.snapshots" ) ).booleanValue();
try ArtifactRepository defaultRepository = getDefaultRepository();
{
defaultRepository = getDefaultRepository();
}
catch ( MalformedURLException me )
{
getLogger().error( me.getMessage() );
}
getLogger().info( "[DiscovererExecution] Started discovery and indexing.." ); getLogger().info( "[DiscovererExecution] Started discovery and indexing.." );
if ( "default".equals( props.getProperty( "layout" ) ) ) String layoutProperty = props.getProperty( "layout" );
{ ArtifactDiscoverer discoverer = (ArtifactDiscoverer) artifactDiscoverers.get( layoutProperty );
executeDiscovererInDefaultRepo(); List artifacts = discoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, includeSnapshots );
}
else if ( "legacy".equals( props.getProperty( "layout" ) ) )
{
executeDiscovererInLegacyRepo();
}
getLogger().info( "[DiscovererExecution] Finished discovery and indexing." );
}
/**
* Method that discovers and indexes artifacts, poms and metadata in a default
* m2 repository structure.
*
* @throws MalformedURLException
* @throws RepositoryIndexException
* @todo why is this any different from legacy? [!]
*/
protected void executeDiscovererInDefaultRepo()
throws MalformedURLException, RepositoryIndexException
{
List artifacts =
defaultArtifactDiscoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, includeSnapshots );
indexArtifact( artifacts, indexPath, defaultRepository ); indexArtifact( artifacts, indexPath, defaultRepository );
List models = defaultArtifactDiscoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, List models = discoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, convertSnapshots );
convertSnapshots );
indexPom( models, indexPath, defaultRepository ); indexPom( models, indexPath, defaultRepository );
List metadataList = defaultMetadataDiscoverer.discoverMetadata( new File( defaultRepository MetadataDiscoverer metadataDiscoverer = (MetadataDiscoverer) metadataDiscoverers.get( layoutProperty );
.getBasedir() ), blacklistedPatterns ); List metadataList =
indexMetadata( metadataList, indexPath, new File( defaultRepository.getBasedir() ) ); metadataDiscoverer.discoverMetadata( new File( defaultRepository.getBasedir() ), blacklistedPatterns );
} indexMetadata( metadataList, indexPath, new File( defaultRepository.getBasedir() ), config.getLayout() );
getLogger().info( "[DiscovererExecution] Finished discovery and indexing." );
/**
* Method that discovers and indexes artifacts in a legacy type repository
*
* @throws RepositoryIndexException
*/
protected void executeDiscovererInLegacyRepo()
throws RepositoryIndexException
{
List artifacts =
legacyArtifactDiscoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, includeSnapshots );
indexArtifact( artifacts, indexPath, defaultRepository );
} }
/** /**
@ -218,12 +162,13 @@ public class DiscovererExecution
* @param indexPath the path to the index file * @param indexPath the path to the index file
* @param repositoryBase the repository where the metadata are located * @param repositoryBase the repository where the metadata are located
*/ */
protected void indexMetadata( List metadataList, String indexPath, File repositoryBase ) protected void indexMetadata( List metadataList, String indexPath, File repositoryBase,
ArtifactRepositoryLayout layout )
throws RepositoryIndexException, MalformedURLException throws RepositoryIndexException, MalformedURLException
{ {
String repoDir = repositoryBase.toURL().toString(); String repoDir = repositoryBase.toURL().toString();
ArtifactRepository repository = repoFactory ArtifactRepository repository =
.createArtifactRepository( "repository", repoDir, layout, null, null ); repoFactory.createArtifactRepository( "repository", repoDir, layout, null, null );
MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository ); MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository );
for ( Iterator iter = metadataList.iterator(); iter.hasNext(); ) for ( Iterator iter = metadataList.iterator(); iter.hasNext(); )

View File

@ -26,6 +26,8 @@ import java.util.Properties;
/** /**
* This class contains the configuration values to be used by the scheduler * 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 public class Configuration
implements Initializable implements Initializable
@ -63,6 +65,7 @@ public class Configuration
public ArtifactRepositoryLayout getLayout() public ArtifactRepositoryLayout getLayout()
{ {
// TODO: lookup from map [!]
ArtifactRepositoryLayout layout; ArtifactRepositoryLayout layout;
if ( "legacy".equals( props.getProperty( "layout" ) ) ) if ( "legacy".equals( props.getProperty( "layout" ) ) )
{ {

View File

@ -58,13 +58,11 @@ public class DiscovererJob
} }
catch ( RepositoryIndexException e ) catch ( RepositoryIndexException e )
{ {
// TODO! getLogger().error( "Error indexing: " + e.getMessage(), e );
e.printStackTrace();
} }
catch ( MalformedURLException me ) catch ( MalformedURLException me )
{ {
// TODO! getLogger().error( "Error indexing: " + me.getMessage(), me );
me.printStackTrace();
} }
getLogger().info( "[DiscovererJob] DiscovererJob has finished executing." ); getLogger().info( "[DiscovererJob] DiscovererJob has finished executing." );