@GET @Path("{userId}/reminders") public Response getAllReminders(@PathParam("userId") final String userId) { final List<Reminder> reminders = reminderDao.getAllReminders(userId); ReminderPage reminderPage = new ReminderPage(0, reminders.size(), reminders); return Response.ok().entity(reminderPage).build(); }
@GET @Path("{userId}/reminders/{reminderId}") public Response getReminder( @PathParam("userId") final String userId, @PathParam("reminderId") final String reminderId) { Reminder reminder = reminderDao.getReminder(reminderId); return Response.ok().entity(reminder).build(); }
@DELETE @Path("{userId}/reminders/{reminderId}") public Response deleteReminder( @PathParam("userId") final String userId, @PathParam("reminderId") final String reminderId) { reminderDao.deleteReminder(reminderId); return Response.ok().build(); }
@PUT @Path("{userId}/reminders/{reminderId}") public Response updateReminder( Reminder reminder, @PathParam("userId") final String userId, @PathParam("reminderId") final String reminderId) { Reminder updatedReminder = reminderDao.updateReminder(reminderId, reminder); return Response.ok().entity(updatedReminder).build(); }
@POST @Path("{userId}/reminders") public Response createReminder( Reminder reminder, @PathParam("userId") final String userId, @QueryParam(REMINDER_ABOUT_QPARM) final String reminderAbout, @QueryParam(CREATED_BY_QPARAM) final String createdBy) { setReminderCreateProperties(reminder); Reminder createdReminder = reminderDao.createReminder(reminder); User reminderForUser = userDao.getUser(userId); Long currentTime = System.currentTimeMillis(); ReminderRelationShip reminderRelationShip = new ReminderRelationShip( createdBy, currentTime, reminderForUser, currentTime, reminderAbout, reminder); userDao.setReminder(reminderRelationShip); return Response.created(null).entity(createdReminder).build(); }