Mercurial > hg > AnnotationManager
comparison src/de/mpiwg/itgroup/annotationManager/restlet/AnnotatorSearch.java @ 10:0bdfe01e30b5
checking auth token works now.
author | casties |
---|---|
date | Tue, 20 Mar 2012 15:55:51 +0100 |
parents | e9fd2e1e0979 |
children | 2f8c72ae4c43 |
comparison
equal
deleted
inserted
replaced
9:e9fd2e1e0979 | 10:0bdfe01e30b5 |
---|---|
32 * @author casties | 32 * @author casties |
33 * | 33 * |
34 */ | 34 */ |
35 public class AnnotatorSearch extends AnnotatorResourceImpl { | 35 public class AnnotatorSearch extends AnnotatorResourceImpl { |
36 | 36 |
37 private Logger logger = Logger.getRootLogger(); | |
38 | |
39 protected String getAllowedMethodsForHeader() { | 37 protected String getAllowedMethodsForHeader() { |
40 return "OPTIONS,GET"; | 38 return "OPTIONS,GET"; |
41 } | 39 } |
42 | 40 |
43 /** | 41 /** |
50 @Get("json") | 48 @Get("json") |
51 public Representation doGetJSON(Representation entity) { | 49 public Representation doGetJSON(Representation entity) { |
52 | 50 |
53 doOptions(entity); | 51 doOptions(entity); |
54 | 52 |
55 // check authToken | 53 boolean authenticated = isAuthenticated(entity); |
56 Form requestHeaders = (Form) getRequest().getAttributes().get("org.restlet.http.headers"); | 54 logger.debug("request authenticated="+authenticated); |
57 String ck = requestHeaders.getFirstValue("x-annotator-consumer-key", true); | |
58 if (ck != null) { | |
59 RestServer restServer = (RestServer) getApplication(); | |
60 String cs = restServer.getConsumerSecret(ck); | |
61 logger.debug("requested consumer key=" + ck + " secret=" + cs); | |
62 } | |
63 | 55 |
64 Form form = getRequest().getResourceRef().getQueryAsForm(); | 56 Form form = getRequest().getResourceRef().getQueryAsForm(); |
65 String uri = form.getFirstValue("uri"); | 57 String uri = form.getFirstValue("uri"); |
66 String user = form.getFirstValue("user"); | 58 String user = form.getFirstValue("user"); |
67 | 59 |
68 String limit = form.getFirstValue("limit"); | 60 String limit = form.getFirstValue("limit"); |
69 String offset = form.getFirstValue("offset"); | 61 String offset = form.getFirstValue("offset"); |
70 | 62 |
71 RDFSearcher searcher = new RDFSearcher("file:///annotations"); // TODO | 63 RDFSearcher searcher = new RDFSearcher("file:///annotations"); // TODO should go into config file |
72 // should | |
73 // ge | |
74 // into | |
75 // config | |
76 // file | |
77 | 64 |
78 JSONArray ja; | 65 JSONArray ja; |
79 try { | 66 try { |
80 | 67 |
81 List<Convert.Annotation> annots = searcher.search(uri, user, limit, offset); | 68 List<Convert.Annotation> annots = searcher.search(uri, user, limit, offset); |