From a5406f81fd98ad46442e79c42c0247d77ca3cd3f Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Tue, 8 Aug 2006 09:23:56 +0000 Subject: [PATCH] [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 --- .../src/main/mdo/configuration.mdo | 309 ++++++++++++++++-- .../AbstractConfigureRepositoryAction.java | 166 ++++++++++ .../admin/AbstractDeleteRepositoryAction.java | 116 +++++++ .../ConfigureProxiedRepositoryAction.java | 54 +++ .../admin/ConfigureRepositoryAction.java | 124 +------ .../admin/DeleteProxiedRepositoryAction.java | 50 +++ .../action/admin/DeleteRepositoryAction.java | 80 +---- .../interceptor/ConfigurationInterceptor.java | 4 + ...gureProxiedRepositoryAction-validation.xml | 41 +++ .../src/main/resources/xwork.xml | 19 ++ .../jsp/admin/addProxiedRepository.jsp | 61 ++++ .../jsp/admin/deleteProxiedRepository.jsp | 48 +++ .../jsp/admin/editProxiedRepository.jsp | 61 ++++ .../WEB-INF/jsp/admin/proxiedRepositories.jsp | 137 ++++++++ .../webapp/WEB-INF/jsp/decorators/default.jsp | 4 +- 15 files changed, 1059 insertions(+), 215 deletions(-) create mode 100644 maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/AbstractConfigureRepositoryAction.java create mode 100644 maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/AbstractDeleteRepositoryAction.java create mode 100644 maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureProxiedRepositoryAction.java create mode 100644 maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteProxiedRepositoryAction.java create mode 100644 maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureProxiedRepositoryAction-validation.xml create mode 100644 maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxiedRepository.jsp create mode 100644 maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteProxiedRepository.jsp create mode 100644 maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxiedRepository.jsp create mode 100644 maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp diff --git a/maven-repository-configuration/src/main/mdo/configuration.mdo b/maven-repository-configuration/src/main/mdo/configuration.mdo index a0d277f97..528f418c4 100644 --- a/maven-repository-configuration/src/main/mdo/configuration.mdo +++ b/maven-repository-configuration/src/main/mdo/configuration.mdo @@ -10,7 +10,7 @@ org.apache.maven.repository.configuration - + Configuration @@ -24,6 +24,22 @@ * + + proxiedRepositories + 1.0.0 + + ProxiedRepositoryConfiguration + * + + + + syncedRepositories + 1.0.0 + + SyncedRepositoryConfiguration + * + + localRepository 1.0.0 @@ -92,23 +108,40 @@ { valid = false; } - else + return valid; + } + + public RepositoryConfiguration getRepositoryById( String id ) + { + for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); ) { - for ( java.util.Iterator i = repositories.iterator(); i.hasNext() && valid; ) + RepositoryConfiguration repository = (RepositoryConfiguration) i.next(); + if ( repository.getId().equals( id ) ) { - RepositoryConfiguration repository = (RepositoryConfiguration) i.next(); + return repository; + } + } + return null; + } - valid = repository.isValid(); + 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 valid; + return null; } - public RepositoryConfiguration getRepositoryById( String id ) + public ProxiedRepositoryConfiguration getProxiedRepositoryById( String id ) { - for ( java.util.Iterator i = getRepositories().iterator(); i.hasNext(); ) + for ( java.util.Iterator i = getProxiedRepositories().iterator(); i.hasNext(); ) { - RepositoryConfiguration repository = (RepositoryConfiguration) i.next(); + ProxiedRepositoryConfiguration repository = (ProxiedRepositoryConfiguration) i.next(); if ( repository.getId().equals( id ) ) { return repository; @@ -116,12 +149,61 @@ } 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; + } ]]> - RepositoryConfiguration + AbstractRepositoryConfiguration + true 1.0.0 @@ -143,24 +225,42 @@ - directory + layout 1.0.0 String true - The location of the repository to monitor. + The layout of the repository. Valid values are "default" and "legacy". + + default + + + + 1.0.0 + + + + + + AbstractRepositoryConfiguration + RepositoryConfiguration + 1.0.0 + - layout + directory 1.0.0 String true - The layout of the repository. Valid values are "default" and "legacy". + The location of the repository to monitor. - - default includeSnapshots @@ -183,24 +283,167 @@ Blacklisted patterns in the discovery process - - + + + AbstractRepositoryConfiguration + ProxiedRepositoryConfiguration + 1.0.0 + + + url 1.0.0 - - - + String + true + + The URL of the remote repository to proxy. + + + + + managedRepository + 1.0.0 + true + String + + The ID of the managed repository to use as the local storage for proxied artifacts. + + + + snapshotsPolicy + 1.0.0 + String + disabled + + The policy for snapshots: one of disabled, daily, hourly, interval, never + (allow snapshots, but never update once retrieved). + + + + snapshotsInterval + 1.0.0 + String + + The interval in minutes before updating snapshots if the policy is set to 'interval'. + + + + releasesPolicy + 1.0.0 + String + daily + + The policy for releases: one of disabled, daily, hourly, interval, never + (allow releases, but never update once retrieved). + + + + releasesInterval + 1.0.0 + String + + The interval in minutes before updating releases if the policy is set to 'interval'. + + + + + + AbstractRepositoryConfiguration + SyncedRepositoryConfiguration + 1.0.0 + + + rsyncHost + 1.0.0 + String + true + + The host of the remote repository to synchronize. + + + + rsyncDirectory + 1.0.0 + String + true + + The location of the repository to synchronize on the remote host. + + + + + managedRepository + 1.0.0 + true + String + + The ID of the managed repository to use as the local storage for proxied artifacts. + + + + cronExpression + 1.0.0 + String + When to run the sync mechanism. Default is every hour on the hour. + 0 0 * * * ? + + + + + SyncedRepositoryConfiguration + RsyncSyncedRepositoryConfiguration + 1.0.0 + + + rsyncHost + 1.0.0 + String + true + + The host of the remote repository to synchronize. + + + + rsyncDirectory + 1.0.0 + String + true + + The location of the repository to synchronize on the remote host. + + + + + + SyncedRepositoryConfiguration + ScmSyncedRepositoryConfiguration + 1.0.0 + + + scmUrl + 1.0.0 + String + true + + The SCM URL of the remote repository to synchronize. + + + + + + SyncedRepositoryConfiguration + FileSyncedRepositoryConfiguration + 1.0.0 + + + directory + 1.0.0 + String + true + + The location of the repository to synchronize on the filesystem. + + + diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/AbstractConfigureRepositoryAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/AbstractConfigureRepositoryAction.java new file mode 100644 index 000000000..de6ac9a24 --- /dev/null +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/AbstractConfigureRepositoryAction.java @@ -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 Brett Porter + */ +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; + } +} diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/AbstractDeleteRepositoryAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/AbstractDeleteRepositoryAction.java new file mode 100644 index 000000000..31244c227 --- /dev/null +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/AbstractDeleteRepositoryAction.java @@ -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 Brett Porter + */ +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; + } +} diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureProxiedRepositoryAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureProxiedRepositoryAction.java new file mode 100644 index 000000000..82607f814 --- /dev/null +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/ConfigureProxiedRepositoryAction.java @@ -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(); + } +} 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 index c43c4b3d0..9c00b52a0 100644 --- 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 @@ -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 } - } - public String input() - { - return INPUT; + configuration.addRepository( repository ); } - public Object getModel() + protected AbstractRepositoryConfiguration createRepository() { - 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]; - } - } } diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteProxiedRepositoryAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteProxiedRepositoryAction.java new file mode 100644 index 000000000..69a7500fe --- /dev/null +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteProxiedRepositoryAction.java @@ -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! + } +} diff --git a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteRepositoryAction.java b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteRepositoryAction.java index 451989b5a..0823afc61 100644 --- a/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteRepositoryAction.java +++ b/maven-repository-webapp/src/main/java/org/apache/maven/repository/manager/web/action/admin/DeleteRepositoryAction.java @@ -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 - { - // 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; - } - - public String input() - { - return INPUT; - } - - public String getRepoId() - { - return repoId; - } - - public void setRepoId( String repoId ) + protected AbstractRepositoryConfiguration getRepository( Configuration configuration ) { - this.repoId = repoId; + return configuration.getRepositoryById( repoId ); } - public String getOperation() + protected void removeRepository( Configuration configuration, AbstractRepositoryConfiguration existingRepository ) { - return operation; + configuration.removeRepository( (RepositoryConfiguration) existingRepository ); } - public void setOperation( String operation ) + protected void removeContents( AbstractRepositoryConfiguration existingRepository ) + throws IOException { - this.operation = operation; + RepositoryConfiguration repository = (RepositoryConfiguration) existingRepository; + getLogger().info( "Removing " + repository.getDirectory() ); + FileUtils.deleteDirectory( repository.getDirectory() ); } } 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 37643516f..388c7222a 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 @@ -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"; } } diff --git a/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureProxiedRepositoryAction-validation.xml b/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureProxiedRepositoryAction-validation.xml new file mode 100644 index 000000000..d111ddd55 --- /dev/null +++ b/maven-repository-webapp/src/main/resources/org/apache/maven/repository/manager/web/action/admin/ConfigureProxiedRepositoryAction-validation.xml @@ -0,0 +1,41 @@ + + + + + + + + + You must enter the repository identifier. + + + + + You must enter the repository name. + + + + + You must enter the repository URL. + + + + + + + \ 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 ee78e7313..df5e9d854 100644 --- a/maven-repository-webapp/src/main/resources/xwork.xml +++ b/maven-repository-webapp/src/main/resources/xwork.xml @@ -142,6 +142,25 @@ index + + /WEB-INF/jsp/admin/proxiedRepositories.jsp + + + + /WEB-INF/jsp/admin/addProxiedRepository.jsp + proxiedRepositories + + + + /WEB-INF/jsp/admin/editProxiedRepository.jsp + proxiedRepositories + + + + /WEB-INF/jsp/admin/deleteProxiedRepository.jsp + proxiedRepositories + + /WEB-INF/jsp/admin/configure.jsp diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxiedRepository.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxiedRepository.jsp new file mode 100644 index 000000000..e2c8b8156 --- /dev/null +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/addProxiedRepository.jsp @@ -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" %> + + + + Configuration + + + + + +

Configuration

+ +
+ +

Add Proxied Repository

+ + + + + + + + + + + + + + + +
+ + + \ No newline at end of file diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteProxiedRepository.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteProxiedRepository.jsp new file mode 100644 index 000000000..b064b5678 --- /dev/null +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/deleteProxiedRepository.jsp @@ -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" %> + + + + Configuration + + + + + +

Configuration

+ +
+ +

Delete Proxied Repository

+ +
+ WARNING: This operation can not be undone. +
+ + + + + + +
+ + + \ No newline at end of file diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxiedRepository.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxiedRepository.jsp new file mode 100644 index 000000000..c1ef2d835 --- /dev/null +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/editProxiedRepository.jsp @@ -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" %> + + + + Configuration + + + + + +

Configuration

+ +
+ +

Edit Proxied Repository

+ + + + + + + + + + + + + + + +
+ + + \ No newline at end of file diff --git a/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp new file mode 100644 index 000000000..505bf6e7d --- /dev/null +++ b/maven-repository-webapp/src/main/webapp/WEB-INF/jsp/admin/proxiedRepositories.jsp @@ -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" %> + + + + Administration + + + + + +

Administration

+ +
+

Proxied Repositories

+ + + + There are no proxied repositories configured yet. + + +
+
+ <%-- TODO! replace with icons --%> + ">Edit + Repository | ">Delete + Repository +
+

${repository.name}

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Identifier + <%-- TODO! must be unique among managed repos --%> + ${repository.id} +
URL${repository.url}
Type + + + Maven 2.x Repository + + + Maven 1.x Repository + + +
Snapshots + + + + DISABLED + + + ENABLED: updated every request + + + ENABLED: updated hourly + + + ENABLED: updated daily + + + ENABLED: updated every ${repository.snapshotsInterval} minutes + + +
Releases + + + + DISABLED + + + ENABLED: updated every request + + + ENABLED: updated hourly + + + ENABLED: updated daily + + + ENABLED: updated every ${repository.releasesInterval} minutes + + +
Proxied through + + ${repositoriesMap[repository.managedRepository].name} + (${repositoriesMap[repository.managedRepository].id}) +
+
+
+ +

+ ">Add Repository +

+
+ + + \ No newline at end of file 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 7f98fcc1b..76f7b3402 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,10 +108,10 @@ Administration
  • - Proxied Repositories + Proxied Repositories
  • - Synced Repositories + Synced Repositories
-- 2.39.5