}
private boolean validateFields( String mode )
{
boolean containsError = false;
CronExpressionValidator validator = new CronExpressionValidator();
Configuration config = archivaConfiguration.getConfiguration();
String repoId = getRepository().getId();
if ( StringUtils.isBlank( repoId ) )
{
addFieldError( "repository.id", "You must enter a repository identifier." );
containsError = true;
}
//if edit mode, do not validate existence of repoId
else if ( config.findRepositoryById( repoId ) != null && !StringUtils.equalsIgnoreCase( mode, "edit" ) )
{
addFieldError( "repository.id",
"Unable to add new repository with id [" + repoId + "], that id already exists." );
containsError = true;
}
if ( StringUtils.isBlank( repository.getUrl() ) )
{
addFieldError( "repository.url", "You must enter a directory or url." );
containsError = true;
}
if ( StringUtils.isBlank( repository.getName() ) )
{
addFieldError( "repository.name", "You must enter a repository name." );
containsError = true;
}
if ( !validator.validate( repository.getRefreshCronExpression() ) )
{
addFieldError( "repository.refreshCronExpression", "Invalid cron expression." );
containsError = true;
}