Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanup #82

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>dev.metaschema</groupId>
<artifactId>oss-parent</artifactId>
<version>5</version>
<version>6-SNAPSHOT</version>
</parent>
<groupId>dev.metaschema.oscal</groupId>
<artifactId>oscal-cli-enhanced</artifactId>
Expand Down Expand Up @@ -105,7 +105,6 @@
<dependency.log4j2.version>2.24.1</dependency.log4j2.version>
<dependency.pmd.version>7.4.0</dependency.pmd.version>
<dependency.spotbugs-annotations.version>4.8.6</dependency.spotbugs-annotations.version>
<dependency.saxon-he.version>12.5</dependency.saxon-he.version>
<dependency.xmlbeans.version>5.2.2</dependency.xmlbeans.version>
<dependency.xmlresolver.version>6.0.11</dependency.xmlresolver.version>

Expand Down Expand Up @@ -223,11 +222,6 @@
<artifactId>commons-io</artifactId>
<version>${dependency.commons-io.version}</version>
</dependency>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>${dependency.saxon-he.version}</version>
</dependency>
<dependency>
<groupId>org.xmlresolver</groupId>
<artifactId>xmlresolver</artifactId>
Expand Down Expand Up @@ -329,6 +323,7 @@
<excludedEnvironmentVariables>
<excludedEnvironmentVariable>JAVA_TOOL_OPTIONS</excludedEnvironmentVariable>
</excludedEnvironmentVariables>
<forkNode implementation="org.apache.maven.plugin.surefire.extensions.SurefireForkNodeFactory"/>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -465,15 +460,29 @@
</dependencies>
<executions>
<execution>
<id>make-assembly-bin</id> <!-- this is used for
<id>make-assembly-dir</id> <!-- this is used for
inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>false</attach>
<descriptors>
<descriptor>src/main/assembly/dir.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>make-assembly-archives</id> <!-- this is used for
inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/bin.xml</descriptor>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
Expand Down
14 changes: 14 additions & 0 deletions src/main/assembly/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>oscal-cli</id>
<formats>
<format>zip</format>
<format>tar.bz2</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<componentDescriptors>
<componentDescriptor>component.xml</componentDescriptor>
</componentDescriptors>
</assembly>
17 changes: 5 additions & 12 deletions src/main/assembly/bin.xml → src/main/assembly/component.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>oscal-cli</id>
<formats>
<format>dir</format>
<format>zip</format>
<format>tar.bz2</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<?xml version="1.0" encoding="UTF-8"?>
<component xmlns="http://maven.apache.org/ASSEMBLY-COMPONENT/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY-COMPONENT/2.0.0 https://maven.apache.org/xsd/assembly-component-2.0.0.xsd">
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
Expand Down Expand Up @@ -65,4 +58,4 @@
</configuration>
</containerDescriptorHandler>
</containerDescriptorHandlers>
</assembly>
</component>
13 changes: 13 additions & 0 deletions src/main/assembly/dir.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>oscal-cli</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<componentDescriptors>
<componentDescriptor>component.xml</componentDescriptor>
</componentDescriptors>
</assembly>
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@

import gov.nist.secauto.metaschema.core.util.IVersionInfo;

