[S2] 2.1.3GA?

2008-08-17 Thread Mike Watson
Is there an ETA on when 2.1.3 (or greater) will go GA?

Mike

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [S2} REST plugin & Security

2008-07-29 Thread Mike Watson
Thanks Jeromy,

Yep, we did get the standard JEE security working in WAS.
(Fat-fingered typing in the web.xml was the culprit).

I'll have a look at the Sping option if we find the container stuff a
bit lacking.

Thanks again for your feedback.

Mike

2008/7/29 Jeromy Evans <[EMAIL PROTECTED]>:
>
> If you don't have complex URL patterns, I'd continue down the JEE path.  It
> should work. Although I haven't tried it with websphere it's a fundamental
> requirement of the container.
>
> I'd temporarily switch to HTTP BASIC instead of LDAP to try isolate the
> problem.
>
> Yes, creating a custom Security Interceptor is another approach.  It's
> pretty simple to throw your own interceptor into the stack that checks the
> Principal or Session and forces a redirect/error if appropriate.  It's a low
> effort approach but you take on some more risk of introducing
> vulnerabilities.
>
> An better approach is to use a third party filter.  Acegi/Spring Security is
> the most popular and probably the most flexible as it's closely bound to
> your (Spring) Object Factory.  There are other open source filters available
> too that may suite you.
>
> Hope that helps,
> Jeromy Evans
>
>
> Mike Watson wrote:
>>
>> I should probably add that I'm just trying to authenticate via LDAP at
>> this stage. Authorization will be implemented later.
>>
>> 2008/7/28 Mike Watson <[EMAIL PROTECTED]>:
>>
>>>
>>> Hi Folks,
>>>
>>> What's the most straightforward way to secure my REST URLs?
>>>
>>> I'd assumed that I'd be able to use the standard JEE approach and
>>> secure based on URL patterns but this doesn't seem to work (on
>>> Websphere anyway) and I'm assuming it's to do with the fact everything
>>> I'm doing is happening in filters rather than working with 'real'
>>> resources. (I don't get any errors, I just get to see resources I
>>> shouldn't when I'm not authenticated).
>>>
>>> Is there some sort of Security Interceptor I should enable or should
>>> this work the way I initially assumed?
>>>
>>> Has anybody else (Jeromy?) done this?
>>>
>>> Cheers
>>>
>>> Mike
>>>
>>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>> Internal Virus Database is out of date.
>> Checked by AVG - http://www.avg.com Version: 8.0.138 / Virus Database:
>> 270.5.5/1569 - Release Date: 23/07/2008 1:31 PM
>>
>>
>>
>>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [S2} REST plugin & Security

2008-07-27 Thread Mike Watson
I should probably add that I'm just trying to authenticate via LDAP at
this stage. Authorization will be implemented later.

2008/7/28 Mike Watson <[EMAIL PROTECTED]>:
> Hi Folks,
>
> What's the most straightforward way to secure my REST URLs?
>
> I'd assumed that I'd be able to use the standard JEE approach and
> secure based on URL patterns but this doesn't seem to work (on
> Websphere anyway) and I'm assuming it's to do with the fact everything
> I'm doing is happening in filters rather than working with 'real'
> resources. (I don't get any errors, I just get to see resources I
> shouldn't when I'm not authenticated).
>
> Is there some sort of Security Interceptor I should enable or should
> this work the way I initially assumed?
>
> Has anybody else (Jeromy?) done this?
>
> Cheers
>
> Mike
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[S2} REST plugin & Security

2008-07-27 Thread Mike Watson
Hi Folks,

What's the most straightforward way to secure my REST URLs?

I'd assumed that I'd be able to use the standard JEE approach and
secure based on URL patterns but this doesn't seem to work (on
Websphere anyway) and I'm assuming it's to do with the fact everything
I'm doing is happening in filters rather than working with 'real'
resources. (I don't get any errors, I just get to see resources I
shouldn't when I'm not authenticated).

Is there some sort of Security Interceptor I should enable or should
this work the way I initially assumed?

Has anybody else (Jeromy?) done this?

Cheers

Mike

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: S2 REST plugin

2008-07-24 Thread Mike Watson
Thanks mate. I'll give that a try tomorrow.

2008/7/24 Jeromy Evans <[EMAIL PROTECTED]>:
> Mike Watson wrote:
>>
>> What I actually return is a DefaultHttpHeaders with a 404 set.
>> getImage() returns an empty (not null) inputstream since there's no
>> content for the body.
>>
>>
>
> You may need to return a different result type for the error case
> (HttpHeaderResult or NullResult) so it only attempts to set the headers
> though.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: S2 REST plugin

