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 1a815531..8406d0e6 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 @@ -134,9 +134,11 @@ public static IDocumentNodeItem resolveProfile(@NotNull IDocumentNodeItem profil throw new MetapathException(String.format("Unable to resolve profile '%s'", profile.getBaseUri()), ex); } IBindingContext bindingContext = OscalBindingContext.instance(); - IAssemblyClassBinding catalogClassBinding = (IAssemblyClassBinding)ObjectUtils.notNull(bindingContext.getClassBinding(Catalog.class)); - - retval = IXdmFactory.INSTANCE.newDocumentNodeItem(new RootAssemblyDefinition(catalogClassBinding), resolvedCatalog, profile.getBaseUri()); + IAssemblyClassBinding catalogClassBinding + = (IAssemblyClassBinding) ObjectUtils.notNull(bindingContext.getClassBinding(Catalog.class)); + + retval = IXdmFactory.INSTANCE.newDocumentNodeItem(new RootAssemblyDefinition(catalogClassBinding), + resolvedCatalog, profile.getBaseUri()); } return retval; } diff --git a/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/AbstractBackMatter.java b/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/AbstractBackMatter.java index c59de8da..452fe38f 100644 --- a/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/AbstractBackMatter.java +++ b/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/AbstractBackMatter.java @@ -37,13 +37,15 @@ public abstract class AbstractBackMatter implements IBackMatter { @Override public Resource getResourceByUuid(@NotNull UUID uuid) { - List resources = getResources(); + List<@NotNull Resource> resources = getResources(); Resource retval = null; if (resources != null) { - retval = resources.stream().filter(resource -> { - return uuid.equals(resource.getUuid()); - }).findFirst().orElse(null); + retval = resources.stream() + .filter(resource -> { + return uuid.equals(resource.getUuid()); + }).findFirst() + .orElse(null); } return retval; } diff --git a/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/AbstractMetadata.java b/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/AbstractMetadata.java index 21d99bff..9b36bccd 100644 --- a/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/AbstractMetadata.java +++ b/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/AbstractMetadata.java @@ -23,7 +23,31 @@ * 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.oscal.lib.model.metadata; +import gov.nist.secauto.oscal.lib.model.BackMatter.Resource; +import gov.nist.secauto.oscal.lib.model.Party; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; +import java.util.UUID; + public abstract class AbstractMetadata implements IMetadata { + + @Override + public Party getPartyByUuid(@NotNull UUID uuid) { + List<@NotNull Party> parties = getParties(); + + Party retval = null; + if (parties != null) { + retval = parties.stream() + .filter(party -> { + return uuid.equals(party.getUuid()); + }).findFirst() + .orElse(null); + } + return retval; + } } diff --git a/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/IMetadata.java b/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/IMetadata.java index 1c94148f..81d3fb04 100644 --- a/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/IMetadata.java +++ b/src/main/java/gov/nist/secauto/oscal/lib/model/metadata/IMetadata.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.oscal.lib.model.metadata; import gov.nist.secauto.oscal.lib.model.Location; @@ -30,10 +31,14 @@ import gov.nist.secauto.oscal.lib.model.Role; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.UUID; public interface IMetadata { + @Nullable + Party getPartyByUuid(@NotNull UUID uuid); List<@NotNull Role> getRoles(); diff --git a/src/test/java/gov/nist/secauto/oscal/java/TestContent.java b/src/test/java/gov/nist/secauto/oscal/java/TestContent.java index 0b349c4a..cd78e4b4 100644 --- a/src/test/java/gov/nist/secauto/oscal/java/TestContent.java +++ b/src/test/java/gov/nist/secauto/oscal/java/TestContent.java @@ -48,7 +48,7 @@ class TestContent { private static final Logger LOGGER = LogManager.getLogger(TestContent.class); - + private enum OperationType { SERIALIZE, DESERIALIZE; @@ -140,7 +140,6 @@ private static void chainReadWrite(File xmlSource, Class clazz, P } } - @Disabled @Test public void testReadWriteOscalCatalog(@TempDir Path tempDir) throws IOException, BindingException { @@ -156,6 +155,7 @@ public void testReadWriteOscalCatalog(@TempDir Path tempDir) throws IOException, chainReadWrite(catalogSourceXml, Catalog.class, outPath, 1); } + @Disabled @Test public void testOscalCatalogMetrics(@TempDir Path tempDir) throws IOException, BindingException { 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 008ba0c9..cc10225f 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 @@ -66,7 +66,6 @@ import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; - class ProfileResolutionTests { private static final String XSLT_PATH = "oscal/src/utils/util/resolver-pipeline/oscal-profile-test-helper.xsl"; private static final String PROFILE_PATH = "oscal/src/specifications/profile-resolution/profile-resolution-examples";