[MRM-138] add configuration of proxied repositories

git-svn-id: https://svn.apache.org/repos/asf/maven/repository-manager/trunk@429613 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2006-08-08 09:23:56 +00:00
parent 8ed7c9d6ca
commit a5406f81fd
15 changed files with 1064 additions and 220 deletions

View File

@ -10,7 +10,7 @@
<value>org.apache.maven.repository.configuration</value>
</default>
</defaults>
<!-- TODO! break out subtypes such as <discovery> and create a list of blacklist, have multiple repositories -->
<!-- TODO! break out subtypes such as <discovery> and create a list of blacklist -->
<classes>
<class rootElement="true" xml.tagName="configuration">
<name>Configuration</name>
@ -24,6 +24,22 @@
<multiplicity>*</multiplicity>
</association>
</field>
<field>
<name>proxiedRepositories</name>
<version>1.0.0</version>
<association>
<type>ProxiedRepositoryConfiguration</type>
<multiplicity>*</multiplicity>
</association>
</field>
<field>
<name>syncedRepositories</name>
<version>1.0.0</version>
<association>
<type>SyncedRepositoryConfiguration</type>
<multiplicity>*</multiplicity>
</association>
</field>
<field>
<name>localRepository</name>
<version>1.0.0</version>
@ -92,15 +108,6 @@
{
valid = false;
}
else
{
for ( java.util.Iterator i = repositories.iterator(); i.hasNext() && valid; )
{
RepositoryConfiguration repository = (RepositoryConfiguration) i.next();
valid = repository.isValid();
}
}
return valid;
}
@ -116,12 +123,87 @@
}
return null;
}
public SyncedRepositoryConfiguration getSyncedRepositoryById( String id )
{
for ( java.util.Iterator i = getSyncedRepositories().iterator(); i.hasNext(); )
{
SyncedRepositoryConfiguration repository = (SyncedRepositoryConfiguration) i.next();
if ( repository.getId().equals( id ) )
{
return repository;
}
}
return null;
}
public ProxiedRepositoryConfiguration getProxiedRepositoryById( String id )
{
for ( java.util.Iterator i = getProxiedRepositories().iterator(); i.hasNext(); )
{
ProxiedRepositoryConfiguration repository = (ProxiedRepositoryConfiguration) i.next();
if ( repository.getId().equals( id ) )
{
return repository;
}
}
return null;
}
private java.util.Map repositoriesMap;
public java.util.Map getRepositoriesMap()
{
if ( repositoriesMap == null )
{
repositoriesMap = new java.util.HashMap();
for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); )
{
RepositoryConfiguration repository = (RepositoryConfiguration) i.next();
repositoriesMap.put( repository.getId(), repository );
}
}
return repositoriesMap;
}
private java.util.Map proxiedRepositoriesMap;
public java.util.Map getProxiedRepositoriesMap()
{
if ( proxiedRepositoriesMap == null )
{
proxiedRepositoriesMap = new java.util.HashMap();
for ( java.util.Iterator i = getProxiedRepositories().iterator(); i.hasNext(); )
{
ProxiedRepositoryConfiguration repository = (ProxiedRepositoryConfiguration) i.next();
proxiedRepositoriesMap.put( repository.getId(), repository );
}
}
return proxiedRepositoriesMap;
}
private java.util.Map syncedRepositoriesMap;
public java.util.Map getSyncedRepositoriesMap()
{
if ( syncedRepositoriesMap == null )
{
syncedRepositoriesMap = new java.util.HashMap();
for ( java.util.Iterator i = getSyncedRepositories().iterator(); i.hasNext(); )
{
SyncedRepositoryConfiguration repository = (SyncedRepositoryConfiguration) i.next();
syncedRepositoriesMap.put( repository.getId(), repository );
}
}
return syncedRepositoriesMap;
}
]]></code>
</codeSegment>
</codeSegments>
</class>
<class>
<name>RepositoryConfiguration</name>
<name>AbstractRepositoryConfiguration</name>
<abstract>true</abstract>
<version>1.0.0</version>
<fields>
<field>
@ -142,15 +224,6 @@
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>
@ -162,6 +235,33 @@
<!-- TODO: should be able to detect this from the repository (perhaps by metadata at the root) -->
<defaultValue>default</defaultValue>
</field>
</fields>
<codeSegments>
<codeSegment>
<version>1.0.0</version>
<code><![CDATA[
public String toString()
{
return name + " (" + id + ")";
}
]]></code>
</codeSegment>
</codeSegments>
</class>
<class>
<superClass>AbstractRepositoryConfiguration</superClass>
<name>RepositoryConfiguration</name>
<version>1.0.0</version>
<fields>
<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>includeSnapshots</name>
<version>1.0.0</version>
@ -183,24 +283,167 @@
<description>Blacklisted patterns in the discovery process</description>
</field>
</fields>
<codeSegments>
<codeSegment>
</class>
<class>
<superClass>AbstractRepositoryConfiguration</superClass>
<name>ProxiedRepositoryConfiguration</name>
<version>1.0.0</version>
<fields>
<field>
<name>url</name>
<version>1.0.0</version>
<code><![CDATA[
public boolean isValid()
{
boolean valid = true;
if ( directory == null )
{
valid = false;
}
return valid;
}
]]></code>
</codeSegment>
</codeSegments>
<type>String</type>
<required>true</required>
<description>
The URL of the remote repository to proxy.
</description>
</field>
<!-- TODO: would be much easier to have an association here, as long as it could be specified as a reference -->
<field>
<name>managedRepository</name>
<version>1.0.0</version>
<required>true</required>
<type>String</type>
<description>
The ID of the managed repository to use as the local storage for proxied artifacts.
</description>
</field>
<field>
<name>snapshotsPolicy</name>
<version>1.0.0</version>
<type>String</type>
<defaultValue>disabled</defaultValue>
<description>
The policy for snapshots: one of disabled, daily, hourly, interval, never
(allow snapshots, but never update once retrieved).
</description>
</field>
<field>
<name>snapshotsInterval</name>
<version>1.0.0</version>
<type>String</type>
<description>
The interval in minutes before updating snapshots if the policy is set to 'interval'.
</description>
</field>
<field>
<name>releasesPolicy</name>
<version>1.0.0</version>
<type>String</type>
<defaultValue>daily</defaultValue>
<description>
The policy for releases: one of disabled, daily, hourly, interval, never
(allow releases, but never update once retrieved).
</description>
</field>
<field>
<name>releasesInterval</name>
<version>1.0.0</version>
<type>String</type>
<description>
The interval in minutes before updating releases if the policy is set to 'interval'.
</description>
</field>
</fields>
</class>
<class>
<superClass>AbstractRepositoryConfiguration</superClass>
<name>SyncedRepositoryConfiguration</name>
<version>1.0.0</version>
<fields>
<field>
<name>rsyncHost</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The host of the remote repository to synchronize.
</description>
</field>
<field>
<name>rsyncDirectory</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The location of the repository to synchronize on the remote host.
</description>
</field>
<!-- TODO: would be much easier to have an association here, as long as it could be specified as a reference -->
<field>
<name>managedRepository</name>
<version>1.0.0</version>
<required>true</required>
<type>String</type>
<description>
The ID of the managed repository to use as the local storage for proxied artifacts.
</description>
</field>
<field>
<name>cronExpression</name>
<version>1.0.0</version>
<type>String</type>
<description>When to run the sync mechanism. Default is every hour on the hour.</description>
<defaultValue>0 0 * * * ?</defaultValue>
</field>
</fields>
</class>
<class>
<superClass>SyncedRepositoryConfiguration</superClass>
<name>RsyncSyncedRepositoryConfiguration</name>
<version>1.0.0</version>
<fields>
<field>
<name>rsyncHost</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The host of the remote repository to synchronize.
</description>
</field>
<field>
<name>rsyncDirectory</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The location of the repository to synchronize on the remote host.
</description>
</field>
</fields>
</class>
<class>
<superClass>SyncedRepositoryConfiguration</superClass>
<name>ScmSyncedRepositoryConfiguration</name>
<version>1.0.0</version>
<fields>
<field>
<name>scmUrl</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The SCM URL of the remote repository to synchronize.
</description>
</field>
</fields>
</class>
<class>
<superClass>SyncedRepositoryConfiguration</superClass>
<name>FileSyncedRepositoryConfiguration</name>
<version>1.0.0</version>
<fields>
<field>
<name>directory</name>
<version>1.0.0</version>
<type>String</type>
<required>true</required>
<description>
The location of the repository to synchronize on the filesystem.
</description>
</field>
</fields>
</class>
</classes>
</model>

