RESTlet, POST & PDFs

2008-04-01 Thread Ben Sgro

Hello,

I am attempting to retrieve the content of a pdf I am POSTing.

I have provided my own implementation of
public void post(Representation representation)

When I call representation.getStream against an XML payload,
I get (ascii, which I converted to characters):

POST /organizations/hw/documenttemplates/ HTTP/1.1
User-Agent: curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 
OpenSSL/0.9.7l zlib/1.2.3

Host: localhost:3000
Accept: */*
Content-Type:application/xml
Content-Length: 13

post_test.xml

And if I call representation.getText, I get the entity of the xml 
document I posted,

which is:

test

Now, I believed that calling representation.getStream would return an 
inputStream of

the contents.

So, that's how my method is behaving for xml. When I try to POST a pdf, 
and I call

getStream(), it returns nothing, null.

If I call representation.getText(), and write the output to a file, its 
not a valid pdf. Which makes

sense, I wouldn't believe you can call getText() on binary data.


So, any idea how to get this to work?

- Ben


--
Ben Sgro ; Arc90 ; http://arc90.com



Re: bug in the spring SpringBeanRouter

2008-04-01 Thread Rhett Sutphin

On Apr 1, 2008, at 3:20 PM, Michael Böckling wrote:
After lots of debugging, it seems wildcards don't work in the  
SpringBeanRouter,

since the * is improperly escaped.


I haven't tried using *.  SpringBeanRouter is taking the bean name and  
passing it directly to attach.  I'm not aware of anything Spring does  
specially with *, but there could be.  Can you provide a reproduceable  
test case?



The SpringBeanRouter also does not work when placed in the
[servlet-name]-servlet.xml, it must be placed in the main  
applicationContext.xml.


SpringBeanRouter is a Spring BeanFactoryPostProcessor.  It will  
operate on all the Resources defined in the same context as it, so it  
has to go in the application context where your resources are  
defined.  For me, this is [servlet-name]-servlet.xml.  If you define  
your resources elsewhere, your SpringBeanRouter will have to go in the  
same place.  If you want to put them in different places, you can use  
a regular Router and SpringBeanFinder.


Rhett

Need help building new authentication types

2008-04-01 Thread Barrie Selack
I am attempting to implement two authentications, one for a shared secret 
similar to Amazon S3, and one for public/private key.

I'm looking for more direction in the relationships between the Guard, 
AuthenticationHelper and Resources. Where do these items go? I started with 
extending an AuthenticationHelper but am confused with authentication methods 
in my Resource, and the role of Guard.

If anyone can offer any suggestions (maps), I'd appreciate it.

Regards,
Barrie Selack



Disclaimer: This e-mail message is intended only for the personal use of
the recipient(s) named above. If you are not an intended recipient, you
may not review, copy or distribute this message. If you have received this
communication in error, please notify us immediately by e-mail and delete
the original message.

This e-mail expresses views only of the sender, which are not to be
attributed to Rite Aid Corporation and may not be copied or distributed
without this statement.


bug in the spring SpringBeanRouter

2008-04-01 Thread Michael Böckling
After lots of debugging, it seems wildcards don't work in the SpringBeanRouter,
since the * is improperly escaped.

The SpringBeanRouter also does not work when placed in the
[servlet-name]-servlet.xml, it must be placed in the main 
applicationContext.xml.

Can you confirm this?



Re: integrating restlet with the spring DispatcherServlet

2008-04-01 Thread Michael Böckling
Seems I solved it, I didn't expect that the web.xml url-pattern is not included
in the url pattern that the router matches against.

I have one last issue here: when I try to use the SpringBeanRouter (instead of
the SpringRouter, which works), no URLs match. I checked and noticed that
'postProcessBeanFactory()' and 'resolveUri()' are never actually called, so the
list of routes is empty.
Do I have to do something special?
I set everything up as described in the SpringBeanRouter Javadoc, and then set
the router as 'root' in my org.restlet.Application.

Is that correct?





Re: Newbie question: Override Resource.post() or Resource.handlePost() ?

2008-04-01 Thread Thierry Boileau
Hello Ian,

we encourage you to use post(Representation), put(Representation), etc
instead of handle* since these methods take care of some behaviours
required from a technical of point of view (e.g. respect of some HTTP
protocol rules) but not essential when coding a Resource. It helps you
focusing on the crucial part of the work: make the resource the bridge
between the Rest world and the world of the domain objects.

Best regards,
Thierry Boileau



On Tue, Apr 1, 2008 at 6:04 PM, Ian Clarke <[EMAIL PROTECTED]> wrote:
> When creating a subclass of Resource, is it preferable to override
>  post() or handlePost() (ditto for put/handlePut - etc)?  What is the
>  difference?
>
>  (Note: I'm using restlet v 1.0.8)
>
>  Thanks,
>
>  Ian.
>
>  --
>  Email: [EMAIL PROTECTED]
>  Cell: +1 512 422 3588
>  Skype: sanity
>


Re: integrating restlet with the spring DispatcherServlet

2008-04-01 Thread Michael Böckling
Thanks for your help!
Looks like thats exactly what I needed!
I still have an error that I can't solve, when I try to call the URL, 
it says:

01.04.2008 18:56:33 org.restlet.Filter doHandle
WARNUNG: A filter was executed without a next Restlet attached to it.

Can you see where the error is?


My web.xml:


restlet
com.noelios.restlet.ext.spring.RestletFrameworkServlet


targetRestletBeanName
root

2



restlet
/rest/*



My restlet-servlet.xml:

















Thanks a lot!
Michael



Re: integrating restlet with the spring DispatcherServlet

2008-04-01 Thread Rhett Sutphin

Hi Michael,

On Apr 1, 2008, at 10:50 AM, Michael Böckling wrote:

I have trouble to figure out how to integrate it with the
org.springframework.web.servlet.DispatcherServlet. I use that for some
SOAP web services (using the xfire exporter), but now I want to  
attach a

restlet using json.
I was not able to find a example on how to do that!

I want to use the DispatcherServlet, so the SpringServer is not an
option. Using the ext.servlet.ServerServlet won't work as well, since
that would bypass the DispatcherServlet too (and I can't get to the
WebApplicationContext from there).


Since 1.1-M2, there's RestletFrameworkServlet in the  
com.noelios.restlet.ext.spring extension:


http://www.restlet.org/documentation/1.1/ext/com/noelios/restlet/ext/spring/RestletFrameworkServlet.html

As it's name indicates, it extends spring's FrameworkServlet, just  
like DispatcherServlet.  It gives access to the WebApplicationContext  
in the same way.


Rhett

another question: adding attributes to a context

2008-04-01 Thread Ian Clarke
I want to pass two objects, cf and rs, in to several resources.  Here
is a code snippet that doesn't work:

--snip--
apiListenerComponent = new Component();

apiListenerComponent.getServers().add(Protocol.HTTP, listenPort);

apiListenerComponent.getContext().getAttributes().put("cf", cf);
apiListenerComponent.getContext().getAttributes().put("rs", rs);

// Attach the sample application.
apiListenerComponent.getDefaultHost().attach(
new Application(apiListenerComponent.getContext()) {

@Override
public Restlet createRoot() {
// Create a root router
Router router = new 
Router(getContext());
router.attach("/users/{id}", 
UserResource.class);
--snip--

However, I find that if I add the attributes directly to the "router"
object when I create it inside createRoot(), that works fine.

Why isn't the router inheriting the attributes from the Component?

Thanks,

Ian.

-- 
Email: [EMAIL PROTECTED]
Cell: +1 512 422 3588
Skype: sanity


integrating restlet with the spring DispatcherServlet

2008-04-01 Thread Michael Böckling
Hi!

This is my first project where I use restlet.

I have trouble to figure out how to integrate it with the
org.springframework.web.servlet.DispatcherServlet. I use that for some 
SOAP web services (using the xfire exporter), but now I want to attach a 
restlet using json.
I was not able to find a example on how to do that! 

I want to use the DispatcherServlet, so the SpringServer is not an 
option. Using the ext.servlet.ServerServlet won't work as well, since 
that would bypass the DispatcherServlet too (and I can't get to the
WebApplicationContext from there).

Is it possible to do what I want? Thanks for any help!

Regards,
Michael



Newbie question: Override Resource.post() or Resource.handlePost() ?

2008-04-01 Thread Ian Clarke
When creating a subclass of Resource, is it preferable to override
post() or handlePost() (ditto for put/handlePut - etc)?  What is the
difference?

(Note: I'm using restlet v 1.0.8)

Thanks,

Ian.

-- 
Email: [EMAIL PROTECTED]
Cell: +1 512 422 3588
Skype: sanity


RE: Restlet 1.1 M3 released

2008-04-01 Thread Jerome Louvel

Hi Stephan,

Thanks for the note and all the hard work on JAX-RS extension! Here is the
link for those interested in JAX-RS (JSR-311):
http://wiki.restlet.org/docs_1.1/g1/13-restlet/28-restlet/57-restlet.html

I wish we had such a documentation for all our extensions... If anyone is
interested in contributing to the wiki, let us know. This is a great way to
learn Restlet inside out and to contribute back.

Best regards,
Jerome  

> -Message d'origine-
> De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Envoyé : mardi 1 avril 2008 16:51
> À : discuss@restlet.tigris.org
> Objet : Re: Restlet 1.1 M3 released
> 
> Hi Jerome,
> 
> FYI: I've updated the wiki JAX-RS page to download Restlet 
> including the 
> JAX-RS extension direct from www.restlet.org.
> 
> best regards
>Stephan
> 
> Jerome Louvel schrieb:
> > Hi again!
> >
> > It's just over a month since 1.1 M2 and we have again made 
> tremendous
> > progress towards our final release.



Re: Restlet 1.1 M3 released

2008-04-01 Thread Stephan Koops

Hi Jerome,

FYI: I've updated the wiki JAX-RS page to download Restlet including the 
JAX-RS extension direct from www.restlet.org.


best regards
  Stephan

Jerome Louvel schrieb:

Hi again!

It's just over a month since 1.1 M2 and we have again made tremendous
progress towards our final release.


Restlet 1.1 M3 released

2008-04-01 Thread Jerome Louvel

Hi again!

It's just over a month since 1.1 M2 and we have again made tremendous
progress towards our final release.

Main changes:
* Licensing scheme changed to CDDL 1.0 or LGPL 2.1 or LGPL 3.0
* New JAX-RS extension implementing the draft JSR-311
* New OAuth extension as a pluggable authentication scheme
* New XDB extension providing integration with Oracle embedded JVM

* SSL support much improved with access to new attributes
* XmlRepresentation refactored to support SAX and DOM sources
* Major TransformRepresentation refactoring (config, reuse, SAX)
* Reference class now enforces the usage of valid URI characters
* Grizzly HTTP server now support chunked encoding of responses

Updated dependencies:
* Spring to version 2.5.2
* db4o to version 7.2 (adds transparent update)
* JavaMail to version 1.4.1
* JAF to version 1.1.1

Direct contributors:
* Adam Rosien (OAuth)
* Avi Flax
* Bruno Harbulot
* Chuck Mortimore
* Dan Diephouse
* Jeroen Goubert
* Joe Nellis
* Kevin Conaway
* Marc Portier
* Marcelo Ochoa (XDB)
* Paul J. Lucas
* Peter Neubauer
* Rhett Sutphin
* Rob Heittman
* Stephan Koops (JAX-RS)
* Steve Loughran
* Yuri de Wit

Changes log:
http://www.restlet.org/documentation/1.1/changes

Download links:
http://www.restlet.org/downloads/1.1/restlet-1.1m3.zip
http://www.restlet.org/downloads/1.1/restlet-1.1m3.exe

Maven repositories:
http://maven.restlet.org is updated on the 1st and 15th of each month
http://maven.noelios.com is updated daily with new artifacts

Best regards,
Jerome Louvel
Thierry Boileau
 



Restlet 1.0.9 released

2008-04-01 Thread Jerome Louvel

Hi all,

A new maintenance release of Restlet 1.0 is available. It mainly fixes a few

bugs (Server.stop(), DomRepresentation, forms parsing) and updates
Jetty to version 6.1.8.

Thanks for the issue reports and contributions!

Changes log:
http://www.restlet.org/documentation/1.0/changes 

Download links:
http://www.restlet.org/downloads/1.0/restlet-1.0.9.zip 
http://www.restlet.org/downloads/1.0/restlet-1.0.9.exe

Maven repositories:
http://maven.restlet.org is updated on the 1st and 15th of each month
http://maven.noelios.com is updated daily with new artifacts

Best regards,
Jerome Louvel
Thierry Boileau



Re: Evaluating Restlet

2008-04-01 Thread Jerome Louvel


Hi all,

Tim Peierls wrote:
I hate to sound like a broken record, but the Restlet Request 
and Response classes are not thread-safe, so Restlet cannot 
yet take *full* advantage of NIO to break out of the 
thread-per-request paradigm. (There is movement on this 
front, however, as Rob Heittman pointed out earlier in this thread.)


I would like to mention that I've completed the work to make Request, 
Response, Representation and all related classes in API, NRE and 
extensions thread safe.


It was mostly a matter of adding the right modifier, either 'volatile' 
or 'final' as there is rarely a need for strong synchronization in those 
classes. Most of the time they are accessed by one thread at a time.


However, I wouldn't mind having expert eyes looking at the result and 
making sure everything is ready to support advanced handling, IO and 
threading scenarios!


Best regards,
Jerome