if ( !update )
{
if ( config.getManagedRepositoriesAsMap().containsKey( repoId ) )
{
throw new RepositoryAdminException( "Unable to add new repository with id [" + repoId
+ "], that id already exists as a managed repository." );
}
else if ( config.getRepositoryGroupsAsMap().containsKey( repoId ) )
{
throw new RepositoryAdminException( "Unable to add new repository with id [" + repoId
+ "], that id already exists as a repository group." );
}
else if ( config.getRemoteRepositoriesAsMap().containsKey( repoId ) )
{
throw new RepositoryAdminException( "Unable to add new repository with id [" + repoId
+ "], that id already exists as a remote repository." );
}
}
if ( StringUtils.isBlank( repoId ) )
{
throw new RepositoryAdminException( "Repository ID cannot be empty." );
}
if ( !GenericValidator.matchRegexp( repoId, REPOSITORY_ID_VALID_EXPRESSION ) )
{
throw new RepositoryAdminException(
"Invalid repository ID. Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
}
String name = abstractRepository.getName();
if ( StringUtils.isBlank( name ) )
{
throw new RepositoryAdminException( "repository name cannot be empty" );
}
if ( !GenericValidator.matchRegexp( name, REPOSITORY_NAME_VALID_EXPRESSION ) )
{
throw new RepositoryAdminException(
"Invalid repository name. Repository Name must only contain alphanumeric characters, white-spaces(' '), "
+ "forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
}
}