/**
* Provides version information for this application.
*/
public class OscalCliVersion implements IVersionInfo {

public static final String NAME = "oscal-cli";
public static final String BUILD_VERSION = "${project.version}";
public static final String BUILD_TIMESTAMP = "${timestamp}";
public static final String COMMIT = "@git.commit.id.abbrev@";
public static final String BRANCH = "@git.branch@";
public static final String CLOSEST_TAG = "@git.closest.tag.name@";
public static final String ORIGIN = "@git.remote.origin.url@";
private static final String NAME = "oscal-cli";
private static final String BUILD_VERSION = "${project.version}";
private static final String BUILD_TIMESTAMP = "${timestamp}";
private static final String COMMIT = "@git.commit.id.abbrev@";
private static final String BRANCH = "@git.branch@";
private static final String CLOSEST_TAG = "@git.closest.tag.name@";
private static final String ORIGIN = "@git.remote.origin.url@";

@Override
public String getName() {
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/gov/nist/secauto/oscal/tools/cli/core/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,17 @@

import edu.umd.cs.findbugs.annotations.NonNull;

/**
* Provides the main entry point for executing the command line interface.
*/
@SuppressWarnings("PMD.ShortClassName")
public final class CLI {
/**
* Executes the CLI and handled the exit code.
*
* @param args
* the CLI arguments
*/
public static void main(String[] args) {
System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager");

Expand All @@ -41,6 +50,13 @@ public static void main(String[] args) {
System.exit(exitCode);
}

/**
* Executes the CLI.
*
* @param args
* the CLI arguments
* @return the result of executing the CLI
*/
@NonNull
public static ExitStatus runCli(String... args) {
@SuppressWarnings("PMD.UseConcurrentHashMap")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

import edu.umd.cs.findbugs.annotations.NonNull;

/**
* This abstract command implementation provides user feedback about extending
* command being deprecated in favor of the {@link ValidateCommand}.
*/
public abstract class AbstractDeprecatedOscalValidationSubcommand
extends AbstractOscalValidationCommand {
private static final Logger LOGGER = LogManager.getLogger(AbstractDeprecatedOscalValidationSubcommand.class);
Expand All @@ -24,7 +28,7 @@ public ICommandExecutor newExecutor(CallingContext callingContext, CommandLine c
return new CommandExecutor(callingContext, commandLine);
}

protected final class CommandExecutor
private final class CommandExecutor
extends AbstractOscalValidationCommand.OscalValidationCommandExecutor {

private CommandExecutor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,21 @@

import edu.umd.cs.findbugs.annotations.NonNull;

/**
* Used by implementing classes to provide an OSCAL content conversion command.
* <p>
* This executor provides user feedback about extending command being deprecated
* in favor of the {@link ConvertCommand}.
*/
public abstract class AbstractOscalConvertCommand
extends AbstractConvertSubcommand {
private static final Logger LOGGER = LogManager.getLogger(AbstractOscalConvertCommand.class);

/**
* Get the bound object class for the assembly associated with the command.
*
* @return the bound object class for the associated assembly
*/
@NonNull
public abstract Class<? extends IBoundObject> getOscalClass();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,50 @@

import edu.umd.cs.findbugs.annotations.NonNull;

/**
* Used by implementing classes to provide an OSCAL content validation command.
*/
public abstract class AbstractOscalValidationCommand
extends AbstractValidateContentCommand {

/**
* Load the OSCAL XML schemas.
*
* @return the XML schema validator instance
* @throws IOException
* if an error occurred while parsing the provided XML schemas
*/
@NonNull
protected abstract XmlSchemaContentValidator getOscalXmlSchemas() throws IOException, SAXException;

protected abstract XmlSchemaContentValidator getOscalXmlSchemas() throws IOException;

/**
* Load the OSCAL JSON schemas.
*
* @return the XML schema validator instance
* @throws IOException
* if an error occurred while parsing the provided XML schemas
*/
@NonNull
protected abstract JsonSchemaContentValidator getOscalJsonSchema() throws IOException;

@Override
public ICommandExecutor newExecutor(CallingContext callingContext, CommandLine commandLine) {
return new AbstractOscalValidationCommand.OscalValidationCommandExecutor(callingContext, commandLine);
}
public abstract ICommandExecutor newExecutor(CallingContext callingContext, CommandLine commandLine);

/**
* Provides OSCAL validation command execution support.
*/
protected class OscalValidationCommandExecutor
extends AbstractValidateContentCommand.AbstractValidationCommandExecutor
implements ISchemaValidationProvider {

/**
* Construct a new command executor.
*
* @param callingContext
* the context of the command execution
* @param commandLine
* the parsed command line details
*/
protected OscalValidationCommandExecutor(
@NonNull CallingContext callingContext,
@NonNull CommandLine commandLine) {
Expand Down
Loading
Loading