Exemplo n.º 1
0
 @POST
 @Path("{userId}/follow/{followUserId}")
 public Response follow(
     @PathParam("userId") final String userId,
     @PathParam("followUserId") final String followUserId) {
   userDao.createFollowingRelation(userDao.getUser(userId), userDao.getUser(followUserId));
   return Response.ok().build();
 }
Exemplo n.º 2
0
 @POST
 @Path("{userId}/friend/{friendUserId}")
 public Response addFriend(
     @PathParam("userId") final String userId,
     @PathParam("friendUserId") final String friendUserId) {
   userDao.createFriendRelationWithPending(userDao.getUser(userId), userDao.getUser(friendUserId));
   return Response.ok().build();
   //  return null;
 }
Exemplo n.º 3
0
  @PUT
  @Path("{userId}/friend/{friendUserId}")
  public Response confirmFriend(
      @PathParam("userId") final String userId,
      @PathParam("friendUserId") final String friendUserId,
      @QueryParam(STATUS_QPARAM) final String status) {
    if (status.toLowerCase().equals("agreed")) {
      userDao.confirmFriendRelation(userDao.getUser(userId), userDao.getUser(friendUserId));
      // TODO:notification to user about acceptance

    } else if (status.toLowerCase().equals("cancel")) {
      userDao.deleteFriendRequest(userId, friendUserId, Constants.FRIEND_REQUEST_CANCEL_DELETE);
    }
    return Response.ok().build();
  }
Exemplo n.º 4
0
 @GET
 @Path("{userId}")
 public Response getUser(@PathParam("userId") final String userId) {
   User user = userDao.getUser(userId);
   com.campusconnect.neo4j.types.web.User returnUser = mapUserNeo4jToWeb(user);
   return Response.ok().entity(returnUser).build();
 }
Exemplo n.º 5
0
 @PUT
 @Path("{userId}/fields")
 public Response updateUserFields(@PathParam("userId") final String userId, Fields fields)
     throws Exception {
   // todo: validate passed fields are valid or not
   User user = userDao.getUser(userId);
   setUpdatedFields(user, fields);
   user.setLastModifiedDate(System.currentTimeMillis());
   User updatedUser = userDao.updateUser(userId, user);
   checkWhetherSynchIsNeeded(updatedUser, fields);
   com.campusconnect.neo4j.types.web.User returnUser = mapUserNeo4jToWeb(updatedUser);
   return Response.ok().entity(returnUser).build();
 }
Exemplo n.º 6
0
  @POST
  @Path("{userId}/addresses")
  public Response addAddress(
      @PathParam("userId") String userId,
      com.campusconnect.neo4j.types.web.Address addressPayload) {
    Address address = mapAddressWebToNeo4j(addressPayload);
    User user = userDao.getUser(userId);
    // create new address
    Address createdAddress = addressDao.createAddress(address, userId);
    // Link to user
    userDao.addAddressToUser(createdAddress, user);

    com.campusconnect.neo4j.types.web.Address returnAddress = mapAddressNeo4jToWeb(createdAddress);
    return Response.ok().entity(returnAddress).build();
  }
Exemplo n.º 7
0
 @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();
 }
Exemplo n.º 8
0
 @POST
 @Path("{userId}/goodreads/synch")
 public Response synchGoodreads(@PathParam("userId") final String userId) throws Exception {
   initiateGoodreadsSynch(userDao.getUser(userId));
   return Response.ok().build();
 }