Re: How do I switch off log output?

2008-04-08 Thread Steve Loughran
On Tue, Apr 8, 2008 at 6:27 AM, Ian Clarke [EMAIL PROTECTED] wrote:
 Thanks for the tip, although I'm afraid it wasn't entirely effective.
  I used getLogService().setEnabled(false) - but I'm still getting the
  following:

  Apr 8, 2008 12:23:48 AM org.apache.commons.httpclient.HttpMethodBase
  readResponseBody
  INFO: Response content length is not known


That's httpclient logging at INFO; if you have commons-logging and
log4j on the classpath, it will log via log4j

in your log4j.properties you could tell HttpClient to only warn you
.
log4j.logger.org.apache.commons.httpclient=WARN


Exception handling

2008-04-08 Thread Stephan Koops

Hi,

is it right, that there is no special excpetion handlung in Restlet for 
RuntimeExceptions, only the mapping to status 500?
Is there more than that and the ResourceException, which is mapped to 
the given status and nothing else?


best regards
  Stephan


Re: How do I switch off log output?

2008-04-08 Thread Rob Heittman
Yes, it can be a bit of a challenge to find and manage logging output from
all the different connectors and plugins that you might possibly be using (a
list that grows all the time), not just Restlet itself.  I wonder if anybody
has any good ideas for easily centralizing this, maybe as part of the future
deployable Restlet configuration effort.

On Tue, Apr 8, 2008 at 5:58 AM, Steve Loughran [EMAIL PROTECTED]
wrote:

 That's httpclient logging at INFO; if you have commons-logging and
 log4j on the classpath, it will log via log4j



First resource page

2008-04-08 Thread Thierry Boileau
Hello all,

We've added a new First resource document in the Restlet web site.
You can get it at the following URL:
http://www.restlet.org/documentation/1.1/firstResource (or
http://www.restlet.org/documentation/1.0/firstResource, for Restlet 1.0).

It simply describes how to create 2 basic resources illustrating how
to handle GET, POST, PUT, DELETE methods.
Your comments and questions are of course welcomed.

best regards,
Thierry Boileau


Re: How do I switch off log output?

2008-04-08 Thread Ian Clarke
Personally I blame the design of logging frameworks.  I find them to
be over-engineered, and unintuitive to use.

I hate to say it, but maybe we need a new logging framework :-)

Ian.

On Tue, Apr 8, 2008 at 6:37 AM, Rob Heittman [EMAIL PROTECTED] wrote:
 Yes, it can be a bit of a challenge to find and manage logging output from
 all the different connectors and plugins that you might possibly be using (a
 list that grows all the time), not just Restlet itself.  I wonder if anybody
 has any good ideas for easily centralizing this, maybe as part of the future
 deployable Restlet configuration effort.



 On Tue, Apr 8, 2008 at 5:58 AM, Steve Loughran [EMAIL PROTECTED]
 wrote:
  That's httpclient logging at INFO; if you have commons-logging and
  log4j on the classpath, it will log via log4j
 




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


Re: Help! Weird timeout on GET to Restlet API

2008-04-08 Thread Rob Heittman
It seems that as you work with Restlet, you're running into a lot of things
that have been a focus of work in the 1.1 cycle.

This one was http://restlet.tigris.org/issues/show_bug.cgi?id=357

The 1.1 milestone builds don't totally fix the issue, but do cover a number
of common cases (perhaps including yours), and log a helpful warning in the
cases that can't be covered.

This is not the first time I've opined this, but I'd personally use a
Restlet 1.1 milestone build if I was doing new exploration of Restlet.
While the downside of using the version under active development is the
potential for change -- which is ameliorated by Jerome's careful management
of this project -- the upside is that you don't have to continually stumble
on the literally hundreds of issues that have been addressed by changes from
the 1.0 tree.  And, of course, any issues you continue to find can be fixed
quickly and improve the quality of the platform.

Since one of the main objectives of 1.1 has been to respond to issues that
confuse or frustrate people coming to the platform, the changes in 1.1 are
extremely on point for the needs of a new Restlet user.

- Rob

On Mon, Apr 7, 2008 at 6:09 PM, Ian Clarke [EMAIL PROTECTED] wrote:

 Ok, I think I fixed it - the problem was that after some calls I
 wasn't doing a getEntity().getText() (I didn't require the entity).

 Its a bit of a nasty pitfall for newbies...

 Ian.

 On Mon, Apr 7, 2008 at 4:29 PM, Ian Clarke [EMAIL PROTECTED] wrote:
  I keep getting the following timeout when I try to do a HTTP GET on a
   resource (I'm using Restlet both server and client side, v1.0.9).  It
   only seems to happen if I PUT and then DELETE the resource, and then
   try to GET it after its been deleted.  If I never create the resource
   in the first place, then the request returns with a 404 as it should.
   If I create, and don't delete the resource, then it returns with a 200
   as it should.




Re: How do I switch off log output?

2008-04-08 Thread Ian Clarke
That didn't work, I think this is commons-logging, I don't have log4j
on my classpath.  Here is how I solved it:

// Switch off logging (stupid f$%king logging frameworks!)
component.getLogService().setEnabled(false);
System.setProperty(org.apache.commons.logging.Log,
org.apache.commons.logging.impl.SimpleLog);

System.setProperty(org.apache.commons.logging.simplelog.showdatetime,
true);

System.setProperty(org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient,
error);

I definitely feel a blog rant coming on about today's Java logging
frameworks :-)

