[MRM-138] add multiple repositories and new configuration pages

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@428659 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-08-04 08:39:03 +00:00
parent 7a20631525
commit c65e5768a5
29 changed files with 666 additions and 148 deletions

View File

@ -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 )
{

View File

@ -17,24 +17,12 @@
<version>1.0.0</version>
<fields>
<field>
<name>repositoryDirectory</name>
<name>repositories</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>
<association>
<type>RepositoryConfiguration</type>
<multiplicity>*</multiplicity>
</association>
</field>
<field>
<name>indexPath</name>
@ -69,14 +57,7 @@
<defaultValue>0 30 0/4 * * ?</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>
<name>globalBlackListPatterns</name>
<version>1.0.0</version>
<type>String</type>
<description>Blacklisted patterns in the discovery process</description>
@ -88,7 +69,126 @@
<code><![CDATA[
public boolean isValid()
{
return indexPath != null & repositoryDirectory != null;
boolean valid = true;
if ( indexPath == null )
{
valid = false;
}
else if ( getRepositories().isEmpty() )
{
valid = false;
}
else
{
for ( java.util.Iterator i = repositories.iterator(); i.hasNext() && valid; )
{
RepositoryConfiguration repository = (RepositoryConfiguration) i.next();
valid = repository.isValid();
}
}
return valid;
}
public RepositoryConfiguration getRepositoryById( String id )
{
for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )
{
RepositoryConfiguration repository = (RepositoryConfiguration) i.next();
if ( repository.getId().equals( id ) )
{
return repository;
}
}
return null;
}
]]></code>
</codeSegment>
</codeSegments>
</class>
<class>
<name>RepositoryConfiguration</name>
<version>1.0.0</version>
<fields>
<field>
<name>id</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The repository identifier.
</description>
</field>
<field>
<name>name</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The descriptive name of the repository.
</description>
</field>
<field>
<name>directory</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The location of the repository to monitor.
</description>
</field>
<field>
<name>layout</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>includeSnapshots</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>indexed</name>
<version>1.0.0</version>
<type>boolean</type>
<description>Whether to index the artifacts in this repository.</description>
<defaultValue>true</defaultValue>
</field>
<field>
<name>blackListPatterns</name>
<version>1.0.0</version>
<type>String</type>
<description>Blacklisted patterns in the discovery process</description>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0</version>
<code><![CDATA[
public RepositoryConfiguration()
{
this.indexed = false; // for webwork
}
public boolean isValid()
{
boolean valid = true;
if ( directory == null )
{
valid = false;
}
return valid;
}
]]></code>
</codeSegment>

View File

@ -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 );
}

View File

@ -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;
}
}

View File

@ -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(); )
{

View File

@ -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 );
}

View File

@ -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() );
}

View File

@ -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",

View File

@ -89,7 +89,7 @@ public class LuceneMinimalArtifactIndexTest
FileUtils.deleteDirectory( indexLocation );
index = factory.createMinimalIndex( indexLocation, repository );
index = factory.createMinimalIndex( indexLocation );
}
public void testIndexExists()

View File

@ -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",

View File

@ -89,7 +89,7 @@ public class LuceneStandardArtifactIndexTest
FileUtils.deleteDirectory( indexLocation );
index = factory.createStandardIndex( indexLocation, repository );
index = factory.createStandardIndex( indexLocation );
}
public void testIndexExists()

View File

@ -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

View File

@ -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" );

View File

@ -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()

View File

@ -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()

View File

@ -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();

View File

@ -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;
}

View File

@ -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];
}
}
}

View File

