Wrap a representation

2009-04-03 Thread Paul Austin
Is there an easy way to create a filter which would take the representation
returned from all resources and if it had a specific media type it would
"wrap" the representation with header and footer content.

What I want to be able to do with my web services is create a navigable HTML
view of all resources. So if the media type was HTML the representation
would be a HTML document without the header and footer. The filter then
could wrap this is an application specific template which gives the
branding.

Paul

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1536704

Re: Loading Spring Beans

2009-04-03 Thread Dustin N. Jenkins
That's a good point.  I'd need to do some refactoring, but that could 
work.  Might be cleaner in the end too.

Thanks!
Dustin


Rhett Sutphin wrote:
> Hi Dustin,
>
> Another option you could consider (if you haven't already) is using  
> RestletFrameworkServlet and SpringBeanRouter to configure your  
> application.  This allows you to use IoC to configure your Resource  
> instances, obviating the need to access the ApplicationContext  
> directly most of the time.  (If you do still need to access the  
> ApplicationContext directly, you can always have the Resource that  
> needs it implement ApplicationContextAware.)
>
> Rhett
>
> On Apr 3, 2009, at 9:35 AM, Dustin N. Jenkins wrote:
>
>   
>> Thanks very much Jerome!
>>
>> We do have other Servlet applications that are outside my control
>> unfortunately.
>>
>> Dustin
>>
>> Jerome Louvel wrote:
>> 
>>> Hi Dustin,
>>>
>>> After looking at the code, there has been changes related to  
>>> context in 1.2,
>>> to better isolate Components from Applications that affect you.
>>>
>>> I suggest that you enter an issue report in our tracker so we can  
>>> have a
>>> closer look at this an see how we could support that again.
>>>
>>> Alternatively, you could initialize Spring from within Restlet  
>>> itself to
>>> bypass this issue, unless you have other pure Servlet applications.
>>>
>>> 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 : Dustin N. Jenkins [mailto:dustin.jenk...@nrc-cnrc.gc.ca]
>>> Envoyé : mercredi 1 avril 2009 21:45
>>> À : discuss@restlet.tigris.org
>>> Objet : Loading Spring Beans
>>>
>>> Hello!
>>>
>>> I'm using JDK 1.6 with Tomcat 6.0 on Fedora Core 8.
>>>
>>> I'm upgrading to Restlet 1.2, and I used to create a BeanUtil class  
>>> that
>>> would load my Spring 1.2.9 beans by casting getContext() to a
>>> ServletContextAdapter, then obtaining the ServletContext from there  
>>> to use
>>> the WebApplicationContextUtils class in Spring to obtain a bean by  
>>> name.
>>> I'm only loading my Services and DAOs from Spring.
>>>
>>> In Restlet 1.2, I can no longer cast it.  Is there an easier way to  
>>> obtain
>>> the ServletContext, or, better yet, to load beans using the Spring
>>> extension?
>>>
>>> Thanks!
>>> Dustin
>>>
>>>   
>> -- 
>>
>>
>> Dustin N. Jenkins | Tel/Tél: 250.363.3101 | dustin.jenk...@nrc-cnrc.gc.ca
>>
>> facsimile/télécopieur: (250) 363-0045
>>
>> National Research Council Canada | 5071 West Saanich Rd, Victoria BC.
>> V9E 2E7
>>
>> Conseil national de recherches Canada | 5071, ch. West Saanich,  
>> Victoria
>> (C.-B) V9E 2E7
>>
>> Government of Canada | Gouvernement du Canada
>>
>> --
>> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1532829
>> 
>
> --
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1533176
>   

-- 


Dustin N. Jenkins | Tel/Tél: 250.363.3101 | dustin.jenk...@nrc-cnrc.gc.ca

facsimile/télécopieur: (250) 363-0045

National Research Council Canada | 5071 West Saanich Rd, Victoria BC. 
V9E 2E7

Conseil national de recherches Canada | 5071, ch. West Saanich, Victoria 
(C.-B) V9E 2E7

Government of Canada | Gouvernement du Canada

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1533278


Re: Loading Spring Beans

2009-04-03 Thread Rhett Sutphin
Hi Dustin,

Another option you could consider (if you haven't already) is using  
RestletFrameworkServlet and SpringBeanRouter to configure your  
application.  This allows you to use IoC to configure your Resource  
instances, obviating the need to access the ApplicationContext  
directly most of the time.  (If you do still need to access the  
ApplicationContext directly, you can always have the Resource that  
needs it implement ApplicationContextAware.)

Rhett

On Apr 3, 2009, at 9:35 AM, Dustin N. Jenkins wrote:

> Thanks very much Jerome!
>
> We do have other Servlet applications that are outside my control
> unfortunately.
>
> Dustin
>
> Jerome Louvel wrote:
>> Hi Dustin,
>>
>> After looking at the code, there has been changes related to  
>> context in 1.2,
>> to better isolate Components from Applications that affect you.
>>
>> I suggest that you enter an issue report in our tracker so we can  
>> have a
>> closer look at this an see how we could support that again.
>>
>> Alternatively, you could initialize Spring from within Restlet  
>> itself to
>> bypass this issue, unless you have other pure Servlet applications.
>>
>> 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 : Dustin N. Jenkins [mailto:dustin.jenk...@nrc-cnrc.gc.ca]
>> Envoyé : mercredi 1 avril 2009 21:45
>> À : discuss@restlet.tigris.org
>> Objet : Loading Spring Beans
>>
>> Hello!
>>
>> I'm using JDK 1.6 with Tomcat 6.0 on Fedora Core 8.
>>
>> I'm upgrading to Restlet 1.2, and I used to create a BeanUtil class  
>> that
>> would load my Spring 1.2.9 beans by casting getContext() to a
>> ServletContextAdapter, then obtaining the ServletContext from there  
>> to use
>> the WebApplicationContextUtils class in Spring to obtain a bean by  
>> name.
>> I'm only loading my Services and DAOs from Spring.
>>
>> In Restlet 1.2, I can no longer cast it.  Is there an easier way to  
>> obtain
>> the ServletContext, or, better yet, to load beans using the Spring
>> extension?
>>
>> Thanks!
>> Dustin
>>
>
> -- 
>
>
> Dustin N. Jenkins | Tel/Tél: 250.363.3101 | dustin.jenk...@nrc-cnrc.gc.ca
>
> facsimile/télécopieur: (250) 363-0045
>
> National Research Council Canada | 5071 West Saanich Rd, Victoria BC.
> V9E 2E7
>
> Conseil national de recherches Canada | 5071, ch. West Saanich,  
> Victoria
> (C.-B) V9E 2E7
>
> Government of Canada | Gouvernement du Canada
>
> --
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1532829

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1533176


RE: Comments against Restlet 1.2M2

2009-04-03 Thread Jerome Louvel
Hi guys,

I agree with your remarks and did the following changes in SVN trunk:
 - RepresentationInfo is now concrete and has more constructors.
 - UniformResource#init() now throws ResourceException and 
   catches it to update the response. 
 - Renamed UniformResource#init() into doInit().
 - Renamed UniformResource#destroy() into release().
 - Added an UniformResource#doRelease() method.
 - ClientResource now overrides finalize() to call the release()
   method.
 
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 : David Fogel [mailto:carrotsa...@gmail.com] 
Envoyé : jeudi 2 avril 2009 20:28
À : discuss@restlet.tigris.org
Objet : Re: Comments against Restlet 1.2M2

I also ran in to the issue of having a constructor that would throw a
ResourceException if the request was bad in some way, and now the
init() method doesn't declare any exceptions.  Seems pretty reasonable to
just add this.

One other alternative would be to change ResourceException to be a
RuntimeException subclass.  This would allow any ServerResource annotated
method to throw this exception without declaring it explicitly...

-Dave Fogel

On Thu, Apr 2, 2009 at 7:58 AM, Lars Heuer  wrote:
> Hi all,
>
> First of all, I love the RepresentationInfo. :) Thanks for adding 
> this. :)
>
> Some comments against that release:
> - I wonder how to create a RepresentationInfo since it is abstract;
>  for the time being I created my own RepresentationInfo class derived
>  from the abstract class.
> - Wouldn't it make sense to add a constructor
>  RepresentationInfo(Variant variant, Date modificationDate)
>  This constructor would add all information available from the
>  variant (i.e. MediaType, Language etc.) to the RepresentationInfo
>  plus the modification time.
> - Previously I used Resource(Context, Request, Response) in my derived
>  Resource classes. This constructor is not available anymore in
>  ServerResource. Not a big problem, though, even I have had to make
>  my properties non-final, which is also not a big problem since
>  Resources are not meant to be thread-safe.
> - Related to the above mentioned point, I allowed that my derived
>  Resources throw an exception in the constructor. This was very
>  convenient since Restlet automatically issued an error status. While
>  moving my initialisation stuff to the ServerResource.init() method I
>  recognised that init() does not allow to throw an exception, so I
>  have to wrap my initialisation code in a try / catch block.
>  I wonder if UniformResource#init() shouldn't be changed to
>
>    protected void init() throws ResourceException;
>
>  (or maybe Exception instead of ResourceException?)
>
>  If an exception was thrown, Restlet 1.2 could handle it like Restlet
>  1.1 handled exceptions thrown by the constructor.
>
> Best regards,
> Lars
> --
> http://www.semagia.com
>
> --
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId
> =1518119
>

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=15224
23

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1533155


