annotate src/main/java/de/mpiwg/itgroup/annotations/restlet/AnnotatorInfo.java @ 2:f2d44c41eedf

nothing much
author casties
date Thu, 28 Jun 2012 19:34:32 +0200
parents 6556943c4fb9
children aafa3884b2c4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
1 package de.mpiwg.itgroup.annotations.restlet;
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
2
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
3 import java.io.InputStream;
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
4
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
5 import org.apache.log4j.Logger;
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
6 import org.restlet.data.Form;
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
7 import org.restlet.data.MediaType;
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
8 import org.restlet.representation.InputRepresentation;
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
9 import org.restlet.representation.Representation;
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
10 import org.restlet.resource.Get;
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
11 import org.restlet.resource.Options;
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
12 import org.restlet.resource.ServerResource;
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
13
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
14
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
15
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
16
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
17
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
18 public class AnnotatorInfo extends ServerResource {
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
19
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
20 private Logger logger = Logger.getRootLogger();
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
21
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
22 /**
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
23 * Erlaubt cross scripting bei Aufruf aus Javascript
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
24 * @param entity
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
25 */
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
26 @Options
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
27 public void doOptions(Representation entity) {
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
28 Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers");
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
29 if (responseHeaders == null) {
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
30 responseHeaders = new Form();
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
31 getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
32 }
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
33 responseHeaders.add("Access-Control-Allow-Origin", "*");
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
34 responseHeaders.add("Access-Control-Allow-Methods", "POST,OPTIONS,GET");
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
35 responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
36 responseHeaders.add("Access-Control-Allow-Credentials", "false");
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
37 responseHeaders.add("Access-Control-Max-Age", "60");
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
38 }
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
39
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
40
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
41
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
42 @Get("html")
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
43 public Representation getHTML(){
2
f2d44c41eedf nothing much
casties
parents: 1
diff changeset
44 InputStream is = getClass().getResourceAsStream("/de/mpiwg/itgroup/annotations/annotator-info.html");
1
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
45
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
46 Representation rep = new InputRepresentation(is,MediaType.TEXT_HTML);
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
47 return rep;
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
48
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
49 }
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
50
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
51 }
6556943c4fb9 include neo4j and restlet
casties
parents:
diff changeset
52