Il 26/10/2015 14:02, Francesco Chicchiriccò ha scritto:
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.
Many thanks for the explanation.
Massi
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);
--
Massimiliano Perrone
Tel +39 393 9121310
Tirasa S.r.l.
Viale D'Annunzio 267 - 65127 Pescara
Tel +39 0859116307 / FAX +39 0859111173
http://www.tirasa.net
"L'apprendere molte cose non insegna l'intelligenza"
(Eraclito)