Re: Loading Spring Beans

2009-04-03 Thread Dustin N. Jenkins
Thanks very much Jerome!

We do have other Servlet applications that are outside my control 
unfortunately.

Dustin

Jerome Louvel wrote:
> Hi Dustin,
>
> After looking at the code, there has been changes related to context in 1.2,
> to better isolate Components from Applications that affect you.
>
> I suggest that you enter an issue report in our tracker so we can have a
> closer look at this an see how we could support that again.
>
> Alternatively, you could initialize Spring from within Restlet itself to
> bypass this issue, unless you have other pure Servlet applications.
>  
> 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 : Dustin N. Jenkins [mailto:dustin.jenk...@nrc-cnrc.gc.ca] 
> Envoyé : mercredi 1 avril 2009 21:45
> À : discuss@restlet.tigris.org
> Objet : Loading Spring Beans
>
> Hello!
>
> I'm using JDK 1.6 with Tomcat 6.0 on Fedora Core 8.
>
> I'm upgrading to Restlet 1.2, and I used to create a BeanUtil class that
> would load my Spring 1.2.9 beans by casting getContext() to a
> ServletContextAdapter, then obtaining the ServletContext from there to use
> the WebApplicationContextUtils class in Spring to obtain a bean by name.
> I'm only loading my Services and DAOs from Spring.
>
> In Restlet 1.2, I can no longer cast it.  Is there an easier way to obtain
> the ServletContext, or, better yet, to load beans using the Spring
> extension?
>
> Thanks!
> Dustin
>   

