Changeset 16:794077e6288c in AnnotationManagerN4J for src/main/java/de/mpiwg/itgroup/annotations/restlet
- Timestamp:
- Sep 4, 2012, 6:02:59 PM (12 years ago)
- Branch:
- default
- Location:
- src/main/java/de/mpiwg/itgroup/annotations/restlet
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorAnnotations.java
r15 r16 55 55 logger.debug("request authenticated=" + authUser); 56 56 57 Annotation annot = getAnnotationStore().getAnnotationById(id); 57 AnnotationStore store = getAnnotationStore(); 58 Annotation annot = store.getAnnotationById(id); 58 59 if (annot != null) { 59 if (! annot.isActionAllowed("read", authUser, null)) {60 if (! annot.isActionAllowed("read", authUser, store)) { 60 61 setStatus(Status.CLIENT_ERROR_FORBIDDEN, "Not Authorized!"); 61 62 return null; … … 160 161 return null; 161 162 } 162 if (! storedAnnot.isActionAllowed("update", authUser, null)) {163 if (! storedAnnot.isActionAllowed("update", authUser, store)) { 163 164 setStatus(Status.CLIENT_ERROR_FORBIDDEN); 164 165 return null; … … 207 208 Person authUser = Person.createPersonWithId(this.checkAuthToken(entity)); 208 209 logger.debug("request authenticated=" + authUser); 209 Annotation annot = getAnnotationStore().getAnnotationById(id); 210 AnnotationStore store = getAnnotationStore(); 211 Annotation annot = store.getAnnotationById(id); 210 212 if (annot != null) { 211 if (! annot.isActionAllowed("delete", authUser, null)) {213 if (! annot.isActionAllowed("delete", authUser, store)) { 212 214 setStatus(Status.CLIENT_ERROR_FORBIDDEN, "Not Authorized!"); 213 215 return null; … … 216 218 217 219 // delete annotation 218 getAnnotationStore().deleteById(id);220 store.deleteById(id); 219 221 setStatus(Status.SUCCESS_NO_CONTENT); 220 222 return null; -
src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorResourceImpl.java
r15 r16 10 10 import java.util.ArrayList; 11 11 import java.util.Calendar; 12 import java.util.HashSet; 12 13 import java.util.List; 14 import java.util.Set; 13 15 import java.util.regex.Matcher; 14 16 import java.util.regex.Pattern; … … 190 192 jo.put("uri", annot.getTargetBaseUri()); 191 193 194 /* 195 * user 196 */ 192 197 if (makeUserObject) { 193 198 // create user object … … 214 219 } 215 220 221 /* 222 * ranges 223 */ 216 224 if (annot.getTargetFragment() != null) { 217 225 // we only look at the first xpointer … … 226 234 } 227 235 228 // permissions 236 /* 237 * permissions 238 */ 229 239 JSONObject perms = new JSONObject(); 230 240 jo.put("permissions", perms); … … 267 277 } 268 278 279 /* 280 * tags 281 */ 282 Set<String> tagset = annot.getTags(); 283 if (tagset != null) { 284 JSONArray tags = new JSONArray(); 285 jo.put("tags", tags); 286 for (String tag : tagset) { 287 tags.put(tag); 288 } 289 } 290 291 /* 292 * id 293 */ 269 294 // encode Annotation URL (=id) in base64 270 295 String annotUrl = annot.getUri(); … … 413 438 public Annotation updateAnnotation(Annotation annot, JSONObject jo, Representation entity) throws JSONException, 414 439 UnsupportedEncodingException { 415 // target uri 440 /* 441 * target uri 442 */ 416 443 if (jo.has("uri")) { 417 444 annot.setTargetBaseUri(jo.getString("uri")); 418 445 } 419 // annotation text 446 /* 447 * annotation text 448 */ 420 449 if (jo.has("text")) { 421 450 annot.setBodyText(jo.getString("text")); 422 451 } 423 // check authentication 452 /* 453 * check authentication 454 */ 424 455 String authUser = checkAuthToken(entity); 425 456 if (authUser == null) { … … 434 465 */ 435 466 } 436 // get or create creator object 467 /* 468 * get or create creator object 469 */ 437 470 Actor creator = annot.getCreator(); 438 471 if (creator == null) { … … 483 516 creator.setUri(userUri); 484 517 } 485 518 /* 519 * creation date 520 */ 486 521 if (annot.getCreated() == null) { 487 522 // set creation date … … 491 526 } 492 527 493 // create xpointer from the first range/area 528 /* 529 * create xpointer from the first range/area 530 */ 494 531 if (jo.has("ranges")) { 495 532 JSONObject ranges = jo.getJSONArray("ranges").getJSONObject(0); … … 505 542 } 506 543 507 // permissions 544 /* 545 * permissions 546 */ 508 547 if (jo.has("permissions")) { 509 548 JSONObject permissions = jo.getJSONObject("permissions"); … … 530 569 } 531 570 571 /* 572 * tags 573 */ 574 if (jo.has("tags")) { 575 HashSet<String> tagset = new HashSet<String>(); 576 JSONArray tags = jo.getJSONArray("tags"); 577 for (int i = 0; i < tags.length(); ++i) { 578 tagset.add(tags.getString(i)); 579 } 580 annot.setTags(tagset); 581 } 582 583 532 584 return annot; 533 585 }
Note: See TracChangeset
for help on using the changeset viewer.