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
> <bean type="com.opensymphony.xwork2.util.PatternMatcher"
> name="namedVariablePatternMatcher"
> class="com.opensymphony.xwork2.util.NamedVariablePatternMatcher"/>
>
> in *actions.*.ChapterContoller.java
> @Namespace("/book/{bookId}")
> public class ChapterController implements ModelDriven<Chapter> {
>
>  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<Book> {  }
>
> 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]

Reply via email to