-- 


Dustin N. Jenkins | Tel/Tél: 250.363.3101 | dustin.jenk...@nrc-cnrc.gc.ca

facsimile/télécopieur: (250) 363-0045

National Research Council Canada | 5071 West Saanich Rd, Victoria BC. 
V9E 2E7

Conseil national de recherches Canada | 5071, ch. West Saanich, Victoria 
(C.-B) V9E 2E7

Government of Canada | Gouvernement du Canada

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1532829


RE: Loading Spring Beans

2009-04-03 Thread Jerome Louvel
Hi Dustin,

After looking at the code, there has been changes related to context in 1.2,
to better isolate Components from Applications that affect you.

I suggest that you enter an issue report in our tracker so we can have a
closer look at this an see how we could support that again.

Alternatively, you could initialize Spring from within Restlet itself to
bypass this issue, unless you have other pure Servlet applications.
 
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 : Dustin N. Jenkins [mailto:dustin.jenk...@nrc-cnrc.gc.ca] 
Envoyé : mercredi 1 avril 2009 21:45
À : discuss@restlet.tigris.org
Objet : Loading Spring Beans

Hello!

I'm using JDK 1.6 with Tomcat 6.0 on Fedora Core 8.

I'm upgrading to Restlet 1.2, and I used to create a BeanUtil class that
would load my Spring 1.2.9 beans by casting getContext() to a
ServletContextAdapter, then obtaining the ServletContext from there to use
the WebApplicationContextUtils class in Spring to obtain a bean by name.
I'm only loading my Services and DAOs from Spring.

