Ejemplo n.º 1
0
 public void delete() {
   for (Principal memberOfPrincipal : getMemberships()) {
     memberOfPrincipal.removeMember(this);
   }
   for (Relationship accessRel :
       getUnderlyingNode().getRelationships(SecurityRelationshipTypes.ACCESS)) {
     accessRel.delete();
   }
   deleteRootRelIfAny();
   getUnderlyingNode().delete();
 }
Ejemplo n.º 2
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();
 }
Ejemplo n.º 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);
   }
 }
Ejemplo n.º 4
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;
 }