From: Brett Porter Date: Wed, 7 Jun 2006 09:22:10 +0000 (+0000) Subject: some webapp task completion X-Git-Tag: archiva-0.9-alpha-1~838 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=7ccdd0eb093550a4e9dd5e5d746e6919ff126750;p=archiva.git some webapp task completion git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@412341 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java index ded2c30df..15ce02e84 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/MetadataRepositoryIndex.java @@ -153,7 +153,7 @@ public class MetadataRepositoryIndex { 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.Keyword( FLD_PACKAGING, "" ) ); doc.add( Field.Text( FLD_SHA1, "" ) ); diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/PomRepositoryIndex.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/PomRepositoryIndex.java index a911b83f8..b4f7260b0 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/PomRepositoryIndex.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/PomRepositoryIndex.java @@ -140,7 +140,7 @@ public class PomRepositoryIndex doc.add( Field.Text( FLD_PLUGINS_ALL, "" ) ); } 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_LASTUPDATE, "" ) ); doc.add( Field.Text( FLD_NAME, "" ) ); diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/RepositoryBrowseAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/RepositoryBrowseAction.java index 3315936c5..5b5031b72 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/RepositoryBrowseAction.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/RepositoryBrowseAction.java @@ -109,20 +109,6 @@ public class RepositoryBrowseAction 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() { return artifactMap; diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java index 4cce7a8ee..1c056e69d 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/execution/DiscovererExecution.java @@ -38,12 +38,14 @@ import java.io.File; 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. * * @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 extends AbstractLogEnabled @@ -54,19 +56,14 @@ public class DiscovererExecution 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; - - /** - * @plexus.requirement role-hint="default" - */ - private MetadataDiscoverer defaultMetadataDiscoverer; + private Map metadataDiscoverers; /** * @plexus.requirement @@ -78,18 +75,6 @@ public class DiscovererExecution */ 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 * @@ -100,7 +85,7 @@ public class DiscovererExecution throws MalformedURLException, RepositoryIndexException { Properties props = config.getProperties(); - indexPath = props.getProperty( "index.path" ); + String indexPath = props.getProperty( "index.path" ); File indexDir = new File( indexPath ); boolean isExisting = false; @@ -123,68 +108,27 @@ public class DiscovererExecution throws MalformedURLException, RepositoryIndexException { Properties props = config.getProperties(); - indexPath = props.getProperty( "index.path" ); - layout = config.getLayout(); - blacklistedPatterns = props.getProperty( "blacklist.patterns" ); - includeSnapshots = Boolean.valueOf( props.getProperty( "include.snapshots" ) ).booleanValue(); - convertSnapshots = Boolean.valueOf( props.getProperty( "convert.snapshots" ) ).booleanValue(); + 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(); - try - { - defaultRepository = getDefaultRepository(); - } - catch ( MalformedURLException me ) - { - getLogger().error( me.getMessage() ); - } + ArtifactRepository defaultRepository = getDefaultRepository(); getLogger().info( "[DiscovererExecution] Started discovery and indexing.." ); - if ( "default".equals( props.getProperty( "layout" ) ) ) - { - executeDiscovererInDefaultRepo(); - } - 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 ); + String layoutProperty = props.getProperty( "layout" ); + ArtifactDiscoverer discoverer = (ArtifactDiscoverer) artifactDiscoverers.get( layoutProperty ); + List artifacts = discoverer.discoverArtifacts( defaultRepository, blacklistedPatterns, includeSnapshots ); indexArtifact( artifacts, indexPath, defaultRepository ); - List models = defaultArtifactDiscoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, - convertSnapshots ); + List models = discoverer.discoverStandalonePoms( defaultRepository, blacklistedPatterns, convertSnapshots ); indexPom( models, indexPath, defaultRepository ); - List metadataList = defaultMetadataDiscoverer.discoverMetadata( new File( defaultRepository - .getBasedir() ), blacklistedPatterns ); - indexMetadata( metadataList, indexPath, new File( defaultRepository.getBasedir() ) ); - } - - /** - * 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 ); + MetadataDiscoverer metadataDiscoverer = (MetadataDiscoverer) metadataDiscoverers.get( layoutProperty ); + List metadataList = + metadataDiscoverer.discoverMetadata( new File( defaultRepository.getBasedir() ), blacklistedPatterns ); + indexMetadata( metadataList, indexPath, new File( defaultRepository.getBasedir() ), config.getLayout() ); + getLogger().info( "[DiscovererExecution] Finished discovery and indexing." ); } /** @@ -218,12 +162,13 @@ public class DiscovererExecution * @param indexPath the path to the index file * @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 { String repoDir = repositoryBase.toURL().toString(); - ArtifactRepository repository = repoFactory - .createArtifactRepository( "repository", repoDir, layout, null, null ); + ArtifactRepository repository = + repoFactory.createArtifactRepository( "repository", repoDir, layout, null, null ); MetadataRepositoryIndex metadataIndex = indexFactory.createMetadataRepositoryIndex( indexPath, repository ); for ( Iterator iter = metadataList.iterator(); iter.hasNext(); ) diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java index 0e147321c..0da84405d 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/Configuration.java @@ -26,6 +26,8 @@ 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 @@ -63,6 +65,7 @@ public class Configuration public ArtifactRepositoryLayout getLayout() { + // TODO: lookup from map [!] ArtifactRepositoryLayout layout; if ( "legacy".equals( props.getProperty( "layout" ) ) ) { diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererJob.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererJob.java index 9a93a115b..af350dced 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererJob.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/job/DiscovererJob.java @@ -58,13 +58,11 @@ public class DiscovererJob } catch ( RepositoryIndexException e ) { - // TODO! - e.printStackTrace(); + getLogger().error( "Error indexing: " + e.getMessage(), e ); } catch ( MalformedURLException me ) { - // TODO! - me.printStackTrace(); + getLogger().error( "Error indexing: " + me.getMessage(), me ); } getLogger().info( "[DiscovererJob] DiscovererJob has finished executing." );