Ian.

On Tue, Apr 8, 2008 at 4:58 AM, Steve Loughran [EMAIL PROTECTED] wrote:
 On Tue, Apr 8, 2008 at 6:27 AM, Ian Clarke [EMAIL PROTECTED] wrote:
   Thanks for the tip, although I'm afraid it wasn't entirely effective.
I used getLogService().setEnabled(false) - but I'm still getting the
following:
  
Apr 8, 2008 12:23:48 AM org.apache.commons.httpclient.HttpMethodBase
readResponseBody
INFO: Response content length is not known
  

  That's httpclient logging at INFO; if you have commons-logging and
  log4j on the classpath, it will log via log4j

  in your log4j.properties you could tell HttpClient to only warn you
  .
  log4j.logger.org.apache.commons.httpclient=WARN




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


Re: How do I switch off log output?

2008-04-08 Thread Rob Heittman
Heh.  One of the guys at my office has been ad-hoc building his own personal
logging framework to talk to the logging frameworks.  Originally I was going
to complain about this on principle, but in truth his code's delightfully
easy to read -- simply because his logging classes are intentionally simpler
and more ad hoc to the application environment and the information being
logged.

Forward a pointer to the blog rant please  ;-)

On Tue, Apr 8, 2008 at 9:38 AM, Ian Clarke [EMAIL PROTECTED] wrote:

 Personally I blame the design of logging frameworks.  I find them to
 be over-engineered, and unintuitive to use.

 I hate to say it, but maybe we need a new logging framework :-)

 Ian.



Re: Authentication Helper/Guard help

2008-04-08 Thread Adam Rosien
Your resource needs to be wrapped (protected) by the Guard, rather
than protecting a Router that routes to the Resource.

Try something like this:

Guard guard = new SharedSecretGuard(...);
guard.setNext(UserResource.class);
secureRouter.attach(/users/{username}, guard);

.. Adam


On Mon, Apr 7, 2008 at 9:20 AM, Barrie Selack [EMAIL PROTECTED] wrote:
 Adam,

  Based on Rhett's example (modified to the same url), if I do:

 Router top = new Router(getContext());

 Guard g = new SharedSecretGuard(getContext(), realm);

   Router secureRouter = new Router(getContext());
 secureRouter.attach(/users/{username}, UserResource.class);
 g.setNext(secureRouter);
 top.attach(/users/{username}, g);

  The guard gets processed, but a 404 is returned, and my UserResource is 
 never called.

  If I just do:

 Router top = new Router(getContext());
 top.attach(/users/{username}, UserResource.class);

  My resource is called, but of course I get no guard.

  It appears that I cannot have a guard and a resource at the same url.


  Barrie Selack
  Rite Aid Corporation


  -Original Message-


 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adam Rosien
  Sent: Monday, April 07, 2008 12:03 PM
  To: discuss@restlet.tigris.org
  Subject: Re: Authentication Helper/Guard help

  You don't have to change the URL.  The Guard wraps the Resource
  attached at that URL.

  .. Adam

  On Mon, Apr 7, 2008 at 6:58 AM, Barrie Selack [EMAIL PROTECTED] wrote:
   Rhett,
  
Thanks, that fills in one of the gaps.
  
So, if I understand correctly, if I have a url:
  
/users/bselack that maps to resource: UserResource
  
And I want it to be secured, then I'd need to assign the guard and add 
 attach it at /secure
  
So my final url would be /secure/users/bselack
  
Is that correct? If so, can it be done without adding the /secure to the 
 front of the url?
  
I really don't want to have an addition to the url as if I have different 
 security methods, I don't want to have different prefixes.
  
