Hi Fabio,
> -----Original Message-----
> From: Fabio Martelli [mailto:[email protected]]
> Sent: Donnerstag, 7. Februar 2013 11:04
> To: [email protected]
> Subject: Add a new method into the PolicyService
>
> Hi All,
> I have to add a new rest method to retrieve sync policy correlation rules.
> As you can see this info is just related to the sync policies.
>
> Since the PolicyService take the policy type as part of the path
> (@Path("policies/{type}")) how do you suggest to introduce a client method
> to retrieve this info?
> Should I do something like the following
>
> @GET
@Path("correlationRules")
> List<String> getCorrelationRules(@PathParam("type") PolicyType type);
>
> throwing an IllegalArgumentException in case of password or account type?
Since PolicyType is part of the URL and not part of a POST body, I would
suggest to rather throw a NotFoundException. This way a user will just get
notified that there are no correlationRules available for any other kind of
policy. (Caller doesn't need to know which part of the URL is mapped to a
parameter, thus I think not found fits better in this case.)
Please be aware of my sample above to insert a @Path annotation. Otherwise you
will have two methods for the same URL pattern (in this case list operation).
Of course you can also use @Path("rules") if you like to shorten URL a little
bit. Here is a sample of how the complete URL will look like:
http://localhost:9080:/syncope/policies/sync/rules --> This will call your
method
http://localhost:9080:/syncope/policies/password/rules --> 404 NotFound
http://localhost:9080:/syncope/policies/xyzABC/rules --> 404 NotFound
http://localhost:9080:/syncope/policies/sync/someURL --> 404 NotFound
http://localhost:9080:/syncope/policies/sync --> Returns list of available sync
policies
>
> What are the best practices for this scenario?
Throw IllegalArgumentException if payload if message is corrupt
and throw NotFoundException if URL does not match a valid useCase.
Best regards.
Jan
>
> Best regards,
> F.