Пример #1
0
  @GET
  @Path("entrante")
  @Produces(MediaType.APPLICATION_JSON)
  public List<Message> mensajesRecibido(
      @QueryParam("nombreUsuario") String nombreUsuario, @QueryParam("imei") String imei) {

    List<Message> mensajes = null;

    if (autenticar(nombreUsuario, imei)) {
      ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(server);
      MessageService mensajeService =
          (MessageService) ctx.getBean(MessageService.class.getSimpleName());
      System.out.println("ingeso");
      mensajes = mensajeService.findByImei(nombreUsuario, imei);
      mensajeService.setEnviado(mensajes, ctx);
    } else {
      throw new NotAuthorizedException();
    }

    return mensajes;
  }
Пример #2
0
 @GET
 @Path("ackRecibido")
 @Produces(MediaType.APPLICATION_JSON)
 public boolean ackMensaje(
     @QueryParam("nombreUsuario") String nombreUsuario,
     @QueryParam("imei") String imei,
     @QueryParam("idMensaje") Integer idMensaje) {
   if (autenticar(nombreUsuario, imei)) {
     ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(server);
     MessageService mensajeService =
         (MessageService) ctx.getBean(MessageService.class.getSimpleName());
     try {
       mensajeService.mensajeRecibido(idMensaje, ctx);
     } catch (PendienteEnvioException e) {
       throw e;
     }
   } else {
     throw new NotAuthorizedException();
   }
   return true;
 }