Restlet 1.0 beta 10 released

Jerome Louvel <contact <at> noelios.com>
2006-05-02 12:11:07 GMT

Main changes:

Fully refactored the org.restlet.data package to reduce usage of
interfaces and remove the need to use the Manager static methods whose
implementation would not significantly vary from one implementation to
another. When interfaces were needed, like for enumerations, the
implementation class is provided with the Default* name.

Renamed RestletCall interface into Call and added a DefaultCall class.
Also renamed RestletCallWrapper to WrapperCall.

Renamed Call.getRestlet*() methods to getContext*() and
Call.setHandlerPath() to setContextPath().

Added a HostMaplet to provide an easy and flexible way to detect the URI
related to a single host such as equivalent IP-based URIs. All aspects are
configurable and there is choice between two attachment modes (parent Chainlet
or Maplet). Suggested by Dave Pawson and John D. Mitchell.

The RestletContainer now also implements the Chainlet interface, in
addition to the Maplet interface. If you use both attachment mechanisms at the
same time, the Chainlet will have a higher priority. This is a convenient way
to chain a Restlet as a root handler with having to specify a URI pattern (ex:
logging, HostMaplet attachment).

Added support for SMTP STARTTLS and SMTPS protocols.

Added support for authentication in JavaMail connector. Provide login and
password using the Call.getSecurity().setLogin() and setPassword()
methods.

Fixed issues with the HTTP client connector (not sending some content
metadata and not correctly reporting IO errors). This uses the new
statuses:CONNECTOR_ERROR_CONNECTION, CONNECTOR_ERROR_COMMUNICATION and
CONNECTOR_ERROR_INTERNAL. Reported by Dave Pawson.

Added "timeout" property to the Client connector interface. Default and
infinite timeouts can be specified. Suggested by Dave Pawson.

Simple GET

Dave Pawson <dave.pawson <at> gmail.com>
2006-05-02 13:53:34 GMT

