I am using java-api of Marklogic database, As per my requirement I delete the triple graph each time I receive request and then create a new one with triples. For now I have wrapped the code in try-catch block to catch exception and proceed.
try {
GraphManager graphManager = client.newGraphManager();
graphManager.setDefaultMimetype(RDFMimeTypes.NTRIPLES);
graphManager.delete(graphUri)
}
catch (Exception ex) {
// do nothing for this
}
Is there any better way to check for the existing graph of triples with graph manager, I have seen graph manager class, but I didn't find any way to check availability of graph.
With GraphManager, call
listGraphUris
. That will give you anIterator<String>
. Loop through that to check whether the URI of the graph you're interested in is present.