Mercurial > hg > AnnotationManagerN4J
comparison src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/AnnotationsUiRestlet.java @ 94:fcb6fe10e08c
added config option for webapp URL prefix.
author | casties |
---|---|
date | Tue, 10 Feb 2015 17:45:56 +0100 |
parents | 25eb2e1df106 |
children | 434264e1839a |
comparison
equal
deleted
inserted
replaced
91:cf44d9e1a4a7 | 94:fcb6fe10e08c |
---|---|
32 import org.restlet.routing.Router; | 32 import org.restlet.routing.Router; |
33 import org.restlet.security.ChallengeAuthenticator; | 33 import org.restlet.security.ChallengeAuthenticator; |
34 import org.restlet.security.MapVerifier; | 34 import org.restlet.security.MapVerifier; |
35 | 35 |
36 import de.mpiwg.itgroup.annotations.restlet.BaseRestlet; | 36 import de.mpiwg.itgroup.annotations.restlet.BaseRestlet; |
37 import de.mpiwg.itgroup.annotations.restlet.utils.UrlPrefixFilter; | |
37 | 38 |
38 /** | 39 /** |
39 * @author casties | 40 * @author casties |
40 * | 41 * |
41 */ | 42 */ |
51 * @see org.restlet.Application#createInboundRoot() | 52 * @see org.restlet.Application#createInboundRoot() |
52 */ | 53 */ |
53 @Override | 54 @Override |
54 public Restlet createInboundRoot() { | 55 public Restlet createInboundRoot() { |
55 // this.authenticator = createAuthenticator(); | 56 // this.authenticator = createAuthenticator(); |
56 | 57 Restlet root = null; |
58 | |
57 Router router = new Router(getContext()); | 59 Router router = new Router(getContext()); |
58 | |
59 router.attach("/groups", GroupsResource.class); | 60 router.attach("/groups", GroupsResource.class); |
60 router.attach("/groups/", GroupsResource.class); | 61 router.attach("/groups/", GroupsResource.class); |
61 router.attach("/groups/{id}", GroupResource.class); | 62 router.attach("/groups/{id}", GroupResource.class); |
62 router.attach("/groups/{id}/", GroupResource.class); | 63 router.attach("/groups/{id}/", GroupResource.class); |
63 router.attach("/groups/{id}/members", GroupMembersResource.class); | 64 router.attach("/groups/{id}/members", GroupMembersResource.class); |
67 router.attach("/persons/{id}/", PersonResource.class); | 68 router.attach("/persons/{id}/", PersonResource.class); |
68 router.attach("/annotations", AnnotationsResource.class); | 69 router.attach("/annotations", AnnotationsResource.class); |
69 router.attach("/annotations/", AnnotationsResource.class); | 70 router.attach("/annotations/", AnnotationsResource.class); |
70 router.attach("/annotations/{id}", AnnotationResource.class); | 71 router.attach("/annotations/{id}", AnnotationResource.class); |
71 router.attach("/annotations/{id}/", AnnotationResource.class); | 72 router.attach("/annotations/{id}/", AnnotationResource.class); |
72 | |
73 router.attach("/", InfoResource.class); | 73 router.attach("/", InfoResource.class); |
74 root = router; | |
75 | |
76 if (this.webappUriPrefix != null) { | |
77 // add prefix path to url | |
78 UrlPrefixFilter prefixFilter = new UrlPrefixFilter(); | |
79 prefixFilter.setPrefix(this.webappUriPrefix);; | |
80 prefixFilter.setNext(root); | |
81 root = prefixFilter; | |
82 } | |
74 | 83 |
75 // use simple password verifier | 84 // use simple password verifier |
76 MapVerifier verifier = new MapVerifier(); | 85 MapVerifier verifier = new MapVerifier(); |
77 // get user name and password | 86 // get user name and password |
78 String user = serverConfig.getProperty(BaseRestlet.ADMIN_USER_KEY); | 87 String user = serverConfig.getProperty(BaseRestlet.ADMIN_USER_KEY); |
84 } | 93 } |
85 // Create a Guard | 94 // Create a Guard |
86 ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, "Tutorial"); | 95 ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, "Tutorial"); |
87 guard.setVerifier(verifier); | 96 guard.setVerifier(verifier); |
88 // put everything through guard | 97 // put everything through guard |
89 guard.setNext(router); | 98 guard.setNext(root); |
90 return guard; | 99 root = guard; |
100 | |
101 return root; | |
91 } | 102 } |
92 | 103 |
93 @Override | 104 @Override |
94 public String getVersion() { | 105 public String getVersion() { |
95 return version; | 106 return version; |