}
private boolean validateFields( Configuration config )
{
boolean containsError = false;
CronExpressionValidator validator = new CronExpressionValidator();
String repoId = repository.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.getManagedRepositoriesAsMap().containsKey( repoId ) ||
config.getRemoteRepositoriesAsMap().containsKey( repoId ) ) &&
!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.getLocation() ) )
{
addFieldError( "repository.location", "You must enter a directory." );
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;
}