comparison src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorSearch.java @ 105:7417f5915181 default tip

check admin permission before changing permissions. Enum for typesafe actions.
author casties
date Fri, 10 Feb 2017 15:45:35 +0100
parents cf44d9e1a4a7
children
comparison
equal deleted inserted replaced
104:e953327d66bb 105:7417f5915181
33 import org.restlet.ext.json.JsonRepresentation; 33 import org.restlet.ext.json.JsonRepresentation;
34 import org.restlet.representation.Representation; 34 import org.restlet.representation.Representation;
35 import org.restlet.resource.Get; 35 import org.restlet.resource.Get;
36 36
37 import de.mpiwg.itgroup.annotations.Annotation; 37 import de.mpiwg.itgroup.annotations.Annotation;
38 import de.mpiwg.itgroup.annotations.Annotation.Action;
38 import de.mpiwg.itgroup.annotations.Person; 39 import de.mpiwg.itgroup.annotations.Person;
39 import de.mpiwg.itgroup.annotations.neo4j.AnnotationStore; 40 import de.mpiwg.itgroup.annotations.neo4j.AnnotationStore;
40 import de.mpiwg.itgroup.annotations.restlet.utils.JSONObjectComparator; 41 import de.mpiwg.itgroup.annotations.restlet.utils.JSONObjectComparator;
41 42
42 /** 43 /**
74 logger.fine(String.format("searching for uri=%s user=%s", uri, user)); 75 logger.fine(String.format("searching for uri=%s user=%s", uri, user));
75 AnnotationStore store = getAnnotationStore(); 76 AnnotationStore store = getAnnotationStore();
76 List<Annotation> annots = store.searchAnnotationByUriUser(uri, user); 77 List<Annotation> annots = store.searchAnnotationByUriUser(uri, user);
77 for (Annotation annot : annots) { 78 for (Annotation annot : annots) {
78 // check permission 79 // check permission
79 if (!annot.isActionAllowed("read", authUser, store)) continue; 80 if (!annot.isActionAllowed(Action.read, authUser, store)) continue;
80 JSONObject jo = createAnnotatorJson(annot, (authUser == null)); 81 JSONObject jo = createAnnotatorJson(annot, (authUser == null));
81 if (jo != null) { 82 if (jo != null) {
82 results.add(jo); 83 results.add(jo);
83 } else { 84 } else {
84 setStatus(Status.SERVER_ERROR_INTERNAL, "JSON Error"); 85 setStatus(Status.SERVER_ERROR_INTERNAL, "JSON Error");