View File

@ -0,0 +1,166 @@
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.AbstractRepositoryConfiguration;
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 java.io.IOException;
import java.util.Map;
/**
* Base action for repository configuration actions.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
public abstract class AbstractConfigureRepositoryAction
extends ActionSupport
implements ModelDriven, Preparable, ParameterAware
{
/**
* @plexus.requirement
*/
private ConfigurationStore configurationStore;
/**
* The repository.
*/
private AbstractRepositoryConfiguration repository;
/**
* The repository ID to lookup when editing a repository.
*/
private String repoId;
/**
* The previously read configuration.
*/
protected 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
AbstractRepositoryConfiguration existingRepository = getRepository( repository.getId() );
if ( existingRepository != null )
{
addFieldError( "id", "A repository with that id already exists" );
return INPUT;
}
return saveConfiguration();
}
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
AbstractRepositoryConfiguration existingRepository = getRepository( repository.getId() );
removeRepository( existingRepository );
return saveConfiguration();
}
protected abstract void removeRepository( AbstractRepositoryConfiguration existingRepository );
protected abstract AbstractRepositoryConfiguration getRepository( String id );
private String saveConfiguration()
throws IOException, ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException
{
addRepository();
configurationStore.storeConfiguration( configuration );
// TODO: do we need to check if indexing is needed?
addActionMessage( "Successfully saved configuration" );
return SUCCESS;
}
protected abstract void addRepository()
throws IOException;
public String input()
{
return INPUT;
}
public Object getModel()
{
if ( repository == null )
{
repository = getRepository( repoId );
}
if ( repository == null )
{
repository = createRepository();
}
return repository;
}
protected abstract AbstractRepositoryConfiguration createRepository();
public void prepare()
throws ConfigurationStoreException
{
configuration = configurationStore.getConfigurationFromStore();
// initialises the repository if it is empty
getModel();
}
public String getRepoId()
{
return repoId;
}
public void setRepoId( String repoId )
{
this.repoId = repoId;
}
public void setParameters( Map map )
{
if ( map.containsKey( "repoId" ) )
{
String[] param = (String[]) map.get( "repoId" );
repoId = param[0];
}
}
protected AbstractRepositoryConfiguration getRepository()
{
return repository;
}
public Configuration getConfiguration()
{
return configuration;
}
}