2008-07-24 Thread Mike Watson
What I actually return is a DefaultHttpHeaders with a 404 set.
getImage() returns an empty (not null) inputstream since there's no
content for the body.

I'll do some debugging when I get time and see where it's failing. It
certainly seems to be StreamResult that has the issue.

Thanks

Mike

2008/7/24 Jeromy Evans <[EMAIL PROTECTED]>:
> Mike Watson wrote:
>>
>> Hi folks,
>>
>> As mentioned in previous posts I'm using the REST plugin to serve
>> images and everything seems to work fine when the content exists.
>>
>> However if I return an empty inputstream to StreamResult with a 404
>> response code I get the exception below.
>> Stepping through the code the getBufferSize() method on my controller
>> is definitely called and returns a legitimate value...
>>
>
> Does this only occur when you return a null or 0 buffer size?
>
> My guess is that it's a bug in the StreamResult or the result handler.  It
> probably evaluates "${bufferSize}" and deduces that the property doesn't
> exist (because it's null/0) and uses it as a literal string value instead.
>  That's just a guess.
>
> Is it really valid to return a zero length stream result?  I would instead
> return a http status result with 404 / NullResult for the error case (ie.
> just headers, no content).
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



S2 REST plugin

2008-07-23 Thread Mike Watson
Hi folks,

As mentioned in previous posts I'm using the REST plugin to serve
images and everything seems to work fine when the content exists.

However if I return an empty inputstream to StreamResult with a 404
response code I get the exception below.
Stepping through the code the getBufferSize() method on my controller
is definitely called and returns a legitimate value...

My struts.xml is included below the stack trace. Does anyone have any
suggestions why I'm getting this error (the calling client doesn't see
it it's just messing up my logs).

[24/07/08 14:03:40:390 NZST] 001c SystemErr R
java.lang.NumberFormatException: For input string: "${bufferSize}"
[24/07/08 14:03:40:390 NZST] 001c SystemErr R   at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:63)
[24/07/08 14:03:40:390 NZST] 001c SystemErr R   at
java.lang.Long.parseLong(Long.java:418)
[24/07/08 14:03:40:390 NZST] 001c SystemErr R   at
java.lang.Long.parseLong(Long.java:476)
[24/07/08 14:03:40:390 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter.longValue(DefaultTypeConverter.java:209)
[24/07/08 14:03:40:390 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter.convertValue(DefaultTypeConverter.java:122)
[24/07/08 14:03:40:390 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.conversion.impl.DefaultTypeConverter.convertValue(DefaultTypeConverter.java:72)
[24/07/08 14:03:40:390 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.doConvertToNumber(XWorkBasicConverter.java:382)
[24/07/08 14:03:40:390 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter.convertValue(XWorkBasicConverter.java:118)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.conversion.impl.XWorkConverter.convertValue(XWorkConverter.java:295)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.ognl.OgnlTypeConverterWrapper.convertValue(OgnlTypeConverterWrapper.java:28)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.OgnlRuntime.getConvertedType(OgnlRuntime.java:701)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.OgnlRuntime.getConvertedTypes(OgnlRuntime.java:717)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.OgnlRuntime.getConvertedMethodAndArgs(OgnlRuntime.java:740)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.OgnlRuntime.getAppropriateMethod(OgnlRuntime.java:797)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:808)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:978)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:75)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:131)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1670)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.ASTProperty.setValueBody(ASTProperty.java:101)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.SimpleNode.setValue(SimpleNode.java:246)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
ognl.Ognl.setValue(Ognl.java:476)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:192)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.ognl.OgnlUtil.internalSetProperty(OgnlUtil.java:385)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.ognl.OgnlUtil.setProperties(OgnlUtil.java:84)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.ognl.OgnlReflectionProvider.setProperties(OgnlReflectionProvider.java:54)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.ObjectFactory.buildResult(ObjectFactory.java:218)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.DefaultActionInvocation.createResult(DefaultActionInvocation.java:201)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:258)
[24/07/08 14:03:40:406 NZST] 001c SystemErr R   at

Re: REST plugin URL syntax

2008-07-14 Thread Mike Watson
Jeromy,

Thanks *heaps* for finfing the time to do that. I'd pretty much done
everything your demo does except for one little detail:

  

Doh!

Now to see if that's broken my fancy pants image handler...

BTW, if I want a controller to work in multiple namespaces do I need
to declare seperate packages in struts.xml instead of just relying on
the @Namespace annotation?

Thanks again for all your help.

