code: public ContentPermission[] insertGraphDoc(String graph) throws IOException {
          ArrayList<ContentPermission> perms = new ArrayList<ContentPermission>();
              ContentPermission[] permissions = defaultPerms;
              StringBuilder sb = graphQry;
              if (countPerBatch >= MAXGRAPHSPERREQUEST) {
                  countPerBatch = 0;
                  submitGraphQuery();
                  graphQry.setLength(0);
              }
              String escapedGraph = escapeXml(graph);
              sb.append("if(fn:empty(fn:doc(\"").append(escapedGraph)
                  .append("\"))) then sem:create-graph-document(sem:iri(\"")
                  .append(escapedGraph).append("\"),(");
              if (permissions != null && permissions.length > 0) {
                  for (int i = 0; i < permissions.length; i++) {
                      ContentPermission cp = permissions[i];
                      if (i > 0)
                          sb.append(",");
                      sb.append("xdmp:permission(\"");
                      sb.append(cp.getRole());
                      sb.append("\",\"");
                      sb.append(cp.getCapability());
                      sb.append("\")");
                  }
                  sb.append(")");
              } else {
                  sb.append("xdmp:default-permissions())");
              }
              sb.append(") else ();\n");
              countPerBatch++;
          return perms.toArray(new ContentPermission[0]);
      }
docs: /*
  create graph doc
  
  return ContentPermission[] for the graph