Re: Restlet-GWT basic authentication possibility...

2008-09-11 Thread Rasmus Agerholm
Sounds good.

/Rasmus


On Wed, Sep 10, 2008 at 8:26 PM, Rob Heittman [EMAIL PROTECTED]wrote:

 Sounds perfectly reasonable.  I think Jerome's still on vacation -- I'll
 try my hand at implementing it.

 On Wed, Sep 10, 2008 at 1:26 PM, Rasmus Agerholm [EMAIL PROTECTED]wrote:


 Would it be possible to use this GWT feature to implement support for
 basic authentication?





-- 
MvH
Rasmus Agerholm


Re: ObjectRepresentation and String encoding

2008-09-11 Thread Thierry Boileau

Hi Hannes,

I had a look at the issue and I don't see what's wrong. I was able to
send a serialized object from a client using UTF-8 to a server using
ISO-8859-1 without encoding issues.
Could you send us a reproductible test case, and send us also the trace
of the following code on both client and server side?

   for (EntryObject, Object entry :
System.getProperties().entrySet()) {
   System.out.print(entry.getKey());
   System.out.print(=);
   System.out.println(entry.getValue());
   }

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
http://www.noelios.com/

Hi Jerome,

  

It looks like a bug but after looking at the code I don't see what we
are doing wrong as we have no control on encoding for Object
serialization.

Anyway, I've entered a bug report:



great, thanks!

  

If you could attach a reproducible test case (client+server code),
that would help us fix it more quickly. Also, could you add a comment
to the report indicating which client and server connectors you are
using?



Yes, I will do this during the next days.

Best regards,
Hannes




[Fwd: Re: Socket closing]

2008-09-11 Thread Thierry Boileau




Mail sent on the 08/18 and
apparently lost.


-- 
 Best regards,
Thierry Boileau
--
 Restlet ~
Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com




---BeginMessage---

Hi Kevin,

I've updated the issue 514.

best regards,
Thierry Boileau

Can you attach your test case to that issue?

On Thu, Aug 14, 2008 at 12:18 PM, Thierry Boileau 
[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote:


Hi Kevin (Conaway),

I would like to have your thinking about a problem we are facing
with (see issue http://restlet.tigris.org/issues/show_bug.cgi?id=514).

I've a simple internal client that simply send several (POST, but
I don't think it is meaningful) requests (in my case, 1
requests) to the server which sets the status and doesn't send a
response entity or sends an entity with an unknown size (which
leads to chunk encoding).
In this case after the handling of several requests, the server
block when accepting a new incoming one.

I think that the required behaviour is the following : after
sending the headers, and because the connection is not persistent,
the server can close the connection.
At this time, the closing of connections relies on the fact that
there is an entity, with or without chunk encoding, with or
without persistent connection.
I notice that the fact there is no entity is not taken into
account. I notice also that when there is chunck encoding, the
ChunckedInputStream class does not close the underlying socket.
To my mind, the closing of the socket  (on server side) relies
only on the fact that the  connection is persistent or not.
So I would like to know if the following test in the
StreamServerCall#complete method could be sufficient:
 if (!this.socket.isClosed()) {
  this.socket.getOutputStream().flush();
  this.socket.shutdownOutput();
  if (!isKeepAlive()) {
  this.socket.close();
  }
}

best regards,
Thierry Boileau




---End Message---


[Fwd: Re: Virtual hosts - no domain only ip address]

2008-09-11 Thread Thierry Boileau




Mail sent on the 08/20 and
apparently lost.


Best regards,
Thierry Boileau
--
 Restlet ~
Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com




---BeginMessage---

Hi Christy,

this message appears when a resource (i.e. an instance of a subclass of 
org.restlet.resource.Resource) is targeted and has an empty list of 
supported variants.
Could you check the routes you define in the 
WidgetApplication#createRoot methods, and the resources you have 
attached to these routes? On of them does not declare its supported 
variants.
This page gives more explanations about resources and variants: 
http://www.restlet.org/documentation/1.1/firstResource


Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
http://www.noelios.com/



Hi all,

I am running a VM on a host, currently I have a work example that is 
routing requests to a resource at https://localhost:8183/jbox/v1/


The virtual machine can see the host through the following ip address 
192.168.0.2


From the VM when I send a request to the resource 
https://192.168.0.2:8183/jbox/v1/ I get the following:


com.vennetics.jbox.fs.api.v1.WidgetApplication1047055737)[WARNING|Thread-2|8:35:58.0959]: 
A resource should normally have at least one variant added by calling 
getVariants().add() in the constructor. Check your resource 
https://192.168.0.2:8183/jbox/v1/;.


org.restlet.Component (1524987604)[INFO|Thread-2|8:35:58.0968]: 
2008-08-1908:35:58127.0.0.1--8183GET
/jbox/v1/-4043310
https://192.168.0.2:8183Mozilla/4.0 (compatible; MSIE 6.0; Windows 
NT 5.1; SV1; InfoPath.2)-



I expect this to work by defining a VirtualHost, even though I have no 
domain defined.  I have defined my VirtualHost as follows:


I have also tried setting the server address directly.

VirtualHost host = new VirtualHost(component.getContext());
host.setHostDomain(192.168.0.2|localhost);
host.setServerAddress(192.168.0.2);
host.setHostPort(8183);
host.attach(/jbox/v1, new 
com.vennetics.jbox.fs.api.v1.WidgetApplication());

component.getHosts().add(host)


Any ideas much appreciated,
Thanks in advance.

Christy Ring
[EMAIL PROTECTED]


---End Message---


[Fwd: Re: RC1: connector with no protocols]

2008-09-11 Thread Thierry Boileau




Mail sent on the 08/21 and
apparently lost.


Best regards,
Thierry Boileau
--
 Restlet ~
Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com




---BeginMessage---

Hello Paolo,

