From a83e5b52a9c66417c4a68da34dcf10fedba5d6cb Mon Sep 17 00:00:00 2001 From: "Maria Odea B. Ching" Date: Fri, 23 May 2008 06:18:36 +0000 Subject: [PATCH] [MRM-694] -add validation check for existing ids for repo groups and remote & managed repos git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@659443 13f79535-47bb-0310-9956-ffa450edef68 --- .../repositories/AddManagedRepositoryAction.java | 7 ++++++- .../repositories/AddRemoteRepositoryAction.java | 5 +++++ .../admin/repositories/RepositoryGroupsAction.java | 14 +++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java index 74a6d5b91..6d5a0bb7b 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddManagedRepositoryAction.java @@ -104,7 +104,12 @@ public class AddManagedRepositoryAction addFieldError( "repository.id", "Unable to add new repository with id [" + repoId + "], that id already exists as a remote repository." ); } - + else if( config.getRepositoryGroupsAsMap().containsKey( repoId ) ) + { + addFieldError( "repository.id", "Unable to add new repository with id [" + repoId + + "], that id already exists as a repository group." ); + } + if ( !validator.validate( repository.getRefreshCronExpression() ) ) { addFieldError( "repository.refreshCronExpression", "Invalid cron expression." ); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryAction.java index bcf517624..80d67582c 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/AddRemoteRepositoryAction.java @@ -100,6 +100,11 @@ public class AddRemoteRepositoryAction addFieldError( "repository.id", "Unable to add new repository with id [" + repoId + "], that id already exists as a remote repository." ); } + else if( config.getRepositoryGroupsAsMap().containsKey( repoId ) ) + { + addFieldError( "repository.id", "Unable to add new repository with id [" + repoId + + "], that id already exists as a repository group." ); + } } public RemoteRepositoryConfiguration getRepository() diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsAction.java index d01cc9b98..9a4f3d134 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoryGroupsAction.java @@ -93,7 +93,19 @@ public class RepositoryGroupsAction if ( configuration.getRepositoryGroupsAsMap().containsKey( repoGroupId ) ) { addActionError( "Unable to add new repository group with id [" + repoGroupId - + "], that id already exists." ); + + "], that id already exists as a repository group." ); + return ERROR; + } + else if ( configuration.getManagedRepositoriesAsMap().containsKey( repoGroupId ) ) + { + addActionError( "Unable to add new repository group with id [" + repoGroupId + + "], that id already exists as a managed repository." ); + return ERROR; + } + else if ( configuration.getRemoteRepositoriesAsMap().containsKey( repoGroupId ) ) + { + addActionError( "Unable to add new repository group with id [" + repoGroupId + + "], that id already exists as a remote repository." ); return ERROR; } -- 2.39.5