annotate src/main/java/de/mpiwg/itgroup/annotationManager/restlet/ExtendedAnnotationInput.java @ 33:e5f5848892a2

new annotation model basically works.
author casties
date Thu, 31 May 2012 19:08:48 +0200
parents a3e324009990
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1 package de.mpiwg.itgroup.annotationManager.restlet;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3 import java.io.InputStream;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5 import org.apache.log4j.Logger;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6 import org.restlet.data.Form;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
7 import org.restlet.data.MediaType;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
8 import org.restlet.representation.InputRepresentation;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
9 import org.restlet.representation.Representation;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
10 import org.restlet.representation.StringRepresentation;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
11 import org.restlet.resource.Get;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
12 import org.restlet.resource.Options;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
13 import org.restlet.resource.Post;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
14 import org.restlet.resource.ServerResource;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
15
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
16
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
17
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
18
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
19
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
20 public class ExtendedAnnotationInput extends ServerResource {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
21
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
22 private Logger logger = Logger.getRootLogger();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
23
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
24 /**
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
25 * Erlaubt cross scripting bei Aufruf aus Javascript
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
26 * @param entity
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
27 */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
28 @Options
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
29 public void doOptions(Representation entity) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
30 Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
31 if (responseHeaders == null) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
32 responseHeaders = new Form();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
33 getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
34 }
7
97f68ab3430f support both read and search api of Annotator.
casties
parents: 5
diff changeset
35 // TODO: better to answer Allow-Origin with the requested Origin
5
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
36 responseHeaders.add("Access-Control-Allow-Origin", "*");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
37 responseHeaders.add("Access-Control-Allow-Methods", "POST,OPTIONS,GET");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
38 responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
7
97f68ab3430f support both read and search api of Annotator.
casties
parents: 5
diff changeset
39 responseHeaders.add("Access-Control-Allow-Credentials", "true");
5
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
40 responseHeaders.add("Access-Control-Max-Age", "60");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
41 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
42
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
43
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
44
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
45 @Get("html")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
46 public Representation getHTML(){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
47 InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/annotationManager/staticPages/annotation.html");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
48
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
49 Representation rep = new InputRepresentation(is,MediaType.TEXT_HTML);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
50 return rep;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
51
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
52 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
53
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
54 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
55