annotate src/de/mpiwg/itgroup/annotationManager/restlet/ExtendedAnnotationInput.java @ 5:0be9d53a6967

editor for annotations
author dwinter
date Tue, 13 Dec 2011 17:43:46 +0100
parents
children 97f68ab3430f
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 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
35 responseHeaders.add("Access-Control-Allow-Origin", "*");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
36 responseHeaders.add("Access-Control-Allow-Methods", "POST,OPTIONS,GET");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
37 responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
38 responseHeaders.add("Access-Control-Allow-Credentials", "false");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
39 responseHeaders.add("Access-Control-Max-Age", "60");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
40 }
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 @Get("html")
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
45 public Representation getHTML(){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
46 InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/annotationManager/staticPages/annotation.html");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
47
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
48 Representation rep = new InputRepresentation(is,MediaType.TEXT_HTML);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
49 return rep;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
50
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