diff --git a/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java index 5ac90a8ef..3d8bdea6b 100644 --- a/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java +++ b/maven-repository-configuration/src/main/java/org/apache/maven/repository/configuration/DefaultConfigurationStore.java @@ -87,7 +87,7 @@ public class DefaultConfigurationStore getLogger().info( "Reading configuration from " + file ); try { - configuration = reader.read( fileReader ); + configuration = reader.read( fileReader, false ); } catch ( IOException e ) { diff --git a/maven-repository-configuration/src/main/mdo/configuration.mdo b/maven-repository-configuration/src/main/mdo/configuration.mdo index 80583cab4..66ed605dd 100644 --- a/maven-repository-configuration/src/main/mdo/configuration.mdo +++ b/maven-repository-configuration/src/main/mdo/configuration.mdo @@ -17,24 +17,12 @@ 1.0.0 - repositoryDirectory + repositories 1.0.0 - String - true - - The location of the repository to monitor. - - - - repositoryLayout - 1.0.0 - String - true - - The layout of the repository. Valid values are "default" and "legacy". - - - default + + RepositoryConfiguration + * + indexPath @@ -69,14 +57,7 @@ 0 30 0/4 * * ? - discoverSnapshots - 1.0.0 - boolean - Whether to include snapshot versions in the discovery process - false - - - discoveryBlackListPatterns + globalBlackListPatterns 1.0.0 String Blacklisted patterns in the discovery process @@ -88,7 +69,126 @@ + + + + + RepositoryConfiguration + 1.0.0 + + + id + 1.0.0 + String + true + + The repository identifier. + + + + name + 1.0.0 + String + true + + The descriptive name of the repository. + + + + directory + 1.0.0 + String + true + + The location of the repository to monitor. + + + + layout + 1.0.0 + String + true + + The layout of the repository. Valid values are "default" and "legacy". + + + default + + + includeSnapshots + 1.0.0 + boolean + Whether to include snapshot versions in the discovery process + false + + + indexed + 1.0.0 + boolean + Whether to index the artifacts in this repository. + true + + + blackListPatterns + 1.0.0 + String + Blacklisted patterns in the discovery process + + + + + 1.0.0 + diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java b/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java index c71b219bb..c6e0b011f 100644 --- a/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java +++ b/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/ConfiguredRepositoryFactory.java @@ -18,6 +18,8 @@ package org.apache.maven.repository.configuration; import org.apache.maven.artifact.repository.ArtifactRepository; +import java.util.List; + /** * Create an artifact repository from the given configuration. * @@ -31,6 +33,15 @@ public interface ConfiguredRepositoryFactory * Create an artifact repository from the given configuration. * * @param configuration the configuration + * @return the artifact repository */ - ArtifactRepository createRepository( Configuration configuration ); + ArtifactRepository createRepository( RepositoryConfiguration configuration ); + + /** + * Create artifact repositories from the given configuration. + * + * @param configuration the configuration containing the repositories + * @return the artifact repositories + */ + List createRepositories( Configuration configuration ); } diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java b/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java index 5e41e308c..f69cc2aa0 100644 --- a/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java +++ b/maven-repository-core/src/main/java/org/apache/maven/repository/configuration/DefaultConfiguredRepositoryFactory.java @@ -21,6 +21,9 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; import java.util.Map; /** @@ -42,14 +45,25 @@ public class DefaultConfiguredRepositoryFactory */ private ArtifactRepositoryFactory repoFactory; - public ArtifactRepository createRepository( Configuration configuration ) + public ArtifactRepository createRepository( RepositoryConfiguration configuration ) { - File repositoryDirectory = new File( configuration.getRepositoryDirectory() ); + File repositoryDirectory = new File( configuration.getDirectory() ); String repoDir = repositoryDirectory.toURI().toString(); - ArtifactRepositoryLayout layout = - (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getRepositoryLayout() ); - // TODO: real ID + ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) repositoryLayouts.get( configuration.getLayout() ); + // TODO! real ID return repoFactory.createArtifactRepository( "test", repoDir, layout, null, null ); } + + public List createRepositories( Configuration configuration ) + { + List repositories = new ArrayList( configuration.getRepositories().size() ); + + for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); ) + { + repositories.add( createRepository( (RepositoryConfiguration) i.next() ) ); + } + + return repositories; + } } diff --git a/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/IndexerTask.java b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/IndexerTask.java index 720d0292b..abc2b761d 100644 --- a/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/IndexerTask.java +++ b/maven-repository-core/src/main/java/org/apache/maven/repository/scheduler/IndexerTask.java @@ -22,6 +22,7 @@ import org.apache.maven.repository.configuration.Configuration; import org.apache.maven.repository.configuration.ConfigurationStore; import org.apache.maven.repository.configuration.ConfigurationStoreException; import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory; +import org.apache.maven.repository.configuration.RepositoryConfiguration; import org.apache.maven.repository.discovery.ArtifactDiscoverer; import org.apache.maven.repository.discovery.DiscovererException; import org.apache.maven.repository.indexing.RepositoryArtifactIndex; @@ -99,19 +100,28 @@ public class IndexerTask try { - String blacklistedPatterns = configuration.getDiscoveryBlackListPatterns(); - boolean includeSnapshots = configuration.isDiscoverSnapshots(); - - ArtifactRepository defaultRepository = repoFactory.createRepository( configuration ); - - String layoutProperty = configuration.getRepositoryLayout(); - ArtifactDiscoverer discoverer = (ArtifactDiscoverer) artifactDiscoverers.get( layoutProperty ); - List artifacts = - discoverer.discoverArtifacts( defaultRepository, "indexer", blacklistedPatterns, includeSnapshots ); - if ( !artifacts.isEmpty() ) + for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); ) { - getLogger().info( "Indexing " + artifacts.size() + " new artifacts" ); - indexArtifact( artifacts, indexPath, defaultRepository ); + RepositoryConfiguration repositoryConfiguration = (RepositoryConfiguration) i.next(); + + if ( repositoryConfiguration.isIndexed() ) + { + // TODO! include global ones + String blacklistedPatterns = repositoryConfiguration.getBlackListPatterns(); + boolean includeSnapshots = repositoryConfiguration.isIncludeSnapshots(); + + ArtifactRepository repository = repoFactory.createRepository( repositoryConfiguration ); + + String layoutProperty = repositoryConfiguration.getLayout(); + ArtifactDiscoverer discoverer = (ArtifactDiscoverer) artifactDiscoverers.get( layoutProperty ); + List artifacts = + discoverer.discoverArtifacts( repository, "indexer", blacklistedPatterns, includeSnapshots ); + if ( !artifacts.isEmpty() ) + { + getLogger().info( "Indexing " + artifacts.size() + " new artifacts" ); + indexArtifact( artifacts, indexPath ); + } + } } } catch ( RepositoryIndexException e ) @@ -144,8 +154,7 @@ public class IndexerTask try { - ArtifactRepository repository = repoFactory.createRepository( configuration ); - RepositoryArtifactIndex artifactIndex = indexFactory.createStandardIndex( indexPath, repository ); + RepositoryArtifactIndex artifactIndex = indexFactory.createStandardIndex( indexPath ); if ( !artifactIndex.exists() ) { execute( configuration, indexPath ); @@ -157,10 +166,10 @@ public class IndexerTask } } - private void indexArtifact( List artifacts, File indexPath, ArtifactRepository repository ) + private void indexArtifact( List artifacts, File indexPath ) throws RepositoryIndexException { - RepositoryArtifactIndex artifactIndex = indexFactory.createStandardIndex( indexPath, repository ); + RepositoryArtifactIndex artifactIndex = indexFactory.createStandardIndex( indexPath ); List records = new ArrayList(); for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryArtifactIndexFactory.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryArtifactIndexFactory.java index 89ec2da27..ed0100527 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryArtifactIndexFactory.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/RepositoryArtifactIndexFactory.java @@ -16,8 +16,6 @@ package org.apache.maven.repository.indexing; * limitations under the License. */ -import org.apache.maven.artifact.repository.ArtifactRepository; - import java.io.File; /** @@ -35,18 +33,16 @@ public interface RepositoryArtifactIndexFactory /** * Method to create an instance of the standard index. * - * @param indexPath the path where the index will be created/updated - * @param repository the repository where the indexed artifacts are located + * @param indexPath the path where the index will be created/updated * @return the index instance */ - RepositoryArtifactIndex createStandardIndex( File indexPath, ArtifactRepository repository ); + RepositoryArtifactIndex createStandardIndex( File indexPath ); /** * Method to create an instance of the minimal index. * - * @param indexPath the path where the index will be created/updated - * @param repository the repository where the indexed artifacts are located + * @param indexPath the path where the index will be created/updated * @return the index instance */ - RepositoryArtifactIndex createMinimalIndex( File indexPath, ArtifactRepository repository ); + RepositoryArtifactIndex createMinimalIndex( File indexPath ); } diff --git a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/lucene/LuceneRepositoryArtifactIndexFactory.java b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/lucene/LuceneRepositoryArtifactIndexFactory.java index 828abcea4..97278b009 100644 --- a/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/lucene/LuceneRepositoryArtifactIndexFactory.java +++ b/maven-repository-indexer/src/main/java/org/apache/maven/repository/indexing/lucene/LuceneRepositoryArtifactIndexFactory.java @@ -16,7 +16,6 @@ package org.apache.maven.repository.indexing.lucene; * limitations under the License. */ -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.repository.indexing.RepositoryArtifactIndex; import org.apache.maven.repository.indexing.RepositoryArtifactIndexFactory; @@ -31,12 +30,12 @@ import java.io.File; public class LuceneRepositoryArtifactIndexFactory implements RepositoryArtifactIndexFactory { - public RepositoryArtifactIndex createStandardIndex( File indexPath, ArtifactRepository repository ) + public RepositoryArtifactIndex createStandardIndex( File indexPath ) { return new LuceneRepositoryArtifactIndex( indexPath, new LuceneStandardIndexRecordConverter() ); } - public RepositoryArtifactIndex createMinimalIndex( File indexPath, ArtifactRepository repository ) + public RepositoryArtifactIndex createMinimalIndex( File indexPath ) { return new LuceneRepositoryArtifactIndex( indexPath, new LuceneMinimalIndexRecordConverter() ); } diff --git a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneMinimalArtifactIndexSearchTest.java b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneMinimalArtifactIndexSearchTest.java index 9134764e3..63198db55 100644 --- a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneMinimalArtifactIndexSearchTest.java +++ b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneMinimalArtifactIndexSearchTest.java @@ -84,7 +84,7 @@ public class LuceneMinimalArtifactIndexSearchTest FileUtils.deleteDirectory( indexLocation ); - index = factory.createMinimalIndex( indexLocation, repository ); + index = factory.createMinimalIndex( indexLocation ); records.put( "test-jar", recordFactory.createRecord( createArtifact( "test-jar" ) ) ); records.put( "test-jar-jdk14", diff --git a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneMinimalArtifactIndexTest.java b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneMinimalArtifactIndexTest.java index 013913419..a08d181ac 100644 --- a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneMinimalArtifactIndexTest.java +++ b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneMinimalArtifactIndexTest.java @@ -89,7 +89,7 @@ public class LuceneMinimalArtifactIndexTest FileUtils.deleteDirectory( indexLocation ); - index = factory.createMinimalIndex( indexLocation, repository ); + index = factory.createMinimalIndex( indexLocation ); } public void testIndexExists() diff --git a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneStandardArtifactIndexSearchTest.java b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneStandardArtifactIndexSearchTest.java index f8062c2b9..19ff16439 100644 --- a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneStandardArtifactIndexSearchTest.java +++ b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneStandardArtifactIndexSearchTest.java @@ -87,7 +87,7 @@ public class LuceneStandardArtifactIndexSearchTest FileUtils.deleteDirectory( indexLocation ); - index = factory.createStandardIndex( indexLocation, repository ); + index = factory.createStandardIndex( indexLocation ); records.put( "test-jar", recordFactory.createRecord( createArtifact( "test-jar" ) ) ); records.put( "test-jar-jdk14", diff --git a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneStandardArtifactIndexTest.java b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneStandardArtifactIndexTest.java index c364f9514..4329dc452 100644 --- a/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneStandardArtifactIndexTest.java +++ b/maven-repository-indexer/src/test/java/org/apache/maven/repository/indexing/lucene/LuceneStandardArtifactIndexTest.java @@ -89,7 +89,7 @@ public class LuceneStandardArtifactIndexTest FileUtils.deleteDirectory( indexLocation ); - index = factory.createStandardIndex( indexLocation, repository ); + index = factory.createStandardIndex( indexLocation ); } public void testIndexExists() diff --git a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java index 8db790a5f..68ead8061 100644 --- a/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java +++ b/maven-repository-reports-standard/src/main/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessor.java @@ -64,7 +64,7 @@ public class DuplicateArtifactFileReportProcessor { if ( artifact.getFile() != null ) { - RepositoryArtifactIndex index = indexFactory.createStandardIndex( new File( indexDirectory ), repository ); + RepositoryArtifactIndex index = indexFactory.createStandardIndex( new File( indexDirectory ) ); String checksum; try diff --git a/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java b/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java index a97df8b78..ea8d3838d 100644 --- a/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java +++ b/maven-repository-reports-standard/src/test/java/org/apache/maven/repository/reporting/DuplicateArtifactFileReportProcessorTest.java @@ -61,7 +61,7 @@ public class DuplicateArtifactFileReportProcessorTest RepositoryArtifactIndexFactory factory = (RepositoryArtifactIndexFactory) lookup( RepositoryArtifactIndexFactory.ROLE, "lucene" ); - RepositoryArtifactIndex index = factory.createStandardIndex( indexDirectory, repository ); + RepositoryArtifactIndex index = factory.createStandardIndex( indexDirectory ); RepositoryIndexRecordFactory recordFactory = (RepositoryIndexRecordFactory) lookup( RepositoryIndexRecordFactory.ROLE, "standard" ); diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BrowseAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BrowseAction.java index 7b79accdd..ad7e9cbb5 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BrowseAction.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/BrowseAction.java @@ -22,7 +22,6 @@ import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.TermQuery; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.repository.configuration.Configuration; import org.apache.maven.repository.configuration.ConfigurationStore; import org.apache.maven.repository.configuration.ConfigurationStoreException; @@ -273,9 +272,7 @@ public class BrowseAction Configuration configuration = configurationStore.getConfigurationFromStore(); File indexPath = new File( configuration.getIndexPath() ); - ArtifactRepository repository = repositoryFactory.createRepository( configuration ); - - return factory.createStandardIndex( indexPath, repository ); + return factory.createStandardIndex( indexPath ); } public List getGroups() diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SearchAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SearchAction.java index 81d219139..d17b19349 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SearchAction.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/SearchAction.java @@ -22,7 +22,6 @@ import org.apache.lucene.index.Term; import org.apache.lucene.queryParser.MultiFieldQueryParser; import org.apache.lucene.queryParser.ParseException; import org.apache.lucene.search.TermQuery; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.repository.configuration.Configuration; import org.apache.maven.repository.configuration.ConfigurationStore; import org.apache.maven.repository.configuration.ConfigurationStoreException; @@ -147,9 +146,7 @@ public class SearchAction Configuration configuration = configurationStore.getConfigurationFromStore(); File indexPath = new File( configuration.getIndexPath() ); - ArtifactRepository repository = repositoryFactory.createRepository( configuration ); - - return factory.createStandardIndex( indexPath, repository ); + return factory.createStandardIndex( indexPath ); } public String doInput() diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/ShowArtifactAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/ShowArtifactAction.java index 745c575de..f2aff7093 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/ShowArtifactAction.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/ShowArtifactAction.java @@ -19,7 +19,6 @@ package org.apache.maven.repository.manager.web.action; import com.opensymphony.xwork.ActionSupport; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProjectBuilder; @@ -31,9 +30,8 @@ import org.apache.maven.repository.configuration.ConfiguredRepositoryFactory; import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import java.io.File; import java.io.IOException; -import java.util.Collections; +import java.util.List; /** * Browse the repository. @@ -74,9 +72,6 @@ public class ShowArtifactAction public String execute() throws ConfigurationStoreException, IOException, XmlPullParserException, ProjectBuildingException { - Configuration configuration = configurationStore.getConfigurationFromStore(); - ArtifactRepository repository = repositoryFactory.createRepository( configuration ); - if ( StringUtils.isEmpty( groupId ) ) { // TODO: i18n @@ -98,18 +93,12 @@ public class ShowArtifactAction return ERROR; } - Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, version ); - // TODO: is this going to be problematic because repository is remote format, but being used as local? - // TODO: should it try to use the repo manager as a remote repo, proxying out? - // TODO: maybe we can decouple the assembly parts of the project builder from the repository handling - MavenProject project = projectBuilder.buildFromRepository( artifact, Collections.EMPTY_LIST, repository ); + Configuration configuration = configurationStore.getConfigurationFromStore(); + List repositories = repositoryFactory.createRepositories( configuration ); - if ( !new File( repository.getBasedir(), repository.pathOf( artifact ) ).exists() ) - { - // TODO: i18n - addActionError( "The given artifact was not found in the repository" ); - return ERROR; - } + Artifact artifact = artifactFactory.createProjectArtifact( groupId, artifactId, version ); + // TODO: maybe we can decouple the assembly parts of the project builder from the repository handling to get rid of the temp repo + MavenProject project = projectBuilder.buildFromRepository( artifact, repositories, null ); model = project.getModel(); diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java index 2c4fd299e..5077365bb 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureAction.java @@ -26,7 +26,6 @@ import org.apache.maven.repository.configuration.ConfigurationStoreException; import org.apache.maven.repository.configuration.InvalidConfigurationException; import org.apache.maven.repository.indexing.RepositoryIndexException; import org.apache.maven.repository.indexing.RepositoryIndexSearchException; -import org.codehaus.plexus.util.StringUtils; import java.io.File; import java.io.IOException; @@ -55,33 +54,17 @@ public class ConfigureAction InvalidConfigurationException, ConfigurationChangeException { // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded + // TODO: if this is changed, do we move the index or recreate it? // Normalize the path - File file = new File( configuration.getRepositoryDirectory() ); - configuration.setRepositoryDirectory( file.getCanonicalPath() ); + File file = new File( configuration.getIndexPath() ); + configuration.setIndexPath( file.getCanonicalPath() ); if ( !file.exists() ) { file.mkdirs(); // TODO: error handling when this fails, or is not a directory } - // TODO: these defaults belong in the model. They shouldn't be stored here, as you want them to re-default - // should the repository change even if these didn't - - // TODO: if these are changed, do we move the index or recreate it? - - // TODO: these should be on an advanced configuration form, not the standard one - if ( StringUtils.isEmpty( configuration.getIndexPath() ) ) - { - configuration.setIndexPath( - new File( configuration.getRepositoryDirectory(), ".index" ).getAbsolutePath() ); - } - if ( StringUtils.isEmpty( configuration.getMinimalIndexPath() ) ) - { - configuration.setMinimalIndexPath( - new File( configuration.getRepositoryDirectory(), ".index-minimal" ).getAbsolutePath() ); - } - // Just double checking that our validation routines line up with what is expected in the configuration assert configuration.isValid(); @@ -94,7 +77,7 @@ public class ConfigureAction return SUCCESS; } - public String doInput() + public String input() { return INPUT; } diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureRepositoryAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureRepositoryAction.java new file mode 100644 index 000000000..7e889284f --- /dev/null +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureRepositoryAction.java @@ -0,0 +1,163 @@ +package org.apache.maven.repository.manager.web.action.admin; + +/* + * 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 com.opensymphony.webwork.interceptor.ParameterAware; +import com.opensymphony.xwork.ActionSupport; +import com.opensymphony.xwork.ModelDriven; +import com.opensymphony.xwork.Preparable; +import org.apache.maven.repository.configuration.Configuration; +import org.apache.maven.repository.configuration.ConfigurationChangeException; +import org.apache.maven.repository.configuration.ConfigurationStore; +import org.apache.maven.repository.configuration.ConfigurationStoreException; +import org.apache.maven.repository.configuration.InvalidConfigurationException; +import org.apache.maven.repository.configuration.RepositoryConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +/** + * Configures the application repositories. + * + * @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureRepositoryAction" + */ +public class ConfigureRepositoryAction + extends ActionSupport + implements ModelDriven, Preparable, ParameterAware +{ + /** + * @plexus.requirement + */ + private ConfigurationStore configurationStore; + + /** + * The repository. + */ + private RepositoryConfiguration repository; + + /** + * The repository ID to lookup when editing a repository. + */ + private String repoId; + + /** + * The previously read configuration. + */ + private Configuration configuration; + + public String add() + throws IOException, ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException + { + // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded + + RepositoryConfiguration existingRepository = configuration.getRepositoryById( repository.getId() ); + if ( existingRepository != null ) + { + addFieldError( "id", "A repository with that id already exists" ); + return INPUT; + } + + return addRepository(); + } + + public String edit() + throws IOException, ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException + { + // TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded + + RepositoryConfiguration existingRepository = configuration.getRepositoryById( repository.getId() ); + configuration.removeRepository( existingRepository ); + + return addRepository(); + } + + private String addRepository() + throws IOException, ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException + { + normalizeRepository(); + + // Just double checking that our validation routines line up with what is expected in the configuration + assert repository.isValid(); + + configuration.addRepository( repository ); + + configurationStore.storeConfiguration( configuration ); + + // TODO: do we need to check if indexing is needed? + + addActionMessage( "Successfully saved configuration" ); + + return SUCCESS; + } + + private void normalizeRepository() + throws IOException + { + // Normalize the path + File file = new File( repository.getDirectory() ); + repository.setDirectory( file.getCanonicalPath() ); + if ( !file.exists() ) + { + file.mkdirs(); + // TODO: error handling when this fails, or is not a directory + } + } + + public String input() + { + return INPUT; + } + + public Object getModel() + { + if ( repository == null ) + { + repository = configuration.getRepositoryById( repoId ); + } + if ( repository == null ) + { + repository = new RepositoryConfiguration(); + } + return repository; + } + + public void prepare() + throws ConfigurationStoreException + { + configuration = configurationStore.getConfigurationFromStore(); + } + + public String getRepoId() + { + return repoId; + } + + public void setRepoId( String repoId ) + { + this.repoId = repoId; + } + + public void setParameters( Map map ) + { + // TODO! can I replace with repository.id or something? + if ( map.containsKey( "repoId" ) ) + { + repoId = ( (String[]) map.get( "repoId" ) )[0]; + } + } +} diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/interceptor/ConfigurationInterceptor.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/interceptor/ConfigurationInterceptor.java index 2e332e3b0..37643516f 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/interceptor/ConfigurationInterceptor.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/interceptor/ConfigurationInterceptor.java @@ -43,7 +43,14 @@ public class ConfigurationInterceptor if ( !configuration.isValid() ) { - return "config-needed"; + if ( configuration.getRepositories().isEmpty() ) + { + return "config-repository-needed"; + } + else + { + return "config-needed"; + } } else { diff --git a/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureAction-validation.xml b/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureAction-validation.xml index 1a58a6aa8..60b774bc7 100644 --- a/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureAction-validation.xml +++ b/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureAction-validation.xml @@ -18,9 +18,9 @@ "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> - + - You must enter the repository directory. + You must enter the index directory. \ No newline at end of file diff --git a/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureRepositoryAction-validation.xml b/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureRepositoryAction-validation.xml new file mode 100644 index 000000000..0a1bb779d --- /dev/null +++ b/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureRepositoryAction-validation.xml @@ -0,0 +1,38 @@ + + + + + + + + + You must enter the repository identifier. + + + + + You must enter the repository name. + + + + + You must enter the repository directory. + + + + \ No newline at end of file diff --git a/maven-repository-webapp/src/main/resources/xwork.xml b/maven-repository-webapp/src/main/resources/xwork.xml index f28f30b59..cae7f2d5e 100644 --- a/maven-repository-webapp/src/main/resources/xwork.xml +++ b/maven-repository-webapp/src/main/resources/xwork.xml @@ -23,8 +23,7 @@ - - + @@ -38,9 +37,32 @@ - /admin/configure.action + + + /admin + configure + + + /admin + + addRepository!input + /WEB-INF/jsp/generalError.jsp + + + + + + + + + + + + + + /WEB-INF/jsp/quickSearch.jsp @@ -64,7 +86,6 @@ /WEB-INF/jsp/findArtifact.jsp /WEB-INF/jsp/noResults.jsp - /browse/${searchResults[0].groupId}/${searchResults[0].artifactId}/${searchResults[0].version} @@ -100,24 +121,35 @@ - - - + /WEB-INF/jsp/admin/index.jsp + + /WEB-INF/jsp/admin/addRepository.jsp + index + + + + + /WEB-INF/jsp/admin/editRepository.jsp + index + + /WEB-INF/jsp/admin/configure.jsp + /WEB-INF/jsp/admin/configure.jsp /WEB-INF/jsp/admin/index.jsp + - /admin/index.action + index diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/addRepository.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/addRepository.jsp new file mode 100644 index 000000000..82c470120 --- /dev/null +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/addRepository.jsp @@ -0,0 +1,43 @@ +<%-- + ~ 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. + --%> + +<%@ taglib prefix="ww" uri="/webwork" %> + + + + Configuration + + + + + +

Configuration

+ +
+ +

Add Managed Repository

+ + + + + <%@ include file="/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf" %> + + + +
+ + + \ No newline at end of file diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp index 557aea9e8..cc361e8da 100644 --- a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/configure.jsp @@ -27,14 +27,12 @@

Configuration

- + + + + + +
diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp new file mode 100644 index 000000000..9afd85681 --- /dev/null +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/editRepository.jsp @@ -0,0 +1,43 @@ +<%-- + ~ 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. + --%> + +<%@ taglib prefix="ww" uri="/webwork" %> + + + + Configuration + + + + + +

Configuration

+ +
+ +

Edit Managed Repository

+ + + + + <%@ include file="/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf" %> + + + +
+ + + \ No newline at end of file diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf new file mode 100644 index 000000000..bad4af44c --- /dev/null +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf @@ -0,0 +1,23 @@ +<%-- + ~ 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. + --%> +<%@ taglib prefix="ww" uri="/webwork" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> + + + +\#{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'} + + diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/index.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/index.jsp index e5a6ff118..34d7a033c 100644 --- a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/index.jsp +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/index.jsp @@ -15,6 +15,7 @@ --%> <%@ taglib prefix="ww" uri="/webwork" %> +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> @@ -28,11 +29,12 @@

Configuration

+ - + @@ -45,12 +47,82 @@ <%-- TODO: a "delete index and run now" operation should be here too (really clean, remove deletions that didn't get picked up) --%> - - - - -
Repository DirectoryIndex Directory - +
">Run Now
">Edit Configuration
+ +

+ ">Edit Configuration +

+ +

Managed Repositories

+ + + + There are no managed repositories configured yet. + + +
+
+ <%-- TODO! replace with icons --%> + ">Edit + Repository | Delete Repository + <%-- TODO! serious confirmation, implement, prompt whether to delete contents too, remember index --%> +
+

${repository.name}

+ + + + + + + + + + + + + + + + + + + + + + +
Identifier + <%-- TODO! must be unique among managed repos --%> + ${repository.id} +
Directory${repository.directory}
Type + + + Maven 2.x Repository + + + Maven 1.x Repository + + +
Snapshots Included + + NO + + + YES + +
Indexed + + NO + + + YES + +
+
+
+ +

+ ">Add Repository +

diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp index 988cdae83..7f98fcc1b 100644 --- a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/decorators/default.jsp @@ -108,7 +108,10 @@ Administration
  • - Configuration + Proxied Repositories +
  • +
  • + Synced Repositories
diff --git a/maven-repository-webapp/src/main/webapp/css/site.css b/maven-repository-webapp/src/main/webapp/css/site.css index 6ab3ec33e..98931b472 100644 --- a/maven-repository-webapp/src/main/webapp/css/site.css +++ b/maven-repository-webapp/src/main/webapp/css/site.css @@ -82,6 +82,12 @@ padding: 0.5em 1em 0.5em 1em; } +.statusWarn { + color: orange; + font-weight: bold; +} +*/ + .statusOk { color: green; font-weight: bold; @@ -92,12 +98,6 @@ font-weight: bold; } -.statusWarn { - color: orange; - font-weight: bold; -} -*/ - /* WebWork validation failures */ .errorMessage { color: red; @@ -107,9 +107,7 @@ .actionMessage { font-weight: bold; } -} - font-weight: bold; -} + sWarn { color: orange; font-weight: bold; @@ -124,3 +122,6 @@ sWarn { .actionMessage { font-weight: bold; } + + font-weight: bold; +}