Hi Thierry,

This is a follow up post to "How to send files using Restlet" that first 
appeared on July 5, 07. I posted it here in case it goes without being noticed.

But in escaped URLs, escaped slashs and backslahs are still slashs and 
backslahs. If my parameters consist of Windows or Unix path separators, there 
will be problems,

e.g., 

Application:
router.attach("/path/{path}/afile/{filename}", AFileResource.class);
AFileResource:
this.systemId = (String) request.getAttributes().get("path");

So when the client calls with the link below, 

on Unix, it is: "/path//tmp/afile/abc.txt"
on Windows, it is: "/path/c:\\temp/afile/abc.txt"

it will result in a 404 (not found) 

I am using restful web services chapter 7 as test. When the client call has 
been passed to Application and router object is created, the exception is 
thrown.

The code is as follows:


@Override
public Restlet createRoot() {
    Router router = new Router(getContext());

    // Add a route for user resources
    router.attach("/users/{username}", UserResource.class);

    // Add a route for user's bookmarks resources
    router.attach("/users/{username}/bookmarks", BookmarksResource.class);

    // Add a route for bookmark resources
    Route uriRoute = router.attach("/users/{username}/bookmarks/{URI}",
            BookmarkResource.class);
    uriRoute.getTemplate().getVariables().put("URI",
            new Variable(Variable.TYPE_URI_ALL));

    // Add a route for user resources
    /*
    router.attach("/afile", AFileResource.class);
    router.attach("/afile/{filename}", AFileResource.class);
    */
    router.attach("/sid/{sid}/afile", AFileResource.class);
    router.attach("/sid/{sid}/afile/{filename}", AFileResource.class);

    return router;
}

BTW, is there an easy way to tell apart the new follow posts to old topics 
without scrolling through all the pages? 

thanks, billy



Reply via email to