Hello,
I am having trouble getting identifier from a Response to a request.
In my resource class, I create a JsonRepresentation and identifier is
set like this :
result.setIdentifier(getRequest().getResourceRef().getIdentifier() +
profileId);
(where profileId is the id of a profile created by this resource).
in my junit test, I do the following :
Response response = client.handle(request);
JsonRepresentation jsonRep = new JsonRepresentation(response.getEntity());
jobj = jsonRep.getJsonObject();
String createdId = jobj.getString("profile created");
Reference createdProfile = jsonRep.getIdentifier() // return null;
Representation entity = response.getEntity();
createdProfile = entity.getIdentifier(); // return the expected reference
Using eclipse to debug my test and inspect object, I can see that
identifier field is
null in my JsonRepresentation object, but not inside the
wrappedRepresentation.
Same for the Response object.
I'm using a 2.0 Snapshot (build 859).
Is my way to handle response and to follow created content correct ?
Thanks for any help,
Laurent.
P.S. here is a copy/paste from eclipse debug view of my object, if this
can help understand what I'm saying.
"jsonRep"= JsonRepresentation (id=80)
UNKNOWN_SIZE= -1
available= true
characterSet= null
digest= null
downloadable= false
downloadName= null
encodings= Variant$1 (id=86)
expirationDate= null
identifier= null
indent= false
indentSize= 0
isTransient= false
jsonObject= null
available= true
characterSet= null
digest= null
downloadable= false
downloadName= null
encodings= null
expirationDate= null
identifier= null
isTransient= false
languages= null
log= Logger (id=97)
mediaType= null
modificationDate= null
range= null
size= -1
socket= Socket (id=99)
tag= null
wrappedRepresentation= InputRepresentation (id=101)
available= false
characterSet= CharacterSet (id=105)
digest= null
downloadable= false
downloadName= null
encodings= Variant$1 (id=106)
expirationDate= null
identifier= Reference (id=107)
isTransient= true
languages= Variant$2 (id=108)
mediaType= MediaType (id=93)
modificationDate= null
range= null
size= -1
stream= null
tag= null
jsonRepresentation= StreamClientCall$SocketWrapperRepresentation
(id=65)
languages= Variant$2 (id=91)
mediaType= MediaType (id=93)
modificationDate= null
range= null
size= -1
"response"= Response (id=51)
CURRENT= ThreadLocal<T> (id=120)
allowedMethods= null
attributes= TreeMap<K,V> (id=55)
challengeRequests= null
cookieSettings= null
dimensions= CopyOnWriteArraySet<E> (id=63)
al= CopyOnWriteArrayList<E> (id=122)
characterSet= null
digest= null
downloadable= false
downloadName= null
encodings= null
expirationDate= null
identifier= null
isTransient= false
languages= null
log= Logger (id=97)
mediaType= null
modificationDate= null
range= null
size= -1
socket= Socket (id=99)
tag= null
wrappedRepresentation= InputRepresentation (id=101)
available= false
characterSet= CharacterSet (id=105)
digest= null
downloadable= false
downloadName= null
encodings= Variant$1 (id=106)
expirationDate= null
identifier= Reference (id=107)
isTransient= true
languages= Variant$2 (id=108)
mediaType= MediaType (id=93)
modificationDate= null
range= null
size= -1
stream= null
tag= null
entity= StreamClientCall$SocketWrapperRepresentation (id=65)
entityForm= null
entityText= null
locationRef= null
proxyChallengeRequests= null
request= Request (id=50)
serverInfo= ServerInfo (id=114)
--
Laurent Rustuel,
Alten contractor for Genesys, an Alcatel-Lucent Company
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2376288