comparison src/main/java/de/mpiwg/itgroup/annotations/restlet/annotations_ui/PersonResource.java @ 65:c0dd5314bada

deal with special characters in urls.
author casties
date Wed, 05 Dec 2012 15:36:43 +0100
parents 0731c4549065
children 2b1e6df5e21a
comparison
equal deleted inserted replaced
64:c48435e7f312 65:c0dd5314bada
1 /** 1 /**
2 * 2 *
3 */ 3 */
4 package de.mpiwg.itgroup.annotations.restlet.annotations_ui; 4 package de.mpiwg.itgroup.annotations.restlet.annotations_ui;
5
6 import java.io.UnsupportedEncodingException;
7 import java.net.URLDecoder;
5 8
6 import org.apache.log4j.Logger; 9 import org.apache.log4j.Logger;
7 import org.restlet.data.Form; 10 import org.restlet.data.Form;
8 import org.restlet.data.MediaType; 11 import org.restlet.data.MediaType;
9 import org.restlet.data.Reference; 12 import org.restlet.data.Reference;
39 @Override 42 @Override
40 protected void doInit() throws ResourceException { 43 protected void doInit() throws ResourceException {
41 super.doInit(); 44 super.doInit();
42 // id from URI /annotations/persons/{id} 45 // id from URI /annotations/persons/{id}
43 requestId = (String) getRequest().getAttributes().get("id"); 46 requestId = (String) getRequest().getAttributes().get("id");
44 logger.debug("group-id=" + requestId); 47 logger.debug("person-id=" + requestId);
45 // get store instance 48 // get store instance
46 if (store == null) { 49 if (store == null) {
47 store = ((BaseRestlet) getApplication()).getAnnotationStore(); 50 store = ((BaseRestlet) getApplication()).getAnnotationStore();
48 } 51 }
49 // get group from store 52 // get person from store
50 if (requestId != null) { 53 if (requestId != null) {
54 // URL decode
55 try {
56 requestId = URLDecoder.decode(requestId, "UTF-8");
57 } catch (UnsupportedEncodingException e) {
58 // this shouldn't happen
59 }
51 person = (Person) store.getActor(new Person(requestId)); 60 person = (Person) store.getActor(new Person(requestId));
52 } 61 }
53 } 62 }
54 63
55 /** 64 /**