to my mind, this message is not the sign of a problem. I get it when I 
run the first steps code 
(http://www.restlet.org/documentation/1.1/firstSteps).
Could you send us a sample test application or give more details about 
the way you define your application's routes, web.xml, etc?


best regards,
Thierry Boileau


Hi,

I am trying to upgrade from M4 to RC1, and I think I made the fixes
related to Context-handling needed to get it up and running.

In fact if I run it with the built in server things seem to work.

However I am facing a problem when running inside Tomcat: Restlet tells
me that the connector has been instanciated with no protocols:

...
21-ago-2008 11.18.05 org.apache.catalina.startup.Catalina start
INFO: Server startup in 439 ms
21-ago-2008 11.18.15 org.restlet.Connector init
AVVERTENZA: The connector has been instantiated without any protocol.
...

And I cannot access any of the resources.


Any suggestions? Do I need to make further changes beside using
createChildContext etc?


Thanks in advance

Paolo


  


---End Message---


[Fwd: Re: Error Handling]

2008-09-11 Thread Thierry Boileau

Mail sent on the 08/21 and apparently lost.

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
http://www.noelios.com/
---BeginMessage---

Hi Michael,

If you are talking about the generation of the response's 
representation, I think it is simpler to throw a ResourceException with 
your own error status and error description. Then, you can use the 
standard status filter or a customized one. I send you a sample code 
that illustrates both cases.
If you think this is too limited according to your needs, then you 
surely will have to handle this directly in the Resource#represent 
method and set the right entity to the response object.


best regards,
Thierry Boileau


Are there best practices for error handling?  I am extending a Resource object
overriding the represent method.  What is the be approach for returning an error
to the user?  Should I throw a ResourceException (as defined by the interface)
or should I add the exception/error information to the Response?  Or Both?

Thanks


  


testResourceException.jar
Description: application/java-archive
---End Message---


[Fwd: Re: Maven groupIDs]

2008-09-11 Thread Thierry Boileau




Mail sent on the 08/21 and
apparently lost.


Best regards,
Thierry Boileau
--
 Restlet ~
Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com




---BeginMessage---

Hi Bruno,

is the org.jssutils package hosted in our Maven repos the same than the 
one hosted in the central one?
If this is the case, I think we can remove it from our Maven repository 
which is simpler.


best regards,
Thierry Boileau


Hello,

I've just realised that the groupId values used by the build script 
(for Maven2 packaging) were actually those used by the original projects.
For example, it creates POMs for groupId org.jsslutils, whereas I've 
used org.jsslutils for the official bundles I've produced for that 
project (to be published in the central repository).


I'm a bit concerned this may conflict with the versions from the 
central repository when they are available. In the case of jsslutils 
(although version 0.5 isn't in the central repository yet), the POM 
generated by the Restlet build file removes some information, such as 
the location of the source, etc.


Because the build script effectively repackages many libraries that 
may also be more officially packaged in the central Maven repository, 
I think the guidelines at [1] should be used, in particular the FAQ I 
have a patched version of the foo project developed at foo.com, what 
groupId should I use? (even if it's not strictly speaking patched).


This could lead to things like:
  groupIdorg.restlet/groupId
  artifactIdorg.jsslutils-jsslutils/artifactId

or some variants:
  groupIdorg.restlet.external/groupId
  artifactIdorg.jsslutils-jsslutils/artifactId
...
  groupIdorg.restlet/groupId
  artifactIdexternal-org.jsslutils-jsslutils/artifactId

I'm not sure what's best.


Best wishes,

Bruno.


[1] 
http://maven.apache.org/guides/mini/guide-central-repository-upload.html




---End Message---


[Fwd: Re: [RFE] LogFilter.afterHandle]

2008-09-11 Thread Thierry Boileau

Mail sent on the 08/21 and apparently lost.

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
http://www.noelios.com/
---BeginMessage---

Hi Vincent,

Thanks for your remark. I've updated the svn repository.

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
http://www.noelios.com/

Hi,

I read LogFilter.afterHanfle() and wondered if these 2 modifications would
be better (from a performance point of view):
- put the whole block into a if (this.logLogger.isLoggable(Level.INFO))
{...}
- compute the duration only if needed.

Regards,
  


---End Message---


[Fwd: Re: Wadl components]

2008-09-11 Thread Thierry Boileau




Mail sent on the 08/21 and
apparently lost.


Best regards,
Thierry Boileau
--
 Restlet ~
Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com




---BeginMessage---

Hi Bora and Vincent.

Bora, does Vincent's answer fit your needs? Do you need more information?

best regards,
Thierry Boileau


Hi Bora,
  

So far I ve been using wadl files to start my component. I was running
them as standalone applications. Is there an easy way to use Wadls within
the servlet container?



Here, i'm starting to use restlet to replace our own rest layer. For the
moment, i just used the servlet extension and added a restlet.xml:
?xml version=1.0?
component xmlns=http://www.restlet.org/schemas/1.1/Component;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation=http://www.restlet.org/schemas/1.1/Component;
client protocols=CLAP /
server protocols=HTTP /
defaultHost
attach 
targetDescriptor=clap://class/connector/rest/app.wadl/
/defaultHost
/component


  


---End Message---


[Fwd: Re: Maven Restlet 1.1-M5]

2008-09-11 Thread Thierry Boileau




Mail sent on the 08/21 and
apparently lost.


Best regards,
Thierry Boileau
--
 Restlet ~
Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com




---BeginMessage---

Hi James and Sanjay,

just in order to complete James answer which is completely correct, you can 
have a look at this page:
http://www.restlet.org/downloads/maven


Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
http://www.noelios.com/



I am trying to obtain the Maven jars for Restlet 1.1-M5 from
http://maven.restlet.org/com/noelios/restlet/com.noelios.restlet/ The
jars don't seem to be there. Are they located elsewhere?



The Maven repos are updated on the 1st and 15th of each month, I think,
so you'll have to wait a few days.

cheers,

Jim

  


---End Message---


Re: PUT method without body entity

2008-09-11 Thread Thierry Boileau

Mail sent on the 08/22 and apparently lost.
--

Hello Vincent,

this question comes back now and then (see [1] and [2]). The current
conclusion is that, as some other implementations, it has been decided
to forbid empty entities for PUT requests inside Restlet according to a
strict interpretation of the HTTP spec. Since the POST method has a more
general meaning, empty entities are tolerable which explains the difference.
Having said that, and since internet browsers don't support PUT
requests, Restlet should provide ways to generate PUT-like requests. A
step has been accomplished with the TunnelFilter (see [3] and [4]) which
allows to fake a PUT with a POST.
If you can't use POST but only GET requests, you seem to have a need
that is not satisfied yet.  You can achieve it with an additionnal
filter that checks the query string and sets the entity of the PUT request.
I've entered an RFE
(http://restlet.tigris.org/issues/show_bug.cgi?id=575) for this point.
I end with the fact that there is a huge drawback: it breaks the
semantics of GET requests which is used for retrieval.

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
http://www.noelios.com/


[1] http://restlet.tigris.org/servlets/ReadMsg?list=discussmsgNo=3903
[2] http://restlet.tigris.org/servlets/ReadMsg?listName=discussmsgNo=5298
[3] http://www.restlet.org/documentation/1.1/faq#19
[4]
http://www.restlet.org/documentation/1.1/api/org/restlet/service/TunnelService.html

Hi,

My application use the PUT methods to update some business objects, but
some of these PUT methods do not expect an entity (the value is a string
passed in the query string). RESTlet returns an HTTP 400 status.

Is it a strict behavior required by the RFC?
I expected the same behavior as the handlePost() method: a log trace, then
a call to storeRepresentation with a 'null' param.

So, is it a bug of an HTTP feature?

Regards,
  




Re: WADL howto?

2008-09-11 Thread Thierry Boileau

Mail sent on the 08/22 and apparently lost.
---

Hello John,

1) I tried deriving my Application from WadlApplication, called 
setAutoDescribed(true), and tested.  I can get the WADL, but not using my
/v1/* URI.  If I use the /v1/* URI, I get a 404; I have to use just 
the /v1/ URI, I get a version of a WADL response, which includes all of 
my various Resources.  This seems to contradict the documentation?


oops, you're right, the javadocs reflected a former state of the
implemented behaviour. I've updated it.
Thanks for your report.


Hi Ralf,


Does the WADL extension support this (from my understanding it does) 
  

and
  

are there any tutorials for it? It haven't found anything yet, besides
the API, and to figure it out with from API alone is a litte tiresome 
  

;)
  
I used the wadl component in the other way (specify the wadl file, and 


let
  
WadlComponent load my Resource subclasses); but in your case, i think 


you
  

just have to inherit WadlApplication to register your WadlResource
subclasses (with createRoot), and for each resource override the
'describe' method.
Excerpt from the javadoc:
This description can be customized by overriding the #describe() and
#describeMethod(Method, MethodInfo) methods.

Hope this help.



I can't speak for Ralf, but I found that it does help, a lot.  I thought 
I'd try this, too, but I'm still getting some odd results.  Here are some 
of my observations, so far.


1) I tried deriving my Application from WadlApplication, called 
setAutoDescribed(true), and tested.  I can get the WADL, but not using my 
/v1/* URI.  If I use the /v1/* URI, I get a 404; I have to use just 
the /v1/ URI, I get a version of a WADL response, which includes all of 
my various Resources.  This seems to contradict the documentation?


2) Next, I think there may be an interaction between WADL auto-generation 
and having a resource available at the root URI.  I tried changing my 
root resource to derive from WadlResource, and my generated WADL became 
ONLY the description of the root resource itself, not the whole resource 
hierarchy as was the case previously.  (This makes a certain amount of 
sense, because with a resource at my URI root, it's using the same URI 
that the WADL request is using.  Probably ought to be document, though.) I 
changed my root resource so that it's subordinate, and it seems like 
that works.




John Wismar
[EMAIL PROTECTED]

  


Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
http://www.noelios.com/



Re: URI templates and URI pattern matching in restlet

2008-09-11 Thread Thierry Boileau

Mail sent on the 08/22 and apparently lost.
---

Hello,

I'm afraid the Template class does not allow you to set the variables as 
you need.
I think it is simpler to define yor own templae class based on a reg exp 
anduse it when you define the routes:


router.getRoutes().add(
   new Route(router,
new MyTemplate(regexp),
restlet));

I send you a sample template class based on regexp pattern and a 
server/client test code.




Hi Prashant,

Just have a look at the Javadocs, there is a match(String) method that you
can use. You might need to adjust the matching mode and the default variable
to fit your matching needs.

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





I'm looking for a way to match a URI in the form of
/file/[a-z]{3}-[0-9]{5}.[a-z]+ i would want to put the first part (before the
dot) in one variable and the second part (after the dot) in another. Can
somebody point me to an example or tutorial or something to do just that if its
possible to do it? I tried the form: /file/{item}.{ext} but this doesn't work it
looks like the dot is not used that way in the URI template schema. Also the
javadocs doesnt explain how to use the Template match function or what do
adjust. Thanks.


  

--
Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
http://www.noelios.com/


testTemplateCustomized.jar
Description: application/java-archive


Re: How to prevent access to nested directories?

2008-09-11 Thread Thierry Boileau




Mail sent on the 08/22 and
apparently lost.
---

Hi Carlos,

That's a good remark since you point a bug.
That's a very good remark because I just wonder if this feature has
already been implemented...
I'll fix it asap.
 
Best regards,
Thierry Boileau
--
 Restlet ~
Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com



  Hi,

I want to restrict access to the nested directories inside the root
directory but I don't know how to accomplish this. I tried to set
deepaccessible property to false but doesn't work because I'm still
getting access to the directories within the  ROOT_DIR.

Here's what I'm trying to do (using restlet-1.1m4):

  @Override
  public synchronized Restlet createRoot() {
 Directory directory = new Directory(getContext(), "file:///"
+ ROOT_DIR);
 directory.setDeeplyAccessible(false);

 Router router = new Router(getContext());
 router.attach("site",
Site.class).getTemplate().setMatchingMode(Template.MODE_EQUALS);
 router.attach("files", directory);
 return router;
  }


Can anybody help me with this?

  





Re: org.restlet.ext.jaxrs-1.1 pom

2008-09-11 Thread Thierry Boileau

Mail sent on the 08/22 and apparently lost.
---

Hello Jim,

thanks a lot for reporting this issue. I've fixed it in the maven directory.

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
http://www.noelios.com/



Hi All,

There's a problem with versions of the org.restlet.ext.jaxrs-1.1 POM
later than 1.1-M4. The version specified for the commons-fileupload
dependency is invalid (@lib-fileupload-version@) and so Maven dependency
resolution fails when building Restlet apps with the JAXRS extension
using M5 or SNAPSHOT.

See (eg):

http://maven.restlet.org/org/restlet/org.restlet.ext.jaxrs/1.1-M5/org.restlet.ext.jaxrs-1.1-M5.pom

cheers,

Jim

  




Re: velocity representation

2008-09-11 Thread Thierry Boileau

Mail sent on the 08/25 and apparently lost.
---

Hi Zsolt,

there is a sample resource in the following class:
org.restlet.example.book.restlet.ch10.VelocityResource.

As far as I can see in the code, I don't think it caches the template.

best regards,
Thierry Boileau


Hello

I have a question on the usage of the Velocity extension. Does it do
any template caching, or it reads the velocity - let's say - file and
creates a template object on every request?

How you use it, folks?


Thanks

Zsolt

  




Re: Question

2008-09-11 Thread Thierry Boileau

Mail sent on the 08/26 and apparently lost.
---

Hello Sanjay,

sorry for the delay. This issue has been solved by the RC1 =
http://restlet.tigris.org/issues/show_bug.cgi?id=555

best regards,
Thierry Boileau


Hi,

This question might have been asked and answered. If so, please excuse. I have 
been using Restlet-1.1-SNAPSHOT and the following piece of Code on the Server 
Servlet:

 protected Component createComponent() {
Component component = null;

// Look for the Component XML configuration file.
final String configPath = getServletContext().getRealPath(
/WEB-INF/restlet.xml);
final File configFile = new File(configPath);
.

throws a NullPointerException when the web app is deployed in a non-exploded 
mode. The exception is:

19:01:16 ERROR - org.apache.catalina.core.ApplicationContext.log(675) | 
StandardWrapper.Throwable
java.lang.NullPointerException
at java.io.File.(Unknown Source)
at 
com.noelios.restlet.ext.servlet.ServerServlet.createComponent(ServerServlet.java:372)
at 
com.noelios.restlet.ext.servlet.ServerServlet.getComponent(ServerServlet.java:636)
at 
com.noelios.restlet.ext.servlet.ServerServlet.init(ServerServlet.java:715)
at javax.servlet.GenericServlet.init(GenericServlet.java:211)
at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1105)
at 
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:757)
at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:13

I see that 1.1RC1 has the following though:

  @SuppressWarnings(unchecked)
protected Component createComponent() {
Component component = null;

// Look for the Component XML configuration file.
ServletWarClient client = new ServletWarClient(new Context(),
getServletContext());
Response response = client.get(war:///WEB-INF/restlet.xml);
if (response.getStatus().isSuccess()  response.isEntityAvailable()) {
component = new Component(response.getEntity());
}

if (component == null) {
final String configPath = getServletContext().getRealPath(
/WEB-INF/restlet.xml);
if (configPath != null) {
final File configFile = new File(configPath);
if (configFile.exists()) {
component = new Component(LocalReference
.createFileReference(configPath));
}
}
}

Has RC1 fixed the solution mentioned. I apologize for not trying the rc1.1 yet. 
Will try to get to the same today. Just curious if the same has been addressed?

Thanks,
Sanjay
_
Be the filmmaker you always wanted to be?learn how to burn a DVD with Windows®.
http://clk.atdmt.com/MRT/go/108588797/direct/01/
  




Re: cutpaste error in ServerServlet

2008-09-11 Thread Thierry Boileau

Mail sent on the 08/26 and apparently lost.
---

Hello Paolo,

thanks for the report, I've updated the svn repository.
What kind of difficulties are you experiencing?
Could you send us a sample test application or give more details about
the way you define your application's routes, web.xml, etc?

best regards,
Thierry Boileau


I am still having a hard time trying to run my restlet app in a servlet
container with RC1 (see my previous post), while looking in the
ServerServlet source to understand how things work I spotted this bit of
code at line 494:

if (this.application != null) {
if (this.application != null) {
log([Noelios Restlet Engine] - Attaching application: 


which looks like a cut and paste error


Paolo


  




Re: Handler has no getMatrixAsForm method

2008-09-11 Thread Thierry Boileau

Mail sent on the 08/26 and apparently lost.
---

Hello Vincent,

is I don't know an acceptable answer? :)
Thanks for your suggestion, I've added  a getMatrix  method.

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
http://www.noelios.com/



Oops, sorry, i meant:
why Handler has no getMatrix() method (which could call
getRequest().getResourceRef().getMatrixAsForm()).

Regards





Re: Using the entity in a Filter

2008-09-11 Thread Thierry Boileau




Mail sent on the 08/28 and
apparently lost.
---

Hello Jim,

you can have a look at this issue:
http://restlet.tigris.org/issues/show_bug.cgi?id=149
The idea was to support the content-md5 standard header and to allow
users to manually check the digest value of a representation.
Here is the list of the additions:
- a Digest object in the org.restlet.data package that stores an
algorithm and a value. 
- a "digest" property on a Representation that contains the checksum
of the representation computed according to an algorithm.
- a computeDigest(String) on a Representation that reads entirely the representation and computes the
digested value
- two checkDigest methods on a Representation that ... checks the current digest value with the
computed one.
- the API handles the mapping between the digest attribute of a
representation (of the request or the response) and the "content-md5"
header (the only supported by the HTTP RFC).

As you may have noticed, there is no automatic way to check the
digested value. The reason is that, as you point, there is a high cost
and we were quite reluctant to "impose" that in a filter.
The idea is to let you store the stream at your convenience and check
the digested value when you want: in a filter, at the resource level.
etc.

best regards,
Thierry Boileau


  Hi,
  
I need to use the entity of a response to generate a digital signature
in a filter before it is passed to the Router. AFAIK you can only call
response.getEntity().getText() once. Is there way to do this from the
Request object.
  
cheers
/jima
  





Re: 'Warning' header

2008-09-11 Thread Thierry Boileau

Mail sent on the 08/31 and apparently lost.
---

Hello Erik,

it only means that you can use it. But, in a future release, manually
adding this header will be forbidden. In this case, you will have to use
the API instead.
Here is the current mapping between HTTP header and Restlet API:
http://wiki.restlet.org/docs_1.1/g1/43-restlet/130-restlet.html

best regards,
Thierry Boileau


I'm manually adding a 'Warning' header, which is generating this in 
the log:


Addition of the standard header Warning is discouraged. Future 
versions of the Restlet API will directly support it.


Is the suggestion just don't use Warning? Or is there some other way I 
should be adding it?


I'm using Warning to send along additional information about what 
caused a 409 Conflict to occur. Is there a better way to communicate 
this information?


Thanks,
Erik





Re: 1.1m5 Javadocs zips we can download?

2008-09-11 Thread Thierry Boileau

Mail sent on the 09/01 and apparently lost.
---

Hello Kris,

the javadocs is located into any distribution files. You can get them
fom http://www.restlet.org/downloads/.
1.1 RC1 is the current version of the 1.1 branch. However, you can still
get the 1.1m5 distribution files by following the older releases link.
And more precisely:
- http://www.restlet.org/downloads/1.1/restlet-1.1m5.zip,
- or http://www.restlet.org/downloads/1.1/restlet-1.1m5.exe


Hi,

We'd like to cache a copy of the restlet javadocs on a local server.
Anyone know where can I get archive copies of them to download?

Regards,

Kris Bravo


  

--
Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
http://www.noelios.com/



Re: Restlet 1.1-RC1 in OSGi

2008-09-11 Thread Thierry Boileau

Mail sent on the 09/02 and apparently lost.
---

Hi Michael,

as I'm not aware of the integration effort with OSGi I'm not able to 
give you a quick answer.
Jérôme can answer you after his return from vacations on the 11th of 
september.


Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
http://www.noelios.com/
 

Hi all,

In trying to run 1.1-RC1 in Eclipse as an OSGi bundle following the
instructions on the wiki, I found I had to add
Engine.setUserClassLoader(this.getClass().getClassLoader()) to my
Activator.  I've updated the wiki with this, but wondered if it was a
bug and should be set in the restlet activator?

If I don't include the user classloader I get the following exception:
5/09/2008 09:33:47 com.noelios.restlet.http.HttpServerHelper getConverter
SEVERE: Unable to create the HTTP server converter
java.lang.ClassNotFoundException
at org.restlet.util.Engine.loadClass(Engine.java:283)
at 
com.noelios.restlet.http.HttpServerHelper.getConverter(HttpServerHelper.java:105)
at com.noelios.restlet.http.HttpServerHelper.handle(HttpServerHelper.java:145)
at 
com.noelios.restlet.ext.jetty.JettyServerHelper$WrappedServer.handle(JettyServerHelper.java:174)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at 
org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at 
org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)

Regards,
Michael.


Re: GWT + Restlet examples?

2008-09-11 Thread Thierry Boileau

Mail sent on the 09/10 and apparently lost.
---

Hello Duong,

what kind of problem are you experiencing with the creation of directories?

best regards,
Thierry Boileau




I don't mean to throw a wet blanket on the GWT discussion, but my
(limited) impression of GWT was that it was trying to abstract away
the web, rather than embrace it. Rather than dealing with loosely
coupled services, resources, and representations, it wraps everything
into a nice tidy Java API that would be familiar to Swing and RPC
service developers. I certainly think there's a good place for
frameworks like these (just look at the popularity of GWT), but trying
to adapt it to a REST world sounds like you're barking up the wrong
tree.
I'd love to hear other points of view, though.

Justin




Hi:

I am exiting with both GWT and Restlet, but have not had time to look at
Reslet-GWT API for client side. On the GWT front, the cited tutorial
demonstrates a new Java overlay integration between Java and JavaScripts
via JSONP. Last time, i looked at the Restlet there is
org.restlet.ext.json_2.0 extension that i plan to dive into. I still
have issue with creating directory resource using
com.noelios.restlet.ext.servlet.ServerServlet in Tomcat 6. The directory
resource work fine under Restlet component server. Please let me know if
anyone has made it work under tomcat or glassfish v3.

BTW, i think Restlet is exiting, so does GWT-1.5. Is there any example
to show server-side Restlet JSON service, even better to integrate with
GWT 1.5 JSONP using Java overlay? My strategy is to separate client-side
and server-side services so my server is only 1 of many possible service
sources for GWT mashup, where GWT application is compiled and served
under directory resource of Restlet under a Servlet engine available at
hosted sides such as GoDaddy. Is it a recommended practice? I can take
criticism so please share your experience.

Duong Batien
DBGROUPS and BudhNet

  

On Tue, Sep 9, 2008 at 12:29 PM, Mark Petrovic [EMAIL PROTECTED] wrote:


Does someone have a single snippet of code that shows how the Restlet-GWT
API would work with the GWT tutorial w/RPC in StockWatcher?  Pseudo code
would be fine.
http://code.google.com/docreader/#p=google-web-toolkit-doc-1-5s=google-web-toolkit-doc-1-5t=GettingStartedRPC
That is, what would the -Async and Service interface look like, and what
part, if any, do annotations like @RemoteServiceRelativePath(stockPrices)
play when using Restlet-GWT?
Thanks.

On Sep 8, 2008, at 6:14 AM, Rob Heittman wrote:

Restlet's GWT (Server) Extension, being just a wrapper around ServerServlet
that can also pass calls to the GWT Hosted Mode adapter, is one small class
file that has been in 1.1 milestone builds for almost a year now.  My
company uses it in a number of large production and in-development
applications.  These do not use Restlet-GWT API yet (though we are starting
to port), but use GWT's built in facilities or JSNI to talk to a
Restlet-powered server.

The Restlet-GWT API (the port of the core Restlet API to work under GWT 1.5)
was a much larger undertaking afflicted by a lot of design complexity, the
moving target of GWT 1.5, and requiring the wisdom and time of Jerome, the
Restlet project founder, to accomplish.
- Rob

On Sun, Sep 7, 2008 at 11:18 PM, Mark Petrovic [EMAIL PROTECTED] wrote:
  

Thank you for the kind and speedy response, Rob.
I intend to spend the week, and then some, on this subject, and would be
happy to receive any guidance or code you can muster.  In return, I can post
my newcomer questions and results.
I'm curious:  how is it that the hosted mode Restlet GWT Extension is
heavily exercised, but the Restlet-GWT API is not?  And what is the
difference again?
Mark
On Sep 7, 2008, at 8:10 PM, Rob Heittman wrote:

Hi Mark, I've been working on a longish example (Chesstlet) that pulls
together a number of Restlet and GWT techniques, but this won't be ready
until November, due to some commitments I have in early October that
complicate my availability.  In the meantime, maybe the best thing to do
would be to pull together a small illustration based on the test case
already in the Restlet source -- just beefing it up to do some useful things
beyond hello, world.  I will try to get that together (or ask someone else
at the office to do so) in the next day or two.

The Restlet-GWT API is still largely unexercised (as opposed to the
Restlet GWT Extension, which is just the hosted mode wrapper for
ServerServlet, which is very heavily exercised) so we are discovering all
sorts of new issues as we try it out.  So you should probably be working
from a Restlet snapshot to pick up all the latest commits.  I think the
latest important thing was an infinite recursion that Thierry removed.  Now
that GWT 1.5 is final and we don't have to chase a moving target any more,
it will be easier to stabilize this.
- Rob
On Sun, Sep 7, 2008 at 10:48 PM, Mark Petrovic [EMAIL PROTECTED]
wrote:


Good day.  I'm 

Re: How to hook end of POST

2008-09-11 Thread Thierry Boileau




Mail sent on the 09/10 and
apparently lost.
---

Hello Kenji,

I'm a little surprised by the fact that the Filter#afterHandle method
does not work as expected. What kind of filter are you suspecting to
fail?
Anyway, I send you a sample code containing 3 classes: an application,
a resource and a filter.
The application puts the filter as its own root restlet, thus the
afterHandle method of the filter is called after all methods. 

Please feel free to detail your need, I may have missed something.

 Best regards,
Thierry Boileau
--
 Restlet ~
Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


  Hi,

I'm trying to hook the end of POST calls, and I've tried these :

Filter#afterHandle
Handler#handleXxx
Application#handle

Works fine for GET requests, but for POST requests, these get called before
response data is sent to the browser.

Is there any way to hook the point when response data is sent?

Thanks,
Kenji Tayama

  



package testPost;

import org.restlet.Application;
import org.restlet.Client;
import org.restlet.Component;
import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.Router;
import org.restlet.data.Protocol;
import org.restlet.resource.StringRepresentation;

public class TestApplication extends Application {
public static void main(String[] args) throws Exception {
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getDefaultHost()
.attachDefault(
new TestApplication(component.getContext()
.createChildContext()));

component.start();

Client client = new Client(Protocol.HTTP);
client.post(http://localhost:8182/;, new StringRepresentation(test));

component.stop();
}

public TestApplication(Context context) {
super(context);
}

@Override
public Restlet createRoot() {
Router router = new Router(getContext());
router.attachDefault(TestResource.class);

// Filter all requests handled by the application.
return new TestFilter(getContext(), router);
}

}

package testPost;

import org.restlet.Context;
import org.restlet.Filter;
import org.restlet.Restlet;
import org.restlet.data.Request;
import org.restlet.data.Response;

public class TestFilter extends Filter {

public TestFilter(Context context, Restlet next) {
super(context, next);
}

@Override
protected void afterHandle(Request request, Response response) {
// TODO Auto-generated method stub
super.afterHandle(request, response);
}

@Override
protected int beforeHandle(Request request, Response response) {
// TODO Auto-generated method stub
return super.beforeHandle(request, response);
}

@Override
protected int doHandle(Request request, Response response) {
// TODO Auto-generated method stub
return super.doHandle(request, response);
}

}

package testPost;

import org.restlet.Context;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.resource.Representation;
import org.restlet.resource.Resource;
import org.restlet.resource.ResourceException;
import org.restlet.resource.StringRepresentation;

public class TestResource extends Resource {

/**
 * Handle post calls
 */
@Override
public void acceptRepresentation(Representation entity)
throws ResourceException {
getResponse().setEntity(new StringRepresentation(ok));
}

public TestResource(Context context, Request request, Response response) {
super(context, request, response);
setModifiable(true);
}

}



Re: Restlet-1.1rc1, Spring2.5, Component and Application creation problem.

2008-09-11 Thread Thierry Boileau




Mail sent on the 09/10 and
apparently lost.
---

Hi Colin,

I think this has already been mentionned and fixed. Could you try with
the latest snapshot (http://www.restlet.org/downloads/snapshot.zip)?

 Best
regards,
Thierry Boileau
--
 Restlet ~
Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com


  Restlet-1.1rc1 with Spring2.5.

There seem to be some sort of conflict with creating Component and Application
objects when using the new Spring integration classes. 

I want to use the default component and so I removed the following setting from
my web.xml and spring bean config.

context-param
param-nameorg.restlet.component/param-name
param-valuecomponent/param-value
/context-param

bean id="component" class="org.restlet.ext.spring.SpringComponent"
   ... bean


However, in SpringServerServlet.java, line 134, the statement

component = (Component) getWebApplicationContext().getBean(componentBeanName);

will throw an IllegalArgumentException if componentBeanName is null or
NoSuchBeanDefinitionException if the bean does not exist, ie no
'org.restlet.component' and 'component'. Null component is never returned and
tested. The call to create the default component is never called.


To avoid the exceptions I add the 'org.restlet.component' and 'component' init
parameter settings. But this prevents the Application object to be created via
the method getApplication() in ServerServlet.java, line 580.

The call to isDefaultComponent() always returns false because I've added the 
'org.restlet.component' context init parameter. This in turn makes the method
getApplication() return null always. There is also a null SuppressWarnings
annotation.

Is there a way around this? 

Thanks.
  





Re: [WADL] NPE in WadlResource.describe(Variant)

2008-09-11 Thread Thierry Boileau

Mail sent on the 09/01 and apparently lost.
---

Hello Vincent,

thanks a lot for your help! I've fixed the NPE and updated the svn
repository. However, I will discuss this point with Jérôme.

best regards,
Thierry Boileau



Hi,

I can get a NPE when i perform a HTTP OPTIONS request with a bad accept
header (text/xml in my case):
curl -v -X OPTIONS -H Accept: text/xml
http://localhost:8080/my-webapp/restlet/service/0;

The line 170 throws the exception (variant is null):
if (MediaType.APPLICATION_WADL_XML.equals(variant.getMediaType()))

I dont know what you prefer to do: returns null or handles the right http
status (or both :))

Cheers,
  




Re: GWT + Restlet examples?

2008-09-11 Thread Duong BaTien
On Thu, 2008-09-11 at 12:04 +0200, Thierry Boileau wrote:
 Mail sent on the 09/10 and apparently lost.
 ---
 
 Hello Duong,
 
 what kind of problem are you experiencing with the creation of directories?
 
 best regards,
 Thierry Boileau
 

Wow, thank you Thierry. 

(1) I will find time to try GWT-Restlet example just sent to the list.
Is your example to the list using just JSON string or JSONP with GWT-1.5
JavaScript Overlay Types?

2) Back to Restlet Directory, the Restlet example using RestletServlet
is working under tomcat-6 and jdk6 in standard web mode of .war file for
http://budhnet.com/index.html which become http://budhnet.com/ under
restlet. Now, using GWT compile code of muweb application, the entry
point of standard web http://budhnet.com/muweb/index.html work as
expected. Under restlet the entry point to the directory
http://budhnet.com/muweb/ does not work under tomcat but work with
Restlet server component and main entry point to start the Restlet
Application with FILE client protocol.

I follow the instruction for under web.xml

context-param
  param-nameorg.restlet.application/param-name
  param-valuecom.dbgroups.psi.privacy.Psi/param-value
/context-param
context-param
   param-nameorg.restlet.clients/param-name
   param-valueFILE/param-value
/context-param

servlet
  servlet-nameRestletServlet/servlet-name
  servlet-class
com.noelios.restlet.ext.servlet.ServerServlet
  /servlet-class
/servlet

 servlet-mapping
  servlet-nameRestletServlet/servlet-name
  url-pattern/*/url-pattern
/servlet-mapping

Other URIs  under router attach are working as expected, except the
directory attached. The same directory structures work under Restlet
component server. According to the attached log, the file absolute paths
are right. /muweb/ and /gwt-compiled-app/ are directory targets to GWT
mudule with index.html are entry points. Env: jdk1.6 (U3), tomcat
6.0.14, linux CentOS (clone of RedHat enterprise).

There are some hosting services that provide either Tomcat-6 or
Glassfish v.3. I think simple integration with popular servlet engines
to make GWT compiled file working as static client that use restlet JSON
service as in your example (i have not looked into it yet) make restlet
work seamlessly in both client and server side using OSGi as the Vision
of Restlet. http://budhnet.com/ http://budhnet.com/muweb/#Home
http://budhnet.com/muweb/#AccountingJobs are the way for Restlet and GWT
working together. Please help and test for this very practical architect
to take restlet to the mass production level, especially with GUICE DI
of reslet resources (please post if someone has made it work under new
restlet).

Best Regards
Duong BaTien
DBGROUPS and BudhNet

  I'd love to hear other points of view, though.
 
  Justin
  
 
  Hi:
 
  I am exiting with both GWT and Restlet, but have not had time to look at
  Reslet-GWT API for client side. On the GWT front, the cited tutorial
  demonstrates a new Java overlay integration between Java and JavaScripts
  via JSONP. Last time, i looked at the Restlet there is
  org.restlet.ext.json_2.0 extension that i plan to dive into. I still
  have issue with creating directory resource using
  com.noelios.restlet.ext.servlet.ServerServlet in Tomcat 6. The directory
  resource work fine under Restlet component server. Please let me know if
  anyone has made it work under tomcat or glassfish v3.
 
  BTW, i think Restlet is exiting, so does GWT-1.5. Is there any example
  to show server-side Restlet JSON service, even better to integrate with
  GWT 1.5 JSONP using Java overlay? My strategy is to separate client-side
  and server-side services so my server is only 1 of many possible service
  sources for GWT mashup, where GWT application is compiled and served
  under directory resource of Restlet under a Servlet engine available at
  hosted sides such as GoDaddy. Is it a recommended practice? I can take
  criticism so please share your experience.
 
  Duong Batien
  DBGROUPS and BudhNet
 



Re: GWT + Restlet examples?

2008-09-11 Thread Mark Petrovic

Fantastic, Thierry.  Thanks much.

Dumb question:  how, or should, one integrate the notion of allow  
post/allow put, etc, in the TestServer code?


Mark

On Sep 11, 2008, at 3:03 AM, Thierry Boileau wrote:


Mail sent on the 09/02 and apparently lost.
---

Hello Mark,

it may be too late, but I send a you a very simple application  
composed of two parts.
One part is developped with the gwt technology and aims at building  
a simple HTML page. It integrates also a simple AJAX call to the  
server part therefore it relies also on the org.rest.gwt.jar  
package which is the integration of both GWT and Restlet (client  
only) technologies. All sources and libraries (except GWT) are  
located in the gwt-Foo.zip file attached to this mail. It contains  
only one source file called Foo.java.
The other part is the server part based exclusively on the Restlet  
technology. It allows first to serve the files generated by GWT and  
then to reply to the AJAX call. I just provide the code of the  
unique class (TestServer). You will need 2 restlet packages  
org.restlet.jar and com.noelios.restlet.jar.


I hope it will help you a little bit.

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com

NB : as said Rob, it is planned to add a more developped example (http://restlet.tigris.org/issues/show_bug.cgi?id=541 
).


Good day.  I'm new here, but not new to Java and its supporting  
technologies.


I'm embarking on teaching myself GWT using Restlets, neither of  
which I have programmed before, although I have read the  
documentation for each.  I know that at the time the Restlet-GWT  
code was released, a whopping 6 weeks ago :-), there were no  
examples illustrating its use.  Perhaps there are snippets of  
examples the community can share now, some weeks after the  
release.  If you have such examples, I would be quite grateful to  
study them, as would be, I'm sure, other newcomers to these  
subjects.  I am particularly interested in running the server side  
using the Restlet NET connector.


All the pieces are in front of me; at this point a few well placed  
examples would help bring it all together.


Thank you.


gwt-Foo.zippackage gwt;

import org.restlet.Component;
import org.restlet.Directory;
import org.restlet.Restlet;
import org.restlet.data.LocalReference;
import org.restlet.data.MediaType;
import org.restlet.data.Protocol;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.data.Status;
import org.restlet.resource.StringRepresentation;

public class TestServer extends Component {
   public static void main(String[] args) throws Exception {
   Component server = new TestServer();
   server.start();
   }

   public TestServer() {
   super();
   getServers().add(Protocol.HTTP, 8182);
   getClients().add(Protocol.FILE);
   Restlet restlet = new Restlet() {

   @Override
   public void handle(Request request, Response response) {
   response.setEntity(new StringRepresentation(This is  
a test,

   MediaType.TEXT_PLAIN));
   response.setStatus(Status.SUCCESS_OK);
   }
   };

   // Path to the directory where are located the gwt client  
pages.
   String gwtClientPagesDir = /home/thierry/workspace/ 
restlet-1.1/Foo/www/com.example.foo.Foo;

   // Simple Directory that serves the gwt client pages.
   Directory directory = new  
Directory(getContext().createChildContext(),

   LocalReference.createFileReference(gwtClientPagesDir));

   // Will be targeted from Internet browser (e.g.
   // http://localhost:8182/testClient/Foo
   getDefaultHost().attach(/testClient, directory);
   // Will be targeted by the gwt sample page via AJAX request
   getDefaultHost().attach(/testServer, restlet);
   }

}





Re: GWT + Restlet examples?

2008-09-11 Thread Thierry Boileau

Hi Mark,

the TestServer is a very simple server-side application using only a 
Restlet.
In this case, if you want to handle only, let's say, GET requests, you 
have to test it by yourself and generate correctly the response in the 
handle(request, Response) method.
I suggest you develop the server-side application with Resource. Here is 
a pointer that will help you: 
http://www.restlet.org/documentation/1.1/firstResource.
The list of allowed methods for a resource can be controlled via the 
allow* methods and or the modifiable/readable properties.
You can see the javadocs for more details 
(http://www.restlet.org/documentation/1.1/api/org/restlet/resource/Resource.html;).




Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
http://www.noelios.com/



Fantastic, Thierry.  Thanks much.

Dumb question:  how, or should, one integrate the notion of allow 
post/allow put, etc, in the TestServer code?


Mark

On Sep 11, 2008, at 3:03 AM, Thierry Boileau wrote:


Mail sent on the 09/02 and apparently lost.
---

Hello Mark,

it may be too late, but I send a you a very simple application 
composed of two parts.
One part is developped with the gwt technology and aims at building a 
simple HTML page. It integrates also a simple AJAX call to the server 
part therefore it relies also on the org.rest.gwt.jar package which 
is the integration of both GWT and Restlet (client only) 
technologies. All sources and libraries (except GWT) are located in 
the gwt-Foo.zip file attached to this mail. It contains only one 
source file called Foo.java.
The other part is the server part based exclusively on the Restlet 
technology. It allows first to serve the files generated by GWT and 
then to reply to the AJAX call. I just provide the code of the unique 
class (TestServer). You will need 2 restlet packages 
org.restlet.jar and com.noelios.restlet.jar.


I hope it will help you a little bit.

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org 
http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
http://www.noelios.com/


NB : as said Rob, it is planned to add a more developped example 
(http://restlet.tigris.org/issues/show_bug.cgi?id=541).


Good day.  I'm new here, but not new to Java and its supporting 
technologies.


I'm embarking on teaching myself GWT using Restlets, neither of 
which I have programmed before, although I have read the 
documentation for each.  I know that at the time the Restlet-GWT 
code was released, a whopping 6 weeks ago :-), there were no 
examples illustrating its use.  Perhaps there are snippets of 
examples the community can share now, some weeks after the release.  
If you have such examples, I would be quite grateful to study them, 
as would be, I'm sure, other newcomers to these subjects.  I am 
particularly interested in running the server side using the Restlet 
NET connector.


All the pieces are in front of me; at this point a few well placed 
examples would help bring it all together.


Thank you.


gwt-Foo.zippackage gwt;

import org.restlet.Component;
import org.restlet.Directory;
import org.restlet.Restlet;
import org.restlet.data.LocalReference;
import org.restlet.data.MediaType;
import org.restlet.data.Protocol;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.data.Status;
import org.restlet.resource.StringRepresentation;

public class TestServer extends Component {
   public static void main(String[] args) throws Exception {
   Component server = new TestServer();
   server.start();
   }

   public TestServer() {
   super();
   getServers().add(Protocol.HTTP, 8182);
   getClients().add(Protocol.FILE);
   Restlet restlet = new Restlet() {

   @Override
   public void handle(Request request, Response response) {
   response.setEntity(new StringRepresentation(This is a 
test,

   MediaType.TEXT_PLAIN));
   response.setStatus(Status.SUCCESS_OK);
   }
   };

   // Path to the directory where are located the gwt client pages.
   String gwtClientPagesDir = 
/home/thierry/workspace/restlet-1.1/Foo/www/com.example.foo.Foo;

   // Simple Directory that serves the gwt client pages.
   Directory directory = new 
Directory(getContext().createChildContext(),

   LocalReference.createFileReference(gwtClientPagesDir));

   // Will be targeted from Internet browser (e.g.
   // http://localhost:8182/testClient/Foo
   getDefaultHost().attach(/testClient, directory);
   // Will be targeted by the gwt sample page via AJAX request
   getDefaultHost().attach(/testServer, restlet);
   }



Re: GWT + Restlet examples?

2008-09-11 Thread Rob Heittman
In a real application, it is usually better to write high-level Resources
than Restlets, though wiring in a Restlet as in the Foo.zip example is often
the briefest way to return an HTTP response.  Have a look at this tutorial,
if you haven't already:

http://www.restlet.org/documentation/1.1/firstResource

Resources are at a higher level of abstraction.  A new instance of a
Resource is created to handle each Request, which frees you from some thread
safety concerns.  Restlet instances are permanently wired in to your
application, and can handle Requests from many threads, so they must be
thread safe.  By overriding methods like allowPost() to return true, the
Resource signals what's allowed higher up the chain.  Methods like
represent() and acceptRepresentation() allow you to expose the
representational details of your object, and let the Restlet API handle the
rest of the connector infrastructure (magically coping with hard stuff like
ETag assignment and dealing with conditional GETs in HTTP).

There's no difference in server-side Restlet programming for a GWT client
and a non-GWT client, so all the existing 1.1 documentation applies.

On Thu, Sep 11, 2008 at 12:49 PM, Mark Petrovic [EMAIL PROTECTED]wrote:

 Fantastic, Thierry.  Thanks much.
 Dumb question:  how, or should, one integrate the notion of allow
 post/allow put, etc, in the TestServer code?

 Mark



Re: GWT + Restlet examples?

2008-09-11 Thread Thierry Boileau

Hi Duong,

1) No, the sample  code is not based on  GWT-RPC API. The server side is 
based on Restlet and I simply answer to requests (in this case AJAX 
requests) with a simple line of plain text (it could be XML)


2) Let me think about it! :)

Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org http://www.restlet.org/
Noelios Technologies ~ Co-founder ~ http://www.noelios.com 
http://www.noelios.com/




Mail sent on the 09/10 and apparently lost.
---

Hello Duong,

what kind of problem are you experiencing with the creation of directories?

best regards,
Thierry Boileau




Wow, thank you Thierry. 


(1) I will find time to try GWT-Restlet example just sent to the list.
Is your example to the list using just JSON string or JSONP with GWT-1.5
JavaScript Overlay Types?

2) Back to Restlet Directory, the Restlet example using RestletServlet
is working under tomcat-6 and jdk6 in standard web mode of .war file for
http://budhnet.com/index.html which become http://budhnet.com/ under
restlet. Now, using GWT compile code of muweb application, the entry
point of standard web http://budhnet.com/muweb/index.html work as
expected. Under restlet the entry point to the directory
http://budhnet.com/muweb/ does not work under tomcat but work with
Restlet server component and main entry point to start the Restlet
Application with FILE client protocol.

I follow the instruction for under web.xml

context-param
  param-nameorg.restlet.application/param-name
  param-valuecom.dbgroups.psi.privacy.Psi/param-value
/context-param
context-param
   param-nameorg.restlet.clients/param-name
   param-valueFILE/param-value
/context-param

servlet
  servlet-nameRestletServlet/servlet-name
  servlet-class
com.noelios.restlet.ext.servlet.ServerServlet
  /servlet-class
/servlet

 servlet-mapping
  servlet-nameRestletServlet/servlet-name
  url-pattern/*/url-pattern
/servlet-mapping

Other URIs  under router attach are working as expected, except the
directory attached. The same directory structures work under Restlet
component server. According to the attached log, the file absolute paths
are right. /muweb/ and /gwt-compiled-app/ are directory targets to GWT
mudule with index.html are entry points. Env: jdk1.6 (U3), tomcat
6.0.14, linux CentOS (clone of RedHat enterprise).

There are some hosting services that provide either Tomcat-6 or
Glassfish v.3. I think simple integration with popular servlet engines
to make GWT compiled file working as static client that use restlet JSON
service as in your example (i have not looked into it yet) make restlet
work seamlessly in both client and server side using OSGi as the Vision
of Restlet. http://budhnet.com/ http://budhnet.com/muweb/#Home
http://budhnet.com/muweb/#AccountingJobs are the way for Restlet and GWT
working together. Please help and test for this very practical architect
to take restlet to the mass production level, especially with GUICE DI
of reslet resources (please post if someone has made it work under new
restlet).

Best Regards
Duong BaTien
DBGROUPS and BudhNet

  

I'd love to hear other points of view, though.

Justin



Hi:

I am exiting with both GWT and Restlet, but have not had time to look at
Reslet-GWT API for client side. On the GWT front, the cited tutorial
demonstrates a new Java overlay integration between Java and JavaScripts
via JSONP. Last time, i looked at the Restlet there is
org.restlet.ext.json_2.0 extension that i plan to dive into. I still
have issue with creating directory resource using
com.noelios.restlet.ext.servlet.ServerServlet in Tomcat 6. The directory
resource work fine under Restlet component server. Please let me know if
anyone has made it work under tomcat or glassfish v3.

BTW, i think Restlet is exiting, so does GWT-1.5. Is there any example
to show server-side Restlet JSON service, even better to integrate with
GWT 1.5 JSONP using Java overlay? My strategy is to separate client-side
and server-side services so my server is only 1 of many possible service
sources for GWT mashup, where GWT application is compiled and served
under directory resource of Restlet under a Servlet engine available at
hosted sides such as GoDaddy. Is it a recommended practice? I can take
criticism so please share your experience.

Duong Batien
DBGROUPS and BudhNet

  


Re: ObjectRepresentation and String encoding

2008-09-11 Thread Hannes Ebner
Hi Thierry,

Thierry Boileau wrote:
 Could you send us a reproductible test case, and send us also the trace
 of the following code on both client and server side?

I will try to reproduce it with a small test case and get back to you.

Best regards,
Hannes


Re: GWT + Restlet examples?

2008-09-11 Thread Rob Heittman
Thanks for this, Thierry!

I have changed some names, made some more objects (a Component, Application,
and Resource ...) and wrapped it up into an Eclipse project with Ant build
script, hosted mode launcher, and a working server side, added tomcat's
web.xml, embedded the Restlet jars, and made the file available on the
Restlet wiki on the GWT documentation page.  I also put some of the code
snippets into the page directly.

http://wiki.restlet.org/docs_1.1/g1/13-restlet/28-restlet/144-restlet.html

This will have to hold us for a little bit until a bigger and better example
comes along.  But I hope that most people can just pop this into Eclipse and
get past most of the configurational pain.

- Rob

On Thu, Sep 11, 2008 at 6:03 AM, Thierry Boileau 
[EMAIL PROTECTED] wrote:


 One part is developped with the gwt technology and aims at building a
 simple HTML page. It integrates also a simple AJAX call to the server part
 therefore it relies also on the org.rest.gwt.jar package which is the
 integration of both GWT and Restlet (client only) technologies. All sources
 and libraries (except GWT) are located in the gwt-Foo.zip file attached to
 this mail. It contains only one source file called Foo.java.



INFO in NRE SecurityUtils

2008-09-11 Thread Avi Flax
I'm using 1.0, so this may already be fixed in 1.1, but a quick search of
the list didn't turn up anything, so I thought I'd ask.
I'm using Basic HTTP Auth, and I've implemented a subclass of Guard, wherein
I've overridden doHandle(). I know that's not the recommended approach, but
I don't think it's relevant to this question.

I keep seeing entries in my logs that look like this:

Sep 11, 2008 6:02:50 PM com.noelios.restlet.util.SecurityUtils parseResponse
INFO: Basic HTTP authentication succeeded: identifier=avif.

The thing is, this is even in cases where basic auth fails, in my Guard,
wherein I call challenge(response).

I think this log record is really just saying I was able to successfully
parse the Authorization header into a ChallengeResponse object, which is
good info, but: (A) it should be a FINE or FINER, not an INFO, and (B) the
message is misleading.

Does that make sense?

Thanks,
Avi

-- 
Avi Flax » Lead Technologist » Partner » Arc90 » http://arc90.com


Restlet + Dojo?

2008-09-11 Thread Justin Stanczak
Anyone using this combo? Any tips? Just wanted to give a shout out. I'm
looking into using this combo, seems like a good fit. I would just use JSON
services with Restlet resources.


Re: GWT + Restlet examples?

2008-09-11 Thread Mark Petrovic
Thank you.  In fact, that example made it to hardcopy and accompanied  
me to lunch twice this week.  Good stuff.


Mark

On Sep 11, 2008, at 10:06 AM, Rob Heittman wrote:

In a real application, it is usually better to write high-level  
Resources than Restlets, though wiring in a Restlet as in the  
Foo.zip example is often the briefest way to return an HTTP  
response.  Have a look at this tutorial, if you haven't already:


http://www.restlet.org/documentation/1.1/firstResource

Resources are at a higher level of abstraction.  A new instance of a  
Resource is created to handle each Request, which frees you from  
some thread safety concerns.  Restlet instances are permanently  
wired in to your application, and can handle Requests from many  
threads, so they must be thread safe.  By overriding methods like  
allowPost() to return true, the Resource signals what's allowed  
higher up the chain.  Methods like represent() and  
acceptRepresentation() allow you to expose the representational  
details of your object, and let the Restlet API handle the rest of  
the connector infrastructure (magically coping with hard stuff like  
ETag assignment and dealing with conditional GETs in HTTP).


There's no difference in server-side Restlet programming for a GWT  
client and a non-GWT client, so all the existing 1.1 documentation  
applies.


On Thu, Sep 11, 2008 at 12:49 PM, Mark Petrovic  
[EMAIL PROTECTED] wrote:

Fantastic, Thierry.  Thanks much.

Dumb question:  how, or should, one integrate the notion of allow  
post/allow put, etc, in the TestServer code?


Mark





Re: How to hook end of POST

2008-09-11 Thread Kenji Tayama
Hi Thierry,

Thank you for the sample codes.
I modifed the codes so they can show this problem.

You can see that Filter#afterHandle is called before
WriterRepresentation#write in the console.

Regards,
Kenji Tayama

2008/9/11 Thierry Boileau [EMAIL PROTECTED]:
 Mail sent on the 09/10 and apparently lost.
 ---

 Hello Kenji,

 I'm a little surprised by the fact that the Filter#afterHandle method does
 not work as expected. What kind of filter are you suspecting to fail?
 Anyway, I send you a sample code containing 3 classes: an application, a
 resource and a filter.
 The application puts the filter as its own root restlet, thus the
 afterHandle method of the filter is called after all methods.

 Please feel free to detail your need, I may have missed something.

 Best regards,
 Thierry Boileau
 --
 Restlet ~ Core developer ~ http://www.restlet.org
 Noelios Technologies ~ Co-founder ~ http://www.noelios.com

 Hi,

 I'm trying to hook the end of POST calls, and I've tried these :

 Filter#afterHandle
 Handler#handleXxx
 Application#handle

 Works fine for GET requests, but for POST requests, these get called before
 response data is sent to the browser.

 Is there any way to hook the point when response data is sent?

 Thanks,
 Kenji Tayama


package testPost;

import org.restlet.Application;
import org.restlet.Client;
import org.restlet.Component;
import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.Router;
import org.restlet.data.Protocol;
import org.restlet.resource.StringRepresentation;

public class TestApplication extends Application {
public static void main(String[] args) throws Exception {
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getDefaultHost()
.attachDefault(
new 
TestApplication(component.getContext()

.createChildContext()));

component.start();

Client client = new Client(Protocol.HTTP);
client.post(http://localhost:8182/;, new 
StringRepresentation(test));

component.stop();
}

public TestApplication(Context context) {
super(context);
}

@Override
public Restlet createRoot() {
Router router = new Router(getContext());
router.attachDefault(TestResource.class);

// Filter all requests handled by the application.
return new TestFilter(getContext(), router);
}

}
package testPost;

import org.restlet.Context;
import org.restlet.Filter;
import org.restlet.Restlet;
import org.restlet.data.Request;
import org.restlet.data.Response;

public class TestFilter extends Filter {

public TestFilter(Context context, Restlet next) {
super(context, next);
}

@Override
protected void afterHandle(Request request, Response response) {
System.out.println(start afterHandle);
super.afterHandle(request, response);
System.out.println(end afterHandle);
}

@Override
protected int beforeHandle(Request request, Response response) {
System.out.println(start beforeHandle);
return super.beforeHandle(request, response);
}

@Override
protected int doHandle(Request request, Response response) {
System.out.println(start doHandle);
return super.doHandle(request, response);
}

}
package testPost;

import java.io.IOException;
import java.io.Writer;

import org.restlet.Context;
import org.restlet.data.CharacterSet;
import org.restlet.data.MediaType;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.restlet.data.Status;
import org.restlet.resource.Representation;
import org.restlet.resource.Resource;
import org.restlet.resource.ResourceException;
import org.restlet.resource.WriterRepresentation;

public class TestResource extends Resource {

/**
 * Handle post calls
 */
@Override
public void acceptRepresentation(Representation entity)
throws ResourceException {
System.out.println(before setEntity);

WriterRepresentation rep = new 
TestWriterRepresentation(entity.getMediaType());
rep.setCharacterSet(CharacterSet.UTF_8);
getResponse().setStatus(Status.SUCCESS_OK);
getResponse().setEntity(rep);

System.out.println(after setEntity);
}

public TestResource(Context context, Request request, Response 
response) {
super(context, request, response);
setModifiable(true);
}

public class TestWriterRepresentation