In Restlet 1.2, I can no longer cast it.  Is there an easier way to obtain
the ServletContext, or, better yet, to load beans using the Spring
extension?

Thanks!
Dustin
-- 


Dustin N. Jenkins | Tel/Tél: 250.363.3101 | dustin.jenk...@nrc-cnrc.gc.ca

facsimile/télécopieur: (250) 363-0045

National Research Council Canada | 5071 West Saanich Rd, Victoria BC. 
V9E 2E7

Conseil national de recherches Canada | 5071, ch. West Saanich, Victoria
(C.-B) V9E 2E7

Government of Canada | Gouvernement du Canada

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=15101
96

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1532720


RE: [NEWBIE] RESTlet with JDBC tutorial

2009-04-03 Thread Jerome Louvel
Hi there,

Just look at the example provided with Restlet (org.restlet.example
packages). You will see how persistence of resource's state is done. 

It should then be straightforward to adapt that to JDBC/Hibernae/JPA or
similar technologies. Nothing really Restlet specific here.
 
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 : webp...@tigris.org [mailto:webp...@tigris.org] 
Envoyé : mercredi 1 avril 2009 18:47
À : discuss@restlet.tigris.org
Objet : [NEWBIE] RESTlet with JDBC tutorial

Do anybody know where can I find tutorials to understand how to implement
simple resources with persistence through JDBC (ex: MySQL, ...) ?

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=15088
25

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1532664


RE: ServerServlet and a Component xml config files in 1.2m1

2009-04-03 Thread Jerome Louvel
Hi Joe,

This would be a nice enhancement indeed. I've added a comment in this RFE:

"Extend XML configuration scope"
http://restlet.tigris.org/issues/show_bug.cgi?id=449
 
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 : Joe Nellis [mailto:newsgro...@jnellis.net] 
Envoyé : dimanche 29 mars 2009 16:49
À : discuss@restlet.tigris.org
Objet : ServerServlet and a Component xml config files in 1.2m1

Greetings,

Component.parseXmlConfiguration parses  tags from a configuration file, stores it in it's context
and then when it comes time to instantiate the Application, those parameters
are lost somewhere.  I tried putting the parameter tag in both locations
shown below but neither is carried into the applications context as I
expected it to.  The existing code parses it fine and puts them in the
component context for the component/parameter tag and for the
defaultHost/parameter tag it puts the params in the defaultHosts context but
none of this is carried over to the Application context when it's created
from what I can tell.  I'm using this in a ServerServlet restlet.xml file so
their should be no point in subclassing ServerServlet or Component to get
this to work if I am understanding the intent of this config file feature.

Sincerely,
Joe.


http://www.restlet.org/schemas/1.2/Component";>
  
  
  
  
  
  


  


--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=14713
35

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1532644


Re: how to get config info from web.xml

2009-04-03 Thread Alexander J. Perez Tchernov
You may try smth like this

ServletContextAdapter adapter = (ServletContextAdapter) getContext();
ServletContext servletContext = adapter.getServletContext();
String filePrefix = servletContext.getInitParameter("internal-configuration")

web.xml


RestletServletAdaptor

org.restlet.ext.servlet.ServerServlet

internal-configuration

conf/internal-configuration.properties




On Thu, Apr 2, 2009 at 10:52 PM, helen chen  wrote:
> Hi,
>
> I'm kind of new to Restlet. I'm using 1.1.3 now.
>
> I want to put some configuration information in the web.xml file,  in common
> jsp, I can use getServletConfig().getServletContext().getInitParameter() to 
> get
> the information.  Is there any similar way for me to get the information in
> Restlet?
>
> Thanks, Helen
>
>



-- 
Best regards,
 ~ Xasima Xirohata ~

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1532470


how to get config info from web.xml

2009-04-03 Thread helen chen
Hi,

I'm kind of new to Restlet. I'm using 1.1.3 now. 

I want to put some configuration information in the web.xml file,  in common
jsp, I can use getServletConfig().getServletContext().getInitParameter() to get
the information.  Is there any similar way for me to get the information in
Restlet?

Thanks, Helen



access control

2009-04-03 Thread helen chen
Hello there,

I'm having a situation like the following:  I need to restrict that only one ip
adddress is allowed to access to a specific uri that is developed by restlet.
And other pages are open to all.

 I know this usually should be done at the web server part. But if I need to do
