Index: src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java
===================================================================
--- src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java	(revision 14)
+++ src/main/java/de/mpiwg/itgroup/annotations/neo4j/AnnotationStore.java	(revision 15)
@@ -35,5 +35,5 @@
 
     public static enum NodeTypes {
-        ANNOTATION, PERSON, TARGET
+        ANNOTATION, PERSON, TARGET, GROUP 
     }
 
@@ -41,5 +41,5 @@
 
     public static enum RelationTypes implements RelationshipType {
-        ANNOTATES, CREATED, PERMITS_ADMIN, PERMITS_DELETE, PERMITS_UPDATE, PERMITS_READ
+        ANNOTATES, CREATED, PERMITS_ADMIN, PERMITS_DELETE, PERMITS_UPDATE, PERMITS_READ, MEMBER_OF
     }
 
@@ -54,4 +54,5 @@
         nodeIndexes.add(NodeTypes.PERSON.ordinal(), graphDb.index().forNodes("persons"));
         nodeIndexes.add(NodeTypes.TARGET.ordinal(), graphDb.index().forNodes("targets"));
+        nodeIndexes.add(NodeTypes.GROUP.ordinal(), graphDb.index().forNodes("groups"));
     }
 
@@ -60,4 +61,58 @@
     }
 
+    /**
+     * @param userUri
+     * @return
+     */
+    public Node getPersonNodeByUri(String userUri) {
+        if (userUri == null) return null;
+        Node person = getNodeIndex(NodeTypes.PERSON).get("uri", userUri).getSingle();
+        return person;
+    }
+
+    
+    /**
+     * Returns List of Groups the person is member of.
+     * 
+     * @param person
+     * @return
+     */
+    public List<Group> getGroupsForPersonNode(Node person) {
+        ArrayList<Group> groups = new ArrayList<Group>();
+        Iterable<Relationship> rels = person.getRelationships(RelationTypes.MEMBER_OF);
+        for (Relationship rel : rels) {
+            Node groupNode = rel.getEndNode();
+            Actor group = createActorFromNode(groupNode);
+            // make sure we're getting a group
+            if (!(group instanceof Group)) {
+                logger.error("target of MEMBER_OF is not GROUP! rel="+rel);
+                continue;
+            }
+            groups.add((Group) group);
+        }
+        return groups;
+    }
+    
+    /**
+     * Returns if person with uri is in Group group.
+     * 
+     * @param person
+     * @param group
+     * @return
+     */
+    public boolean isPersonInGroup(Person person, Group group) {
+        Node pn = getPersonNodeByUri(person.getUriString());
+        if (pn == null) return false;
+        // optimised version of getGroupsForPersonNode
+        Iterable<Relationship> rels = pn.getRelationships(RelationTypes.MEMBER_OF);
+        for (Relationship rel : rels) {
+            Node gn = rel.getEndNode();
+            if (gn.getProperty("uri", "").equals(group.getUriString()) || gn.getProperty("id", "").equals(group.getId())) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
     /**
      * Returns the Annotation with the given id.
@@ -143,11 +198,12 @@
      */
     protected Actor createActorFromNode(Node actorNode) {
+        String id = (String) actorNode.getProperty("id", null);
         String uri = (String) actorNode.getProperty("uri", null);
         String name = (String) actorNode.getProperty("name", null);
         String type = (String) actorNode.getProperty("TYPE", null);
         if (type != null && type.equals("PERSON")) {
-            return new Person(uri, name);
+            return new Person(id, uri, name);
         } else if (type != null && type.equals("GROUP")) {
-            return new Group(uri, name);
+            return new Group(id, uri, name);
         }
         return null;
@@ -210,5 +266,5 @@
             Actor creator = annot.getCreator();
             if (creator != null) {
-                Node creatorNode = getOrCreatePersonNode(creator);
+                Node creatorNode = getOrCreateActorNode(creator);
                 getOrCreateRelation(creatorNode, RelationTypes.CREATED, annotNode);
             }
@@ -301,5 +357,5 @@
         if (userUri != null) {
             // there should be only one
-            Node person = getNodeIndex(NodeTypes.PERSON).get("uri", userUri).getSingle();
+            Node person = getPersonNodeByUri(userUri);
             if (person != null) {
                 Iterable<Relationship> relations = person.getRelationships(RelationTypes.CREATED);
@@ -381,9 +437,15 @@
     }
 
-    protected Node getOrCreatePersonNode(Actor actor) {
-        // Person is identified by URI
+    protected Node getOrCreateActorNode(Actor actor) {
+        // Person/Group is identified by URI or id
         String uri = actor.getUriString();
         String name = actor.getName();
-        Index<Node> idx = getNodeIndex(NodeTypes.PERSON);
+        String id = actor.getId();
+        Index<Node> idx;
+        if (actor.isGroup()) {
+            idx = getNodeIndex(NodeTypes.GROUP);
+        } else {
+            idx = getNodeIndex(NodeTypes.PERSON);
+        }
         IndexHits<Node> persons = idx.get("uri", uri);
         Node person = persons.getSingle();
@@ -393,5 +455,9 @@
             try {
                 person = graphDb.createNode();
-                person.setProperty("TYPE", NodeTypes.PERSON.name());
+                if (actor.isGroup()) {
+                    person.setProperty("TYPE", NodeTypes.GROUP.name());
+                } else {
+                    person.setProperty("TYPE", NodeTypes.PERSON.name());                    
+                }
                 person.setProperty("uri", uri);
                 idx.add(person, "uri", uri);
@@ -399,4 +465,7 @@
                     person.setProperty("name", name);
                 }
+                if (id != null) {
+                    person.setProperty("id", id);
+                }
                 tx.success();
             } finally {
@@ -417,5 +486,5 @@
         Node newActorNode = null;
         if (actor != null) {
-            newActorNode = getOrCreatePersonNode(actor);
+            newActorNode = getOrCreateActorNode(actor);
         }
         Relationship rel = getRelation(annotNode, type, null);
@@ -464,4 +533,11 @@
     }
 
+    /** returns the (first) Relationship of RelationTypes type from Node start.
+     *  
+     * @param start
+     * @param type
+     * @param direction
+     * @return
+     */
     protected Relationship getRelation(Node start, RelationTypes type, Direction direction) {
         Iterable<Relationship> rels;
