Skip to content

Commit

Permalink
Improved some logging messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
david-waltermire committed Sep 20, 2023
1 parent ee819d5 commit 4fbe56d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public T load(@NonNull URI resource) throws MetaschemaException, IOException {
*/
@NonNull
public T load(@NonNull Path path) throws MetaschemaException, IOException {
return loadInternal(ObjectUtils.notNull(path.toUri()), new LinkedList<>());
return loadInternal(ObjectUtils.notNull(path.toAbsolutePath().normalize().toUri()), new LinkedList<>());
}

/**
Expand All @@ -123,7 +123,7 @@ public T load(@NonNull Path path) throws MetaschemaException, IOException {
*/
@NonNull
public T load(@NonNull File file) throws MetaschemaException, IOException {
return loadInternal(ObjectUtils.notNull(file.toURI()), new LinkedList<>());
return load(file.toPath());
}

/**
Expand Down Expand Up @@ -183,7 +183,7 @@ protected T loadInternal(@NonNull URI resource, @NonNull Deque<URI> visitedResou

T retval = cache.get(resource);
if (retval == null) {
LOGGER.info("Loading metaschema '{}'", resource);
LOGGER.info("Loading module '{}'", resource);

try {
visitedResources.push(resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,18 @@ public static MetapathExpression decodeMetaschemaPathType(SimpleValue value) {
XmlBookmark bookmark = cursor.getBookmark(XmlLineNumber.class);
if (bookmark != null) {
XmlLineNumber lineNumber = (XmlLineNumber) bookmark;
builder.append(" at location ")
.append(lineNumber.getLine())
builder.append(" at location '");

String source = cursor.documentProperties().getSourceName();
if (source != null) {
builder.append(source)
.append(':');
}

builder.append(lineNumber.getLine())
.append(':')
.append(lineNumber.getColumn());
.append(lineNumber.getColumn())
.append('\'');
}
}
XmlValueNotSupportedException exNew
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import gov.nist.secauto.metaschema.databind.codegen.ClassUtils;
import gov.nist.secauto.metaschema.databind.codegen.config.IBindingConfiguration;

import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -164,7 +165,7 @@ private String generateClassName(@NonNull String packageOrTypeName, @NonNull IFl
clash = true;
// first try to append the metaschema's short name
String metaschemaShortName = definition.getContainingModule().getShortName();
retval = ClassUtils.toClassName(className + metaschemaShortName);
retval = ClassUtils.toClassName(className + StringUtils.capitalize(metaschemaShortName));
}

String classNameBase = retval;
Expand All @@ -176,8 +177,9 @@ private String generateClassName(@NonNull String packageOrTypeName, @NonNull IFl

if (clash && LOGGER.isWarnEnabled()) {
LOGGER.warn(String.format(
"Class name '%s' in metaschema '%s' conflicts with a previously used class name. Using '%s' instead.",
"Class name '%s', based on '%s' in '%s', clashes with another bound class. Using '%s' instead.",
className,
definition.getName(),
definition.getContainingModule().getLocation(),
retval));
}
Expand Down

0 comments on commit 4fbe56d

Please sign in to comment.