class ExplorableDatasetRest {

    @DELETE
    @Path("{recordIRI}/instances/{instanceIRI}")
    @Produces(MediaType.APPLICATION_JSON)
    @RolesAllowed("user")
    @ApiOperation("Deletes an instance by its ID.")
    public Response deleteInstance(@PathParam("recordIRI") String recordIRI,
                            @PathParam("instanceIRI") String instanceIRI) {
        checkStringParam(recordIRI, "The Dataset Record IRI is required.");
        checkStringParam(instanceIRI, "The Instance IRI is required.");
        try (DatasetConnection conn = datasetManager.getConnection(factory.createIRI(recordIRI))) {
            Model instanceModel = getInstance(instanceIRI, conn);
            if (instanceModel.size() == 0) {
                throw ErrorUtils.sendError("The requested instance could not be found.", Response.Status.BAD_REQUEST);
            }
            conn.begin();
            conn.remove(instanceModel);
            conn.remove((Resource) null, null, factory.createIRI(instanceIRI));
            conn.commit();
            return Response.ok().build();
        } catch (IllegalArgumentException e) {
            throw ErrorUtils.sendError(e, e.getMessage(), Response.Status.BAD_REQUEST);
        } catch (IllegalStateException | MobiException e) {
            throw ErrorUtils.sendError(e, e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
        }
    }

}