Regards,
Barrie Selack
Rite Aid Corporation
  
  
  
  
-Original Message-
From: Rhett Sutphin [mailto:[EMAIL PROTECTED] On Behalf Of Rhett Sutphin
Sent: Sunday, April 06, 2008 7:35 PM
To: discuss@restlet.tigris.org
Subject: Re: Authentication Helper/Guard help
  
Hi Barrie,
  
Restlet is the base class for all the stateless request handling
aspects of the framework, including Router and Guard.  Resource is the
base class for the stateful handling of a single request.  The
configured restlets determine which Resource winds up handling a
particular request, based on the URI, the headers, etc.  Restlets may
also respond to requests themselves (e.g., a Guard will respond with
401 status if authentication is required).
  
The specific ordering of the restlets is going to depend on your
particular situation.  If you want to secure everything with the same
Guard, it might go like this (pseudocode):
  
Guard g = new Guard(...)
Router r = new Router(...)
r.attach(...)
// etc.
g.setNext(r)
  
Or if you want to only secure some things, you might do it like this:
  
Router top = new Router(...)
top.attach(/insecure, InsecureResource.class)
Guard g = new Guard(...)
Router secureRouter = new Router(...)
secureRouter.attach(/a, SecureResource.class)
g.setNext(secureRouter)
top.attach(/secure, g)
  
If it's still unclear, take a look at the API documentation for
Restlet and its subclasses.
  
HTH,
Rhett
  
On Apr 6, 2008, at 5:46 PM, Barrie Selack wrote:
 Rhett,

 Thanks. I've been through all the examples and tutorials. But I'm
 lost on the relationship of Restlet, Router, Resource, Guard, etc.
 The tutorial attaches Guards to a Restlet, but I'm attaching
 Resources to a Route (which is also show later in the tutorials, but
 not in the context of a Guard).

 Maybe I have the concept mixed up. Can a Resource be secured by an
 Authentication method? The tutorial doesn't seem to show that. Am am
 mixing the wrong components to get to my solution?

 So i guess the questions is... where am I having the disconnect (in
 my mind) of how the pieces fit together.

 Regards,
 Barrie

 
 From: Rhett Sutphin [EMAIL PROTECTED] On Behalf Of Rhett
 Sutphin [EMAIL PROTECTED]
 Sent: Sunday, April 06, 2008 5:33 PM
 To: discuss@restlet.tigris.org
 Subject: Re: Authentication Helper/Guard help

 Hi Barrie,

 That's what I believe as well... except I'm not sure how to do the
 wiring in the UserResource.

 You don't wire in the resource -- you create a chain of restlets that
 leads to the resource.  Take a look at section 9 of the tutorial.

 

Re: Exception handling

2008-04-08 Thread Adam Rosien
That is correct.  You'll have lots of code in your Resources that
handles translating detectable errors and exceptions into either
ResourceExceptions (or doing getResponse().setStatus(...) in 1.0
code).

.. Adam

On Tue, Apr 8, 2008 at 2:12 AM, Stephan Koops [EMAIL PROTECTED] wrote:
 Hi,

  is it right, that there is no special excpetion handlung in Restlet for
 RuntimeExceptions, only the mapping to status 500?
  Is there more than that and the ResourceException, which is mapped to the
 given status and nothing else?

  best regards
   Stephan



Tracking Request and Patterns

2008-04-08 Thread Sanjay Acharya

Hi,
 
I am trying to develop a tracker to determine which pattern uri of a restlet 
service has been invoked. For example, an OrderApplication may support:
 
/order 
/order/{orderId}
/order/lineItem/{lineItemId}
 
I would like to be able to intercept a request and place the pattern uri 
(example:/order/{orderId})  into the request object so that I might be able to 
use it later for tracking purpose. For example, 
being able to use the the result that I place in the request within a Tomcat 
Valve or Filter:
 
I am searching for the best place to handle this. My first thought was to 
extend the Application class by providing a custom AbstractApplication that 
would do the following:
 
public abstract class MyApplication extends Application {
 
  public void handle(Request request, Response response) {
super.handle(request, response);
Restlet root = super.getRoot();

if (! (root instanceof Router)) {
  return;
}

Router router = (Router) root;
RouteList rlist = router.getRoutes();

Route route = rlist.getBest(request, response, router.getRequiredScore());
Template t = route.getTemplate();
String servicedPattern = t.getPattern();

Map attributes = new HashMap();

attribues.put(SERVICED_PATTERN, servicedPattern);  
 
 // Place the pattern serviced in the request so that it may be extracted 
later. 
 request.setAttributes(attributes);
  }
}
 
I however do not believe the above is the correct place for this sort of 
tracking as the above code assumes that the routers are not chained. Further 
placing I am not sure whether 
placing objects in org.restlet.data.Request will be available after the restlet 
finishes the processing, something I have yet to try.
 
Any suggestions/thoughts/experiences with where the best place to plugin this 
tracking information would be appreciated.
 
Regards,
Sanjay

_
Pack up or back up–use SkyDrive to transfer files or keep extra copies. Learn 
how.
hthttp://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh_skydrive_packup_042008

StackOverFlow warning

2008-04-08 Thread Bao,Sam
Hi,

I've seen a couple of other discussion about this in the past, but didn't know 
if there's been any progress.  Anyways, I've encountered a 
java.lang.StackOverflowError when sending in a long attribute.  Here's the 
warning I'm getting:

Apr 8, 2008 10:59:58 AM org.restlet.util.Template match
WARNING: StackOverflowError exception encountered while matching this string : 
/result/c045d791-11b0-408e-8d60-b2f6ce6c117d,af3e28f4-2bdf-4b34-a74a-48f6c638a9b8,b242e13a-7083-45d6-a4db-5961883690db,a315b9cb-743c-422e-bb1b-bedfa93957bd,ac399b7f-5a2a-4ddc-8a7b-d1106e1e28f4,ffe736ef-5dbf-4204-a69c-b1599e012b75,1b876179-e897-4eb9-a5ae-b124fd69cbcb,b1c5abc4-b69c-4d5a-85fe-b320adab8f29,44efad37-ed0a-4bf0-80c8-55a82dfe89d3,bd43c7c4-0949-40a3-998b-b6cf0d895cc9,45b046c1-a509-4835-a801-c5bca0855d49,8260a9fd-9773-4803-8218-2de29082ef7a,2acd118a-5721-4aee-afcc-a28b3dd8bcbd,8943d432-a147-4393-afbf-5de3bbfb3f28,3db028ad-4f8c-4355-a7ca-ac4af7a712be,d00faab9-0c2d-4b5b-84bf-810e375ec38f,c8780a2a-a7be-458e-a6ef-9f73922b0ca7,16525506-0df4-453e-b930-d9fd46e08b72,a50839f2-e3b2-4604-86bf-646af2ca048d,5383406a-c566-455b-8725-2c81aba82db0,ae3ceaa9-a495-4311-8e65-4e83aa02b2ad,0cfc54f9-9852-451e-9856-a63689cbb4e3,2faaa074-b21c-4c40-a632-b5e8e84aa09a,ec4f38de-e0de-437e-9e3f-19db4576f177,185b9d55-237f-42b3-ba8a-bb005db09f2a,887ffc64-c190-439e-a9b2-261f55ea18e3,97683f00-151e-4508-8b77-5d34d1048843,1cfde617-ad79-4f81-bc30-bf017ecb5636,c4551d09-b558-40a1-96ca-eea503d72815,2fa39dc8-d375-42a6-bc11-e8cf4a91ceb8,e2198d2c-86c8-49e2-95c3-b6e88901cd68,f32600d5-1f27-4a4c-ae87-25caf0d91bdd,5156d109-aa69-4cf6-813c-7682b55d139e,b360f697-af9f-4e1e-8aff-e3d2fd510b0e,07f1db89-5b7f-4c9a-a177-003dffda8206,bc1103d2-7f0a-412e-9dc3-8c311c66c16b,2cefe92b-92ce-430f-89ee-8f2713afff2b,85cf0fb2-06d6-4d86-9146-4e8c951682b7,7acbaa77-d6bf-4271-a6b9-965ba5b83637,6ed9b90b-a533-4925-9019-282f27c32f86,4447c1b8-7333-4be1-ad37-9a552aed8243,d1e0593e-c340-4526-bc61-e98b74e2796b

I'm trying to call a GET at the result resource using a list of comma delimited 
uuids.  When it gets to the match(String formattedString) method and it calls 
getRegexPattern().match(formattedString) on the string above, it produces a 
Matcher with this regex: 
/result/((?:[a-zA-Z0-9\\-\\.\\_\\~\\!\\$'\\(\\)\\*\\+\\,\\;\\=\\:[EMAIL 
PROTECTED]|(?:\\%[0-9ABCDEFabcdef][0-9ABCDEFabcdef]))+), and I get the stack 
overflow when matcher.lookingAt() is called.

I've tried just matching on the above string with the regex standalone, and it 
looks to be recursively calling pattern.match, and causing the 
StackOverflowError.

String s = 
/result/c045d791-11b0-408e-8d60-b2f6ce6c117d,af3e28f4-2bdf-4b34-a74a-48f6c638a9b8,b242e13a-7083-45d6-a4db-5961883690db,a315b9cb-743c-422e-bb1b-bedfa93957bd,ac399b7f-5a2a-4ddc-8a7b-d1106e1e28f4,ffe736ef-5dbf-4204-a69c-b1599e012b75,1b876179-e897-4eb9-a5ae-b124fd69cbcb,b1c5abc4-b69c-4d5a-85fe-b320adab8f29,44efad37-ed0a-4bf0-80c8-55a82dfe89d3,bd43c7c4-0949-40a3-998b-b6cf0d895cc9,45b046c1-a509-4835-a801-c5bca0855d49,8260a9fd-9773-4803-8218-2de29082ef7a,2acd118a-5721-4aee-afcc-a28b3dd8bcbd,8943d432-a147-4393-afbf-5de3bbfb3f28,3db028ad-4f8c-4355-a7ca-ac4af7a712be,d00faab9-0c2d-4b5b-84bf-810e375ec38f,c8780a2a-a7be-458e-a6ef-9f73922b0ca7,16525506-0df4-453e-b930-d9fd46e08b72,a50839f2-e3b2-4604-86bf-646af2ca048d,5383406a-c566-455b-8725-2c81aba82db0,ae3ceaa9-a495-4311-8e65-4e83aa02b2ad,0cfc54f9-9852-451e-9856-a63689cbb4e3,2faaa074-b21c-4c40-a632-b5e8e84aa09a,ec4f38de-e0de-437e-9e3f-19db4576f177,185b9d55-237f-42b3-ba8a-bb005db09f2a,887ffc64-c190-439e-a9b2-261f55ea18e3,97683f00-151e-4508-8b77-5d34d1048843,1cfde617-ad79-4f81-bc30-bf017ecb5636,c4551d09-b558-40a1-96ca-eea503d72815,2fa39dc8-d375-42a6-bc11-e8cf4a91ceb8,e2198d2c-86c8-49e2-95c3-b6e88901cd68,f32600d5-1f27-4a4c-ae87-25caf0d91bdd,5156d109-aa69-4cf6-813c-7682b55d139e,b360f697-af9f-4e1e-8aff-e3d2fd510b0e,07f1db89-5b7f-4c9a-a177-003dffda8206,bc1103d2-7f0a-412e-9dc3-8c311c66c16b,2cefe92b-92ce-430f-89ee-8f2713afff2b,85cf0fb2-06d6-4d86-9146-4e8c951682b7,7acbaa77-d6bf-4271-a6b9-965ba5b83637,6ed9b90b-a533-4925-9019-282f27c32f86,4447c1b8-7333-4be1-ad37-9a552aed8243,d1e0593e-c340-4526-bc61-e98b74e2796b;
Pattern p = 
Pattern.compile(/result/((?:[a-zA-Z0-9\\-\\.\\_\\~\\!\\$'\\(\\)\\*\\+\\,\\;\\=\\:[EMAIL
 PROTECTED]|(?:\\%[0-9ABCDEFabcdef][0-9ABCDEFabcdef]))+));
Matcher m = p.matcher(s);
m.matches();
m.lookingAt();

Due to this problem, we're having to hack a solution of using the POST method 
for doing gets (as well as deletes) when operating on a large batch.  This 
works, but still a hack for what I presume to be a poorly generated regex 
that's preventing us for truly using a GET to do a get and a DELETE to do 
deletes.  I just wanted to bring this to people's attention, and to probe for 
any answers.  Has there been any fix for this, or will there be a fix for this 
in the future?  Thanks.

Sam

--
CONFIDENTIALITY NOTICE This message and any included attachments are 

Re: Problem with DomRepresentation

2008-04-08 Thread Stephan Koops

Hi Ludovic,

It seems, that see server uses chuncked encoding here.
Than the bb is the length of the next chunk, and the 0 says, that 
the end is reached.

Take a look at http://tools.ietf.org/html/rfc2616#section-3.6.1

best regards
  Stephan

Ludovic chaplin schrieb:

bb
?xml version=1.0 encoding=UTF-8 standalone=no?
city
nameParis/name
cityID75056/cityID
/city
0
  


Re: How do I switch off log output?

2008-04-08 Thread Kevin Conaway
So the solution to the confusion surrounding the various log frameworks in
use by Restlet and its components isanother log framework? :)