it through Restlet, Can I use Guard to do it? If yes, does anyone have example?

Thanks, Helen



Re: access control

2009-04-03 Thread helen chen
I'm reading the document about the Guard. It looks like when creating a Guard, I
can specify ChallengeScheme.CUSTOM which can be used for IP address check.

But if I do it, then when should I check the IP address? Does that mean I have
to create a sub class of Guard, override method authenticate() and authorize()? 
Does anyone have ever done this? Is there any sample code I can take a look?

since only server side it check IP address, at client side, I guess I don't need
to do request.setChallengeResponse() for the ChallengeSchema.CUSTOM right? 

I would appreciate if anyone has any ideasabout how to deal with it .

helen 



>>> Helen Chen 04/02/09 5:09 PM >>>
Hello there,

I'm having a situation like the following:  I need to restrict that only one ip
adddress is allowed to access to a specific uri that is developed by restlet.
And other pages are open to all.

 I know this usually should be done at the web server part. But if I need to do
it through Restlet, Can I use Guard to do it? If yes, does anyone have example?

Thanks, Helen




Getting various mediaTypes through browser

2009-04-03 Thread webpost
for a given Resource R, i want it accessible through these links:
R.html : returns html representation for resource R
R.xml : returns xml represenation
R.pdf : returns pdf representation

apart from this i want to keep the behaviour of setting mime types in the http 
protocol and get the corresponding representation for R.

my question is do i have to add separate entry for each type .html, .xml, .pdf 
for each resource or is there some other way out.
I am having 10-12 resources and creating a separate entry for each of the 
representation for each resource seems to be a cumbersome task.

pracheer gupta

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1528032


how to set media type for requests

2009-04-03 Thread webpost
how to create a client that asks for the xml representation of a resource i.e. 
how to set the media type for a given request.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1528788


RE: Example of using the Tag class with Restlet

2009-04-03 Thread Jerome Louvel
Hi Faisal,

Yes, it is possible to optimize this since Restlet 1.2 M2 released this
week! For this you can leverage the new ServerResource (instead of
Resource), the getInfo() methods and the RepresentationInfo class which
contains the "tag" property without the rest of the representation.
 
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 : Faisal [mailto:faisal-f.k...@ubs.com] 
Envoyé : vendredi 3 avril 2009 12:31
À : discuss@restlet.tigris.org
Objet : RE: Example of using the Tag class with Restlet

Hi Jerome,

Thanks for the reply and apologies for a delayed acknowledgment. I was
execpting something more complicated than just setting a valid eTag, works
well, thanks.

Is there a way to manually check the tag coming in with the request so I can
avoid generating the XML response only to return a 304, so as to reduce
unneccesary work on the server side.

Regards
Faisal



Hi Faisal,

If you use Restlet Resource subclasses, the conditional gets should be
handled automatically for you. You just need to set the Representation#tag
property on your result entities.
 
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 : Faisal [mailto:faisal-f.k...@ubs.com] Envoyé : jeudi 19 mars 2009 17:54
À : discuss@restlet.tigris.org Objet : Example of using the Tag class with
Restlet

Hi,

I am struggling to find an example of how to implement etag functionality in
my restlet service. Have tried to search but to no avail.

Can anyone provide example of how I can verify the state of the tag and
content so as to decide whether to send the new XML response or content not
modified response.

Thanks
Faisal
--
View this message in context:
http://n2.nabble.com/Example-of-using-the-Tag-class-with-Restlet-tp2504042p2
504042.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=13564
77

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=14161
52



--
View this message in context:
http://n2.nabble.com/Example-of-using-the-Tag-class-with-Restlet-tp2504042p2
579899.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=15310
12

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1531040


RE: Example of using the Tag class with Restlet

2009-04-03 Thread Faisal
Hi Jerome,

Thanks for the reply and apologies for a delayed acknowledgment. I was 
execpting something more complicated than just setting a valid eTag, works 
well, thanks.

Is there a way to manually check the tag coming in with the request so I can 
avoid generating the XML response only to return a 304, so as to reduce 
unneccesary work on the server side.

Regards
Faisal



Hi Faisal,

