Mercurial > hg > AnnotationManagerN4J
annotate src/main/java/de/mpiwg/itgroup/annotations/Annotation.java @ 15:58357a4b86de
ASSIGNED - # 249: Annotations shared in groups
https://it-dev.mpiwg-berlin.mpg.de/tracs/mpdl-project-software/ticket/249
author | casties |
---|---|
date | Tue, 28 Aug 2012 20:23:12 +0200 |
parents | 629e15b345aa |
children | 794077e6288c |
rev | line source |
---|---|
4 | 1 /** |
2 * | |
3 */ | |
4 package de.mpiwg.itgroup.annotations; | |
5 | |
15 | 6 import de.mpiwg.itgroup.annotations.neo4j.AnnotationStore; |
7 | |
4 | 8 /** |
9 * @author casties | |
10 * | |
11 */ | |
12 public class Annotation { | |
13 /** | |
14 * The URI of this annotation. | |
15 */ | |
16 protected String uri; | |
17 | |
18 /** | |
19 * The annotation (body) text. | |
20 */ | |
21 protected String bodyText; | |
22 | |
23 /** | |
24 * The URI of the annotation text | |
25 */ | |
26 protected String bodyUri; | |
27 | |
28 /** | |
29 * The base URI of the annotation target. | |
30 */ | |
31 protected String targetBaseUri; | |
32 | |
33 /** | |
34 * The fragment part of the annotation target. | |
35 */ | |
36 protected String targetFragment; | |
37 | |
38 /** | |
39 * The types of annotation targets. | |
40 * | |
41 */ | |
42 public static enum FragmentTypes { | |
43 XPOINTER, AREA | |
44 }; | |
45 | |
46 /** | |
47 * The type of the annotation target fragment. | |
48 */ | |
49 protected FragmentTypes fragmentType; | |
50 | |
51 /** | |
9 | 52 * The creator of this annotation. |
4 | 53 */ |
9 | 54 protected Actor creator; |
5 | 55 |
56 /** | |
4 | 57 * The creation date of this annotation. |
58 */ | |
59 protected String created; | |
60 | |
10 | 61 /** |
62 * The user or group that has admin permissions. | |
63 * null means any user. | |
64 */ | |
65 protected Actor adminPermission; | |
66 | |
67 /** | |
68 * The user or group that has delete permissions. | |
69 * null means any user. | |
70 */ | |
71 protected Actor deletePermission; | |
72 | |
73 /** | |
74 * The user or group that has update permissions. | |
75 * null means any user. | |
76 */ | |
77 protected Actor updatePermission; | |
78 | |
79 /** | |
80 * The user or group that has read permissions. | |
81 * null means any user. | |
82 */ | |
83 protected Actor readPermission; | |
8 | 84 |
14
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
85 |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
86 /** |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
87 * Returns if the requested action is allowed on this annotation. |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
88 * |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
89 * @param action |
15 | 90 * @param user |
91 * @param store AnnotationStore to check group membership | |
14
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
92 * @return |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
93 */ |
15 | 94 public boolean isActionAllowed(String action, Person user, AnnotationStore store) { |
14
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
95 if (action.equals("read")) { |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
96 Actor reader = getReadPermission(); |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
97 if (reader == null) { |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
98 return true; |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
99 } else { |
15 | 100 return reader.isEquivalentWith(user, store); |
14
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
101 } |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
102 } else if (action.equals("update")) { |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
103 // require at least an authenticated user |
15 | 104 if (user == null) return false; |
14
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
105 Actor updater = getUpdatePermission(); |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
106 if (updater == null) { |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
107 return true; |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
108 } else { |
15 | 109 return updater.isEquivalentWith(user, store); |
14
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
110 } |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
111 } else if (action.equals("delete")) { |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
112 // require at least an authenticated user |
15 | 113 if (user == null) return false; |
14
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
114 Actor updater = getUpdatePermission(); |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
115 if (updater == null) { |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
116 return true; |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
117 } else { |
15 | 118 return updater.isEquivalentWith(user, store); |
14
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
119 } |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
120 } else if (action.equals("admin")) { |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
121 // require at least an authenticated user |
15 | 122 if (user == null) return false; |
14
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
123 Actor admin = getAdminPermission(); |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
124 if (admin == null) { |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
125 return true; |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
126 } else { |
15 | 127 return admin.isEquivalentWith(user, store); |
14
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
128 } |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
129 } |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
130 return false; |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
131 } |
629e15b345aa
permissions mostly work. need more server-side checking.
casties
parents:
10
diff
changeset
|
132 |
4 | 133 /** |
134 * @return the uri | |
135 */ | |
136 public String getUri() { | |
137 return uri; | |
138 } | |
139 | |
140 /** | |
141 * @param uri the uri to set | |
142 */ | |
143 public void setUri(String uri) { | |
144 this.uri = uri; | |
145 } | |
146 | |
147 /** | |
148 * @return the bodyText | |
149 */ | |
150 public String getBodyText() { | |
151 return bodyText; | |
152 } | |
153 | |
154 /** | |
155 * @param bodyText the bodyText to set | |
156 */ | |
157 public void setBodyText(String bodyText) { | |
158 this.bodyText = bodyText; | |
159 } | |
160 | |
161 /** | |
162 * @return the bodyUri | |
163 */ | |
164 public String getBodyUri() { | |
165 return bodyUri; | |
166 } | |
167 | |
168 /** | |
169 * @param bodyUri the bodyUri to set | |
170 */ | |
171 public void setBodyUri(String bodyUri) { | |
172 this.bodyUri = bodyUri; | |
173 } | |
174 | |
175 /** | |
176 * @return the targetBaseUri | |
177 */ | |
178 public String getTargetBaseUri() { | |
179 return targetBaseUri; | |
180 } | |
181 | |
182 /** | |
183 * @param targetBaseUri the targetBaseUri to set | |
184 */ | |
185 public void setTargetBaseUri(String targetBaseUri) { | |
186 this.targetBaseUri = targetBaseUri; | |
187 } | |
188 | |
189 /** | |
190 * @return the targetFragment | |
191 */ | |
192 public String getTargetFragment() { | |
193 return targetFragment; | |
194 } | |
195 | |
196 /** | |
197 * @param targetFragment the targetFragment to set | |
198 */ | |
199 public void setTargetFragment(String targetFragment) { | |
200 this.targetFragment = targetFragment; | |
201 } | |
202 | |
203 /** | |
204 * @return the targetType | |
205 */ | |
206 public FragmentTypes getFragmentType() { | |
207 return fragmentType; | |
208 } | |
209 | |
210 /** | |
211 * @param fragmentType the fragmentType to set | |
212 */ | |
213 public void setFragmentType(FragmentTypes fragmentType) { | |
214 this.fragmentType = fragmentType; | |
215 } | |
216 | |
217 /** | |
9 | 218 * @return the creator |
219 */ | |
220 public Actor getCreator() { | |
221 return creator; | |
222 } | |
223 | |
224 /** | |
225 * @param creator the creator to set | |
226 */ | |
227 public void setCreator(Actor creator) { | |
228 this.creator = creator; | |
229 } | |
230 | |
231 /** | |
4 | 232 * @return the creatorUri |
233 */ | |
234 public String getCreatorUri() { | |
9 | 235 if (creator != null) { |
236 return creator.getUri(); | |
237 } | |
238 return null; | |
4 | 239 } |
240 | |
241 /** | |
5 | 242 * @return the creatorName |
243 */ | |
244 public String getCreatorName() { | |
9 | 245 if (creator != null) { |
246 return creator.getName(); | |
247 } | |
248 return null; | |
5 | 249 } |
250 | |
251 /** | |
4 | 252 * @return the created |
253 */ | |
254 public String getCreated() { | |
255 return created; | |
256 } | |
257 | |
258 /** | |
259 * @param created the created to set | |
260 */ | |
261 public void setCreated(String created) { | |
262 this.created = created; | |
263 } | |
10 | 264 |
265 /** | |
266 * @return the adminPermission | |
267 */ | |
268 public Actor getAdminPermission() { | |
269 return adminPermission; | |
270 } | |
271 | |
272 /** | |
273 * @param adminPermission the adminPermission to set | |
274 */ | |
275 public void setAdminPermission(Actor adminPermission) { | |
276 this.adminPermission = adminPermission; | |
277 } | |
278 | |
279 /** | |
280 * @return the deletePermission | |
281 */ | |
282 public Actor getDeletePermission() { | |
283 return deletePermission; | |
284 } | |
285 | |
286 /** | |
287 * @param deletePermission the deletePermission to set | |
288 */ | |
289 public void setDeletePermission(Actor deletePermission) { | |
290 this.deletePermission = deletePermission; | |
291 } | |
292 | |
293 /** | |
294 * @return the updatePermission | |
295 */ | |
296 public Actor getUpdatePermission() { | |
297 return updatePermission; | |
298 } | |
299 | |
300 /** | |
301 * @param updatePermission the updatePermission to set | |
302 */ | |
303 public void setUpdatePermission(Actor updatePermission) { | |
304 this.updatePermission = updatePermission; | |
305 } | |
306 | |
307 /** | |
308 * @return the readPermission | |
309 */ | |
310 public Actor getReadPermission() { | |
311 return readPermission; | |
312 } | |
313 | |
314 /** | |
315 * @param readPermission the readPermission to set | |
316 */ | |
317 public void setReadPermission(Actor readPermission) { | |
318 this.readPermission = readPermission; | |
319 } | |
4 | 320 |
321 | |
322 } |