As much as I'm against using one of the bridge frameworks for logging, it
might make sense for Restlet seeing as how the various components all could
(and some indeed do) use different frameworks.

You could also adopt a discovery policy similar to what jetty does

On Tue, Apr 8, 2008 at 11:17 AM, Ian Clarke [EMAIL PROTECTED] wrote:

 Does your colleague have any plans to release his framework under a
 commercial-friendly license (eg. LGPL)?  If so, I'll definitely take a
 look at it for my own project :-)

 Ian.

 On Tue, Apr 8, 2008 at 8:46 AM, Rob Heittman [EMAIL PROTECTED]
 wrote:
  Heh.  One of the guys at my office has been ad-hoc building his own
 personal
  logging framework to talk to the logging frameworks.  Originally I was
 going
  to complain about this on principle, but in truth his code's
 delightfully
  easy to read -- simply because his logging classes are intentionally
 simpler
  and more ad hoc to the application environment and the information being
  logged.
 
  Forward a pointer to the blog rant please  ;-)
 
 
 
  On Tue, Apr 8, 2008 at 9:38 AM, Ian Clarke [EMAIL PROTECTED] wrote:
   Personally I blame the design of logging frameworks.  I find them to
   be over-engineered, and unintuitive to use.
  
   I hate to say it, but maybe we need a new logging framework :-)
  
   Ian.
  
 



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



