Re: Identifier null in JsonRepresentation in client side

2009-08-18 Thread Laurent Rustuel
Hello Jerome,
Jerome Louvel a écrit :
 The JsonRepresentation class doesn't act as a WrappedRepresentation.
 Therefore, the JsonRepresentation(Representation) constructor should only be
 used as a facility to parse the enclosed representation into a JSON
 artifact.
 
 In your case, you need to retrieve the entity identifier on the response
 entity directly.
Ok, I was doing that way, but I was not sure if it was the correct way 
or not, I was hoping the JsonRepresentation could do such thing. It is 
ok for me to get the entity.
Thanks for the reply.

Regards,
Laurent.

-- 
Laurent Rustuel,
Alten contractor for Alcatel-Lucent, Brest

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2384310


RE: Identifier null in JsonRepresentation in client side

2009-08-16 Thread Jerome Louvel
Hi Laurent,

Thanks for your patience.

The JsonRepresentation class doesn't act as a WrappedRepresentation.
Therefore, the JsonRepresentation(Representation) constructor should only be
used as a facility to parse the enclosed representation into a JSON
artifact.

In your case, you need to retrieve the entity identifier on the response
entity directly.

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com



-Message d'origine-
De : Laurent Rustuel [mailto:laurent.rust...@genesyslab.com] 
Envoyé : mardi 28 juillet 2009 16:01
À : discuss@restlet.tigris.org
Objet : Identifier null in JsonRepresentation in client side

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= ThreadLocalT  (id=120)   
allowedMethods= null
attributes= TreeMapK,V  (id=55)   
challengeRequests= null 
cookieSettings= null
dimensions= CopyOnWriteArraySetE  (id=63) 
al= CopyOnWriteArrayListE  (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

Identifier null in JsonRepresentation in client side

2009-07-28 Thread Laurent Rustuel
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= ThreadLocalT  (id=120)   
allowedMethods= null
attributes= TreeMapK,V  (id=55)   
challengeRequests= null 
cookieSettings= null
dimensions= CopyOnWriteArraySetE  (id=63) 
al= CopyOnWriteArrayListE  (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)