Search in sources :

Example 6 with UpdateException

use of org.apache.jena.update.UpdateException in project jena by apache.

the class AbstractTestUpdateGraphMgt method testCreateDrop1.

@Test
public void testCreateDrop1() {
    DatasetGraph gStore = getEmptyDatasetGraph();
    Update u = new UpdateCreate(graphIRI);
    UpdateAction.execute(u, gStore);
    // Only true if a graph caching layer exists.
    // JENA-1068 removed that layer
    // (which wasn't safe anyway - it only "existed" in the memory cache)
    // assertTrue(gStore.containsGraph(graphIRI)) ;
    assertTrue(graphEmpty(gStore.getGraph(graphIRI)));
    // With "auto SILENT" then these aren't errors.
    boolean silentMode = true;
    if (!silentMode) {
        // try again - should fail (already exists)
        try {
            UpdateAction.execute(u, gStore);
            fail();
        } catch (UpdateException ex) {
        }
    }
    // Drop it.
    u = new UpdateDrop(graphIRI);
    UpdateAction.execute(u, gStore);
    assertFalse(gStore.containsGraph(graphIRI));
    if (!silentMode) {
        // Drop it again. - should fail
        try {
            UpdateAction.execute(u, gStore);
            fail();
        } catch (UpdateException ex) {
        }
    }
}
Also used : UpdateCreate(org.apache.jena.sparql.modify.request.UpdateCreate) UpdateException(org.apache.jena.update.UpdateException) Update(org.apache.jena.update.Update) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) UpdateDrop(org.apache.jena.sparql.modify.request.UpdateDrop) Test(org.junit.Test)

Example 7 with UpdateException

use of org.apache.jena.update.UpdateException in project jena by apache.

the class UpdateExecDatasetBuilder method build.

@Override
public UpdateExec build() {
    Objects.requireNonNull(dataset, "No dataset for update");
    Objects.requireNonNull(updateRequest, "No update request");
    UpdateRequest actualUpdate = updateRequest;
    if (substitutionMap != null && !substitutionMap.isEmpty())
        actualUpdate = UpdateTransformOps.transform(actualUpdate, substitutionMap);
    Context cxt = Context.setupContextForDataset(context, dataset);
    UpdateEngineFactory f = UpdateEngineRegistry.get().find(dataset, cxt);
    if (f == null)
        throw new UpdateException("Failed to find an UpdateEngine");
    UpdateExec uExec = new UpdateExecDataset(actualUpdate, dataset, initialBinding, cxt, f);
    return uExec;
}
Also used : Context(org.apache.jena.sparql.util.Context) UpdateEngineFactory(org.apache.jena.sparql.modify.UpdateEngineFactory) UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateException(org.apache.jena.update.UpdateException)

Aggregations

UpdateException (org.apache.jena.update.UpdateException)7 QueryException (org.apache.jena.query.QueryException)3 QueryParseException (org.apache.jena.query.QueryParseException)3 UpdateRequest (org.apache.jena.update.UpdateRequest)3 JenaException (org.apache.jena.shared.JenaException)2 SPARQLParser11 (org.apache.jena.sparql.lang.sparql_11.SPARQLParser11)2 Context (org.apache.jena.sparql.util.Context)2 HttpClient (java.net.http.HttpClient)1 InternalErrorException (org.apache.jena.atlas.lib.InternalErrorException)1 TypedInputStream (org.apache.jena.atlas.web.TypedInputStream)1 Graph (org.apache.jena.graph.Graph)1 Node (org.apache.jena.graph.Node)1 QueryBuildException (org.apache.jena.query.QueryBuildException)1 Lang (org.apache.jena.riot.Lang)1 RDFParser (org.apache.jena.riot.RDFParser)1 OperationDeniedException (org.apache.jena.shared.OperationDeniedException)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1 QueryExceptionHTTP (org.apache.jena.sparql.engine.http.QueryExceptionHTTP)1 TemplateLib.remapDefaultGraph (org.apache.jena.sparql.modify.TemplateLib.remapDefaultGraph)1 UpdateEngineFactory (org.apache.jena.sparql.modify.UpdateEngineFactory)1