It seems you can use org.apache.jena.sparql.syntax.syntaxtransform.UpdateTransformOps
I have the same requirement and as the documentation is super limited here, I'm still using debug mode to see how I can achieve my goal. You can inspire from this, if you have a better solution I would be very interested.
Something like that:
public class OpPermissionTransformer extends ElementTransformCopyBase {
@Override
public Element transform(ElementNamedGraph el, Node gn, Element elt1) {
return elt1;
}
}
UpdateRequest modified = UpdateTransformOps.transform(update, new OpPermissionTransformer(), new NodeTransformExpr(n -> {
// modify the node as you wish
return n;
});