Changeset 65:c0dd5314bada in AnnotationManagerN4J for src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorAnnotations.java
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorAnnotations.java
r63 r65 6 6 7 7 import java.io.IOException; 8 import java.io.UnsupportedEncodingException; 9 import java.net.URLDecoder; 8 10 import java.util.ArrayList; 9 11 import java.util.List; … … 50 52 setCorsHeaders(); 51 53 // id from URI /annotations/{id} 54 String id = null; 52 55 String jsonId = (String) getRequest().getAttributes().get("id"); 53 String id = decodeJsonId(jsonId); 54 logger.debug("annotation-id=" + id); 56 if (jsonId != null) { 57 // URL decode 58 try { 59 jsonId = URLDecoder.decode(jsonId, "UTF-8"); 60 } catch (UnsupportedEncodingException e) { 61 // this shouldn't happen 62 } 63 id = decodeJsonId(jsonId); 64 logger.debug("annotation-id=" + id); 65 } 55 66 56 67 // do authentication … … 87 98 AnnotationStore store = getAnnotationStore(); 88 99 ArrayList<JSONObject> results = new ArrayList<JSONObject>(); 89 100 90 101 // read all annotations 91 102 List<Annotation> annotations = store.getAnnotations(null, null); 92 103 for (Annotation annotation : annotations) { 93 104 // check permission 94 if (!annotation.isActionAllowed("read", authUser, store)) continue; 105 if (!annotation.isActionAllowed("read", authUser, store)) 106 continue; 95 107 // add annotation to list 96 108 JSONObject jo = createAnnotatorJson(annotation, false); … … 102 114 JSONObjectComparator.sortAnnotations(results, sortBy); 103 115 } 104 116 105 117 // put in JSON list 106 118 JSONArray rows = new JSONArray(); … … 108 120 for (JSONObject result : results) { 109 121 cnt += 1; 110 if (offset > 0 && cnt < offset) continue; 122 if (offset > 0 && cnt < offset) 123 continue; 111 124 rows.put(result); 112 if (limit > 0 && cnt >= limit) break; 125 if (limit > 0 && cnt >= limit) 126 break; 113 127 } 114 128
Note: See TracChangeset
for help on using the changeset viewer.