Skip to content

Commit a1ee16c

Browse files
fix: address PR review feedback
- Fix Quick Start example to use loadCatalog convenience method - Fix ProfileResolver API to use Path and return IDocumentNodeItem
1 parent 073305a commit a1ee16c

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

src/site/markdown/guides/resolving-profiles.md.vm

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,42 +26,44 @@ Profile resolution takes an OSCAL profile and produces a **resolved catalog** co
2626

2727
## Basic Profile Resolution
2828

29+
The `ProfileResolver` accepts file paths, URLs, or document nodes and returns an `IDocumentNodeItem` containing the resolved catalog:
30+
2931
```java
3032
import dev.metaschema.oscal.lib.OscalBindingContext;
3133
import dev.metaschema.oscal.lib.model.Catalog;
32-
import dev.metaschema.oscal.lib.model.Profile;
3334
import dev.metaschema.oscal.lib.profile.resolver.ProfileResolver;
34-
import dev.metaschema.databind.io.Format;
35-
import dev.metaschema.databind.io.IDeserializer;
35+
import dev.metaschema.core.model.IDocumentNodeItem;
3636

3737
import java.nio.file.Path;
3838

39-
// Load the profile
40-
OscalBindingContext context = OscalBindingContext.instance();
41-
IDeserializer<Profile> deserializer = context.newDeserializer(
42-
Format.JSON, Profile.class);
43-
Profile profile = deserializer.deserialize(Path.of("profile.json"));
44-
45-
// Resolve to catalog
39+
// Resolve a profile directly from a file path
4640
ProfileResolver resolver = new ProfileResolver();
47-
Catalog resolvedCatalog = resolver.resolve(profile);
41+
IDocumentNodeItem resolvedDocument = resolver.resolve(Path.of("profile.json"));
42+
43+
// Extract the catalog from the resolved document
44+
Catalog resolvedCatalog = (Catalog) resolvedDocument.getValue();
4845
```
4946

5047
## Resolution with Custom Document Loader
5148

52-
For profiles that import external resources:
49+
For profiles that import external resources, configure a document loader:
5350

5451
```java
55-
import dev.metaschema.core.util.IDocumentLoader;
5652
import dev.metaschema.databind.io.DefaultBoundLoader;
5753

58-
// Create a document loader
59-
IDocumentLoader loader = new DefaultBoundLoader(context);
54+
// Get the binding context
55+
OscalBindingContext context = OscalBindingContext.instance();
6056

61-
// Resolve with custom loader
57+
// Create a document loader with the context
58+
DefaultBoundLoader loader = new DefaultBoundLoader(context);
59+
60+
// Configure resolver with custom loader
6261
ProfileResolver resolver = new ProfileResolver();
6362
resolver.setDocumentLoader(loader);
64-
Catalog resolvedCatalog = resolver.resolve(profile);
63+
64+
// Resolve the profile
65+
IDocumentNodeItem resolvedDocument = resolver.resolve(Path.of("profile.json"));
66+
Catalog resolvedCatalog = (Catalog) resolvedDocument.getValue();
6567
```
6668

6769
## Saving the Resolved Catalog

src/site/markdown/index.md.vm

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,13 @@ Load and work with an OSCAL catalog:
4545
```java
4646
import dev.metaschema.oscal.lib.OscalBindingContext;
4747
import dev.metaschema.oscal.lib.model.Catalog;
48-
import dev.metaschema.databind.io.Format;
49-
import dev.metaschema.databind.io.IDeserializer;
5048
import java.nio.file.Path;
5149

5250
// Get the binding context
5351
OscalBindingContext context = OscalBindingContext.instance();
5452

55-
// Load a catalog
56-
IDeserializer<Catalog> deserializer = context.newDeserializer(
57-
Format.JSON, Catalog.class);
58-
Catalog catalog = deserializer.deserialize(Path.of("catalog.json"));
53+
// Load a catalog using the convenience method
54+
Catalog catalog = context.loadCatalog(Path.of("catalog.json"));
5955

6056
// Access content
6157
System.out.println("Catalog: " + catalog.getMetadata().getTitle());

0 commit comments

Comments
 (0)