From 8ec833a64d81429bea5519ba963698b708cc5701 Mon Sep 17 00:00:00 2001 From: David Waltermire Date: Thu, 19 Oct 2023 03:03:07 -0400 Subject: [PATCH] Updating to latest metaschema-java:1.0.0-M2-SNAPSHOT. --- pom.xml | 4 ++-- .../metapath/function/library/HasOscalNamespace.java | 10 +++++----- .../lib/metapath/function/library/ResolveProfile.java | 2 +- .../oscal/lib/profile/resolver/ProfileResolver.java | 9 ++------- .../resolver/policy/ReferenceCountingVisitor.java | 2 +- .../java/gov/nist/secauto/oscal/java/ExamplesTest.java | 2 +- .../nist/secauto/oscal/java/MetaschemaVisitorTest.java | 2 +- .../lib/profile/resolver/ProfileResolutionTests.java | 2 +- 8 files changed, 14 insertions(+), 19 deletions(-) diff --git a/pom.xml b/pom.xml index a52c055f..f6b85196 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ gov.nist.secauto oss-parent - 27-SNAPSHOT + 28-SNAPSHOT gov.nist.secauto.oscal @@ -124,7 +124,7 @@ UTF-8 UTF-8 - 1.0.0-SNAPSHOT + 1.0.0-M2-SNAPSHOT 1.0.1 3.13.0 diff --git a/src/main/java/gov/nist/secauto/oscal/lib/metapath/function/library/HasOscalNamespace.java b/src/main/java/gov/nist/secauto/oscal/lib/metapath/function/library/HasOscalNamespace.java index 1fc46886..b4ef4004 100644 --- a/src/main/java/gov/nist/secauto/oscal/lib/metapath/function/library/HasOscalNamespace.java +++ b/src/main/java/gov/nist/secauto/oscal/lib/metapath/function/library/HasOscalNamespace.java @@ -56,7 +56,7 @@ public final class HasOscalNamespace { static final IFunction SIGNATURE_ONE_ARG = IFunction.builder() .name("has-oscal-namespace") .namespace(OscalBindingContext.NS_OSCAL) - .argument(IArgument.newBuilder() + .argument(IArgument.builder() .name("namespace") .type(IStringItem.class) .oneOrMore() @@ -74,12 +74,12 @@ public final class HasOscalNamespace { static final IFunction SIGNATURE_TWO_ARGS = IFunction.builder() .name("has-oscal-namespace") .namespace(OscalBindingContext.NS_OSCAL) - .argument(IArgument.newBuilder() + .argument(IArgument.builder() .name("propOrPart") .type(IAssemblyNodeItem.class) .one() .build()) - .argument(IArgument.newBuilder() + .argument(IArgument.builder() .name("namespace") .type(IStringItem.class) .oneOrMore() @@ -173,10 +173,10 @@ public static IBooleanItem hasNamespace( Object defaultValue = flag.getDefinition().getDefaultValue(); if (defaultValue != null) { - nodeNamespace = IAnyUriItem.valueOf(ObjectUtils.notNull(defaultValue.toString())).getValue(); + nodeNamespace = IAnyUriItem.valueOf(ObjectUtils.notNull(defaultValue.toString())).asUri(); } } else { - nodeNamespace = IAnyUriItem.cast(FnData.fnDataItem(ns)).getValue(); + nodeNamespace = IAnyUriItem.cast(FnData.fnDataItem(ns)).asUri(); } String nodeNamespaceString = AbstractProperty.normalizeNamespace(nodeNamespace).toString(); diff --git a/src/main/java/gov/nist/secauto/oscal/lib/metapath/function/library/ResolveProfile.java b/src/main/java/gov/nist/secauto/oscal/lib/metapath/function/library/ResolveProfile.java index f2edfa53..5a2604e2 100644 --- a/src/main/java/gov/nist/secauto/oscal/lib/metapath/function/library/ResolveProfile.java +++ b/src/main/java/gov/nist/secauto/oscal/lib/metapath/function/library/ResolveProfile.java @@ -64,7 +64,7 @@ public final class ResolveProfile { static final IFunction SIGNATURE_ONE_ARG = IFunction.builder() .name("resolve-profile") .namespace(OscalBindingContext.NS_OSCAL) - .argument(IArgument.newBuilder() + .argument(IArgument.builder() .name("profile") .type(INodeItem.class) .zeroOrOne() diff --git a/src/main/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolver.java b/src/main/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolver.java index 25710e6c..ac6d0f33 100644 --- a/src/main/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolver.java +++ b/src/main/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolver.java @@ -26,8 +26,6 @@ package gov.nist.secauto.oscal.lib.profile.resolver; -import com.fasterxml.jackson.databind.util.ByteBufferBackedInputStream; - import gov.nist.secauto.metaschema.core.metapath.DynamicContext; import gov.nist.secauto.metaschema.core.metapath.IDocumentLoader; import gov.nist.secauto.metaschema.core.metapath.ISequence; @@ -81,7 +79,6 @@ import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -159,7 +156,7 @@ public void setBoundLoader(@NonNull IBoundLoader loader) { public DynamicContext getDynamicContext() { synchronized (this) { if (dynamicContext == null) { - dynamicContext = StaticContext.builder().build().newDynamicContext(); + dynamicContext = StaticContext.builder().build().dynamicContext(); dynamicContext.setDocumentLoader(getBoundLoader()); } assert dynamicContext != null; @@ -446,9 +443,7 @@ private IDocumentNodeItem getImport( if (buffer != null) { URI resourceUri = baseUri.resolve("#" + resource.getUuid()); assert resourceUri != null; - try (InputStream is = new ByteBufferBackedInputStream(buffer)) { - retval = loader.loadAsNodeItem(is, resourceUri); - } + retval = loader.loadAsNodeItem(resourceUri); } if (retval == null) { diff --git a/src/main/java/gov/nist/secauto/oscal/lib/profile/resolver/policy/ReferenceCountingVisitor.java b/src/main/java/gov/nist/secauto/oscal/lib/profile/resolver/policy/ReferenceCountingVisitor.java index 510413ff..55e08dd6 100644 --- a/src/main/java/gov/nist/secauto/oscal/lib/profile/resolver/policy/ReferenceCountingVisitor.java +++ b/src/main/java/gov/nist/secauto/oscal/lib/profile/resolver/policy/ReferenceCountingVisitor.java @@ -428,7 +428,7 @@ private static void handleMarkup( @NonNull IFieldNodeItem item, @NonNull Context context) { IMarkupItem markupItem = (IMarkupItem) FnData.fnDataItem(item); - IMarkupString markup = markupItem.getValue(); + IMarkupString markup = markupItem.asMarkup(); handleMarkup(item, markup, context); } diff --git a/src/test/java/gov/nist/secauto/oscal/java/ExamplesTest.java b/src/test/java/gov/nist/secauto/oscal/java/ExamplesTest.java index fe80bfaf..6815d34b 100644 --- a/src/test/java/gov/nist/secauto/oscal/java/ExamplesTest.java +++ b/src/test/java/gov/nist/secauto/oscal/java/ExamplesTest.java @@ -93,7 +93,7 @@ void testConstraintValidation() IDocumentNodeItem nodeItem = loader.loadAsNodeItem(new URL( "https://raw.githubusercontent.com/Rene2mt/fedramp-automation/a692b9385d8fbcacbb1d3e3d0b0d7e3c45a205d0/src/content/baselines/rev5/xml/FedRAMP_rev5_HIGH-baseline_profile.xml")); - DynamicContext dynamicContext = StaticContext.builder().build().newDynamicContext(); + DynamicContext dynamicContext = StaticContext.instance().dynamicContext(); dynamicContext.setDocumentLoader(loader); FindingCollectingConstraintValidationHandler handler = new FindingCollectingConstraintValidationHandler(); DefaultConstraintValidator validator = new DefaultConstraintValidator(dynamicContext, handler); diff --git a/src/test/java/gov/nist/secauto/oscal/java/MetaschemaVisitorTest.java b/src/test/java/gov/nist/secauto/oscal/java/MetaschemaVisitorTest.java index 0e50b3d3..a8f0334f 100644 --- a/src/test/java/gov/nist/secauto/oscal/java/MetaschemaVisitorTest.java +++ b/src/test/java/gov/nist/secauto/oscal/java/MetaschemaVisitorTest.java @@ -62,7 +62,7 @@ void test() throws FileNotFoundException, IOException, URISyntaxException { StaticContext staticContext = StaticContext.builder() .baseUri(baseUri) .build(); - DynamicContext dynamicContext = staticContext.newDynamicContext(); + DynamicContext dynamicContext = staticContext.dynamicContext(); dynamicContext.setDocumentLoader(loader); // File file = new diff --git a/src/test/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolutionTests.java b/src/test/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolutionTests.java index 5554e8c3..bb27e8b6 100644 --- a/src/test/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolutionTests.java +++ b/src/test/java/gov/nist/secauto/oscal/lib/profile/resolver/ProfileResolutionTests.java @@ -86,7 +86,7 @@ class ProfileResolutionTests { @BeforeAll static void setup() throws SaxonApiException { - DynamicContext context = StaticContext.builder().build().newDynamicContext(); + DynamicContext context = StaticContext.instance().dynamicContext(); context.setDocumentLoader(new DefaultBoundLoader(OscalBindingContext.instance())); profileResolver = new ProfileResolver(); profileResolver.setDynamicContext(context);