@ -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
{

View File

@ -18,9 +18,9 @@
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
<field name="repositoryDirectory">
<field name="indexPath">
<field-validator type="requiredstring">
<message>You must enter the repository directory.</message>
<message>You must enter the index directory.</message>
</field-validator>
</field>
</validators>

View File

@ -0,0 +1,38 @@
<!--
~ 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.
-->
<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
"http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd">
<validators>
<!-- TODO: constrain more -->
<field name="id">
<field-validator type="requiredstring">
<message>You must enter the repository identifier.</message>
</field-validator>
</field>
<field name="name">
<field-validator type="requiredstring">
<message>You must enter the repository name.</message>
</field-validator>
</field>
<field name="directory">
<field-validator type="requiredstring">
<message>You must enter the repository directory.</message>
</field-validator>
</field>
<!-- TODO: validate layout -->
</validators>

View File

@ -23,8 +23,7 @@
<!-- Include webwork defaults (from WebWork JAR). -->
<include file="webwork-default.xml"/>
<!-- Configuration for the default package. -->
<package name="default" extends="webwork-default" namespace="/">
<package name="base" extends="webwork-default">
<interceptors>
<interceptor name="configuration" class="configurationInterceptor"/>
<interceptor-stack name="configuredStack">
@ -38,9 +37,32 @@
<global-results>
<!-- TODO: might want an extra message on the configure page when this first happens -->
<result name="config-needed" type="redirect">/admin/configure.action</result>
<!-- TODO: can we send them back to the original location afterwards? -->
<result name="config-needed" type="redirect-action">
<param name="namespace">/admin</param>
<param name="actionName">configure</param>
</result>
<result name="config-repository-needed" type="redirect-action">
<param name="namespace">/admin</param>
<!-- TODO should use param name=method, but WW 2.2.2 doesn't recognise it -->
<param name="actionName">addRepository!input</param>
</result>
<result name="error">/WEB-INF/jsp/generalError.jsp</result>
</global-results>
</package>
<!-- Configuration for the default package. -->
<package name="default" extends="base" namespace="/">
<interceptors>
<interceptor name="configuration" class="configurationInterceptor"/>
<interceptor-stack name="configuredStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="configuration"/>
</interceptor-stack>
</interceptors>
<!-- Default interceptor stack. -->
<default-interceptor-ref name="configuredStack"/>
<action name="index" class="searchAction" method="input">
<result name="input">/WEB-INF/jsp/quickSearch.jsp</result>
@ -64,7 +86,6 @@
<result name="error">/WEB-INF/jsp/findArtifact.jsp</result>
<result name="noResults">/WEB-INF/jsp/noResults.jsp</result>
<!-- TODO! -->
<!-- TODO! use redirect-action instead -->
<result name="artifact" type="redirect">
/browse/${searchResults[0].groupId}/${searchResults[0].artifactId}/${searchResults[0].version}
</result>
@ -100,24 +121,35 @@
</package>
<!-- Configuration for the admin package. -->
<package name="admin" namespace="/admin" extends="webwork-default">
<default-interceptor-ref name="defaultStack"/>
<package name="admin" namespace="/admin" extends="base">
<action name="index" class="configureAction" method="input">
<result name="input">/WEB-INF/jsp/admin/index.jsp</result>
</action>
<action name="addRepository" class="configureRepositoryAction" method="add">
<result name="input">/WEB-INF/jsp/admin/addRepository.jsp</result>
<result type="redirect-action">index</result>
<interceptor-ref name="defaultStack"/>
</action>
<action name="editRepository" class="configureRepositoryAction" method="edit">
<result name="input">/WEB-INF/jsp/admin/editRepository.jsp</result>
<result type="redirect-action">index</result>
</action>
<action name="configure" class="configureAction" method="input">
<result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
<interceptor-ref name="defaultStack"/>
</action>
<action name="saveConfiguration" class="configureAction">
<result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
<result>/WEB-INF/jsp/admin/index.jsp</result>
<interceptor-ref name="defaultStack"/>
</action>
<action name="runIndexer" class="runIndexerAction">
<result type="redirect">/admin/index.action</result>
<result type="redirect-action">index</result>
</action>
</package>
</xwork>

View File

@ -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" %>
<html>
<head>
<title>Configuration</title>
<ww:head />
</head>
<body>
<h1>Configuration</h1>
<div id="contentArea">
<h2>Add Managed Repository</h2>
<ww:actionmessage />
<ww:form method="post" action="addRepository" namespace="/admin" validate="true">
<ww:textfield name="id" label="Identifier" size="10" />
<%@ include file="/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf" %>
<ww:checkbox name="indexed" fieldValue="true" value="true" label="Indexed" />
<ww:submit value="Add Repository" />
</ww:form>
</div>
</body>
</html>

View File

@ -27,14 +27,12 @@
<h1>Configuration</h1>
<div id="contentArea">
<div id="searchBox">
<ww:actionmessage />
<ww:form method="post" action="saveConfiguration" namespace="/admin" validate="true">
<ww:textfield name="repositoryDirectory" label="Repository Directory" size="100" />
<ww:textfield name="indexerCronExpression" label="Indexing Cron Expression" />
<ww:submit value="Save Configuration" />
</ww:form>
</div>
<ww:actionmessage />
<ww:form method="post" action="saveConfiguration" namespace="/admin" validate="true">
<ww:textfield name="indexPath" label="Index Directory" size="100" />
<ww:textfield name="indexerCronExpression" label="Indexing Schedule" />
<ww:submit value="Save Configuration" />
</ww:form>
</div>
</body>

View File

@ -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" %>
<html>
<head>
<title>Configuration</title>
<ww:head />
</head>
<body>
<h1>Configuration</h1>
<div id="contentArea">
<h2>Edit Managed Repository</h2>
<ww:actionmessage />
<ww:form method="post" action="editRepository" namespace="/admin" validate="true">
<ww:hidden name="id" />
<%@ include file="/WEB-INF/jsp/admin/include/managedRepositoryForm.jspf" %>
<ww:checkbox name="indexed" fieldValue="true" label="Indexed" />
<ww:submit value="Change Repository" />
</ww:form>
</div>
</body>
</html>

View File

@ -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" %>
<ww:textfield name="name" label="Name" size="50" />
<ww:textfield name="directory" label="Directory" size="100" />
<c:set var="list">\#{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}</c:set>
<ww:select list="${list}" name="layout" label="Type" />
<ww:checkbox name="includeSnapshots" fieldValue="true" label="Snapshots Included" />

View File

@ -15,6 +15,7 @@
--%>
<%@ taglib prefix="ww" uri="/webwork" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
@ -28,11 +29,12 @@
<div id="contentArea">
<h2>Configuration</h2>
<table>
<tr>
<th>Repository Directory</th>
<th>Index Directory</th>
<td>
<ww:property value="repositoryDirectory" />
<ww:property value="indexPath" />
</td>
<td></td>
</tr>
@ -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) --%>
<td><a href="<ww:url action="runIndexer" />">Run Now</a></td>
</tr>
<tr>
<td><a href="<ww:url action="configure" />">Edit Configuration</a></td>
<td></td>
<td></td>
</tr>
</table>
<p>
<a href="<ww:url action="configure" />">Edit Configuration</a>
</p>
<h2>Managed Repositories</h2>
<ww:set name="repositories" value="repositories" />
<c:if test="${empty(repositories)}">
<strong>There are no managed repositories configured yet.</strong>
</c:if>
<c:forEach items="${repositories}" var="repository" varStatus="i">
<div>
<div style="float: right">
<%-- TODO! replace with icons --%>
<a href="<ww:url action="editRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Edit
Repository</a> | <a href="#">Delete Repository</a>
<%-- TODO! serious confirmation, implement, prompt whether to delete contents too, remember index --%>
</div>
<h3>${repository.name}</h3>
<table>
<tr>
<th>Identifier</th>
<td>
<%-- TODO! must be unique among managed repos --%>
<code>${repository.id}</code>
</td>
</tr>
<tr>
<th>Directory</th>
<td>${repository.directory}</td>
</tr>
<tr>
<th>Type</th>
<!-- TODO: can probably just use layout appended to a key prefix in i18n to simplify this -->
<td>
<c:choose>
<c:when test="${repository.layout == 'default'}">
Maven 2.x Repository
</c:when>
<c:otherwise>
Maven 1.x Repository
</c:otherwise>
</c:choose>
</td>
</tr>
<tr>
<th>Snapshots Included</th>
<td>
<c:if test="${!repository.includeSnapshots}">
<span class="statusFailed">NO</span>
</c:if>
<c:if test="${repository.includeSnapshots}">
<span class="statusOk">YES</span>
</c:if>
</td>
</tr>
<tr>
<th>Indexed</th>
<td>
<c:if test="${!repository.indexed}">
<span class="statusFailed">NO</span>
</c:if>
<c:if test="${repository.indexed}">
<span class="statusOk">YES</span>
</c:if>
</td>
</tr>
</table>
</div>
</c:forEach>
<p>
<a href="<ww:url action="addRepository" method="input" />">Add Repository</a>
</p>
</div>
</body>

View File

@ -108,7 +108,10 @@
<my:currentWWUrl action="index" namespace="/admin">Administration</my:currentWWUrl>
<ul>
<li class="none">
<my:currentWWUrl action="configure" namespace="/admin">Configuration</my:currentWWUrl>
<my:currentWWUrl action="proxied" namespace="/admin">Proxied Repositories</my:currentWWUrl>
</li>
<li class="none">
<my:currentWWUrl action="synced" namespace="/admin">Synced Repositories</my:currentWWUrl>
</li>
</ul>
</li>

View File

@ -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;
}