Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@


package gov.nist.secauto.metaschema.cli.processor;

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

/**
* Provides version information for this library.
* <p>
* This class exposes build-time metadata including version numbers, build
* timestamps, and Git repository information.
*/
public class ProcessorVersion implements IVersionInfo {

private static final String NAME = "metaschema-java";
private static final String 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() {
return NAME;
}

@Override
public String getVersion() {
return VERSION;
}

@Override
public String getBuildTimestamp() {
return BUILD_TIMESTAMP;
}

@Override
public String getGitOriginUrl() {
return ORIGIN;
}

@Override
public String getGitCommit() {
return COMMIT;
}

@Override
public String getGitBranch() {
return BRANCH;
}

@Override
public String getGitClosestTag() {
return CLOSEST_TAG;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

/**
* Records information about the exit status of a CLI command.
*/
public abstract class AbstractExitStatus implements ExitStatus {
private static final Logger LOGGER = LogManager.getLogger(AbstractExitStatus.class);

Expand Down Expand Up @@ -61,8 +64,8 @@ public ExitStatus withThrowable(@NonNull Throwable throwable) {
@Nullable
protected abstract String getMessage();

@Override
public void generateMessage(boolean showStackTrace) {
@Nullable
private LogBuilder getLogBuilder() {
LogBuilder logBuilder = null;
if (getExitCode().getStatusCode() <= 0) {
if (LOGGER.isInfoEnabled()) {
Expand All @@ -71,24 +74,31 @@ public void generateMessage(boolean showStackTrace) {
} else if (LOGGER.isErrorEnabled()) {
logBuilder = LOGGER.atError();
}
return logBuilder;
}

if (logBuilder != null) {
if (showStackTrace && throwable != null) {
Throwable throwable = getThrowable();
logBuilder.withThrowable(throwable);
}
@Override
public void generateMessage(boolean showStackTrace) {
LogBuilder logBuilder = getLogBuilder();
if (logBuilder == null) {
return;
}

String message = getMessage();
if (message == null && throwable != null) {
message = throwable.getLocalizedMessage();
}
boolean useStackTrace = showStackTrace && throwable != null;
if (useStackTrace) {
logBuilder.withThrowable(throwable);
}

if (message != null && !message.isEmpty()) {
logBuilder.log(message);
} else if (showStackTrace && throwable != null) {
// log the throwable
logBuilder.log();
}
String message = getMessage();
if (throwable != null && message == null) {
message = throwable.getLocalizedMessage();
}

if (message != null && !message.isEmpty()) {
logBuilder.log(message);
} else if (useStackTrace) {
// log the throwable
logBuilder.log();
}
}

Expand Down
Loading
Loading