Based on Tutorial02b.java, I'm trying to do a GET.
The basics are below.
String myIP = s.getmyIPaddress() ;
// The call
RestletCall call = Manager.createCall();
call.setResourceRef(Manager.createReference(source.toString()));
call.setReferrerRef(Manager.createReference(myIP));
call.setMethod(Methods.GET);
// Ask to the HTTP client connector to handle the call
Client client = Manager.createClient(Protocols.HTTP, "DPTest");
client.handle(call);
Status st = call.getStatus();
System.err.println("doGet: Status: "+ st.toString());
// Output the result representation on the JVM console
if (!st.isError()){
Representation output = call.getOutput();
if (output == null) {
System.err.println("0 length input");
System.exit(2);
}
The problem is that the output object is null;
Using curl I can retrieve content fine from the same url.
I don't know how to test the Representation to see if it has succeeded?
Any help appreciated.
regards DaveP

RE: Simple GET

Jerome Louvel <contact <at> noelios.com>
2006-05-02 14:08:23 GMT

Hi Dave,
> Status st = call.getStatus();
> System.err.println("doGet: Status: "+ st.toString());
> // Output the result representation on the JVM console
> if (!st.isError()){
>
> Representation output = call.getOutput();
> if (output == null) {
> System.err.println("0 length input");
> System.exit(2);
>
>
> }
Are you attempting to access to a public URI? If so, could you share it so I
can test too? If you are using Firefox, I recommand to install the
LiveHTTPHeaders extensions in order so see the flow of a request, including
any redirections, headers,etc.
http://livehttpheaders.mozdev.org/
Also, maybe the remote server is issuing redirections? Redirections are not
considered as errors.
A good test to do after a GET is to check if the status is SUCCESS_OK then
to attempt to get the output representation. As a general recommandation you
should test if the output object is not null before accessing it.
> I don't know how to test the Representation to see if it has
> succeeded?
The indicator of success is only the status property.
Thanks,
Jerome

Re: Simple GET

Dave Pawson <dave.pawson <at> gmail.com>
2006-05-02 14:19:36 GMT

Jerome Louvel wrote:
> Hi Dave,
>
>> Status st = call.getStatus();
>> System.err.println("doGet: Status: "+ st.toString());
>> // Output the result representation on the JVM console
>> if (!st.isError()){
>>
>> Representation output = call.getOutput();
>> if (output == null) {
>> System.err.println("0 length input");
>> System.exit(2);
>>
>>
>> }
>
> Are you attempting to access to a public URI? If so, could you share it so I
> can test too? If you are using Firefox, I recommand to install the
> LiveHTTPHeaders extensions in order so see the flow of a request, including
> any redirections, headers,etc.
> http://livehttpheaders.mozdev.org/
No Jerome, it is to a local network. 10.1.xxx
I can do a GET with curl OK.
>
> Also, maybe the remote server is issuing redirections? Redirections are not
> considered as errors.
>
> A good test to do after a GET is to check if the status is SUCCESS_OK then
> to attempt to get the output representation. As a general recommandation you
> should test if the output object is not null before accessing it.
I'm doing that ( if (!st.isError()) which is the 'same'/inverse test?)
>
>> I don't know how to test the Representation to see if it has
>> succeeded?
>
> The indicator of success is only the status property.
OK, I'll change the test.
Still working with an older version, unsure how much will change
if I update to your beta Jerome?
regards DaveP

RE: Simple GET

Jerome Louvel <contact <at> noelios.com>
2006-05-02 14:51:02 GMT

> No Jerome, it is to a local network. 10.1.xxx
> I can do a GET with curl OK.
Could you give me the name of the status returned?
System.out.println(call.getStatus());
Also, could you send a trace file generated by CURL using this option:
--trace <file>
> > Also, maybe the remote server is issuing redirections?
> Redirections are not
> > considered as errors.
> >
> > A good test to do after a GET is to check if the status is
> SUCCESS_OK then
> > to attempt to get the output representation. As a general
> recommandation you
> > should test if the output object is not null before accessing it.
> I'm doing that ( if (!st.isError()) which is the 'same'/inverse test?)
Right! Another possibility is that your server is requiring certain
properties/preferences from your client, like accepted media types and
languages.
> >> I don't know how to test the Representation to see if it has
> >> succeeded?
> >
> > The indicator of success is only the status property.
>
> OK, I'll change the test.
> Still working with an older version, unsure how much will change
> if I update to your beta Jerome?
I suggest that you check the online tutorial
(http://www.restlet.org/tutotial) to get a feel of how much changed from an
application point of view. If you have half an hour for this upgrade
process, I would recommand doing it as it includes the enhanced error
reporting that you requested for the HTTP client connector. In previous
versions, the status could stay to SUCCESS_OK even if a communication error
occured.
> Status st = call.getStatus();
> System.err.println("doGet: Status: "+ st.toString());
> // Output the result representation on the JVM console
> if (st.isSuccess()){
> Representation output = call.getOutput();
> System.err.println("OUtput returned " + call.getResourcePath());
> if (output == null) {
> System.err.println("0 length input");
> System.exit(2);
> so the status is indicating success...
> yet the Representation is null?
BTW, note that doing st.isSuccess() is not strictly equivalent to doing
st.equals(Statuses.SUCCESS_OK). Indeed there are multiple SUCCESS_* statuses
for other situations like creation.
Thanks,
Jerome
> -----Message d'origine-----
> De : news [mailto:news <at> sea.gmane.org] De la part de Dave Pawson
> Envoyé : mardi 2 mai 2006 16:20
> À : discuss <at> restlet.tigris.org
> Objet : Re: Simple GET
>
> Jerome Louvel wrote:
> > Hi Dave,
> >
> >> Status st = call.getStatus();
> >> System.err.println("doGet: Status: "+ st.toString());
> >> // Output the result representation on the JVM console
> >> if (!st.isError()){
> >>
> >> Representation output = call.getOutput();
> >> if (output == null) {
> >> System.err.println("0 length input");
> >> System.exit(2);
> >>
> >>
> >> }
> >
> > Are you attempting to access to a public URI? If so, could
> you share it so I
> > can test too? If you are using Firefox, I recommand to install the
> > LiveHTTPHeaders extensions in order so see the flow of a
> request, including
> > any redirections, headers,etc.
> > http://livehttpheaders.mozdev.org/
>
> No Jerome, it is to a local network. 10.1.xxx
> I can do a GET with curl OK.
>
>
>
> >
> > Also, maybe the remote server is issuing redirections?
> Redirections are not
> > considered as errors.
> >
> > A good test to do after a GET is to check if the status is
> SUCCESS_OK then
> > to attempt to get the output representation. As a general
> recommandation you
> > should test if the output object is not null before accessing it.
> I'm doing that ( if (!st.isError()) which is the 'same'/inverse test?)
>
>
>
>
> >
> >> I don't know how to test the Representation to see if it has
> >> succeeded?
> >
> > The indicator of success is only the status property.
>
> OK, I'll change the test.
> Still working with an older version, unsure how much will change
> if I update to your beta Jerome?
>
> regards DaveP
>
>
>

Redirecting

Yuri de Wit <ydewit <at> gmail.com>
2006-05-06 23:00:39 GMT

What is the best way to create a redirect URL when processing an HTTP
request? Is it possible to do relative redirections that are resolved
against the resource URL?
for instance: I am processing a GET request for a resource identified by
http://server/app/product/122eee, but the product 122eee does not
exist. I would like to do the following:
call.setRedirectionRef("..");
call.setStatus(Statuses.CLIENT_ERROR_NOT_FOUND);
because I want the client to redirect to the list of all products
identified by http://server/app/product
I am trying to stay away from hardcoding url in my resources and keep
all that centralized in the RestletContainer.
any ideas?
thanks,
-- yuri