Skip to content

Commit b53a2cf

Browse files
namedgraphclaude
andcommitted
Seed the ad-hoc ontology repository in Namespace
Namespace built a fresh OntologyRepository without the bundled vocabulary/ontology mappings, so an empty SPARQL result would fall through to an HTTP dereference of a bundled URI instead of the shipped file. Extract Application.createRepository(app) (the seeding done by getRepository(app)) and use it in both places. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5d4d91a commit b53a2cf

2 files changed

Lines changed: 22 additions & 11 deletions

File tree

src/main/java/com/atomgraph/linkeddatahub/Application.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,15 +1782,25 @@ protected Map<String, OntologyRepository> getEndUserRepositories()
17821782
*/
17831783
public OntologyRepository getRepository(EndUserApplication app)
17841784
{
1785-
return getEndUserRepositories().computeIfAbsent(app.getURI(), uri ->
1786-
{
1787-
OntologyRepository appRepository = new OntologyRepository(app, this, GraphStoreClient.create(getClient(), getMediaTypes()), getOntologyQuery());
1788-
// seed bundled vocabulary/ontology mappings from the global repository
1789-
getRepository().getLocationMappings().forEach(appRepository::addLocationMapping);
1790-
getRepository().getPrefixMappings().forEach(appRepository::addPrefixMapping);
1785+
return getEndUserRepositories().computeIfAbsent(app.getURI(), uri -> createRepository(app));
1786+
}
17911787

1792-
return appRepository;
1793-
});
1788+
/**
1789+
* Creates a fresh ontology repository for an application, seeded with the bundled
1790+
* vocabulary/ontology mappings from the global repository so that mapped URIs resolve to shipped
1791+
* files rather than being dereferenced over HTTP.
1792+
*
1793+
* @param app end-user application resource
1794+
* @return ontology repository
1795+
*/
1796+
public OntologyRepository createRepository(EndUserApplication app)
1797+
{
1798+
OntologyRepository appRepository = new OntologyRepository(app, this, GraphStoreClient.create(getClient(), getMediaTypes()), getOntologyQuery());
1799+
// seed bundled vocabulary/ontology mappings from the global repository
1800+
getRepository().getLocationMappings().forEach(appRepository::addLocationMapping);
1801+
getRepository().getPrefixMappings().forEach(appRepository::addPrefixMapping);
1802+
1803+
return appRepository;
17941804
}
17951805

17961806
/**

src/main/java/com/atomgraph/linkeddatahub/resource/Namespace.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,10 @@ public Response get(@QueryParam(QUERY) Query query,
139139
{
140140
// the application ontology MUST use a <ns> URI! This is the URI this ontology endpoint is deployed on by the Dispatcher class
141141
String ontologyURI = getApplication().getOntology().getURI();
142-
if (log.isDebugEnabled()) log.debug("Returning namespace ontology from OntDocumentManager: {}", ontologyURI);
143-
// not returning the injected in-memory ontology because it has inferences applied to it
144-
OntologyRepository repository = new OntologyRepository(getApplication().as(EndUserApplication.class), getSystem(), com.atomgraph.linkeddatahub.client.GraphStoreClient.create(getSystem().getClient(), getSystem().getMediaTypes()), getSystem().getOntologyQuery());
142+
if (log.isDebugEnabled()) log.debug("Returning raw namespace ontology: {}", ontologyURI);
143+
// not returning the injected in-memory ontology because it has inferences applied to it;
144+
// a fresh, mapping-seeded repository serves the raw SPARQL-loaded ontology
145+
OntologyRepository repository = getSystem().createRepository(getApplication().as(EndUserApplication.class));
145146
return getResponseBuilder(org.apache.jena.rdf.model.ModelFactory.createModelForGraph(repository.get(ontologyURI))).build();
146147
}
147148
else throw new BadRequestException("SPARQL query string not provided");

0 commit comments

Comments
 (0)