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)   
 

RE: JSON and File Representation

2009-07-28 Thread Thomas Cozien
Hi Jérome,

Thanks for the answer. 

Regards 
Tom

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


Considering Restlet for my web service

2009-07-28 Thread Chris Davis
Hello,

I am currently trying to implement web service that will run on our existing
servlet based system. Restlet looks almost perfect for what I need but there
are two things that I need to be sure I can do before I can proceed with it.

1) Authentication - I need to allow a user to authenticate themselves before
accepting any other requests from that user

2) Server side caching - I need to keep data retrieved from a 3rd party
system temporarily cached in memory for each user, to open new a connection
and retrieve this data is too expensive an operation to do on every request.

Of course you know I am going to say I need some sort of session :) but I
also agree that to do without the session is a good way to go.
So do you have any suggestions as to what to do? I am sure others must have
come up against this scenario.
Or perhaps restlet is not the correct solution in this case?

Any advice is much appreciated, this is my first stab at a web service and I
have looked at most of the other possible java web service solutions but
they all seem so overweight and disparate  (which I guess is why restlet was
created in the first place)

thanks in advance
Chris D

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

RE: Checking for Request Entity

2009-07-28 Thread webpost
Dont know why getRequest().isEntit​yAvailable() returns true, however 
getRequest().getEntity().getMediaType() return null if the request entity is 
missing.

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


very minor issue with freemarker ContextTemplateLoader

2009-07-28 Thread Stoph
I am using Restlet with the included Freemarker integration and it's working
very well. I have found a minor issue when using the ContextTemplateLoader.

File URIs given to the ContextTemplateLoader must not include the colon,
i.e. use file://c/ instead of file://c:/

Otherwise you get a screen full of this warning:

[java] WARNING: Can't parse hostPort :
[hostRef,requestUri]=[null,file://c:/my/path/src/mypackage/templates/user_en_US.html]
-- 
View this message in context: 
http://n2.nabble.com/very-minor-issue-with-freemarker-ContextTemplateLoader-tp3347379p3347379.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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