If you use Restlet Resource subclasses, the conditional gets should be
handled automatically for you. You just need to set the Representation#tag
property on your result entities.
 
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 : Faisal [mailto:faisal-f.k...@ubs.com] 
Envoyé : jeudi 19 mars 2009 17:54
À : discuss@restlet.tigris.org
Objet : Example of using the Tag class with Restlet

Hi,

I am struggling to find an example of how to implement etag functionality in
my restlet service. Have tried to search but to no avail.

Can anyone provide example of how I can verify the state of the tag and
content so as to decide whether to send the new XML response or content not
modified response.

Thanks
Faisal
--
View this message in context:
http://n2.nabble.com/Example-of-using-the-Tag-class-with-Restlet-tp2504042p2
504042.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=13564
77

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1416152



-- 
View this message in context: 
http://n2.nabble.com/Example-of-using-the-Tag-class-with-Restlet-tp2504042p2579899.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1531012


RE: Apache URLEncode Pattern Match Issue

2009-04-03 Thread Jerome Louvel
Hi Tim, 

You could add a custom Filter as a root of your application, before your
Router in order to take care of those cases. 
 
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 : Tim White [mailto:t...@cyface.com] 
Envoyé : jeudi 26 mars 2009 19:36
À : discuss@restlet.tigris.org
Objet : Apache URLEncode Pattern Match Issue

Hello -

 We're running through Apache in front of WebLogic to connect to our
restlet.

 Apache urldecodes the incoming url, which is turning this: %7C into this: |

 This is causing our URI pattern not to match in the restlet.

 There doesn't seem to be any way to force Apache not to urldecode the
incoming URL before it sends it on to WebLogic.

 Where could we intercept the URL coming in to the restlet and URLencode it
before the pattern matching occurs?

 Or, is there some way to match the pattern matching less sensitive to
having | in the URL?

Thanks!

Tim White

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=14335
44

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1530591


Re: problem with securityContext.isUserInRole() with new SecurityAPI

2009-04-03 Thread Alexander J. Perez Tchernov
FINE! I spent a time on debugging and resolved the problem.
I hope my remarks may help someone to prevent him from making such a mistake.

In my application I just create roles  in following manner

public Restlet сreateRoot() {
// create roles 
this.getRoles().add(new Role(ADMIN_ROLE, "Admin Role"));

//After I create JAXRSApplication
   JaxRsApplication jaxRsApplication = new
JaxRsApplication(getContext());
jaxRsApplication.add(new JaxRsConfiguration()); 

// Guard it and attach to router
   guard.setNext(jaxRsApplication);
   router.attach("/xxx", guard);
   return router;
}

My mistake was in the assumption that jaxRsApplication may inherit
roles from the 'parent' application.
Of course, it doesn't inherit these roles. So Application.getCurrent()
actually doesn't return role while ClientInfo has valid Principal and
Role.

public boolean isUserInRole(String roleName) {
// ...
Role role = Application.getCurrent().findRole(roleName);
// role == null if we don't set up roles for the
application explicitly
return role != null && this.request.getClientInfo().isInRole(role);
}
}


To fix this I just add the following  before guarding application and
attaching it to route.
// add roles from parent application to the child ones
jaxRsApplication.getRoles().addAll(this.getRoles());

That's all.


