throws RepositoryAdminException
{
String repoGroupId = repositoryGroup.getId();
if ( StringUtils.isBlank( repoGroupId ) )
{
throw new RepositoryAdminException( "repositoryGroup id cannot be empty" );
}
if ( repoGroupId.length() > 100 )
{
throw new RepositoryAdminException(
"Identifier [" + repoGroupId + "] is over the maximum limit of 100 characters" );
}
Matcher matcher = REPO_GROUP_ID_PATTERN.matcher( repoGroupId );
if ( !matcher.matches() )
{
throw new RepositoryAdminException(
"Invalid character(s) found in identifier. Only the following characters are allowed: alphanumeric, '.', '-' and '_'" );
}
if ( repositoryGroup.getMergedIndexTtl() <= 0 )
{
throw new RepositoryAdminException( "Merged Index TTL must be greater than 0." );
}
Configuration configuration = getArchivaConfiguration().getConfiguration();
if ( configuration.getRepositoryGroupsAsMap().containsKey( repoGroupId ) )
{
if ( !updateMode )
{
throw new RepositoryAdminException( "Unable to add new repository group with id [" + repoGroupId
+ "], that id already exists as a repository group." );
}
}
else if ( configuration.getManagedRepositoriesAsMap().containsKey( repoGroupId ) )
{
throw new RepositoryAdminException( "Unable to add new repository group with id [" + repoGroupId
+ "], that id already exists as a managed repository." );
}
else if ( configuration.getRemoteRepositoriesAsMap().containsKey( repoGroupId ) )
{
throw new RepositoryAdminException( "Unable to add new repository group with id [" + repoGroupId
+ "], that id already exists as a remote repository." );
}
return Boolean.TRUE;
}