archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/DefaultRepositoryCommonValidator.java
/**
     * @param abstractRepository
     * @param update             in update mode if yes already exists won't be check
     * @throws RepositoryAdminException
     */
@param abstractRepository
@param update             in update mode if yes already exists won't be check
@throws RepositoryAdminException
@param abstractRepository @param update in update mode if yes already exists won ' t be check @throws RepositoryAdminException
@Override
    public void basicValidation( AbstractRepository abstractRepository, boolean update )
        throws RepositoryAdminException
    {
        Configuration config = archivaConfiguration.getConfiguration( );
        String repoId = abstractRepository.getId( );
        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 ( !REPOSITORY_ID_VALID_EXPRESSION_PATTERN.matcher( repoId ).matches( ) )
        {
            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 ( !REPOSITORY_NAME_VALID_EXPRESSION_PATTERN.matcher( name ).matches( ) )
        {
            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(-)." );
        }
    }
@ Override public void basicValidation ( AbstractRepository abstractRepository , boolean update ) throws RepositoryAdminException { Configuration config = archivaConfiguration . getConfiguration ( ) ; String repoId = abstractRepository . getId ( ) ; 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 ( ! REPOSITORY_ID_VALID_EXPRESSION_PATTERN . matcher ( repoId ) . matches ( ) ) { 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 ( ! REPOSITORY_NAME_VALID_EXPRESSION_PATTERN . matcher ( name ) . matches ( ) ) { 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(-)." ) ; } }
@param abstractRepository
 @param update             in update mode if yes already exists won't be check
 @throws RepositoryAdminException
@param abstractRepository @param update in update mode if yes already exists won ' t be check @throws RepositoryAdminException