PUT method without body entity

2008-08-22 Thread Vincent Ricard
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,
-- 
Vincent Ricard



Re: Routing in Restlet JAX-RS applications

2008-08-22 Thread Roman Geus

Hi Stephan

Thanks for your reply and for looking into this.

My expectation was, that path parameters should only be assigned a 
single path segment, with the exception of the last path parameter when 
the limited flag is set to false (but I might be wrong).


Feel free to use my code fragments for unit testing.

Best regards,
Roman

Stephan Koops wrote:

Hi Roman,

after a short review this seems to me to be a bug. The matching needs 
a rework, because the specification changes at some points in JAX-RS 
0.10. I hope I have time for it the next days. I will also take a look 
into your message about UriInfo.getPath().


If it is ok, I will use your code fragments as JUnit test cases.

best regards
 Stephan

P.S.: I've had a small holiday from tuesday, so sorry for the delay.

Roman Geus schrieb:

Hallo all

I'm using restlet 1.1-m5 and I have a problem with routing http 
requests to JAX-RS  resource methods:


My resource class looks as follows:

@Path(admin)
public class RestAdminServiceResource {

   /**
* Provides both static and dynamic, per-request information, 
about the

* components of a request URI.
*/
   @Context
   UriInfo uriInfo;

   @GET
   @Produces(text/html)
   public Response root() {
   ...
   }

   @GET
   @Path({project})
   @Produces(text/html)
   public Response project(@PathParam(project) String project) {
   ...
   }

   @GET
   @Path({project}/{repository})
   @Produces(text/html)
   public Response repository(@PathParam(project) String project,
   @PathParam(repository) String repository) {
   ...
   }

   @GET
   @Path({project}/{repository}/schema)
   @Produces(text/html)
   public Response schemaDir(@PathParam(project) String project,
   @PathParam(repository) String repository) {
   ...
   }

   @GET
   @Path({project}/{repository}/schema/{schema})
   @Produces(text/html)
   public Response schema(@PathParam(project) String project,
   @PathParam(repository) String repository,
   @PathParam(schema) String schema) {
   ...
   }

}

The following requests are routed as expected:

http://host/admin
http://host/admin/PRJ
http://host/admin/PRJ/REPO

However requests containing the schema path segment are all routed 
to the repository method, instead of the schemaDir and schema method:


http://host/admin/PRJ/REPO/schema
http://host/admin/PRJ/REPO/schema/SCM

Is this working as intended? If yes, how can I implement resources 
for {project}/{repository}/schema and 
{project}/{repository}/schema/{schema}.


Thanks,
Roma 




Re: WADL howto?

2008-08-22 Thread Ralf Bommersbach
Thanks alot. I'm able to retrieve descriptions of individual resources 
now, when I do a OPTIONS request on the resources URI. The *-targetUri 
however doesn't work. I get an empty response. But its okay for me now.



Greetings Ralf

Vincent Ricard schrieb:

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.

Regards,


Re: PUT method without body entity

2008-08-22 Thread Bruno Harbulot

Hi Vincent,

We had this discussion a few month ago:
http://thread.gmane.org/gmane.comp.web.services.rest/8046

In short, the conclusion was that a PUT without an entity wasn't 
allowed, but a PUT with a Content-Length: 0 entity was.



Strictly speaking, the query string in the URI is part of the URI. Thus, 
every time you change this query string, you effectively make a request 
to a different resource potentially. Perhaps the problem you're having 
is a symptom showing that these parameters ought to be in the body of 
the request.


Best wishes,

Bruno.

Vincent Ricard wrote:

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: openid?

2008-08-22 Thread Story Henry

Hi Jerome,

I am really excited to read about these plans for  RDF integration  
into Restlet 1.2 .  There is a lot here that could be done, and done  
in many different ways. I'd be happy to help out as far as I can.  
Perhaps one thing to do would be to meet up and go over some ideas,  
and help flesh them out.


Henry


On 19 Aug 2008, at 15:04, Jerome Louvel wrote:



Hi Henry!

We do have an RFE for this. It is targeted for Restlet 1.2. There  
are a few

links in it to follow:

Support OpenID authentication
http://restlet.tigris.org/issues/show_bug.cgi?id=446

I'm not sure how this will be designed yet. Any recommendation? If  
you are

interested in helping out that would be great.

BTW, there will be an important focus on the Semantic Web in Restlet  
1.2.

More about that later today!

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 : Story Henry [mailto:[EMAIL PROTECTED]
Envoye : mardi 19 aout 2008 13:00
A : discuss@restlet.tigris.org
Objet : openid?

Anyone here know of good openid libraries? Perhaps one using RESTlets.

Henry

Home page: http://bblfish.net/





Question

2008-08-22 Thread Sanjay Acharya

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/

How to prevent access to nested directories?

2008-08-22 Thread Carlos Alexandre Moscoso
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?

-- 
Carlos Alexandre Moscoso


org.restlet.ext.jaxrs-1.1 pom

2008-08-22 Thread James Rutherford
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: Error Handling

2008-08-22 Thread Michael Dunn
David,
  Thanks for your response.  I should have been more clear.  I was wondering the
proper way from a service standpoint to return an error.

For example when inheriting from Resource in the server, - if the following code
generates an exception - is it better to return an error via the response or
throw an exception?

code
public void acceptRepresentation(Representation entity)
throws ResourceException {  
  try {
// Set the response's status and entity
  } catch (Exception e) {

// OPTION 1
// which is the best way to return an error?
// set it in the response as follows
response.setStatus(Status.CLIENT_ERROR_NOT_FOUND);
response.setEntity(Error, MediaType.TEXT_PLAIN)

// OR
// OPTION 2
throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, Error, e);
  }
}
/code