Re: How do I switch off log output?

2008-04-08 Thread Ian Clarke
It seems ridiculous, I know, but unfortunately if all the existing
options are over-engineered and hard to use, and produce spurious
output in their default configuration, then the natural alternative is
to create a framework that doesn't suffer from these problems.

Of course, a simple solution to the immediate issue is to ensure that
logging is switched off by default in all code and libraries shipped
with Restlet.

Ian.

On Tue, Apr 8, 2008 at 11:31 AM, Kevin Conaway [EMAIL PROTECTED] wrote:
 So the solution to the confusion surrounding the various log frameworks in
 use by Restlet and its components isanother log framework? :)

 As much as I'm against using one of the bridge frameworks for logging, it
 might make sense for Restlet seeing as how the various components all could
 (and some indeed do) use different frameworks.

 You could also adopt a discovery policy similar to what jetty does



 On Tue, Apr 8, 2008 at 11:17 AM, Ian Clarke [EMAIL PROTECTED] wrote:

  Does your colleague have any plans to release his framework under a
  commercial-friendly license (eg. LGPL)?  If so, I'll definitely take a
  look at it for my own project :-)
 
  Ian.
 
 
 
 
  On Tue, Apr 8, 2008 at 8:46 AM, Rob Heittman [EMAIL PROTECTED]
 wrote:
   Heh.  One of the guys at my office has been ad-hoc building his own
 personal
   logging framework to talk to the logging frameworks.  Originally I was
 going
   to complain about this on principle, but in truth his code's
 delightfully
   easy to read -- simply because his logging classes are intentionally
 simpler
   and more ad hoc to the application environment and the information being
   logged.
  
   Forward a pointer to the blog rant please  ;-)
  
  
  
   On Tue, Apr 8, 2008 at 9:38 AM, Ian Clarke [EMAIL PROTECTED] wrote:
Personally I blame the design of logging frameworks.  I find them to
be over-engineered, and unintuitive to use.
   
I hate to say it, but maybe we need a new logging framework :-)
   
Ian.
   
  
 
 
 
 
 
 
  --
  Email: [EMAIL PROTECTED]
  Cell: +1 512 422 3588
  Skype: sanity
 





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


Re: Problem with DomRepresentation

2008-04-08 Thread Thierry Boileau

Hi Ludovic,

I've tried several configurations[(standalone with Jetty or Simple 
connectors) and Servlet container] and Firefox2.0/IE7, and was not able 
to reproduce your problem.

