class ExplorableDatasetRest {

    @PUT
    @Path("{recordIRI}/instances/{instanceIRI}")
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    @RolesAllowed("user")
    @ApiOperation("Updates an instance of a particular class type from a Dataset in the local Catalog")
    public Response updateInstance(@PathParam("recordIRI") String recordIRI,
                            @PathParam("instanceIRI") String instanceIRI,
                            String json) {
        checkStringParam(recordIRI, "The Dataset Record IRI is required.");
        checkStringParam(instanceIRI, "The Instance IRI is required.");
        try (DatasetConnection conn = datasetManager.getConnection(factory.createIRI(recordIRI))) {
            Resource instanceId = factory.createIRI(instanceIRI);
            RepositoryResult<Statement> statements = conn.getStatements(instanceId, null, null);
            if (!statements.hasNext()) {
                throw ErrorUtils.sendError("The requested instance could not be found.", Response.Status.BAD_REQUEST);
            }
            RepositoryResult<Statement> reifiedDeclarations = conn.getStatements(null,
                    sesameTransformer.mobiIRI(RDF.SUBJECT), instanceId);
            conn.begin();
            conn.remove(statements);
            reifiedDeclarations.forEach(statement -> {
                RepositoryResult<Statement> reification = conn.getStatements(statement.getSubject(), null, null);
                conn.remove(reification);
            });
            conn.add(jsonldToDeskolemizedModel(json, sesameTransformer, bNodeService));
            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);
        }
    }

}