Skip to content

Commit

Permalink
Do not use InfModel in ImportItem as it consumes a lot of memory
Browse files Browse the repository at this point in the history
  • Loading branch information
namedgraph committed Oct 22, 2023
1 parent 4f30f58 commit 06df4e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
1 change: 0 additions & 1 deletion http-tests/imports/rdf-test.rq
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ CONSTRUCT
?item a dh:Item ;
foaf:primaryTopic ?concept ;
sioc:has_container ?container ;
dh:slug ?id ;
dct:title ?prefLabel .
}
}
Expand Down
17 changes: 6 additions & 11 deletions src/main/java/com/atomgraph/linkeddatahub/resource/ImportItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.atomgraph.linkeddatahub.apps.model.EndUserApplication;
import com.atomgraph.linkeddatahub.client.LinkedDataClient;
import com.atomgraph.linkeddatahub.model.CSVImport;
import com.atomgraph.linkeddatahub.model.Import;
import com.atomgraph.linkeddatahub.model.RDFImport;
import com.atomgraph.linkeddatahub.resource.graph.Item;
import com.atomgraph.linkeddatahub.server.security.AgentContext;
Expand All @@ -41,9 +40,7 @@
import jakarta.ws.rs.core.UriInfo;
import jakarta.ws.rs.ext.Providers;
import org.apache.jena.ontology.Ontology;
import org.apache.jena.rdf.model.InfModel;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.NodeIterator;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.sparql.vocabulary.FOAF;
Expand Down Expand Up @@ -86,25 +83,23 @@ public ImportItem(@Context Request request, @Context UriInfo uriInfo, MediaTypes

@PUT
@Override
public Response put(Model model, @QueryParam("default") @DefaultValue("false") Boolean defaultGraph, @QueryParam("graph") URI graphUri)
public Response put(Model model, @QueryParam("default") @DefaultValue("false") Boolean defaultGraph, @QueryParam("graph") URI graphUriUnused)
{
Response response = super.put(model, defaultGraph, graphUri); // construct Import
Response response = super.put(model, defaultGraph, getURI()); // construct Import

if (response.getStatus() == Status.CREATED.getStatusCode()) // import created
{
URI importGraphUri = response.getLocation();
//Model importModel = (Model)super.get(false, importGraphUri).getEntity();
InfModel infModel = ModelFactory.createRDFSModel(getOntology().getOntModel(), model);
Resource doc = infModel.createResource(importGraphUri.toString());
URI graphUri = response.getLocation();
Resource doc = model.createResource(graphUri.toString());

NodeIterator it = infModel.listObjectsOfProperty(doc, FOAF.primaryTopic);
NodeIterator it = model.listObjectsOfProperty(doc, FOAF.primaryTopic);
try
{
if (it.hasNext())
{
Resource topic = it.next().asResource();

if (topic != null && topic.canAs(Import.class))
if (topic != null && !topic.canAs(CSVImport.class) && !topic.canAs(RDFImport.class))
{
Service adminService = getApplication().canAs(EndUserApplication.class) ? getApplication().as(EndUserApplication.class).getAdminApplication().getService() : null;
LinkedDataClient ldc = LinkedDataClient.create(getSystem().getClient(), getSystem().getMediaTypes()).
Expand Down

0 comments on commit 06df4e5

Please sign in to comment.