Example #1
0
 private Map<String, Object> getHeadersForAddingBook(String status) {
   Map<String, Object> properties = new HashMap<>();
   properties.put("createdDate", System.currentTimeMillis());
   properties.put("status", status);
   properties.put("lastModifiedDate", System.currentTimeMillis());
   return properties;
 }
Example #2
0
 private Map<String, Object> getRequiredHeadersForAccess(String createdBy, String role) {
   Map<String, Object> properties = new HashMap<>();
   properties.put("createdBy", createdBy);
   properties.put("createdDate", System.currentTimeMillis());
   properties.put("role", role);
   return properties;
 }
Example #3
0
 @PUT
 @Path("{userId}")
 public Response updateUser(
     @PathParam("userId") final String userId,
     com.campusconnect.neo4j.types.web.User userPayload) {
   User user = mapUserWebToNeo4j(userPayload);
   user.setLastModifiedDate(System.currentTimeMillis());
   User updatedUser = userDao.updateUser(userId, user);
   com.campusconnect.neo4j.types.web.User returnUser = mapUserNeo4jToWeb(updatedUser);
   return Response.ok().entity(returnUser).build();
 }
Example #4
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();
 }
Example #5
0
 private void setUpdatedFields(User user, Fields fields) throws Exception {
   ObjectMapper objectMapper = new ObjectMapper();
   for (Field field : fields.getFields()) {
     BeanUtils.setProperty(user, field.getName(), field.getValue());
   }
   Long currentTime = System.currentTimeMillis();
   String targetUserId = user.getId();
   String targetUserName = objectMapper.writeValueAsString(fields);
   String targetUrl = null;
   Target target = new Target(IdType.USER_ID.toString(), targetUserName, targetUrl);
   Event followedUSerEvent =
       new Event(AuditEventType.USER_UPDATED.toString(), target, currentTime, false);
   auditEventDao.addEvent(targetUserId, followedUSerEvent);
 }
Example #6
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();
 }
Example #7
0
 private void setReminderCreateProperties(Reminder reminder) {
   Long currentTime = System.currentTimeMillis();
   reminder.setCreatedDate(currentTime);
   reminder.setLastModifiedTime(currentTime);
 }
Example #8
0
 private Map<String, Object> getRequiredHeadersForAddressLink(String addressType) {
   Map<String, Object> properties = new HashMap<>();
   properties.put("createdDate", System.currentTimeMillis());
   properties.put("type", addressType);
   return properties;
 }
Example #9
0
 private void addPropertiesForCreate(User user) {
   final Long createdDate = System.currentTimeMillis();
   user.setCreatedDate(createdDate);
   user.setLastModifiedDate(createdDate);
   user.setGoodreadsAuthStatus(GoodreadsAuthStatus.NONE.toString());
 }