{
CronExpressionValidator validator = new CronExpressionValidator();
if ( !validator.validate( cronExpression ) )
{
throw new RepositoryAdminException( "Invalid cron expression." );
}
}
else
{
throw new RepositoryAdminException( "Cron expression cannot be empty." );
}
String repoLocation = getRepositoryCommonValidator().removeExpressions( location );
if ( !GenericValidator.matchRegexp( repoLocation, 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(-)." );
}
ManagedRepositoryConfiguration repository = new ManagedRepositoryConfiguration();
repository.setId( repoId );
repository.setBlockRedeployments( blockRedeployments );
repository.setReleases( releasesIncluded );
repository.setSnapshots( snapshotsIncluded );
repository.setName( name );
repository.setLocation( repoLocation );
repository.setLayout( layout );
repository.setRefreshCronExpression( cronExpression );
repository.setIndexDir( indexDir );
repository.setDaysOlder( daysOlder );
repository.setRetentionCount( retentionCount );
repository.setDeleteReleasedSnapshots( deteleReleasedSnapshots );
repository.setIndexDir( indexDir );
try
{
addRepository( repository, config );
addRepositoryRoles( repository );
if ( stageRepoNeeded )
{
ManagedRepositoryConfiguration stagingRepository = getStageRepoConfig( repository );
addRepository( stagingRepository, config );
addRepositoryRoles( stagingRepository );
triggerAuditEvent( stagingRepository.getId(), null, AuditEvent.ADD_MANAGED_REPO, auditInformation );
}
}
catch ( RoleManagerException e )
{
throw new RepositoryAdminException( "failed to add repository roles " + e.getMessage(), e );
}
catch ( IOException e )
{
throw new RepositoryAdminException( "failed to add repository " + e.getMessage(), e );
}
saveConfiguration( config );
//MRM-1342 Repository statistics report doesn't appear to be working correctly