I'm using Restlet 1.0.9.
Could you precise your context (Restlet version, server connector, 
client, etc)?


best regards,
Thierry Boileau





Hello,

I'm beginning with the RESTlet Framework and I trying to create a 
DomRepresentation of my ressource.
I adapt the sample I found here : 
http://www.restlet.org/documentation/1.1/firstResource

to have something like that :

public Representation getRepresentation(Variant variant) {
Representation result = null;
try {
DomRepresentation representation = new 
DomRepresentation(MediaType.TEXT_XML);

Document d = representation.getDocument();
Element eltItem = d.createElement(city);
d.appendChild(eltItem);
Element eltName = d.createElement(name);
eltName.appendChild(d.createTextNode(oCity.getName()));
eltItem.appendChild(eltName);
Element eltDescription = d.createElement(cityID);
eltDescription.appendChild(d.createTextNode(oCity.getCityID()));
eltItem.appendChild(eltDescription);
d.normalizeDocument();
return representation;
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

I had a weird problem, cause the first time I acces  to my ressource (with a 
web browser) it's working great. But when I reload the page the XML is not 
correct, there is 2 characters (bb) at the beginning and one at the end (0).

Look like that :
bb
?xml version=1.0 encoding=UTF-8 standalone=no?
city
nameParis/name
cityID75056/cityID
/city
0

Anyone as an idea to help me?
Thank you
Ludovic 





  




Re: How do I switch off log output?

2008-04-08 Thread Adam Rosien
I think a well-written FAQ entry or explicit documentation page with
recommended solutions would be the most practical solution to
alleviating a lot of the pain of the logging conundrum.  This page
must be easy to find as this situation happens to every user of
Restlet, and, well, sucks.

.. Adam

On Tue, Apr 8, 2008 at 9:44 AM, Ian Clarke [EMAIL PROTECTED] wrote:
 It seems ridiculous, I know, but unfortunately if all the existing
  options are over-engineered and hard to use, and produce spurious
  output in their default configuration, then the natural alternative is
  to create a framework that doesn't suffer from these problems.

  Of course, a simple solution to the immediate issue is to ensure that
  logging is switched off by default in all code and libraries shipped
  with Restlet.

  Ian.



  On Tue, Apr 8, 2008 at 11:31 AM, Kevin Conaway [EMAIL PROTECTED] wrote:
   So the solution to the confusion surrounding the various log frameworks in
   use by Restlet and its components isanother log framework? :)
  
   As much as I'm against using one of the bridge frameworks for logging, it
   might make sense for Restlet seeing as how the various components all could
   (and some indeed do) use different frameworks.
  
   You could also adopt a discovery policy similar to what jetty does
  
  
  
   On Tue, Apr 8, 2008 at 11:17 AM, Ian Clarke [EMAIL PROTECTED] wrote:
  
Does your colleague have any plans to release his framework under a
commercial-friendly license (eg. LGPL)?  If so, I'll definitely take a
look at it for my own project :-)
   
Ian.
   
   
   
   
On Tue, Apr 8, 2008 at 8:46 AM, Rob Heittman [EMAIL PROTECTED]
   wrote:
 Heh.  One of the guys at my office has been ad-hoc building his own
   personal
 logging framework to talk to the logging frameworks.  Originally I was
   going
 to complain about this on principle, but in truth his code's
   delightfully
 easy to read -- simply because his logging classes are intentionally
   simpler
 and more ad hoc to the application environment and the information 
 being
 logged.

 Forward a pointer to the blog rant please  ;-)



 On Tue, Apr 8, 2008 at 9:38 AM, Ian Clarke [EMAIL PROTECTED] wrote:
  Personally I blame the design of logging frameworks.  I find them to
  be over-engineered, and unintuitive to use.
 
  I hate to say it, but maybe we need a new logging framework :-)
 
  Ian.
 

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



  --


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



Re: Problem with DomRepresentation

2008-04-08 Thread Thierry Boileau

Hello Ludovic,

are you running your code from a servlet container? Or as a standalone 
application?

Are you using Firefox, IE?

best regards,
Thierry Boileau


Hello,

I'm beginning with the RESTlet Framework and I trying to create a 
DomRepresentation of my ressource.
I adapt the sample I found here : 
http://www.restlet.org/documentation/1.1/firstResource

to have something like that :

