Skip to content

Commit

Permalink
Merge pull request #31 from ModelDriven/feature/ST5AS-74
Browse files Browse the repository at this point in the history
ST5AS-74 Temporarily inline JSON-LD @context by default.
  • Loading branch information
ivan-gomes authored Jul 28, 2020
2 parents 81bc211 + 27532e4 commit cb3ea22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/controllers/ElementController.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public class ElementController extends Controller {
@Inject
private Environment environment;

private static final boolean INLINE_JSON_LD_CONTEXT_DEFAULT = true;
private static final boolean INLINE_JSON_LD_CONTEXT = Optional.ofNullable(System.getenv("INLINE_JSON_LD_CONTEXT"))
.map(Boolean::parseBoolean).orElse(INLINE_JSON_LD_CONTEXT_DEFAULT);

public Result byId(String id) {
UUID uuid = UUID.fromString(id);
Optional<Element> element = elementService.getById(uuid);
Expand Down Expand Up @@ -95,7 +99,7 @@ static JsonLdMofObjectAdornment adornMofObject(MofObject mof, Http.Request reque
return new JsonLdMofObjectAdornment(mof, metamodelProvider, environment,
String.format("http://%s", request.host()),
String.format("/projects/%s/commits/%s/elements/", projectId, commitId),
false
INLINE_JSON_LD_CONTEXT
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/jackson/JsonLdMofObjectAdornment.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public JsonLdMofObjectAdornment(MofObject mof, MetamodelProvider metamodelProvid
if (!(cachedContext instanceof ObjectNode)) {
throw new IllegalStateException("context expected to be an ObjectNode");
}
contextObjectNode.setAll((ObjectNode) cachedContext);
contextObjectNode.setAll((ObjectNode) cachedContext.get("@context"));
}
else {
contextObjectNode.put("@import", URI.create(host).resolve(String.format("/jsonld/%s.jsonld", type)).toString());
Expand Down

0 comments on commit cb3ea22

Please sign in to comment.