@GET @Path("consistencycheck") @Produces(MediaType.APPLICATION_JSON) public ConsistencyErrorCollector checkConsistency(@QueryParam("serviceTemplatesOnly") boolean serviceTemplatesOnly, @QueryParam("checkDocumentation") boolean checkDocumentation) { IRepository repo = RepositoryFactory.getRepository(); EnumSet<ConsistencyCheckerVerbosity> verbosity = EnumSet.of(ConsistencyCheckerVerbosity.NONE); ConsistencyCheckerConfiguration config = new ConsistencyCheckerConfiguration(serviceTemplatesOnly, checkDocumentation, verbosity, repo); final ConsistencyChecker consistencyChecker = new ConsistencyChecker(config); consistencyChecker.checkCorruption(); return consistencyChecker.getErrorCollector(); }
/** * Checks whether a README.md and a LICENSE file exists for the given definitions child id. */ private void checkDocumentation(DefinitionsChildId id) { checkFileExistenceAndSize(id, "README.md"); checkFileExistenceAndSize(id, "LICENSE"); }
ConsistencyCheckerConfiguration configuration = new ConsistencyCheckerConfiguration(serviceTemplatesOnly, checkDocumentation, verbosity, repository); final ConsistencyChecker consistencyChecker = new ConsistencyChecker(configuration); int numberOfDefinitionsToCheck = consistencyChecker.numberOfDefinitionsToCheck(); ProgressBar progressBar = new ProgressBar("Check", numberOfDefinitionsToCheck, ProgressBarStyle.ASCII); consistencyChecker.setConsistencyCheckerProgressListener(new ConsistencyCheckerProgressListener() { @Override public void updateProgress(float progress) { consistencyChecker.checkCorruption(); progressBar.stop(); ConsistencyErrorCollector errors = consistencyChecker.getErrorCollector();
checkId(id); checkXmlSchemaValidation(id); checkReferencedQNames(id); checkPropertiesValidation(id); if (id instanceof ServiceTemplateId) { checkServiceTemplate((ServiceTemplateId) id); checkDocumentation(id); checkPlainConformance(id, tempCsar); checkCsar(id, tempCsar);
/** * This method may be called only once during the lifecycle of this object */ public void checkCorruption() { if (configuration.getVerbosity().contains(ConsistencyCheckerVerbosity.OUTPUT_NUMBER_OF_TOSCA_COMPONENTS)) { System.out.format("Number of TOSCA definitions to check: %d\n", numberOfDefinitionsToCheck()); } checkAllDefinitions(); // some console output cleanup if (configuration.getVerbosity().contains(ConsistencyCheckerVerbosity.OUTPUT_ERRORS) && !configuration.getVerbosity().contains(ConsistencyCheckerVerbosity.OUTPUT_CURRENT_TOSCA_COMPONENT_ID)) { System.out.println(); } }
private void checkId(DefinitionsChildId id) { checkNamespaceUri(id); checkNcname(id, id.getXmlId().getDecoded()); }
@OnMessage public void onMessage(String message, Session session) throws IOException { ObjectMapper mapper = new ObjectMapper(); ConsistencyCheckerConfiguration config = mapper.readValue(message, ConsistencyCheckerConfiguration.class); final ConsistencyChecker consistencyChecker = new ConsistencyChecker(config, this); consistencyChecker.checkCorruption(); ConsistencyErrorCollector errorList = consistencyChecker.getErrorCollector(); // Transform object to JSON and send it. this.session.getBasicRemote().sendText(mapper.writeValueAsString(errorList)); // Close the connection after the check has passed. onClose(session); }