diff --git a/cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/AbstractExitStatus.java b/cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/AbstractExitStatus.java index c2d17e982..46d0fd85c 100644 --- a/cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/AbstractExitStatus.java +++ b/cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/AbstractExitStatus.java @@ -44,7 +44,7 @@ public abstract class AbstractExitStatus implements ExitStatus { /** * Construct a new exit status based on the provided {@code exitCode}. - * + * * @param exitCode * the exit code */ @@ -59,7 +59,7 @@ public ExitCode getExitCode() { /** * Get the associated throwable. - * + * * @return the throwable or {@code null} */ @Override @@ -76,7 +76,7 @@ public ExitStatus withThrowable(@NonNull Throwable throwable) { /** * Get the associated message. - * + * * @return the message or {@code null} */ @Nullable diff --git a/cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/CLIProcessor.java b/cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/CLIProcessor.java index 45222e4e2..5d0f2b8ff 100644 --- a/cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/CLIProcessor.java +++ b/cli-processor/src/main/java/gov/nist/secauto/metaschema/cli/processor/CLIProcessor.java @@ -138,7 +138,7 @@ public CLIProcessor(@NonNull String exec, @NonNull List versionInf /** * Gets the command used to execute for use in help text. - * + * * @return the command name */ @NonNull @@ -148,7 +148,7 @@ public String getExec() { /** * Retrieve the version information for this application. - * + * * @return the versionInfo */ @NonNull @@ -164,7 +164,7 @@ public void addCommandHandler(@NonNull Command handler) { * Process a set of CLIProcessor arguments. *

* process().getExitCode().getStatusCode() - * + * * @param args * the arguments to process * @return the exit status @@ -202,9 +202,8 @@ private static void handleNoColor() { } public static void handleQuiet() { - @SuppressWarnings("resource") - LoggerContext ctx = (LoggerContext) LogManager.getContext(false); // NOPMD not - // closable here + @SuppressWarnings("resource") LoggerContext ctx = (LoggerContext) LogManager.getContext(false); // NOPMD not + // closable here Configuration config = ctx.getConfiguration(); LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME); Level oldLevel = loggerConfig.getLevel(); @@ -215,8 +214,7 @@ public static void handleQuiet() { } protected void showVersion() { - @SuppressWarnings("resource") - PrintStream out = AnsiConsole.out(); // NOPMD - not owner + @SuppressWarnings("resource") PrintStream out = AnsiConsole.out(); // NOPMD - not owner getVersionInfos().stream().forEach((info) -> { out.println(ansi() .bold().a(getExec()).boldOff() @@ -232,12 +230,12 @@ protected void showVersion() { out.flush(); } -// @SuppressWarnings("null") -// @NonNull -// public String[] getArgArray() { -// return Stream.concat(options.stream(), extraArgs.stream()).toArray(size -> new String[size]); -// } - + // @SuppressWarnings("null") + // @NonNull + // public String[] getArgArray() { + // return Stream.concat(options.stream(), extraArgs.stream()).toArray(size -> new String[size]); + // } + public class CallingContext { @NonNull private final List

- - - \ No newline at end of file diff --git a/metaschema-java-binding/pom.xml b/metaschema-java-binding/pom.xml index 1dc41e418..d6dea81ef 100644 --- a/metaschema-java-binding/pom.xml +++ b/metaschema-java-binding/pom.xml @@ -10,7 +10,7 @@ metaschema-java-binding jar - Java Metaschema Data Binding + Metaschema Java Data Binding A Metaschema binding-based parser for Java objects supporting serialization of conformant XML, JSON, and YAML data. ${site.url}${project.artifactId}/ diff --git a/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/IBindingContext.java b/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/IBindingContext.java index 1d9feef28..bf69dee6f 100644 --- a/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/IBindingContext.java +++ b/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/IBindingContext.java @@ -248,7 +248,10 @@ default INodeItem toNodeItem(@NonNull Object boundObject, @NonNull URI baseUri) /** * Get a new single use constraint validator. - * + * + * @param handler + * the validation handler to use to process the validation results + * * @return the validator */ default IConstraintValidator newValidator(@NonNull IConstraintValidationHandler handler) { @@ -293,7 +296,7 @@ default IValidationResult validateWithConstraints(@NonNull Path target) throws I /** * Perform schema and constraint validation on the target. The constraint validation will only be * performed if the schema validation is passes. - * + * * @param target * the target to validate * @param asFormat @@ -302,7 +305,9 @@ default IValidationResult validateWithConstraints(@NonNull Path target) throws I * provides callbacks to get the appropriate schemas * @return the validation result * @throws IOException + * if an error occurred while reading the target * @throws SAXException + * if an error occurred when parsing the target as XML */ default IValidationResult validate( @NonNull Path target, diff --git a/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/xml/DefaultXmlSerializer.java b/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/xml/DefaultXmlSerializer.java index 6976d68ed..6b96d2bfd 100644 --- a/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/xml/DefaultXmlSerializer.java +++ b/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/xml/DefaultXmlSerializer.java @@ -78,7 +78,7 @@ protected void setXMLOutputFactory(@NonNull XMLOutputFactory2 xmlOutputFactory) protected XMLStreamWriter2 newXMLStreamWriter(@NonNull Writer writer) throws IOException { try { XMLStreamWriter2 streamWriter = (XMLStreamWriter2) getXMLOutputFactory().createXMLStreamWriter(writer); -// streamWriter = new IndentingXmlStreamWriter2(streamWriter); + // streamWriter = new IndentingXmlStreamWriter2(streamWriter); return streamWriter; } catch (XMLStreamException ex) { throw new IOException(ex); diff --git a/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/xml/XmlUtil.java b/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/xml/XmlUtil.java index a4db8bae9..cf9ff08f7 100644 --- a/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/xml/XmlUtil.java +++ b/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/xml/XmlUtil.java @@ -23,6 +23,7 @@ * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. */ + package gov.nist.secauto.metaschema.binding.io.xml; import java.io.File; diff --git a/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/yaml/YamlOperations.java b/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/yaml/YamlOperations.java index 868f5d6a0..83264d65b 100644 --- a/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/yaml/YamlOperations.java +++ b/metaschema-java-binding/src/main/java/gov/nist/secauto/metaschema/binding/io/yaml/YamlOperations.java @@ -79,7 +79,7 @@ public static Map parseYaml(Path target) throws IOException { /** * Converts the provided YAML {@code map} into JSON. - * + * * @param map * the YAML map * @return the JSON object diff --git a/metaschema-java-binding/src/site/markdown/index.md.vm b/metaschema-java-binding/src/site/markdown/index.md.vm index d20802684..e352e28cf 100644 --- a/metaschema-java-binding/src/site/markdown/index.md.vm +++ b/metaschema-java-binding/src/site/markdown/index.md.vm @@ -1,3 +1,4 @@ +# ${project.name} This module provides a Java parser library, that can read and write XML, JSON, and YAML content that is valid to the associated Metaschema model from and to bound Java objects. This library is a dependency for Java code generated from a Metaschema using the [Metaschema code generator](../metaschema-java-codegen) plugin. diff --git a/metaschema-java-codegen/pom.xml b/metaschema-java-codegen/pom.xml index 94e267332..6cbb389a3 100644 --- a/metaschema-java-codegen/pom.xml +++ b/metaschema-java-codegen/pom.xml @@ -102,13 +102,6 @@ - - org.apache.maven.plugins - maven-javadoc-plugin - - gov.nist.secauto.metaschema.codegen.xmlbeans,org.apache.xmlbeans.metadata.* - - com.github.spotbugs spotbugs-maven-plugin diff --git a/metaschema-java-codegen/src/site/markdown/index.md.vm b/metaschema-java-codegen/src/site/markdown/index.md.vm index 186724cea..d6ef45d69 100644 --- a/metaschema-java-codegen/src/site/markdown/index.md.vm +++ b/metaschema-java-codegen/src/site/markdown/index.md.vm @@ -1,3 +1,4 @@ +# ${project.name} This module provides a Java code generator [Java API](apidocs/index.html) that generates Java classes for a Metaschema definition. These generated classes can be used to read and write XML, JSON, and YAML content that is valid to the associated Metaschema model using the [binding parser](../metaschema-java-binding/) library. diff --git a/metaschema-maven-plugin/src/site/markdown/index.md.vm b/metaschema-maven-plugin/src/site/markdown/index.md.vm index fe39e0b01..f44f2b194 100644 --- a/metaschema-maven-plugin/src/site/markdown/index.md.vm +++ b/metaschema-maven-plugin/src/site/markdown/index.md.vm @@ -1,3 +1,4 @@ +# ${project.name} This Maven build plugin automates the generation of Java classes for a set of Metaschema definitions as part of a Maven build. diff --git a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/constraint/DefaultIndex.java b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/constraint/DefaultIndex.java index 23dd3d7d3..56a51eaf5 100644 --- a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/constraint/DefaultIndex.java +++ b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/constraint/DefaultIndex.java @@ -55,7 +55,7 @@ public class DefaultIndex implements IIndex { /** * Construct a new index. - * + * * @param keyFields * the key field components to use to generate keys by default */ @@ -100,7 +100,7 @@ public List toKey(@NonNull INodeItem item, @NonNull List keyFields) { /** * Check if a key contains information other than {@code null} Strings. - * + * * @param key * the key to check * @return {@code true} if the series of key values contains only {@code null} values, or @@ -67,7 +67,7 @@ static boolean isAllNulls(@NonNull Iterable key) { /** * Retrieve the key field components used to generate a key for this index. - * + * * @return the key field components */ @NonNull @@ -75,7 +75,7 @@ static boolean isAllNulls(@NonNull Iterable key) { /** * Store the provided item in the index using the index's key field components to generate the key. - * + * * @param item * the item to store in the index * @param dynamicContext @@ -90,7 +90,7 @@ default INodeItem put(@NonNull INodeItem item, @NonNull DynamicContext dynamicCo /** * Store the provided item using the provided key. - * + * * @param item * the item to store * @param key @@ -103,7 +103,7 @@ default INodeItem put(@NonNull INodeItem item, @NonNull DynamicContext dynamicCo /** * Retrieve the item from the index that matches the key generated by evaluating the index's default * key field components against the provided item. - * + * * @param item * the item to store in the index * @param dynamicContext @@ -118,7 +118,7 @@ default INodeItem get(@NonNull INodeItem item, @NonNull DynamicContext dynamicCo /** * Retrieve the item from the index that matches the key generated by evaluating the provided key * field components against the provided item. - * + * * @param item * the item to generate the key from * @param keyFields @@ -138,7 +138,7 @@ default INodeItem get( /** * Retrieve the item from the index that matches the provided key. - * + * * @param key * the key to use for lookup * @return the item with the matching key or {@code null} if no matching item was found @@ -147,7 +147,7 @@ default INodeItem get( /** * Construct a key by evaluating the provided key field components against the provided item. - * + * * @param item * the item to generate the key from * @param keyFields diff --git a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/IMarkupString.java b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/IMarkupString.java index 87a3ebad9..905b9adc3 100644 --- a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/IMarkupString.java +++ b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/IMarkupString.java @@ -80,6 +80,7 @@ public interface IMarkupString> @NonNull String toXHtml(@NonNull String namespace) throws XMLStreamException, IOException; + @NonNull String toMarkdown(); diff --git a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/AstCollectingVisitor.java b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/AstCollectingVisitor.java index 3ba2b6f8f..59f7e19a6 100644 --- a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/AstCollectingVisitor.java +++ b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/AstCollectingVisitor.java @@ -45,7 +45,7 @@ public static String asString(@NonNull Node node) { visitor.collect(node); return visitor.getAst(); } - + @SuppressWarnings("null") @NonNull public String getAst() { diff --git a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/FlexmarkConfiguration.java b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/FlexmarkConfiguration.java index ad89556a1..6c67d31a3 100644 --- a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/FlexmarkConfiguration.java +++ b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/FlexmarkConfiguration.java @@ -135,7 +135,6 @@ private static DataSet initFlexmarkConfig() { Formatter.MAX_TRAILING_BLANK_LINES.set(options, -1); Formatter.LIST_BULLET_MARKER.set(options, ListBulletMarker.DASH); - HtmlRenderer.MAX_TRAILING_BLANK_LINES.set(options, -1); HtmlRenderer.UNESCAPE_HTML_ENTITIES.set(options, true); HtmlRenderer.PERCENT_ENCODE_URLS.set(options, true); diff --git a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/XmlMarkupParser.java b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/XmlMarkupParser.java index ea653da05..1fd07bb2b 100644 --- a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/XmlMarkupParser.java +++ b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/XmlMarkupParser.java @@ -89,7 +89,7 @@ public MarkupMultiline parseMarkupMultiline(XMLEventReader2 reader) throws XMLSt StringBuilder buffer = new StringBuilder(); parseToString(reader, buffer); String html = buffer.toString().trim(); - + if (LOGGER.isDebugEnabled()) { LOGGER.debug("XML->HTML: {}", html); } @@ -224,7 +224,8 @@ private void parseContents(XMLEventReader2 reader, StartElement start, StringBui } assert start == null - || XmlEventUtil.isNextEventEndElement(reader,ObjectUtils.notNull(start.getName())) : XmlEventUtil.toString(reader.peek()); + || XmlEventUtil.isNextEventEndElement(reader, ObjectUtils.notNull(start.getName())) : XmlEventUtil + .toString(reader.peek()); // if (LOGGER.isDebugEnabled()) { // LOGGER.debug("parseContents(exit): {}", reader.peek() != null ? diff --git a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/util/XmlEventUtil.java b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/util/XmlEventUtil.java index 6896a3f62..3faca5df4 100644 --- a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/util/XmlEventUtil.java +++ b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/util/XmlEventUtil.java @@ -512,7 +512,7 @@ private static CharSequence generateAssertMessage(XMLEvent event, int presumedEv } builder.append("', instead found ") .append(toString(event)); - + Location location = toLocation(event); if (location != null) { builder.append(" at ").append(toString(location)); diff --git a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/validation/AggregateValidationResult.java b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/validation/AggregateValidationResult.java index 74cb00f1c..3744e2168 100644 --- a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/validation/AggregateValidationResult.java +++ b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/validation/AggregateValidationResult.java @@ -23,6 +23,7 @@ * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT * OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER. */ + package gov.nist.secauto.metaschema.model.common.validation; import gov.nist.secauto.metaschema.model.common.constraint.IConstraint.Level; @@ -58,10 +59,10 @@ public static IValidationResult aggregate(@NonNull IValidationResult... results) assert stream != null; return aggregate(stream); } - + public static IValidationResult aggregate(@NonNull Stream findingStream) { AtomicReference highestSeverity = new AtomicReference<>(Level.INFORMATIONAL); - + List findings = new LinkedList<>(); findingStream.sequential().forEachOrdered(finding -> { findings.add(finding); diff --git a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/validation/IContentValidator.java b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/validation/IContentValidator.java index 1159ca49b..30f44baea 100644 --- a/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/validation/IContentValidator.java +++ b/metaschema-model-common/src/main/java/gov/nist/secauto/metaschema/model/common/validation/IContentValidator.java @@ -95,7 +95,7 @@ default IValidationResult validate(@NonNull URL url) throws IOException, URISynt /** * Validate the target using the provided XML schemas. - * + * * @param target * the target to validate * @param schemaSources @@ -114,7 +114,7 @@ static IValidationResult validateWithXmlSchema(@NonNull Path target, @NonNull Li /** * Validate the target using the provided JSON schema. - * + * * @param target * the target to validate * @param schema @@ -122,7 +122,7 @@ static IValidationResult validateWithXmlSchema(@NonNull Path target, @NonNull Li * @return the validation result * @throws IOException * if an error occurred while performing validation - * @see {@link JsonSchemaContentValidator#toJsonObject(InputStream)} + * @see JsonSchemaContentValidator#toJsonObject(InputStream) */ @NonNull static IValidationResult validateWithJsonSchema(@NonNull Path target, @NonNull JSONObject schema) diff --git a/metaschema-model-common/src/site/markdown/index.md.vm b/metaschema-model-common/src/site/markdown/index.md.vm index 68405b3ae..1c261d652 100644 --- a/metaschema-model-common/src/site/markdown/index.md.vm +++ b/metaschema-model-common/src/site/markdown/index.md.vm @@ -1,3 +1,5 @@ +# ${project.name} + This module provides a [Java API](apidocs/index.html) using Metaschema information. This API allows for the full Metaschema model to be explored in code. The following dependency can be added to your POM to use this library. diff --git a/metaschema-model-common/src/test/java/gov/nist/secauto/metaschema/model/common/datatype/markup/MarkupStringTest.java b/metaschema-model-common/src/test/java/gov/nist/secauto/metaschema/model/common/datatype/markup/MarkupStringTest.java index 17f330f91..d10d6654e 100644 --- a/metaschema-model-common/src/test/java/gov/nist/secauto/metaschema/model/common/datatype/markup/MarkupStringTest.java +++ b/metaschema-model-common/src/test/java/gov/nist/secauto/metaschema/model/common/datatype/markup/MarkupStringTest.java @@ -177,7 +177,7 @@ void markupMultilineFromMarkdownTest() throws XMLStreamException, IOException { + "

A param: .

"; MarkupMultiline ms = MarkupMultiline.fromMarkdown(markdown); - LOGGER.atInfo().log("AST: {}", AstCollectingVisitor.asString(ms.getDocument())); + LOGGER.atInfo().log("AST: {}", AstCollectingVisitor.asString(ms.getDocument())); LOGGER.atInfo().log("HTML: {}", ms.toXHtml("")); LOGGER.atInfo().log("Markdown: {}", ms.toMarkdown()); @@ -229,7 +229,7 @@ void markupSpaceHandlingTest() throws XMLStreamException, IOException { final String markdown = "a *b* **c**"; MarkupMultiline ms = MarkupMultiline.fromHtml(html); LOGGER.atInfo().log("HTML Source: {}", html); - LOGGER.atInfo().log("AST: {}", AstCollectingVisitor.asString(ms.getDocument())); + LOGGER.atInfo().log("AST: {}", AstCollectingVisitor.asString(ms.getDocument())); LOGGER.atInfo().log("HTML: {}", ms.toXHtml("")); LOGGER.atInfo().log("Markdown: {}", ms.toMarkdown()); assertNotEquals(markdown, ms.toMarkdown()); @@ -363,13 +363,12 @@ void testAposRoundTrip() throws XMLStreamException { assertEquals(markdown, ms.toMarkdown()); assertEquals(html, ms.toHtml().trim()); } - + @Test void testHtml() { String html = "

before <thing[02] text> after

"; MarkupMultiline ms = MarkupMultiline.fromHtml(html); - LOGGER.atInfo().log("AST: {}", AstCollectingVisitor.asString(ms.getDocument())); LOGGER.atInfo().log("HTML: {}", ms.toHtml()); LOGGER.atInfo().log("Markdown: {}", ms.toMarkdown()); diff --git a/metaschema-model-common/src/test/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/MarkupParserTest.java b/metaschema-model-common/src/test/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/MarkupParserTest.java index c9aa50db2..b1a16cb2f 100644 --- a/metaschema-model-common/src/test/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/MarkupParserTest.java +++ b/metaschema-model-common/src/test/java/gov/nist/secauto/metaschema/model/common/datatype/markup/flexmark/MarkupParserTest.java @@ -104,7 +104,7 @@ void emptyParagraphTest() throws XMLStreamException { LOGGER.atInfo().log("StartElement: {}", XmlEventUtil.toString(reader.nextEvent())); assertDoesNotThrow(() -> { MarkupMultiline ms = XmlMarkupParser.instance().parseMarkupMultiline(reader); - LOGGER.atInfo().log("AST: {}", AstCollectingVisitor.asString(ms.getDocument())); + LOGGER.atInfo().log("AST: {}", AstCollectingVisitor.asString(ms.getDocument())); LOGGER.atInfo().log("HTML: {}", ms.toXHtml("")); LOGGER.atInfo().log("Markdown: {}", ms.toMarkdown()); }); diff --git a/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlFieldInstance.java b/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlFieldInstance.java index 7d946e84b..3966ebc43 100644 --- a/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlFieldInstance.java +++ b/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlFieldInstance.java @@ -101,6 +101,7 @@ public boolean isInXmlWrapped() { return retval; } + @SuppressWarnings("CPD-START") @Override public String getFormalName() { return getXmlField().isSetFormalName() ? getXmlField().getFormalName() : null; @@ -170,6 +171,7 @@ public MarkupMultiline getRemarks() { return getXmlField().isSetRemarks() ? MarkupStringConverter.toMarkupString(getXmlField().getRemarks()) : null; } + @SuppressWarnings("CPD-END") @Override public Object getValue(@NonNull Object parentValue) { // there is no value diff --git a/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlGlobalFieldDefinition.java b/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlGlobalFieldDefinition.java index 26baebd54..2cd4217c6 100644 --- a/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlGlobalFieldDefinition.java +++ b/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlGlobalFieldDefinition.java @@ -184,7 +184,7 @@ public IFieldInstance getInlineInstance() { return null; } - @SuppressWarnings("null") + @SuppressWarnings({ "null", "CPD-START" }) @Override public String getName() { return getXmlField().getName(); @@ -308,6 +308,7 @@ public MarkupMultiline getRemarks() { return getXmlField().isSetRemarks() ? MarkupStringConverter.toMarkupString(getXmlField().getRemarks()) : null; } + @SuppressWarnings("CPD-END") @Override public Object getFieldValue(@NonNull Object parentFieldValue) { // there is no value diff --git a/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlInlineFieldDefinition.java b/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlInlineFieldDefinition.java index 4847ba09d..4ed7bd28c 100644 --- a/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlInlineFieldDefinition.java +++ b/metaschema-model/src/main/java/gov/nist/secauto/metaschema/model/XmlInlineFieldDefinition.java @@ -106,6 +106,7 @@ public IMetaschema getContainingMetaschema() { return getContainingDefinition().getContainingMetaschema(); } + @SuppressWarnings("CPD-START") @Override public boolean isInXmlWrapped() { boolean retval; @@ -182,6 +183,7 @@ public MarkupMultiline getRemarks() { return getXmlField().isSetRemarks() ? MarkupStringConverter.toMarkupString(getXmlField().getRemarks()) : null; } + @SuppressWarnings("CPD-END") @Override public Object getValue(@NonNull Object parentValue) { // there is no value diff --git a/metaschema-model/src/site/markdown/index.md.vm b/metaschema-model/src/site/markdown/index.md.vm index 22e824d91..69a2942b8 100644 --- a/metaschema-model/src/site/markdown/index.md.vm +++ b/metaschema-model/src/site/markdown/index.md.vm @@ -1,3 +1,5 @@ +# ${project.name} + This module provides a [Java API](apidocs/index.html) for parsing and accessing Metaschema information. This API allows for the full Metaschema model to be explored in code. The following dependency can be added to your POM to use this library. diff --git a/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGenerator.java b/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGenerator.java index 6828657ae..225b97111 100644 --- a/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGenerator.java +++ b/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/AbstractSchemaGenerator.java @@ -101,7 +101,7 @@ public void generateFromMetaschema( Writer out, IConfiguration configuration) { // IInlineStrategy inlineStrategy = IInlineStrategy.newInlineStrategy(configuration); - try { + try { // avoid automatically closing streams not owned by the generator T schemaWriter = newWriter(out); S generationState = newGenerationState(metaschema, schemaWriter, configuration); diff --git a/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/IGenerationState.java b/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/IGenerationState.java index a80b6a0ab..29e055c6e 100644 --- a/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/IGenerationState.java +++ b/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/IGenerationState.java @@ -41,7 +41,7 @@ public interface IGenerationState { WRITER getWriter(); boolean isInline(@NonNull IDefinition definition); - + void flushWriter() throws IOException; // // @NonNull diff --git a/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/json/JsonSchemaGenerator.java b/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/json/JsonSchemaGenerator.java index 2b2b9301c..6f92c8b9a 100644 --- a/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/json/JsonSchemaGenerator.java +++ b/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/json/JsonSchemaGenerator.java @@ -94,7 +94,6 @@ protected JsonGenerationState newGenerationState( protected void generateSchema(JsonGenerationState state) { IMetaschema metaschema = state.getMetaschema(); - // analyze all definitions List rootAssemblyDefinitions = analyzeDefinitions( state, @@ -119,7 +118,7 @@ protected void generateSchema(JsonGenerationState state) { return new RootPropertyEntry(root, state); }) .collect(Collectors.toUnmodifiableList()); - + try { state.writeStartObject(); @@ -137,8 +136,7 @@ protected void generateSchema(JsonGenerationState state) { state.writeField("definitions", definitionsObject); } - @SuppressWarnings("resource") - JsonGenerator writer = state.getWriter(); // NOPMD not owned + @SuppressWarnings("resource") JsonGenerator writer = state.getWriter(); // NOPMD not owned if (rootEntries.size() == 1) { rootEntries.iterator().next().write(writer); diff --git a/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/json/property/IJsonProperty.java b/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/json/property/IJsonProperty.java index 7d3d26455..0d5183516 100644 --- a/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/json/property/IJsonProperty.java +++ b/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/json/property/IJsonProperty.java @@ -56,6 +56,7 @@ public interface IJsonProperty { * Generate the schema type. * * @param properties + * the containing property context to add the property to * @param state * the schema generation state used for context and writing * @throws SchemaGenerationException diff --git a/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/XmlGenerationState.java b/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/XmlGenerationState.java index 56a75e201..929d4f110 100644 --- a/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/XmlGenerationState.java +++ b/metaschema-schema-generator/src/main/java/gov/nist/secauto/metaschema/schemagen/xml/XmlGenerationState.java @@ -284,6 +284,4 @@ public void flushWriter() throws IOException { throw new IOException(ex); } } - } - - \ No newline at end of file +} diff --git a/pom.xml b/pom.xml index f6a9443b7..5c0c296bf 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ gov.nist.secauto oss-parent - 22-SNAPSHOT + 24-SNAPSHOT gov.nist.secauto.metaschema metaschema-framework @@ -666,8 +666,7 @@ org.apache.maven.plugins maven-javadoc-plugin - - gov.nist.secauto.metaschema.*.xmlbeans,org.apache.xmlbeans.* + *.xmlbeans false
@@ -716,6 +715,22 @@ appassembler-maven-plugin ${plugin.appassembler.version} + + org.apache.maven.plugins + maven-pmd-plugin + + + cpd-verify + verify + + cpd-check + + + false + + + + @@ -820,13 +835,15 @@ org.apache.maven.plugins maven-javadoc-plugin - - :*.impl - aggregate false + + *.xmlbeans:*.xmlbeans.* + false + false + aggregate