コード例 #1
0
 public void addMember(Principal principal) {
   // Add the principal as member in this principal if it isn't
   // already a member.
   if (findMemberRelationshipTo(principal) != null) {
     return;
   }
   principal
       .getUnderlyingNode()
       .createRelationshipTo(getUnderlyingNode(), SecurityRelationshipTypes.MEMBER);
   principal.deleteRootRelIfAny();
 }
コード例 #2
0
 private Relationship findMemberRelationshipTo(Principal principal) {
   for (Relationship rel :
       principal
           .getUnderlyingNode()
           .getRelationships(SecurityRelationshipTypes.MEMBER, Direction.OUTGOING)) {
     if (rel.getEndNode().equals(getUnderlyingNode())) {
       return rel;
     }
   }
   return null;
 }
コード例 #3
0
 public void removeMember(Principal principal) {
   Relationship rel = findMemberRelationshipTo(principal);
   if (rel == null) {
     throw new IllegalArgumentException(principal + " not a member of " + this);
   }
   rel.delete();
   if (!principal.getMemberships().iterator().hasNext()) {
     getGraphDb()
         .getReferenceNode()
         .createRelationshipTo(principal.getUnderlyingNode(), SecurityRelationshipTypes.PRINCIPAL);
   }
 }