2008/7/12 Jeromy Evans <[EMAIL PROTECTED]>:
> Jeromy Evans wrote:
>>
>>
>> Dusty, you're right. I just had a quick look and I do have a custom action
>> mapper that checks whether the pattern above references an action or method
>> for that exact reason (it checks the list of available actions and gives
>> precedence to those).  Works great for me.
>>
>> I released another actionmapper that solved the problem using a different
>> approach. It will be deprecated, but it's still up for info:
>> http://code.google.com/p/struts2urlplugin/
>
> I had an opportunity to throw together a sample application.  Apologies for
> the delay.
>
> Relevant source and commentary are included in the demo.
> http://www.blueskyminds.com.au/url-hierarchy/
>
> From the description:
> "This webapp demonstrates a technique to access resources with hierarchical
> relationships in Struts 2.
>
> The model is a Book with a list of Chapters. Each Book has a unique URI:
> eg. /book/1 (book #1)
>
> Each chapter also has a unique URI:
> eg. /book/1/chapter/2 (chapter #2 in book #1)
>
> Following Struts2 conventions, the list of books and list of chapters in a
> book are also available:
> eg. /book (list of books)
> eg. /book/1/chapter (list of chapters in book #1)
>
> regards,
> Jeromy Evans
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: REST plugin URL syntax

2008-07-10 Thread Mike Watson
So what's the best way to get the latest 2.1.3 snapshot as source?
Only the jars seem to be in the maven snapshot repo...

Are there any instructions on doing that somewhere? I've looked but
can't find them...

2008/7/3 Jeromy Evans <[EMAIL PROTECTED]>:
> Mike Watson wrote:
>>
>> Hi Jeromy,
>>
>> I've finally found time to try to resolve this but haven't had much luck.
>>
>> Just to recap, I'm looking to be able to do something similar to the
>> following:
>> /book -> returns a list of books
>> /book/123 -> returns book with id 123
>> /book/123/chapter/1 -> return chapter with id 1, retrieved from book
>> 123 (this is a simplistic example, all resources have a unique ID)
>>
>> I'd also like to be able to control access based on the
>> context/namespace used to access a resource e.g.:
>> /logo/abc -> read or update
>> /book/123/logo/abc -> read only
>> (would I need multiple LogoControllers for this?)
>>
>> Using Namespaces as described by Jeromy below certainly seems to make
>> sense but as soon as I start to try the example provided I lose the
>> ability to GET /book/123, and I've tried with BookController having
>> namespace of "/" or "/book" and neither works. And so far I haven't
>> been able to successfully hit the ChapterController using a url like
>> /book/123/chapter.
>>
>> Am I missing something really obvious? Is there something I need to
>> put in the struts.xml to configure the namespaces as well as using the
>> @Namespace annotation?
>>
>> Jeromy, you seem to be pretty knowledgeable about this - can you think
>> of anything I might be doing wrong?
>>
>> Thanks in advance for your help.
>>
>> Mike
>>
>>
>
> Hi Mike, I'll throw a quick answer together now and try to give you a more
> in-depth one in a day or two by building an example.
> The steps are:
> 1. ensure struts is up-to-date. (2.1.3-SNAPSHOT preferably, to ensure you
> have the latest ActionMappingParamsInterceptor)
> 2. enable the NamedVariablePatternMatcher via struts.xml 3. Create the
> BookController in the root namespace.  GET /book/123 will invoke
> BookController.show() with id=123
> 4. Create the ChapterController in the namespace containing the book id
> variable (/book/{bookid}). GET /book/123/chapter will invoke
> ChapterContoller.index() with bookId=123.
>
> ie.
>
> @Namespace("/")
> public class BookController implements ModelDriven {  }
>
>
> @Namespace("/book/{bookId}")
> public class ChapterController implements ModelDriven {  }
>
>
> Now that's what *should* happen.  I use it in a large application that
> includes many other related tweaks so I'll throw together a vanilla sample
> and post it somewhere.
>
> I'll come back to the authorization issue separately.  The quick answer is
> that you can omit methods that are never permitted and/or filter URLs based
> on a URI pattern and/or user's role.
> regards,
> Jeromy Evans
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: REST plugin URL syntax

2008-07-06 Thread Mike Watson
The trick (I believe) is that the url should be parsed from right to
left, not left to right. I don't think it's a hijack; for the
application I'm working on context is very important so knowing that a
given resource is being accessed in the context of another resource
has a big part to play in dictating which functions should be
available and how they behave. (The book/chapter model is just an
example I used to try and simplify the problem).

Jeromy, I'm still really struggling to get this going, I don't suppose
you've found time to knock up that demo app?

Thanks in advance,

Mike

2008/7/6 dusty <[EMAIL PROTECTED]>:
>
> This doesn't seem right.  How can you distinguish between something like
> /book/1/customMethod and /book/1/chapter?  Is it smart enough to see that
> chapter is a mapped action and customMethod is not and change what it
> invokes?  If it works then great, but doesn't it feel like a hijack?
>
> As I look at apps in Struts and Rails I realize that I really don't ever
> need to address a child resource with something like /books/1/chapters/1.
> That is because the :id property for chapter is unique and so you just
> address chapters with /chapters/1.  Most of the time, once I get a child I
> can figure out who the parent is in the action rather than relying on the
> url to tell me.  I suppose that if :id is not unique for chapter and is some
> kind of composite that requires the book id in order to look the chapter up
> then you need both pieces of information, but that is an exception case,
> right?
>
> Either way, I am definitely interested on how Jeremy got this to work using
> namespaces.  Are you using Codebehind or Convention Jeremy?
>
>
> Jeromy Evans - Blue Sky Minds wrote:
>>
>> Mike Watson wrote:
>>> Hi Jeromy,
>>>
>>> I've finally found time to try to resolve this but haven't had much luck.
>>>
>>> Just to recap, I'm looking to be able to do something similar to the
>>> following:
>>> /book -> returns a list of books
>>> /book/123 -> returns book with id 123
>>> /book/123/chapter/1 -> return chapter with id 1, retrieved from book
>>> 123 (this is a simplistic example, all resources have a unique ID)
>>>
>>> I'd also like to be able to control access based on the
>>> context/namespace used to access a resource e.g.:
>>> /logo/abc -> read or update
>>> /book/123/logo/abc -> read only
>>> (would I need multiple LogoControllers for this?)
>>>
>>> Using Namespaces as described by Jeromy below certainly seems to make
>>> sense but as soon as I start to try the example provided I lose the
>>> ability to GET /book/123, and I've tried with BookController having
>>> namespace of "/" or "/book" and neither works. And so far I haven't
>>> been able to successfully hit the ChapterController using a url like
>>> /book/123/chapter.
>>>
>>> Am I missing something really obvious? Is there something I need to
>>> put in the struts.xml to configure the namespaces as well as using the
>>> @Namespace annotation?
>>>
>>> Jeromy, you seem to be pretty knowledgeable about this - can you think
>>> of anything I might be doing wrong?
>>>
>>> Thanks in advance for your help.
>>>
>>> Mike
>>>
>>>
>>
>> Hi Mike, I'll throw a quick answer together now and try to give you a
>> more in-depth one in a day or two by building an example.
>>
>> The steps are:
>>  1. ensure struts is up-to-date. (2.1.3-SNAPSHOT preferably, to ensure
>> you have the latest ActionMappingParamsInterceptor)
>>  2. enable the NamedVariablePatternMatcher via struts.xml
>>  3. Create the BookController in the root namespace.  GET /book/123 will
>> invoke BookController.show() with id=123
>>  4. Create the ChapterController in the namespace containing the book id
>> variable (/book/{bookid}). GET /book/123/chapter will invoke
>> ChapterContoller.index() with bookId=123.
>>
>> ie.
>>
>> @Namespace("/")
>> public class BookController implements ModelDriven {  }
>>
>>
>> @Namespace("/book/{bookId}")
>> public class ChapterController implements ModelDriven {  }
>>
>>
>> Now that's what *should* happen.  I use it in a large application that
>> includes many other related tweaks so I'll throw together a vanilla
>> sample and post it somewhere.
>>
>> I'll come back to the authorizat

Re: REST plugin URL syntax

2008-07-02 Thread Mike Watson
Thanks heaps Jeromy, I'll grab the 2.1.3 snapshot and try again.

A vanilla sample app would be great (others would probably find it useful too).

Cheers

Mike

2008/7/3 Jeromy Evans <[EMAIL PROTECTED]>:
> Mike Watson wrote:
>>
>> Hi Jeromy,
>>
>> I've finally found time to try to resolve this but haven't had much luck.
>>
>> Just to recap, I'm looking to be able to do something similar to the
>> following:
>> /book -> returns a list of books
>> /book/123 -> returns book with id 123
>> /book/123/chapter/1 -> return chapter with id 1, retrieved from book
>> 123 (this is a simplistic example, all resources have a unique ID)
>>
>> I'd also like to be able to control access based on the
>> context/namespace used to access a resource e.g.:
>> /logo/abc -> read or update
>> /book/123/logo/abc -> read only
>> (would I need multiple LogoControllers for this?)
>>
>> Using Namespaces as described by Jeromy below certainly seems to make
>> sense but as soon as I start to try the example provided I lose the
>> ability to GET /book/123, and I've tried with BookController having
>> namespace of "/" or "/book" and neither works. And so far I haven't
>> been able to successfully hit the ChapterController using a url like
>> /book/123/chapter.
>>
>> Am I missing something really obvious? Is there something I need to
>> put in the struts.xml to configure the namespaces as well as using the
>> @Namespace annotation?
>>
>> Jeromy, you seem to be pretty knowledgeable about this - can you think
>> of anything I might be doing wrong?
>>
>> Thanks in advance for your help.
>>
>> Mike
>>
>>
>
> Hi Mike, I'll throw a quick answer together now and try to give you a more
> in-depth one in a day or two by building an example.
> The steps are:
> 1. ensure struts is up-to-date. (2.1.3-SNAPSHOT preferably, to ensure you
> have the latest ActionMappingParamsInterceptor)
> 2. enable the NamedVariablePatternMatcher via struts.xml 3. Create the
> BookController in the root namespace.  GET /book/123 will invoke
> BookController.show() with id=123
> 4. Create the ChapterController in the namespace containing the book id
> variable (/book/{bookid}). GET /book/123/chapter will invoke
> ChapterContoller.index() with bookId=123.
>
> ie.
>
> @Namespace("/")
> public class BookController implements ModelDriven {  }
>
>
> @Namespace("/book/{bookId}")
> public class ChapterController implements ModelDriven {  }
>
>
> Now that's what *should* happen.  I use it in a large application that
> includes many other related tweaks so I'll throw together a vanilla sample
> and post it somewhere.
>
> I'll come back to the authorization issue separately.  The quick answer is
> that you can omit methods that are never permitted and/or filter URLs based
> on a URI pattern and/or user's role.
> regards,
> Jeromy Evans
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: REST plugin URL syntax

2008-07-01 Thread Mike Watson
Hi Jeromy,

I've finally found time to try to resolve this but haven't had much luck.

Just to recap, I'm looking to be able to do something similar to the following:
/book -> returns a list of books
/book/123 -> returns book with id 123
/book/123/chapter/1 -> return chapter with id 1, retrieved from book
123 (this is a simplistic example, all resources have a unique ID)

I'd also like to be able to control access based on the
context/namespace used to access a resource e.g.:
/logo/abc -> read or update
/book/123/logo/abc -> read only
(would I need multiple LogoControllers for this?)

Using Namespaces as described by Jeromy below certainly seems to make
sense but as soon as I start to try the example provided I lose the
ability to GET /book/123, and I've tried with BookController having
namespace of "/" or "/book" and neither works. And so far I haven't
been able to successfully hit the ChapterController using a url like
/book/123/chapter.

Am I missing something really obvious? Is there something I need to
put in the struts.xml to configure the namespaces as well as using the
@Namespace annotation?

Jeromy, you seem to be pretty knowledgeable about this - can you think
of anything I might be doing wrong?

Thanks in advance for your help.

Mike

2008/6/18 Jeromy Evans <[EMAIL PROTECTED]>:
> Don Brown wrote:
>>
>> I believe it is technically possible to do this, but not at all
>> intuitive right now.  This is probably my number one improvement
>> request for the REST plugin.
>>
>> You should be able change the wildcard mapper to one that recognizes
>> named wildcards then use them in your namespace annotation like this:
>> @Namespace("/book/{bookId}")
>>
>>
>> Don
>>
>
> Yeah, I use this feature heavily to support URIs matching Mike's
> requirement.
>
> in struts.xml
>  name="namedVariablePatternMatcher"
> class="com.opensymphony.xwork2.util.NamedVariablePatternMatcher"/>
>
> in *actions.*.ChapterContoller.java
> @Namespace("/book/{bookId}")
> public class ChapterController implements ModelDriven {
>
>  private void setBookId(Long id) {...}
>  private void setId(Long id) { ..}
>  private Chapter getModel() {...}
>
>  public HttpHeaders show() {
>   model = bookService.lookupChapter(bookid, id);
>   if (model != null) {
> return new DefaultHttpHeaders("show");
>   } else {
> return new DefaultHttpHeaders("error");
>   }
>  }
>  public HttpHeaders index() {...}
> }
>
> and
>
> in *actions.BookContoller.java
> @Namespace("/")
> public class BookController implements ModelDriven {  }
>
> regards,
> Jeromy Evans
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Rest plugin and binary data

2008-06-24 Thread Mike Watson
Hi Jeromy,

Please ignore my other email, I was being a dumb-ass.

Thanks heaps for the tips, I managed to get this working today.

Mike

2008/6/20 Jeromy Evans <[EMAIL PROTECTED]>:
> Mike Watson wrote:
>>
>> Hi Folks,
>>
>> I'm trying to figure out how to return binary data from the REST plugin.
>>
>> I'd like to be able to return images that are generated on the fly by
>> a REST request but looking at ContentTypeHandlerManager, it assumes
>> that we'll only ever want to return a string and so passes a
>> StringWriter as the output for implementers of
>> ContentTypeHandler.fromObject.
>>
>>
>
> At first, don't create a custom ContentTypeHander.
> Just have your Controller declare a StreamResult. The default
> ContentTypeHandler will drop through for result processing by XWork (as per
> a ServletRedirectResult).
>
> eg. GET /namespace/image/21
>
> @Result("stream", type = StreamResult.class, value="image")
> class ImageController {
>  public InputStream getImage() {}
>
>  public String show() {
>// create the stream
>return "stream";}
> }
>
> See StreamResult for how to set the Content-type and other properties.
>
> One that works, you could (potentially) register a ContentTypeHandler for
> each image content type you want to return (eg. register the jpg and png
> extensions).  The ContentTypeHandler should do nothing except return a
> result name for XWork that is mapped to a StreamResult.  The image retrieval
> would have to be performed in the Controller rather than the Handler though.
>  There is probably a bit of work to do in the plugin to handle binary
> results better though.
>
> Hope that gets you started.
> Jeromy Evans
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Rest plugin and binary data

2008-06-22 Thread Mike Watson
Hi Jeromy,

Thanks for the response, that's really helpful.

Could you possibly provide a little bit more detail though as I
haven't been able to get this working yet.

This might seem like a stupid question, but in your code snippet below
where you have: // create the stream
Where does the output go? Should I use ModelDriven and assign it to the model?

Also how do I get a handle on the StreamResult object so I can specify
attributes programmatically? All the samples I have seen do so
declaratively.

Thanks again for the tips!

Mike


2008/6/20 Jeromy Evans <[EMAIL PROTECTED]>:
> Mike Watson wrote:
>>
>> Hi Folks,
>>
>> I'm trying to figure out how to return binary data from the REST plugin.
>>
>> I'd like to be able to return images that are generated on the fly by
>> a REST request but looking at ContentTypeHandlerManager, it assumes
>> that we'll only ever want to return a string and so passes a
>> StringWriter as the output for implementers of
>> ContentTypeHandler.fromObject.
>>
>>
>
> At first, don't create a custom ContentTypeHander.
> Just have your Controller declare a StreamResult. The default
> ContentTypeHandler will drop through for result processing by XWork (as per
> a ServletRedirectResult).
>
> eg. GET /namespace/image/21
>
> @Result("stream", type = StreamResult.class, value="image")
> class ImageController {
>  public InputStream getImage() {}
>
>  public String show() {
>// create the stream
>return "stream";}
> }
>
> See StreamResult for how to set the Content-type and other properties.
>
> One that works, you could (potentially) register a ContentTypeHandler for
> each image content type you want to return (eg. register the jpg and png
> extensions).  The ContentTypeHandler should do nothing except return a
> result name for XWork that is mapped to a StreamResult.  The image retrieval
> would have to be performed in the Controller rather than the Handler though.
>  There is probably a bit of work to do in the plugin to handle binary
> results better though.
>
> Hope that gets you started.
> Jeromy Evans
>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Rest plugin and binary data

2008-06-19 Thread Mike Watson
Hi Folks,

I'm trying to figure out how to return binary data from the REST plugin.

I'd like to be able to return images that are generated on the fly by
a REST request but looking at ContentTypeHandlerManager, it assumes
that we'll only ever want to return a string and so passes a
StringWriter as the output for implementers of
ContentTypeHandler.fromObject.

Am I missing something really obvious or do I need to 'tweak' this
behaviour and decide what type of writer to provide?

Thanks in advance.

Mike

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: REST plugin URL syntax

2008-06-17 Thread Mike Watson
Hmmm, I haven't come across the Namspace annotation stuff. I'll
investigate that and see how I get on. If anyone can point me at some
useful examples of how I might achieve this it'd be greatly
appreciated.

Thanks again for all the responses...

2008/6/17 Don Brown <[EMAIL PROTECTED]>:
> I believe it is technically possible to do this, but not at all
> intuitive right now.  This is probably my number one improvement
> request for the REST plugin.
>
> You should be able change the wildcard mapper to one that recognizes
> named wildcards then use them in your namespace annotation like this:
> @Namespace("/book/{bookId}")
>
> As I said, it really needs work as this is a huge deficiency in the
> REST plugin right now, but the reason I haven't just made this easier
> as I'm toying with the idea of borrowing the URI mapping behavior from
> Jersey, which I find very intuitive, if a bit un-Struts/xwork-like.
>
> Don
>
> On Tue, Jun 17, 2008 at 9:10 AM, Mike Watson <[EMAIL PROTECTED]> wrote:
>> Well that'd be nice but I'm really struggling to get it to behave the
>> way I want. Any thoughts on how I might do this?
>>
>> 2008/6/17 Dave Newton <[EMAIL PROTECTED]>:
>>> --- On Mon, 6/16/08, Mike Watson <[EMAIL PROTECTED]> wrote:
>>>> Can anybody suggest where I would start in an attempt to
>>>> implement this hierarchical model?
>>>
>>> The existing REST plugin?
>>>
>>> Just an idea.
>>>
>>> Dave
>>>
>>>
>>> -
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: REST plugin URL syntax

2008-06-17 Thread Mike Watson
Hi Al,

Thanks for the comments. The book/chapter description is actually a
simplification of my real problem domain (which is commercially
sensitive).

The under-lying storage mechanism isn't simple but is quite abstract
from the REST API we are providing and the hierarchical model is
required to describe the relationships between resources in the
desired way.

If you can get your hands on that O'Reilly book it's worth a read,
seems to be one of the better REST resources around.

Mike

2008/6/17 Al Sutton <[EMAIL PROTECTED]>:
> Mike,
>
> The safari signup requires a credit card which I'm not going to give so I'm
> afraid I can't comment after seeing the book.
>
> It has always been my understanding that the /Earth/France/Paris style of
> notation is a search engine optimised  (SEO) layer which has the design goal
> of being descriptive to humans and search engines and is not designed with
> the REST principals of performance and efficiency.
>
> The main problem with performance is that, in most cases, you're going to be
> looking the data up in a database table, therefore you have your unique ID
> as the primary key for the table. The data in the table may, in turn, be a
> reference to a storage device and location where the data is stored, but at
> the top level you have the single primary key, hence the single /noun/id
> combination.
>
> If you're thinking of mapping the book to a folder name and the chapter to a
> filename in the folder then I would urge you to look at some of the comments
> around the web on how flat file systems scale, and possibly think about an
> intermediate table which maps IDs to the location of the chapter data which
> would allow you to have separate file stores to spread the data accross.
>
> Al.
>
> Mike Watson wrote:
>>
>> Thanks for the feedback.
>>
>> I actually disagree regarding whether my url syntax is restful.
>>
>> Have you read the O'Reilly book: "RESTful Web Services" by Leonard
>> Richardson; Sam Ruby?
>>
>> If not please take a look (you can probably see sample chapters on
>> Safari if you don't have an account).
>> Specifically in section 5.5.1 Encode Heirarchy into Path Variables
>> where examples like this are provided:
>> http://maps.example.com/Earth/France/Paris
>>
>> In fact the samples the entire book is based on all rely on hierarchy.
>> Hierarchy is *very* relevant to my problem domain and is something
>> that a RESTful interface *should* be able to support. Do you not agree
>> a news website is hierarchical? The web is hierarchical in nature.
>> REST is supposed to be the language of the web...
>>
>> If the REST plugin can't support this hierarchical model I'd say it is
>> fundamentally flawed. I'm happy to help rectify this but to say that
>> this approach just isn't REST is simply not true.
>>
>> Can anybody suggest where I would start in an attempt to implement
>> this hierarchical model? Or do I need to start looking for a
>> replacement for the Struts2 REST plugin?
>>
>> Thanks for your time.
>>
>> Mike
>>
>> 2008/6/17 Al Sutton <[EMAIL PROTECTED]>:
>>
>>>
>>> It's true that it takes a bit of reading between the lines, but basically
>>> REST relies on unique identifiers for resources, which for HTTP is
>>> commonly
>>> taken to mean a URLs of the form;
>>>
>>> http://server/resource_noun/id
>>>
>>> (to confirm this have a spin through the google results showing various
>>> examples).
>>>
>>> With servers with many apps on this is commonly expanded to;
>>>
>>> http://server/app/resource_noun/id
>>>
>>> In the strictest send the Mikes URLs should be;
>>>
>>> http://www.mydomain.com/chapter/123_1
>>>
>>> because we are uniquely identifying a chapter and to do this we need to
>>> include the book id, but for the sake of clarity (which was the reason I
>>> beleive he was using x/x_id/y/y_id notation I expanded the noun to show
>>> book
>>> and chapter.
>>>
>>> Al.
>>>
>>>
>>> Laurie Harper wrote:
>>>
>>>>
>>>> It may be the case that the REST plugin can't support this (I don't know
>>>> if that's true) but I don't see anything in the cited reference that
>>>> says
>>>> such URLs are un-RESTful. And a Struts apps should certainly be able to
>>>> support them, even if it requires writing a little more code (e.g. a
&g

Re: REST plugin URL syntax

2008-06-16 Thread Mike Watson
Well that'd be nice but I'm really struggling to get it to behave the
way I want. Any thoughts on how I might do this?

2008/6/17 Dave Newton <[EMAIL PROTECTED]>:
> --- On Mon, 6/16/08, Mike Watson <[EMAIL PROTECTED]> wrote:
>> Can anybody suggest where I would start in an attempt to
>> implement this hierarchical model?
>
> The existing REST plugin?
>
> Just an idea.
>
> Dave
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: REST plugin URL syntax

2008-06-16 Thread Mike Watson
Thanks for the feedback.

I actually disagree regarding whether my url syntax is restful.

Have you read the O'Reilly book: "RESTful Web Services" by Leonard
Richardson; Sam Ruby?

If not please take a look (you can probably see sample chapters on
Safari if you don't have an account).
Specifically in section 5.5.1 Encode Heirarchy into Path Variables
where examples like this are provided:
http://maps.example.com/Earth/France/Paris

In fact the samples the entire book is based on all rely on hierarchy.
Hierarchy is *very* relevant to my problem domain and is something
that a RESTful interface *should* be able to support. Do you not agree
a news website is hierarchical? The web is hierarchical in nature.
REST is supposed to be the language of the web...

If the REST plugin can't support this hierarchical model I'd say it is
fundamentally flawed. I'm happy to help rectify this but to say that
this approach just isn't REST is simply not true.

Can anybody suggest where I would start in an attempt to implement
this hierarchical model? Or do I need to start looking for a
replacement for the Struts2 REST plugin?

Thanks for your time.

Mike

2008/6/17 Al Sutton <[EMAIL PROTECTED]>:
> It's true that it takes a bit of reading between the lines, but basically
> REST relies on unique identifiers for resources, which for HTTP is commonly
> taken to mean a URLs of the form;
>
> http://server/resource_noun/id
>
> (to confirm this have a spin through the google results showing various
> examples).
>
> With servers with many apps on this is commonly expanded to;
>
> http://server/app/resource_noun/id
>
> In the strictest send the Mikes URLs should be;
>
> http://www.mydomain.com/chapter/123_1
>
> because we are uniquely identifying a chapter and to do this we need to
> include the book id, but for the sake of clarity (which was the reason I
> beleive he was using x/x_id/y/y_id notation I expanded the noun to show book
> and chapter.
>
> Al.
>
>
> Laurie Harper wrote:
>>
>> It may be the case that the REST plugin can't support this (I don't know
>> if that's true) but I don't see anything in the cited reference that says
>> such URLs are un-RESTful. And a Struts apps should certainly be able to
>> support them, even if it requires writing a little more code (e.g. a custom
>> action mapper?)
>>
>> L.
>>
>> Al Sutton wrote:
>>>
>>> Mike,
>>>
>>> Rest URLs doesn't work that way, so the plugin is correct and your needs
>>> are not in sync with REST standards (see
>>> http://en.wikipedia.org/wiki/Representational_State_Transfer for a more
>>> details on REST).
>>>
>>> If you want to do something with multiple IDs my suggestion would be URLs
>>> along the lines of;
>>>
>>> http://www.mydomain.com/rest/bookAndChapter/123_1
>>>
>>> Al.
>>>
>>> Mike Watson wrote:
>>>>
>>>> Hi Folks,
>>>>
>>>> I'm trying to use the REST plugin to implement a service that serves
>>>> resources using the following url syntax:
>>>>
>>>> http://www.mydomain.com/rest/book/123   (which works fine)
>>>> http://www.mydomain.com/rest/book/123/chapter   (which throws a 500
>>>> because my book controller doesn't have a chapter() method)
>>>> http://www.mydomain.com/rest/book/123/chapter/1   (which returns 404)
>>>>
>>>> I'd expect the two chapter urls to access the ChapterController
>>>> instead of the BookController.
>>>>
>>>> Being able to request resources 'within resources' like this is
>>>> crucial to my application. Can anybody tell me how I can configure the
>>>> rest plugin to behave like this, or point me at some documentation
>>>> that does?
>>>>
>>>> Thanks in advance,
>>>>
>>>> Mike
>>>>
>>>> -
>>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>>
>>>>
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



REST plugin URL syntax

2008-06-15 Thread Mike Watson
Hi Folks,

I'm trying to use the REST plugin to implement a service that serves
resources using the following url syntax:

http://www.mydomain.com/rest/book/123   (which works fine)
http://www.mydomain.com/rest/book/123/chapter   (which throws a 500
because my book controller doesn't have a chapter() method)
http://www.mydomain.com/rest/book/123/chapter/1   (which returns 404)

I'd expect the two chapter urls to access the ChapterController
instead of the BookController.

Being able to request resources 'within resources' like this is
crucial to my application. Can anybody tell me how I can configure the
rest plugin to behave like this, or point me at some documentation
that does?

Thanks in advance,

Mike

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]