On 26/10/2015 13:20, Massimiliano Perrone wrote:
Good morning Syncopers,
working with org.apache.syncope.common.rest.api.service.UserService
interface I had a doubt about the response parameter of some methods.
For instance, the two methods [1] and [2] returns a Response object as
response, why not the respective username or long id value?
Also because, to get the requested information, I need to take it from
the header of the response.... (see [3] or [4]).
There was a discussion about this specific point at the time that we
migrated to CXF / JAX RS 2.0, you should be able to find it in the archives.
The technical point is that JAX RS methods cannot return plain values
(long, string, ..) since JAXB always require some wrapping - and we need
JAXB in order to deal with both JSON and XML payloads transparently.
The best-practice rationale is that the two operations mentioned above
were more logically mapped to HTTP OPTIONS rather than complete GET.
Regards.
[1] Response getUsername(@NotNull @PathParam("key") Long key);
[2] Response getUserKey(@NotNull @PathParam("username") String username);
[3]
userService.getUsername(Long.valueOf(input.firstParameter())).getHeaderString(RESTHeaders.USERNAME)
[4]
userService.getUserKey(input.firstParameter()).getHeaderString(RESTHeaders.USER_KEY);