protected void validateDocument(Document document) throws Exception { LOGGER.debug("[Config Save] In XSD validation: Starting."); writer.verifyXsdValid(document); LOGGER.debug("[Config Save] In XSD validation: Done."); LOGGER.debug("[Config Save] In DOM validation: Starting."); MagicalGoConfigXmlLoader.validateDom(document.getRootElement(), configElementImplementationRegistry); LOGGER.debug("[Config Save] In DOM validation: Done."); }
private Element parseInputStream(InputStream inputStream) throws Exception { Element rootElement = buildXmlDocument(inputStream, GoConfigSchema.getCurrentSchema(), registry.xsds()).getRootElement(); validateDom(rootElement, registry); return rootElement; }
public void write(CruiseConfig configForEdit, OutputStream output, boolean skipPreprocessingAndValidation) throws Exception { LOGGER.debug("[Serializing Config] Starting to write. Validation skipped? {}", skipPreprocessingAndValidation); MagicalGoConfigXmlLoader loader = new MagicalGoConfigXmlLoader(configCache, registry); if (!configForEdit.getOrigin().isLocal()) { throw new GoConfigInvalidException(configForEdit, "Attempted to save merged configuration with patials"); } if (!skipPreprocessingAndValidation) { loader.preprocessAndValidate(configForEdit); LOGGER.debug("[Serializing Config] Done with cruise config validators."); } Document document = createEmptyCruiseConfigDocument(); write(configForEdit, document.getRootElement(), configCache, registry); LOGGER.debug("[Serializing Config] XSD and DOM validation."); verifyXsdValid(document); MagicalGoConfigXmlLoader.validateDom(document.getRootElement(), registry); LOGGER.info("[Serializing Config] Generating config partial."); XmlUtils.writeXml(document, output); LOGGER.debug("[Serializing Config] Finished writing config partial."); }