View File

@ -0,0 +1,116 @@
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 org.apache.maven.repository.configuration.AbstractRepositoryConfiguration;
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 org.codehaus.plexus.xwork.action.PlexusActionSupport;
import java.io.IOException;
/**
* Base action for repository removal actions.
*
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
*/
public abstract class AbstractDeleteRepositoryAction
extends PlexusActionSupport
{
/**
* @plexus.requirement
*/
private ConfigurationStore configurationStore;
/**
* The repository ID to lookup when editing a repository.
*/
protected String repoId;
/**
* Which operation to select.
*/
private String operation = "unmodified";
public String execute()
throws ConfigurationStoreException, IOException, 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
if ( "delete-entry".equals( operation ) || "delete-contents".equals( operation ) )
{
Configuration configuration = configurationStore.getConfigurationFromStore();
AbstractRepositoryConfiguration existingRepository = getRepository( configuration );
if ( existingRepository == null )
{
addActionError( "A repository with that id does not exist" );
return ERROR;
}
// TODO: remove from index too!
removeRepository( configuration, existingRepository );
configurationStore.storeConfiguration( configuration );
if ( "delete-contents".equals( operation ) )
{
removeContents( existingRepository );
}
}
return SUCCESS;
}
protected abstract void removeContents( AbstractRepositoryConfiguration existingRepository )
throws IOException;
protected abstract AbstractRepositoryConfiguration getRepository( Configuration configuration );
protected abstract void removeRepository( Configuration configuration,
AbstractRepositoryConfiguration existingRepository );
public String input()
{
return INPUT;
}
public String getRepoId()
{
return repoId;
}
public void setRepoId( String repoId )
{
this.repoId = repoId;
}
public String getOperation()
{
return operation;
}
public void setOperation( String operation )
{
this.operation = operation;
}
}