On Thu, Apr 2, 2009 at 11:26 PM, Xasima Xirohata  wrote:
> hi, I just created new organization, user (login admin, pass admin),
> and group using new security API (1.2 M2) . Bind user + group to
> organization. Bind group to role "ADMIN_ROLE". Set up authorizer
> against this role + HTTP_BASIC Guard against appropriate resource (
> /admin/*)  with this role authorizer.
>
> When point to resource (/admin/subresource), I just pass the admin /
> admin credentials (so Guard and authorizer works) and get access to
> the page (generated by resource), but the check
> securityContext.isUserInRole() in my JAX-RS resource fails against the
> ROLE i have just recently been checked. UserPrincipals is still valid
> (it shows admin).
>
> Sorry, am i right with the code or just miss something?
>
> 
> public class Application extends org.restlet.Application {
>        public Application() {  this(null); }
>        public Application(Context context) { super(context);}
>
>        public static final String ADMIN_ROLE = "ADMIN_ROLE";
>
>       �...@override
>        public Restlet createRoot() {
>                Router router = new Router(getContext());
>
>                // create roles
>                this.getRoles().add(new Role(ADMIN_ROLE, "Admin Role"));
>
>               // create realm (i.e. create users and groups, bind
> users to groups, bind groups to roles)
>                MemoryRealm realm = new MemoryRealm();
>                Organization org = createOrganization(realm, this); //static 
> methods
> that create org, groups, user + bind to the role group
>                realm.getOrganizations().add(org);
>                getContext().setRealm(realm);
>
>               // create specific (ADMIN_ONLY) role policy
>                RoleAuthorizer roleAuthorizer = new RoleAuthorizer();
>                
> roleAuthorizer.getAuthorizedRoles().add(this.findRole(ADMIN_ROLE));
>
>                 // create authentification guard
>                ChallengeGuard guard = new ChallengeGuard(getContext(),
>                        ChallengeScheme.HTTP_BASIC, "Guard");
>
>               // create application
>                JaxRsApplication jaxRsApplication = new 
> JaxRsApplication(getContext());
>                jaxRsApplication.add(new JaxRsConfiguration()); 
> //JAXRSConfiguration
> extends javax.ws.rs.core.Application+ pick up AdminResource in
> getClasses() method.
>
>                // set role authorizer  to guard
>                guard.setAuthorizer(roleAuthorizer);
>                // bind application to guard
>                guard.setNext(jaxRsApplication);
>                // attach guard to router
>                router.attach("/admin", guard);
>
>                return router;
>       }}
>  -
> @Path("/{subresource}")
> public class AdminResource {
>       �...@context
>    SecurityContext securityContext;
>
>       �...@get
>        public Response station(@PathParam("subresource") String station) {
>                String role = roleChecker();
>                return Response.ok("Subresourse '" + subresource +
>                                              "', Principal '" +
> securityContext.getUserPrincipal().getName() +
>                                              ", InRole" +
>
> securityContext.isUserInRole(Application.ADMIN_ROLE)+ "' ",
>           MediaType.TEXT_HTML).build();
>        }
> }
>
> web.xml
> 
> http://www.w3.org/2001/XMLSchema-instance";
> xmlns="http://java.sun.com/xml/ns/javaee"

Re: ServerResource conditional mode

2009-04-03 Thread Tal Liron




You
don't need to put a media type if you're using void (although, you
could potentially have more than one @Post handler, for several media
types, to be used depending on the expectation of a media type
from the client...).


But,
you do need to disable conditional mode:

@Post
public void handlePost(Representation rep) { ... }

@Override
protected void init()
{
    setConditional(false);
}




Why?
I'm still a bit in the dark about this. My current instinct tells me
that there's a bug in how the preferred variant is calculated for
conditional mode, in that it doesn't gather variants for the particular
method. Thus, I suspect (I haven't tested this) that if you had a @Get
with a particular media type (say, @Get("txt")) then there would be a
preferred variant and your @Post would be called, even in conditional
mode.


Please
take that last paragraph with a truckload of salt. :)


-Tal





David Fogel wrote:


  Hi Tal-

I will definitely take a look at your script extension, thanks for the
suggestion!

I think I understand the general deal with the mediatype annotation
argument.  But like I said, I was trying to define a Post method that
doesn't return content (and which therefore wouldn't make sense to
declare a mediatype for.  So what's the right annotation argument for
this method?

@Post("[what goes here?]")
public void handlePost(Representation rep) { ... }

what I found was that I had to put a return type or a mediatype, or
else ServerResource refuses to call the method, due to the lack of a
"preferredVariant".

-Dave

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1529543
  






Re: ServerResource conditional mode

2009-04-03 Thread David Fogel
Hi Tal-

I will definitely take a look at your script extension, thanks for the
suggestion!

I think I understand the general deal with the mediatype annotation
argument.  But like I said, I was trying to define a Post method that
doesn't return content (and which therefore wouldn't make sense to
declare a mediatype for.  So what's the right annotation argument for
this method?

@Post("[what goes here?]")
public void handlePost(Representation rep) { ... }

what I found was that I had to put a return type or a mediatype, or
else ServerResource refuses to call the method, due to the lack of a
"preferredVariant".

-Dave

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1529543