I'm trying to get the response from a REST service from my GWTP presenter. My securityDelegate trigger onSuccess method but the UserDTO seems to be empty. The network tool show me the request with HTTP code 200 and the response with current user. For some reason the UserDTO seems to be empty.
The LOGGER show me
CLASS:xx.xxxx.xxx.web.shared.dto.UserDTO@1f
Name:undefined
//LoginPresenter.java
securityDelegate.withCallback(new AsyncCallback<UserDTO>() {
@Override
public void onFailure(Throwable throwable) {
Window.alert("fail");
}
@Override
public void onSuccess(UserDTO user) {
LOGGER.info("CLASS:"+user.toString());
LOGGER.info("Name:"+user.getName());
}
}).authenticate(username,password);
//SecurityResource.java
@Path("/security")
@Produces (MediaType.APPLICATION_JSON)
@Consumes (MediaType.APPLICATION_JSON)
public interface SecurityResource {
@POST
@Path ("/authenticate")
RestAction<UserDTO> authenticate(@HeaderParam ("username") String username,@HeaderParam("password") String password);
}
//SecurityResourceImpl.java
@Path ("/security")
@Produces(MediaType.APPLICATION_JSON)
@Consumes (MediaType.APPLICATION_JSON)
public class SecurityResourceImpl {
@EJB
private SecurityBean securityBean;
@POST
@Path("/authenticate")
@Override
public Response authenticate(@HeaderParam ("username")
String username, @HeaderParam("password") String password){
User currentUser = securityBean.find(username,password);
return Response.ok().entity(new UserDTO(currentUser)).build();
}
}
//UserDTO.java
public class UserDTO implements Serializable {
private String name;
public UserDTO(){
}
public UserDTO(User user){...}
//getters/setters
}