use of org.apache.archiva.redback.components.scheduler.CronExpressionValidator in project archiva by apache.
the class DefaultRepositoryCommonValidator method validateManagedRepository.
/**
* validate cronExpression and location format
*
* @param managedRepository
* @since 1.4-M2
*/
@Override
public void validateManagedRepository(ManagedRepository managedRepository) throws RepositoryAdminException {
String cronExpression = managedRepository.getCronExpression();
// FIXME : olamy can be empty to avoid scheduled scan ?
if (StringUtils.isNotBlank(cronExpression)) {
CronExpressionValidator validator = new CronExpressionValidator();
if (!validator.validate(cronExpression)) {
throw new RepositoryAdminException("Invalid cron expression.", "cronExpression");
}
} else {
throw new RepositoryAdminException("Cron expression cannot be empty.");
}
String repoLocation = removeExpressions(managedRepository.getLocation());
if (!GenericValidator.matchRegexp(repoLocation, ManagedRepositoryAdmin.REPOSITORY_LOCATION_VALID_EXPRESSION)) {
throw new RepositoryAdminException("Invalid repository location. Directory must only contain alphanumeric characters, equals(=), question-marks(?), " + "exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-).", "location");
}
}
Aggregations