use of org.apache.archiva.common.ArchivaException in project archiva by apache.
the class SecuritySynchronization method executeEnvironmentChecks.
private void executeEnvironmentChecks() throws ArchivaException {
if ((checkers == null) || CollectionUtils.isEmpty(checkers.values())) {
throw new ArchivaException("Unable to initialize the Redback Security Environment, " + "no Environment Check components found.");
}
StopWatch stopWatch = new StopWatch();
stopWatch.reset();
stopWatch.start();
List<String> violations = new ArrayList<>();
for (Entry<String, EnvironmentCheck> entry : checkers.entrySet()) {
EnvironmentCheck check = entry.getValue();
List<String> v = new ArrayList<>();
check.validateEnvironment(v);
log.info("Environment Check: {} -> {} violation(s)", entry.getKey(), v.size());
for (String s : v) {
violations.add("[" + entry.getKey() + "] " + s);
}
}
if (CollectionUtils.isNotEmpty(violations)) {
StringBuilder msg = new StringBuilder();
msg.append("EnvironmentCheck Failure.\n");
msg.append("======================================================================\n");
msg.append(" ENVIRONMENT FAILURE !! \n");
msg.append("\n");
for (String violation : violations) {
msg.append(violation).append("\n");
}
msg.append("\n");
msg.append("======================================================================");
log.error(msg.toString());
throw new ArchivaException("Unable to initialize Redback Security Environment, [" + violations.size() + "] violation(s) encountered, See log for details.");
}
stopWatch.stop();
log.info("time to execute all EnvironmentCheck: {} ms", stopWatch.getTime());
}
use of org.apache.archiva.common.ArchivaException in project archiva by apache.
the class DefaultRepositoryArchivaTaskScheduler method startup.
@PostConstruct
public void startup() throws ArchivaException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
archivaConfiguration.addListener(this);
List<ManagedRepositoryConfiguration> repositories = archivaConfiguration.getConfiguration().getManagedRepositories();
RepositorySession repositorySession = repositorySessionFactory.createSession();
try {
MetadataRepository metadataRepository = repositorySession.getRepository();
for (ManagedRepositoryConfiguration repoConfig : repositories) {
if (repoConfig.isScanned()) {
try {
scheduleRepositoryJobs(repoConfig);
} catch (SchedulerException e) {
throw new ArchivaException("Unable to start scheduler: " + e.getMessage(), e);
}
try {
if (!isPreviouslyScanned(repoConfig, metadataRepository)) {
queueInitialRepoScan(repoConfig);
}
} catch (MetadataRepositoryException e) {
log.warn("Unable to determine if a repository is already scanned, skipping initial scan: {}", e.getMessage(), e);
}
}
}
} finally {
repositorySession.close();
}
stopWatch.stop();
log.info("Time to initalize DefaultRepositoryArchivaTaskScheduler: {} ms", stopWatch.getTime());
}
use of org.apache.archiva.common.ArchivaException in project archiva by apache.
the class ArchivaStartup method contextInitialized.
@Override
public void contextInitialized(ServletContextEvent contextEvent) {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(contextEvent.getServletContext());
SecuritySynchronization securitySync = wac.getBean(SecuritySynchronization.class);
repositoryTaskScheduler = wac.getBean("archivaTaskScheduler#repository", DefaultRepositoryArchivaTaskScheduler.class);
Properties archivaRuntimeProperties = wac.getBean("archivaRuntimeProperties", Properties.class);
tqeRepoScanning = wac.getBean("taskQueueExecutor#repository-scanning", ThreadedTaskQueueExecutor.class);
tqeIndexing = wac.getBean("taskQueueExecutor#indexing", ThreadedTaskQueueExecutor.class);
try {
securitySync.startup();
repositoryTaskScheduler.startup();
Banner.display((String) archivaRuntimeProperties.get("archiva.version"));
} catch (ArchivaException e) {
throw new RuntimeException("Unable to properly startup archiva: " + e.getMessage(), e);
}
}
Aggregations