annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
1 /**
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
2 *
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
3 */
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
4 package de.mpiwg.itgroup.annotations;
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
5
10
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
6 import de.mpiwg.itgroup.annotations.old.NS;
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
7
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
8 /**
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
9 * @author casties
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
10 *
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
11 */
10
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
12 public abstract class Actor {
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
13
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
14 public String uri;
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
15 public String name;
10
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
16 public String id;
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
17
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
18 /**
10
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
19 * @return if this Actor is a Group
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
20 */
10
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
21 public abstract boolean isGroup();
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
22
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
23 /**
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
24 * Returns if this Actor is equivalent to an Actor with this id. If this is
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
25 * a Group returns true when the Person is in the Group.
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
26 *
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
27 * @param userId
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
28 * @return
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
29 */
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
30 public boolean isEquivalentWith(String userId) {
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
31 if (userId == null) return false;
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
32 if (userId.equals(getIdString())) {
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
33 return true;
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
34 }
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
35 if (isGroup()) {
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
36 // TODO: check if person in group
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
37 }
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
38 return false;
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
39 }
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
40
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
41 /**
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
42 * @return the uri
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
43 */
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
44 public String getUri() {
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
45 return uri;
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
46 }
13
abe25edf2178 storing and retrieving permissions works now.
casties
parents: 10
diff changeset
47
abe25edf2178 storing and retrieving permissions works now.
casties
parents: 10
diff changeset
48 /**
abe25edf2178 storing and retrieving permissions works now.
casties
parents: 10
diff changeset
49 * Returns the uri (uses id if empty).
abe25edf2178 storing and retrieving permissions works now.
casties
parents: 10
diff changeset
50 *
abe25edf2178 storing and retrieving permissions works now.
casties
parents: 10
diff changeset
51 * @return the uri
abe25edf2178 storing and retrieving permissions works now.
casties
parents: 10
diff changeset
52 */
abe25edf2178 storing and retrieving permissions works now.
casties
parents: 10
diff changeset
53 public String getUriString() {
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
54 if (uri == null) {
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
55 return getUriFromId(id, isGroup());
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
56 }
13
abe25edf2178 storing and retrieving permissions works now.
casties
parents: 10
diff changeset
57 return uri;
abe25edf2178 storing and retrieving permissions works now.
casties
parents: 10
diff changeset
58 }
abe25edf2178 storing and retrieving permissions works now.
casties
parents: 10
diff changeset
59
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
60 /**
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
61 * @param uri
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
62 * the uri to set
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
63 */
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
64 public void setUri(String uri) {
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
65 this.uri = uri;
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
66 }
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
67
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
68 /**
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
69 * @return the name
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
70 */
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
71 public String getName() {
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
72 return name;
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
73 }
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
74
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
75 /**
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
76 * @param name
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
77 * the name to set
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
78 */
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
79 public void setName(String name) {
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
80 this.name = name;
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
81 }
10
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
82
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
83 /**
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
84 * @return the id
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
85 */
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
86 public String getId() {
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
87 return id;
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
88 }
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
89
10
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
90 /**
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
91 * Returns id as a String starting with "group:" for groups.
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
92 *
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
93 * @return
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
94 */
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
95 public abstract String getIdString();
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
96
10
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
97 /**
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
98 * @param id
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
99 * the id to set
10
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
100 */
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
101 public void setId(String id) {
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
102 this.id = id;
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
103 }
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
104
10
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
105 /**
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
106 * Returns a short id from an uri.
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
107 *
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
108 * @param uri
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
109 * @return
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
110 */
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
111 public static String getIdFromUri(String uri, boolean isGroup) {
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
112 String id = null;
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
113 String prefix = NS.MPIWG_PERSONS_URL;
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
114 if (isGroup) {
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
115 prefix = NS.MPIWG_GROUPS_URL;
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
116 }
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
117 if (uri != null && uri.startsWith(prefix)) {
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
118 id = uri.replace(prefix, "");
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
119 }
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
120 return id;
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
121 }
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
122
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
123 /**
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
124 * Returns an uri from a short id.
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
125 *
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
126 * @param id
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
127 * @return
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
128 */
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
129 public static String getUriFromId(String id, boolean isGroup) {
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
130 String uri = null;
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
131 String prefix = NS.MPIWG_PERSONS_URL;
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
132 if (isGroup) {
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
133 prefix = NS.MPIWG_GROUPS_URL;
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
134 }
14
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
135 if (id != null && !id.startsWith("http://")) {
629e15b345aa permissions mostly work. need more server-side checking.
casties
parents: 13
diff changeset
136 uri = prefix + id;
10
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
137 }
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
138 return uri;
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
139 }
90911b2da322 more work on permissions...
casties
parents: 9
diff changeset
140
9
b2bfc3bc9ba8 new internal actor class for creator.
casties
parents:
diff changeset
141 }