JCL-361: Make it easier to modify Access Control resources by acoburn · Pull Request #473 · inrupt/solid-client-java

This introduces a utility function to make it easier to modify Access Control resources to support AccessGrants.

Eventually, this will become part of a stand-alone ACP module, but adding full support for ACP is beyond the scope of the 1.0 release. This, however, allows developers to interact more easily with ACRs within the 1.0 release timeframe.

A sample usage of this would be:

try (final SolidRDFSource resource = client.read(uri, SolidRDFSource.class)) {
    resource.getMetadata().getAcl().ifPresent(acl -> {
        try (final SolidRDFSource acr = client.read(acl, SolidRDFSource.class)) {
            AccessGrantUtils.accessControlPolicyTriples(acl, ACL.Read, ACL.Write)
                .forEach(acr.getGraph()::add);
            client.update(acr);
        }
    });
}