View File

@ -0,0 +1,54 @@
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 org.apache.maven.repository.configuration.AbstractRepositoryConfiguration;
import org.apache.maven.repository.configuration.ProxiedRepositoryConfiguration;
import java.io.IOException;
/**
* Configures the application repositories.
*
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureProxiedRepositoryAction"
*/
public class ConfigureProxiedRepositoryAction
extends AbstractConfigureRepositoryAction
{
protected void removeRepository( AbstractRepositoryConfiguration existingRepository )
{
configuration.removeProxiedRepository( (ProxiedRepositoryConfiguration) existingRepository );
}
protected AbstractRepositoryConfiguration getRepository( String id )
{
return configuration.getProxiedRepositoryById( id );
}
protected void addRepository()
throws IOException
{
ProxiedRepositoryConfiguration repository = (ProxiedRepositoryConfiguration) getRepository();
configuration.addProxiedRepository( repository );
}
protected AbstractRepositoryConfiguration createRepository()
{
return new ProxiedRepositoryConfiguration();
}
}

View File

@ -16,20 +16,11 @@ package org.apache.maven.repository.manager.web.action.admin;
* 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 org.apache.maven.repository.configuration.AbstractRepositoryConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.Map;
/**
* Configures the application repositories.
@ -37,77 +28,23 @@ import java.util.Map;
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="configureRepositoryAction"
*/
public class ConfigureRepositoryAction
extends ActionSupport
implements ModelDriven, Preparable, ParameterAware
extends AbstractConfigureRepositoryAction
{
/**
* @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
protected void removeRepository( AbstractRepositoryConfiguration existingRepository )
{
// 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();
configuration.removeRepository( (RepositoryConfiguration) existingRepository );
}
public String edit()
throws IOException, ConfigurationStoreException, InvalidConfigurationException, ConfigurationChangeException
protected AbstractRepositoryConfiguration getRepository( String id )
{
// 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();
return configuration.getRepositoryById( id );
}
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()
protected void addRepository()
throws IOException
{
RepositoryConfiguration repository = (RepositoryConfiguration) getRepository();
// Normalize the path
File file = new File( repository.getDirectory() );
repository.setDirectory( file.getCanonicalPath() );
@ -116,49 +53,14 @@ public class ConfigureRepositoryAction
file.mkdirs();
// TODO: error handling when this fails, or is not a directory
}
configuration.addRepository( repository );
}
public String input()
protected AbstractRepositoryConfiguration createRepository()
{
return INPUT;
}
public Object getModel()
{
if ( repository == null )
{
repository = configuration.getRepositoryById( repoId );
}
if ( repository == null )
{
repository = new RepositoryConfiguration();
repository.setIndexed( false );
}
RepositoryConfiguration repository = new RepositoryConfiguration();
repository.setIndexed( false );
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

@ -0,0 +1,50 @@
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 org.apache.maven.repository.configuration.AbstractRepositoryConfiguration;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.configuration.ProxiedRepositoryConfiguration;
import org.apache.maven.repository.configuration.RepositoryConfiguration;
import org.codehaus.plexus.util.FileUtils;
import java.io.IOException;
/**
* Configures the application repositories.
*
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="deleteProxiedRepositoryAction"
*/
public class DeleteProxiedRepositoryAction
extends AbstractDeleteRepositoryAction
{
protected AbstractRepositoryConfiguration getRepository( Configuration configuration )
{
return configuration.getProxiedRepositoryById( repoId );
}
protected void removeRepository( Configuration configuration, AbstractRepositoryConfiguration existingRepository )
{
configuration.removeProxiedRepository( (ProxiedRepositoryConfiguration) existingRepository );
}
protected void removeContents( AbstractRepositoryConfiguration existingRepository )
throws IOException
{
// TODO!
}
}

View File

@ -16,14 +16,10 @@ package org.apache.maven.repository.manager.web.action.admin;
* limitations under the License.
*/
import org.apache.maven.repository.configuration.AbstractRepositoryConfiguration;
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 org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.xwork.action.PlexusActionSupport;
import java.io.IOException;
@ -33,77 +29,23 @@ import java.io.IOException;
* @plexus.component role="com.opensymphony.xwork.Action" role-hint="deleteRepositoryAction"
*/
public class DeleteRepositoryAction
extends PlexusActionSupport
extends AbstractDeleteRepositoryAction
{
/**
* @plexus.requirement
*/
private ConfigurationStore configurationStore;
/**
* The repository ID to lookup when editing a repository.
*/
private String repoId;
/**
* Which operation to select.
*/
private String operation = "unmodified";
public String execute()
throws ConfigurationStoreException, IOException, InvalidConfigurationException, ConfigurationChangeException
protected AbstractRepositoryConfiguration getRepository( Configuration configuration )
{
// TODO: if this didn't come from the form, go to configure.action instead of going through with re-saving what was just loaded
if ( "delete-entry".equals( operation ) || "delete-contents".equals( operation ) )
{
Configuration configuration = configurationStore.getConfigurationFromStore();
RepositoryConfiguration existingRepository = configuration.getRepositoryById( repoId );
if ( existingRepository == null )
{
addActionError( "A repository with that id does not exist" );
return ERROR;
}
// TODO: remove from index too!
configuration.removeRepository( existingRepository );
configurationStore.storeConfiguration( configuration );
if ( "delete-contents".equals( operation ) )
{
getLogger().info( "Removing " + existingRepository.getDirectory() );
FileUtils.deleteDirectory( existingRepository.getDirectory() );
}
}
return SUCCESS;
return configuration.getRepositoryById( repoId );
}
public String input()
protected void removeRepository( Configuration configuration, AbstractRepositoryConfiguration existingRepository )
{
return INPUT;
configuration.removeRepository( (RepositoryConfiguration) existingRepository );
}
public String getRepoId()
protected void removeContents( AbstractRepositoryConfiguration existingRepository )
throws IOException
{
return repoId;
}
public void setRepoId( String repoId )
{
this.repoId = repoId;
}
public String getOperation()
{
return operation;
}
public void setOperation( String operation )
{
this.operation = operation;
RepositoryConfiguration repository = (RepositoryConfiguration) existingRepository;
getLogger().info( "Removing " + repository.getDirectory() );
FileUtils.deleteDirectory( repository.getDirectory() );
}
}

View File

@ -20,6 +20,7 @@ import com.opensymphony.xwork.ActionInvocation;
import com.opensymphony.xwork.interceptor.Interceptor;
import org.apache.maven.repository.configuration.Configuration;
import org.apache.maven.repository.configuration.ConfigurationStore;
import org.codehaus.plexus.logging.AbstractLogEnabled;
/**
* An interceptor that makes the application configuration available
@ -29,6 +30,7 @@ import org.apache.maven.repository.configuration.ConfigurationStore;
* @plexus.component role="com.opensymphony.xwork.interceptor.Interceptor" role-hint="configurationInterceptor"
*/
public class ConfigurationInterceptor
extends AbstractLogEnabled
implements Interceptor
{
/**
@ -45,10 +47,12 @@ public class ConfigurationInterceptor
{
if ( configuration.getRepositories().isEmpty() )
{
getLogger().info( "No repositories were configured - forwarding to repository configuration page" );
return "config-repository-needed";
}
else
{
getLogger().info( "Configuration is incomplete - forwarding to configuration page" );
return "config-needed";
}
}

View File

@ -0,0 +1,41 @@
<!--
~ 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="url">
<field-validator type="requiredstring">
<message>You must enter the repository URL.</message>
</field-validator>
</field>
<!-- TODO: validate layout -->
<!-- TODO: validate policies -->
<!-- TODO: validate that intervals are integers -->
<!-- TODO: validate that intervals are empty if policy is not interval -->
</validators>

View File

@ -142,6 +142,25 @@
<result type="redirect-action">index</result>
</action>
<action name="proxiedRepositories" class="configureAction" method="input">
<result name="input">/WEB-INF/jsp/admin/proxiedRepositories.jsp</result>
</action>
<action name="addProxiedRepository" class="configureProxiedRepositoryAction" method="add">
<result name="input">/WEB-INF/jsp/admin/addProxiedRepository.jsp</result>
<result type="redirect-action">proxiedRepositories</result>
</action>
<action name="editProxiedRepository" class="configureProxiedRepositoryAction" method="edit">
<result name="input">/WEB-INF/jsp/admin/editProxiedRepository.jsp</result>
<result type="redirect-action">proxiedRepositories</result>
</action>
<action name="deleteProxiedRepository" class="deleteProxiedRepositoryAction">
<result name="input">/WEB-INF/jsp/admin/deleteProxiedRepository.jsp</result>
<result type="redirect-action">proxiedRepositories</result>
</action>
<action name="configure" class="configureAction" method="input">
<result name="input">/WEB-INF/jsp/admin/configure.jsp</result>
<interceptor-ref name="defaultStack"/>

View File

@ -0,0 +1,61 @@
<%--
~ 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 Proxied Repository</h2>
<ww:actionmessage />
<ww:form method="post" action="addProxiedRepository" namespace="/admin" validate="true">
<ww:textfield name="id" label="Identifier" size="10" />
<ww:textfield name="name" label="Name" size="50" />
<ww:textfield name="url" label="URL" size="50" />
<ww:select list="#@java.util.LinkedHashMap@{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}"
name="layout" label="Type" />
<ww:select name="snapshotsPolicy" label="Snapshots" list="#@java.util.LinkedHashMap@{
'disabled' : 'Disabled',
'daily' : 'Enabled, updated daily',
'hourly' : 'Enabled, updated hourly',
'never' : 'Enabled, never updated',
'interval' : 'Enabled, updated on given interval'}" />
<ww:textfield label="Snapshot update interval" name="snapshotsInterval" size="4" />
<ww:select name="releasesPolicy" label="Releases" list="#@java.util.LinkedHashMap@{
'disabled' : 'Disabled',
'daily' : 'Enabled, updated daily',
'hourly' : 'Enabled, updated hourly',
'never' : 'Enabled, never updated',
'interval' : 'Enabled, updated on given interval'}" />
<ww:textfield label="Release update interval" name="releasesInterval" size="4" />
<ww:select list="configuration.repositoriesMap" name="managedRepository" label="Proxied through"/>
<ww:submit value="Add Repository" />
</ww:form>
</div>
</body>
</html>

View File

@ -0,0 +1,48 @@
<%--
~ 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>Delete Proxied Repository</h2>
<blockquote>
<strong><span class="statusFailed">WARNING:</span> This operation can not be undone.</strong>
</blockquote>
<ww:form method="post" action="deleteProxiedRepository" namespace="/admin" validate="true">
<ww:hidden name="repoId" />
<ww:radio list="#@java.util.LinkedHashMap@{
'delete-contents' : 'Remove the repository and delete its contents from managed repositories',
'delete-entry' : 'Remove the repository from the available list, but leave the contents in the managed repositories',
'unmodified' : 'Leave the repository unmodified'}" name="operation" theme="repository-manager" />
<ww:submit value="Go" />
</ww:form>
</div>
</body>
</html>

View File

@ -0,0 +1,61 @@
<%--
~ 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 Proxied Repository</h2>
<ww:actionmessage />
<ww:form method="post" action="editProxiedRepository" namespace="/admin" validate="true">
<ww:hidden name="id" />
<!-- TODO! share with add -->
<ww:textfield name="name" label="Name" size="50" />
<ww:textfield name="url" label="URL" size="50" />
<ww:select list="#@java.util.LinkedHashMap@{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}"
name="layout" label="Type" />
<ww:select name="snapshotsPolicy" label="Snapshots" list="#@java.util.LinkedHashMap@{
'disabled' : 'Disabled',
'daily' : 'Enabled, updated daily',
'hourly' : 'Enabled, updated hourly',
'never' : 'Enabled, never updated',
'interval' : 'Enabled, updated on given interval'}" />
<ww:textfield label="Snapshot update interval" name="snapshotsInterval" size="4" />
<ww:select name="releasesPolicy" label="Releases" list="#@java.util.LinkedHashMap@{
'disabled' : 'Disabled',
'daily' : 'Enabled, updated daily',
'hourly' : 'Enabled, updated hourly',
'never' : 'Enabled, never updated',
'interval' : 'Enabled, updated on given interval'}" />
<ww:textfield label="Release update interval" name="releasesInterval" size="4" />
<ww:select list="configuration.repositoriesMap" name="managedRepository" label="Proxied through"/>
<ww:submit value="Change Repository" />
</ww:form>
</div>
</body>
</html>

View File

@ -0,0 +1,137 @@
<%--
~ 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" %>
<html>
<head>
<title>Administration</title>
<ww:head />
</head>
<body>
<h1>Administration</h1>
<div id="contentArea">
<h2>Proxied Repositories</h2>
<ww:set name="proxiedRepositories" value="proxiedRepositories" />
<c:if test="${empty(proxiedRepositories)}">
<strong>There are no proxied repositories configured yet.</strong>
</c:if>
<c:forEach items="${proxiedRepositories}" var="repository" varStatus="i">
<div>
<div style="float: right">
<%-- TODO! replace with icons --%>
<a href="<ww:url action="editProxiedRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Edit
Repository</a> | <a
href="<ww:url action="deleteProxiedRepository" method="input"><ww:param name="repoId" value="%{'${repository.id}'}" /></ww:url>">Delete
Repository</a>
</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>URL</th>
<td><a href="${repository.url}">${repository.url}</a></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</th>
<td>
<!-- TODO! turn into a tag -->
<c:choose>
<c:when test="${repository.snapshotsPolicy == 'disabled'}">
<span class="statusFailed">DISABLED</span>
</c:when>
<c:when test="${repository.snapshotsPolicy == 'always'}">
<span class="statusOk">ENABLED</span>: updated every request
</c:when>
<c:when test="${repository.snapshotsPolicy == 'hourly'}">
<span class="statusOk">ENABLED</span>: updated hourly
</c:when>
<c:when test="${repository.snapshotsPolicy == 'daily'}">
<span class="statusOk">ENABLED</span>: updated daily
</c:when>
<c:when test="${repository.snapshotsPolicy == 'interval'}">
<span class="statusOk">ENABLED</span>: updated every ${repository.snapshotsInterval} minutes
</c:when>
</c:choose>
</td>
</tr>
<tr>
<th>Releases</th>
<td>
<!-- TODO! turn into a tag -->
<c:choose>
<c:when test="${repository.releasesPolicy == 'disabled'}">
<span class="statusFailed">DISABLED</span>
</c:when>
<c:when test="${repository.releasesPolicy == 'always'}">
<span class="statusOk">ENABLED</span>: updated every request
</c:when>
<c:when test="${repository.releasesPolicy == 'hourly'}">
<span class="statusOk">ENABLED</span>: updated hourly
</c:when>
<c:when test="${repository.releasesPolicy == 'daily'}">
<span class="statusOk">ENABLED</span>: updated daily
</c:when>
<c:when test="${repository.releasesPolicy == 'interval'}">
<span class="statusOk">ENABLED</span>: updated every ${repository.releasesInterval} minutes
</c:when>
</c:choose>
</td>
</tr>
<tr>
<th>Proxied through</th>
<td>
<!-- TODO: this is the hard way! would be nice if there was a ref in the model so it was directly linked -->
${repositoriesMap[repository.managedRepository].name}
(<code>${repositoriesMap[repository.managedRepository].id}</code>)
</td>
</tr>
</table>
</div>
</c:forEach>
<p>
<a href="<ww:url action="addProxiedRepository" method="input" />">Add Repository</a>
</p>
</div>
</body>
</html>

View File

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