I've got another thing to throw in to this problem.  So our reqs changed and 
now we need to also specify a person id type in the url, e.g. 
http://localhost:8182/lastRiskEval/{personid}/{personidtype}

So how do I attach to the router so that all of these patterns would match to 
the single resource, rather than return a 404:

http://localhost:8182/lastRiskEval/
http://localhost:8182/lastRiskEval/12345
http://localhost:8182/lastRiskEval/12345/
http://localhost:8182/lastRiskEval/12345/12345

This is what I've tried:
          Route route = 
router.attach("/lastRiskEval/{personid}/{personidtype}", 
LastRiskEvaluationResource.class);
        Variable variable = new Variable(Variable.TYPE_ALL, "", false, false);
        route.getTemplate().getVariables().put("personid", variable);
        route.getTemplate().getVariables().put("personidtype", variable);

I've tried setting personid and personidtype variable to be both optional, I've 
tried setting personidtype to be the only variable optional, and I've tried 
setting personid to be the only variable optional, but no matter, the first 
example always returns a 404.  How do I match on the first example?

>Sam Bao | Software Engineer | Cerner Corporation | 816.201.8242 | [EMAIL 
>PROTECTED] | www.cerner.com

-----Original Message-----
From: Bao,Sam [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, May 13, 2008 10:55 AM
To: [email protected]
Subject: RE: Re: URI won't match what's attached to the router

Thanks Stephan,  That had been my original thought on the project, but our 
design has been trimmed so that we limit a single request to a single person 
id, as there is not usecase (yet) for wanting to retrieve info for more than 
one person. 


>Sam Bao | Software Engineer | Cerner Corporation | 816.201.8242 | 
>[EMAIL PROTECTED] | www.cerner.com

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 13, 2008 10:52 AM
To: [email protected]
Subject: Re: URI won't match what's attached to the router

Hi Sam,

you could also create a resource for /lastRiskEval (without slash at the
end) that handles the requests for the collection of persons.

best regards
   Stephan

Bao,Sam schrieb:
> Ah, I gotcha.  My previous application could match because I actually had  
> "/results/" that was attached to a resource.  In this case "/lastRiskEval/" 
> is not attached to any resource.  LastRiskEvaluationResource only supports 
> GET when given a 'personid', nothing else, so I didn't think there would be a 
> need to attach the uri pattern "/lastRiskEva/" to anything.  That makes sense 
> to me now.  Thanks.
>   
> -----Original Message-----
> From: Thierry Boileau [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 13, 2008 10:42 AM
> To: [email protected]
> Subject: Re: URI won't match what's attached to the router
>
> Hi Sam,
>
> by default a variable is supposed to "eat" at least one character. In your 
> case, the route "/lastRiskEval/{personid}" cannot match the URI 
> "/lastRiskEval/".
> Another question is what is the resource behind "/lastRiskEval/"? Does this 
> URI really correspond to a "LastRiskEvaluationResource" instance?
>
> best regards,
> Thierry Boileau
>
>   
>> I can try this, but I'm curious as to am I declaring the variable wrong?  Is 
>> the example below the proper way to do that?  Thanks. 
>>     
>> -----Original Message-----
>> From: Thierry Boileau [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, May 13, 2008 10:03 AM
>> To: [email protected]
>> Subject: Re: URI won't match what's attached to the router
>>
>> Hello Sam,
>>
>> you can update the "personid" variable in order to make it facultative:
>>
>> Route route = router.attach("/lastRiskEval/{personid}",
>> LastRiskEvaluationResource.class);
>> // You can use other Variable.TYPE_...
>> Variable variable = new Variable(Variable.TYPE_ALPHA_DIGIT, "", 
>> false, false); route.getTemplate().getVariables().put("personid",
>> variable);
>>
>> best regards,
>> Thierry Boileau
>>     
>>> I've got the following resource attached to my router:
>>>
>>>         Router router = new Router(getContext());
>>>         router.attach("/conditions", ConditionsResource.class);
>>>         router.attach("/facts", FactsResource.class);
>>>         router.attach("/risks", RisksResource.class);
>>>         router.attach("/riskEval", RiskEvaluationResource.class);
>>>         router.attach("/lastRiskEval/{personid}",
>>> LastRiskEvaluationResource.class);
>>>
>>> However, when I try to go to the LastRiskEvaluationResource without giving 
>>> it a person id, I get a 404.
>>>
>>> I'm just running the http server locally, and so the url I'm using is: 
>>> http://localhost:8182/lastRiskEval/
>>>
>>> However, I get a 404.  I traced it down to where the Decoder.handle() tries 
>>> to getNext() and doesn't find the 'next' because when getting routes, it 
>>> uses the BEST method, but never matches my URI.  I'm using 1.0.9, does 
>>> anyone have a clue on what I should try?
>>>
>>> I've had this work before on another Application where I had 
>>> "/results/{personid}" and it'd work.
>>>       

----------------------------------------------------------------------
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.

Reply via email to