Mercurial > hg > AnnotationManagerN4J
diff src/main/java/de/mpiwg/itgroup/annotations/Actor.java @ 14:629e15b345aa
permissions mostly work. need more server-side checking.
author | casties |
---|---|
date | Fri, 13 Jul 2012 20:41:02 +0200 |
parents | abe25edf2178 |
children | 58357a4b86de |
line wrap: on
line diff
--- a/src/main/java/de/mpiwg/itgroup/annotations/Actor.java Fri Jul 13 17:22:05 2012 +0200 +++ b/src/main/java/de/mpiwg/itgroup/annotations/Actor.java Fri Jul 13 20:41:02 2012 +0200 @@ -7,19 +7,37 @@ /** * @author casties - * + * */ public abstract class Actor { public String uri; public String name; public String id; - + /** * @return if this Actor is a Group */ public abstract boolean isGroup(); - + + /** + * Returns if this Actor is equivalent to an Actor with this id. If this is + * a Group returns true when the Person is in the Group. + * + * @param userId + * @return + */ + public boolean isEquivalentWith(String userId) { + if (userId == null) return false; + if (userId.equals(getIdString())) { + return true; + } + if (isGroup()) { + // TODO: check if person in group + } + return false; + } + /** * @return the uri */ @@ -33,26 +51,30 @@ * @return the uri */ public String getUriString() { - if (uri == null) { - return getUriFromId(id, isGroup()); - } + if (uri == null) { + return getUriFromId(id, isGroup()); + } return uri; } /** - * @param uri the uri to set + * @param uri + * the uri to set */ public void setUri(String uri) { this.uri = uri; } + /** * @return the name */ public String getName() { return name; } + /** - * @param name the name to set + * @param name + * the name to set */ public void setName(String name) { this.name = name; @@ -64,21 +86,22 @@ public String getId() { return id; } - + /** * Returns id as a String starting with "group:" for groups. * * @return */ public abstract String getIdString(); - + /** - * @param id the id to set + * @param id + * the id to set */ public void setId(String id) { this.id = id; } - + /** * Returns a short id from an uri. * @@ -109,8 +132,8 @@ if (isGroup) { prefix = NS.MPIWG_GROUPS_URL; } - if (id != null && ! id.startsWith("http://")) { - uri = prefix + id; + if (id != null && !id.startsWith("http://")) { + uri = prefix + id; } return uri; }