@Override public void afterGroup(Group group) throws RuleException { analyzerContext.getStore().beginTransaction(); reportPlugin.endGroup(); analyzerContext.getStore().commitTransaction(); }
@Override public void beforeGroup(Group group, Severity effectiveSeverity) throws RuleException { analyzerContext.getLogger().info("Executing group '" + group.getId() + "'"); analyzerContext.getStore().beginTransaction(); reportPlugin.beginGroup(group); analyzerContext.getStore().commitTransaction(); }
if (!store.hasActiveTransaction()) { store.beginTransaction(); descriptor = scan(item, descriptor, path, scope, pipeline); store.commitTransaction();
IOUtils.closeQuietly(xmlReportFileWriter); store.beginTransaction(); LOGGER.info("Verifying results, severity=" + severity); try {
@Override public void skipConcept(Concept concept, Severity effectiveSeverity) throws RuleException { analyzerContext.getStore().beginTransaction(); reportPlugin.beginConcept(concept); Result<Concept> result = Result.<Concept> builder().rule(concept).status(Result.Status.SKIPPED).severity(effectiveSeverity).build(); reportPlugin.setResult(result); reportPlugin.endConcept(); analyzerContext.getStore().commitTransaction(); }
@Override public void skipConstraint(Constraint constraint, Severity effectiveSeverity) throws RuleException { analyzerContext.getStore().beginTransaction(); reportPlugin.beginConstraint(constraint); Result<Constraint> result = Result.<Constraint> builder().rule(constraint).status(Result.Status.SKIPPED).severity(effectiveSeverity).build(); reportPlugin.setResult(result); reportPlugin.endConstraint(); analyzerContext.getStore().commitTransaction(); }
@Override public void visitConstraint(Constraint constraint, Severity effectiveSeverity) throws RuleException { analyzerContext.getLogger() .info("Validating constraint '" + constraint.getId() + "' with severity: '" + constraint.getSeverity().getInfo(effectiveSeverity) + "'."); try { analyzerContext.getStore().beginTransaction(); reportPlugin.beginConstraint(constraint); reportPlugin.setResult(execute(constraint, effectiveSeverity)); reportPlugin.endConstraint(); analyzerContext.getStore().commitTransaction(); } catch (XOException e) { analyzerContext.getStore().rollbackTransaction(); throw new RuleException("Cannot validate constraint " + constraint.getId(), e); } }
private <T> void scan(ScannerContext scannerContext, T element, String path, String scopeName, Map<String, ScannerPlugin<?, ?>> scannerPlugins) throws CliExecutionException { ScannerConfiguration configuration = new ScannerConfiguration(); configuration.setContinueOnError(continueOnError); Store store = scannerContext.getStore(); store.beginTransaction(); Scanner scanner; try { scanner = new ScannerImpl(configuration, scannerContext, scannerPlugins, pluginRepository.getScopePluginRepository().getScopes()); } catch (PluginRepositoryException e) { throw new CliExecutionException("Cannot get scope plugins.", e); } Scope scope = scanner.resolveScope(scopeName); try { scanner.scan(element, path, scope); } finally { store.commitTransaction(); } }
public InMemoryReportWriter analyze(List<String> conceptNames, List<String> constraintNames, List<String> groupNames) throws Exception { RuleSelection ruleSelection = RuleSelection.Builder.newInstance().addConceptIds(conceptNames).addConstraintIds(constraintNames).addGroupIds(groupNames) .get(); InMemoryReportWriter reportWriter = new InMemoryReportWriter(new CompositeReportWriter(Collections.<String, AnalysisListener>emptyMap())); AnalyzerConfiguration configuration = new AnalyzerConfiguration(); Analyzer analyzer = new AnalyzerImpl(configuration, store, reportWriter, logger); analyzer.execute(getAvailableRules(), ruleSelection); store.beginTransaction(); ReportHelper reportHelper = new ReportHelper(logger); reportHelper.verifyConceptResults(Concept.DEFAULT_SEVERITY, reportWriter); reportHelper.verifyConstraintResults(Constraint.DEFAULT_SEVERITY, reportWriter); store.commitTransaction(); return reportWriter; } }
@Override public boolean visitConcept(Concept concept, Severity effectiveSeverity) throws RuleException { try { analyzerContext.getStore().beginTransaction(); ConceptDescriptor conceptDescriptor = analyzerContext.getStore().find(ConceptDescriptor.class, concept.getId()); Result.Status status; if (conceptDescriptor == null || configuration.isExecuteAppliedConcepts()) { analyzerContext.getLogger() .info("Applying concept '" + concept.getId() + "' with severity: '" + concept.getSeverity().getInfo(effectiveSeverity) + "'."); reportPlugin.beginConcept(concept); Result<Concept> result = execute(concept, effectiveSeverity); reportPlugin.setResult(result); status = result.getStatus(); if (conceptDescriptor == null) { conceptDescriptor = analyzerContext.getStore().create(ConceptDescriptor.class); conceptDescriptor.setId(concept.getId()); conceptDescriptor.setStatus(status); } reportPlugin.endConcept(); } else { status = conceptDescriptor.getStatus(); } analyzerContext.getStore().commitTransaction(); return Result.Status.SUCCESS.equals(status); } catch (XOException e) { analyzerContext.getStore().rollbackTransaction(); throw new RuleException("Cannot apply concept " + concept.getId(), e); } }