public Representation getRepresentation(Variant variant) {
Representation result = null;
try {
DomRepresentation representation = new 
DomRepresentation(MediaType.TEXT_XML);

Document d = representation.getDocument();
Element eltItem = d.createElement(city);
d.appendChild(eltItem);
Element eltName = d.createElement(name);
eltName.appendChild(d.createTextNode(oCity.getName()));
eltItem.appendChild(eltName);
Element eltDescription = d.createElement(cityID);
eltDescription.appendChild(d.createTextNode(oCity.getCityID()));
eltItem.appendChild(eltDescription);
d.normalizeDocument();
return representation;
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}

I had a weird problem, cause the first time I acces  to my ressource (with a 
web browser) it's working great. But when I reload the page the XML is not 
correct, there is 2 characters (bb) at the beginning and one at the end (0).

Look like that :
bb
?xml version=1.0 encoding=UTF-8 standalone=no?
city
nameParis/name
cityID75056/cityID
/city
0

Anyone as an idea to help me?
Thank you
Ludovic 





  




RE: Authentication Helper/Guard help

2008-04-08 Thread Barrie Selack
Adam,

Thanks, that was the trick!

Barrie Selack
Rite Aid Corporation

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adam Rosien
Sent: Tuesday, April 08, 2008 11:17 AM
To: discuss@restlet.tigris.org
Subject: Re: Authentication Helper/Guard help

Your resource needs to be wrapped (protected) by the Guard, rather
than protecting a Router that routes to the Resource.

Try something like this:

Guard guard = new SharedSecretGuard(...);
guard.setNext(UserResource.class);
secureRouter.attach(/users/{username}, guard);

.. Adam


On Mon, Apr 7, 2008 at 9:20 AM, Barrie Selack [EMAIL PROTECTED] wrote:
 Adam,

  Based on Rhett's example (modified to the same url), if I do:

 Router top = new Router(getContext());

 Guard g = new SharedSecretGuard(getContext(), realm);

   Router secureRouter = new Router(getContext());
 secureRouter.attach(/users/{username}, UserResource.class);
 g.setNext(secureRouter);
 top.attach(/users/{username}, g);

  The guard gets processed, but a 404 is returned, and my UserResource is 
 never called.

  If I just do:

 Router top = new Router(getContext());
 top.attach(/users/{username}, UserResource.class);

  My resource is called, but of course I get no guard.

  It appears that I cannot have a guard and a resource at the same url.


  Barrie Selack
  Rite Aid Corporation


  -Original Message-


 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Adam Rosien
  Sent: Monday, April 07, 2008 12:03 PM
  To: discuss@restlet.tigris.org
  Subject: Re: Authentication Helper/Guard help

  You don't have to change the URL.  The Guard wraps the Resource
  attached at that URL.

  .. Adam

  On Mon, Apr 7, 2008 at 6:58 AM, Barrie Selack [EMAIL PROTECTED] wrote:
   Rhett,
  
Thanks, that fills in one of the gaps.
  
So, if I understand correctly, if I have a url:
  
/users/bselack that maps to resource: UserResource
  
And I want it to be secured, then I'd need to assign the guard and add 
 attach it at /secure
  
So my final url would be /secure/users/bselack
  
Is that correct? If so, can it be done without adding the /secure to the 
 front of the url?
  
I really don't want to have an addition to the url as if I have different 
 security methods, I don't want to have different prefixes.
  
Regards,
Barrie Selack
Rite Aid Corporation
  
  
  
  
-Original Message-
From: Rhett Sutphin [mailto:[EMAIL PROTECTED] On Behalf Of Rhett Sutphin
Sent: Sunday, April 06, 2008 7:35 PM
To: discuss@restlet.tigris.org
Subject: Re: Authentication Helper/Guard help
  
Hi Barrie,
  
Restlet is the base class for all the stateless request handling
aspects of the framework, including Router and Guard.  Resource is the
base class for the stateful handling of a single request.  The
configured restlets determine which Resource winds up handling a
particular request, based on the URI, the headers, etc.  Restlets may
also respond to requests themselves (e.g., a Guard will respond with
401 status if authentication is required).
  
The specific ordering of the restlets is going to depend on your
particular situation.  If you want to secure everything with the same
Guard, it might go like this (pseudocode):
  
Guard g = new Guard(...)
Router r = new Router(...)
r.attach(...)
// etc.
g.setNext(r)
  
Or if you want to only secure some things, you might do it like this:
  
Router top = new Router(...)
top.attach(/insecure, InsecureResource.class)
Guard g = new Guard(...)
Router secureRouter = new Router(...)
secureRouter.attach(/a, SecureResource.class)
g.setNext(secureRouter)
top.attach(/secure, g)
  
If it's still unclear, take a look at the API documentation for
Restlet and its subclasses.
  
HTH,
Rhett
  
On Apr 6, 2008, at 5:46 PM, Barrie Selack wrote:
 Rhett,

 Thanks. I've been through all the examples and tutorials. But I'm
 lost on the relationship of Restlet, Router, Resource, Guard, etc.
 The tutorial attaches Guards to a Restlet, but I'm attaching
 Resources to a Route (which is also show later in the tutorials, but
 not in the context of a Guard).

 Maybe I have the concept mixed up. Can a Resource be secured by an
 Authentication method? The tutorial doesn't seem to show that. Am am
 mixing the wrong components to get to my solution?

 So i guess the questions is... where am I having the disconnect (in
 my mind) of how the pieces fit together.

 Regards,
 Barrie

 
 From: Rhett Sutphin [EMAIL PROTECTED] On Behalf Of Rhett
 Sutphin [EMAIL PROTECTED]
 Sent: Sunday, April 06, 2008 5:33 PM
 To: discuss@restlet.tigris.org
 Subject: Re: Authentication Helper/Guard help

 Hi 

Re: How do I switch off log output?

2008-04-08 Thread Rob Heittman
After musing about this for a few hours, I wonder if the core of the
frustration is the lack of any standard way for a Java component vendor to
expose artifacts that communicate (at a machine-understandable level)

- What logging framework the component uses
- What logging keys or properties are useful to configure
- What configurations are recommended for development and production use (or
other named or well-known use cases)

It would be nice to be able to have utilities, perhaps even IDE support,
that could look at the components on the classpath and use such artifacts to
present you with a recommended logging configuration for a given use case.
Then you could actually enjoy the flexibility and sophistication offered by
the various logging mechanisms, instead of being frustated by hours of
archaeology.

I guess I am thinking of an approach like Maven but for logging instead of
building.  Does this exist already?

Yes, I will stop polluting Restlet with noise now.

- Rob


Re: How do I switch off log output?

2008-04-08 Thread Michael McCallum
sfl4j in a nutshell...

you write all your code and all the libraries write code againsts a simple 
api.. which has not deps and no implementation

when someone decides they actually wish to run the code and log the results 
they choose the implementation - be that logback, juli, log4j etc etc - that 
works for their deployment

its solves all of the problems

There is a OOTB adapter to turn commons logging calls into slf4j for further 
adaptation into the chose logging implementation

The only caveat I've found so far is that there is no elegant way to adapt 
juli as you must override the implementation in the system classpath which 
reeks havoc with containers... but maybe i'm missing something simple


Re: Serving PDF content

2008-04-08 Thread Avi Flax
On Wed, Mar 26, 2008 at 3:03 PM, Jerome Louvel [EMAIL PROTECTED] wrote:

  Hi Avi,

  Why don't you try using an InputRepresentation instead? It is a concrete
  class, you just need to pass an InputStream (ex: ByteArrayInputStream).

Thanks Jerome, that's perfect. For some reason I missed that class, or
thought it was abstract, or something.

-- 
Avi Flax » Partner » Compulsive Technologist » Arc90 » http://arc90.com


Re: StackOverFlow warning

2008-04-08 Thread William Pietri

Bao,Sam wrote:
I'm sorry, but I don't set up the template at all.  Is that where I'm 
going wrong?  Should I be setting a template?
 
I'm just using createRoot() to init the router, and register my 
resource as such:
 
* *


*public* *synchronized* Restlet createRoot()

{

Router router = *new* Router(getContext());

router.attach(/result, ResultResource.*class*);

router.attach(/result/{id}, ResultResource.*class*);

router.attach(/result?{method}, ResultResource.*class*);



I'm no expert, but have you tried removing  the {id} and {method} 
bits, and just parsing the URL yourself instead of using Router to 
extract the attributes? From my hazy memory of the routing stuff, that 
might work better for you, and would be less of a distortion to your app 
design until this bug is fixed.


I do agree that it's a bug, though; a 1500-character URL is big, but not 
unreasonably so.


William


RE: Re: StackOverFlow warning

2008-04-08 Thread Bao,Sam
Ah, that seems to get through all the template stuff, and at that point, I can 
indeed extract the attributes myself.  I agree it's a roundabout way to do it 
instead of using the router functionality, but no more hackish than using the 
post to do a get.  I'll keep going down this path and see what happens.  thanks.
 

Sam Bao | Software Engineer | Cerner Corporation | 816.201.8242 | [EMAIL 
PROTECTED] mailto:[EMAIL PROTECTED]  | www.cerner.com 
http://www.cerner.com/  

 



From: William Pietri [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 08, 2008 6:15 PM
To: discuss@restlet.tigris.org
Subject: Re: StackOverFlow warning


Bao,Sam wrote: 

I'm sorry, but I don't set up the template at all.  Is that where I'm 
going wrong?  Should I be setting a template?
 
I'm just using createRoot() to init the router, and register my 
resource as such:
 
public synchronized Restlet createRoot()

{

Router router = new Router(getContext());

router.attach(/result, ResultResource.class);

router.attach(/result/{id}, ResultResource.class);

router.attach(/result?{method}, ResultResource.class);


I'm no expert, but have you tried removing  the {id} and {method} bits, and 
just parsing the URL yourself instead of using Router to extract the 
attributes? From my hazy memory of the routing stuff, that might work better 
for you, and would be less of a distortion to your app design until this bug is 
fixed.

I do agree that it's a bug, though; a 1500-character URL is big, but not 
unreasonably so.

William

--
CONFIDENTIALITY NOTICE This message and any included attachments are from 
Cerner Corporation and are intended only for the addressee. The information 
contained in this message is confidential and may constitute inside or 
non-public information under international, federal, or state securities laws. 
Unauthorized forwarding, printing, copying, distribution, or use of such 
information is strictly prohibited and may be unlawful. If you are not the 
addressee, please promptly delete this message and notify the sender of the 
delivery error by e-mail or you may call Cerner's corporate offices in Kansas 
City, Missouri, U.S.A at (+1) (816)221-1024.

Small glitch in Freemarker dependency?

2008-04-08 Thread Konstantin Läufer
Hi,

The org.restlet.ext.freemarker 1.1-M3 dependency on Freemarker reads as
follows:

  dependency
 groupIdfreemarker/groupId
 artifactIdfreemarker/artifactId
 version2.3.11/version
  /dependency

However, there is no corresponding entry in the official Maven repository,
and one has to install the Freemarker jar manually. I believe this
dependency should be changed to

  dependency
 groupIdorg.freemarker/groupId
 artifactIdfreemarker/artifactId
 version2.3.11/version
  /dependency

In addition, the version could be changed to 2.3.12.

Thanks,

Konstantin