annotate src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/AnnotationsUiRestlet.java @ 50:64aa756c60cc

annotations ui can show and delete annotations now.
author casties
date Thu, 27 Sep 2012 17:12:08 +0200
parents f30f42080711
children fc4c23247bb5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
1 /**
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
2 *
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
3 */
23
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
4 package de.mpiwg.itgroup.annotations.restlet.annotations_ui;
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
5
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
6 import org.apache.log4j.Logger;
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
7 import org.restlet.Context;
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
8 import org.restlet.Restlet;
49
f30f42080711 first steps for authorization for annotations ui.
casties
parents: 34
diff changeset
9 import org.restlet.data.ChallengeScheme;
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
10 import org.restlet.routing.Router;
49
f30f42080711 first steps for authorization for annotations ui.
casties
parents: 34
diff changeset
11 import org.restlet.security.ChallengeAuthenticator;
f30f42080711 first steps for authorization for annotations ui.
casties
parents: 34
diff changeset
12 import org.restlet.security.MapVerifier;
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
13
23
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
14 import de.mpiwg.itgroup.annotations.restlet.BaseRestlet;
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
15
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
16 /**
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
17 * @author casties
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
18 *
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
19 */
23
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
20 public class AnnotationsUiRestlet extends BaseRestlet {
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
21
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents: 49
diff changeset
22 public final String version = "AnnotationManagerN4J/AnnotationsUI 0.3";
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
23
23
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
24 public static Logger logger = Logger.getLogger(AnnotationsUiRestlet.class);
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
25
23
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
26 public AnnotationsUiRestlet(Context context) {
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
27 super(context);
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents: 49
diff changeset
28 logger.info(version);
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
29 }
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
30
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
31 /*
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
32 * (non-Javadoc)
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
33 *
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
34 * @see org.restlet.Application#createInboundRoot()
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
35 */
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
36 @Override
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
37 public Restlet createInboundRoot() {
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
38 // this.authenticator = createAuthenticator();
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
39
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
40 Router router = new Router(getContext());
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
41
23
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
42 router.attach("/groups", GroupsResource.class);
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
43 router.attach("/groups/", GroupsResource.class);
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
44 router.attach("/groups/{id}", GroupResource.class);
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
45 router.attach("/groups/{id}/", GroupResource.class);
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
46 router.attach("/groups/{id}/members", GroupMembersResource.class);
32
0731c4549065 UI for editing groups and persons works now. (still no authorisation!)
casties
parents: 23
diff changeset
47 router.attach("/persons", PersonsResource.class);
0731c4549065 UI for editing groups and persons works now. (still no authorisation!)
casties
parents: 23
diff changeset
48 router.attach("/persons/", PersonsResource.class);
0731c4549065 UI for editing groups and persons works now. (still no authorisation!)
casties
parents: 23
diff changeset
49 router.attach("/persons/{id}", PersonResource.class);
0731c4549065 UI for editing groups and persons works now. (still no authorisation!)
casties
parents: 23
diff changeset
50 router.attach("/persons/{id}/", PersonResource.class);
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents: 49
diff changeset
51 router.attach("/annotations", AnnotationsResource.class);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents: 49
diff changeset
52 router.attach("/annotations/", AnnotationsResource.class);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents: 49
diff changeset
53 router.attach("/annotations/{id}", AnnotationResource.class);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents: 49
diff changeset
54 router.attach("/annotations/{id}/", AnnotationResource.class);
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
55
23
d22d01ba953a reorganised code for annotations and groups ui. work in progress.
casties
parents: 22
diff changeset
56 router.attach("/", InfoResource.class);
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
57
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents: 49
diff changeset
58 // use simple password verifier
49
f30f42080711 first steps for authorization for annotations ui.
casties
parents: 34
diff changeset
59 MapVerifier verifier = new MapVerifier();
50
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents: 49
diff changeset
60 // get user name and password
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents: 49
diff changeset
61 String user = serverConfig.getProperty(BaseRestlet.ADMIN_USER_KEY);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents: 49
diff changeset
62 String pw = serverConfig.getProperty(BaseRestlet.ADMIN_PASSWORD_KEY);
64aa756c60cc annotations ui can show and delete annotations now.
casties
parents: 49
diff changeset
63 verifier.getLocalSecrets().put(user, pw.toCharArray());
49
f30f42080711 first steps for authorization for annotations ui.
casties
parents: 34
diff changeset
64 // Create a Guard
f30f42080711 first steps for authorization for annotations ui.
casties
parents: 34
diff changeset
65 ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, "Tutorial");
f30f42080711 first steps for authorization for annotations ui.
casties
parents: 34
diff changeset
66 guard.setVerifier(verifier);
f30f42080711 first steps for authorization for annotations ui.
casties
parents: 34
diff changeset
67 // put everything through guard
f30f42080711 first steps for authorization for annotations ui.
casties
parents: 34
diff changeset
68 guard.setNext(router);
f30f42080711 first steps for authorization for annotations ui.
casties
parents: 34
diff changeset
69 return guard;
18
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
70 }
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
71
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
72 @Override
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
73 public String getVersion() {
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
74 return version;
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
75 }
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
76
aafa3884b2c4 new AnnotationStore restlet for HTML-UI.
casties
parents:
diff changeset
77 }