@GET @Path("{googleId}/googleId") public Response getUserByGoogleId(@PathParam("googleId") final String googleId) { User user = userDao.getUserByGoogleId(googleId); if (user == null) { return Response.status(Response.Status.NOT_FOUND) .entity( new Neo4jErrorResponse( "NOT_FOUND", "client", "User is nto found with googleId : " + googleId)) .build(); } return Response.ok().entity(user).build(); }
@POST public Response createUser( @QueryParam(ACCESS_TOKEN_QPARAM) final String accessToken, final com.campusconnect.neo4j.types.web.User userPayload) throws URISyntaxException { StringBuffer validateUserDataMessage = Validator.validateUserObject(userPayload); if (null != validateUserDataMessage) { throw new InvalidInputDataException(INVALId_ARGMENTS, validateUserDataMessage.toString()); } User user = mapUserWebToNeo4j(userPayload); if (user.getEmail() != null) { User existingUser = userDao.getUserByEmail(user.getEmail()); if (null != existingUser) { if (existingUser.getFbId() == null && user.getFbId() != null) { existingUser.setFbId(user.getFbId()); existingUser = userDao.updateUser(existingUser.getId(), existingUser); } if (existingUser.getGoogleId() == null && user.getGoogleId() != null) { existingUser.setGoogleId(user.getGoogleId()); existingUser = userDao.updateUser(existingUser.getId(), existingUser); } com.campusconnect.neo4j.types.web.User returnUser = mapUserNeo4jToWeb(existingUser); return Response.created(new URI("/users/" + returnUser.getId())).entity(returnUser).build(); } } if (user.getFbId() != null) { User existingUser = userDao.getUserByFbId(user.getFbId()); if (null != existingUser) { com.campusconnect.neo4j.types.web.User returnUser = mapUserNeo4jToWeb(existingUser); return Response.created(new URI("/users/" + returnUser.getId())).entity(returnUser).build(); } } if (user.getGoogleId() != null) { User existingUser = userDao.getUserByGoogleId(user.getGoogleId()); if (null != existingUser) { com.campusconnect.neo4j.types.web.User returnUser = mapUserNeo4jToWeb(existingUser); return Response.created(new URI("/users/" + returnUser.getId())).entity(returnUser).build(); } } addPropertiesForCreate(user); User createdUser = userDao.createUser(user, accessToken); com.campusconnect.neo4j.types.web.User returnUser = mapUserNeo4jToWeb(createdUser); return Response.created(new URI("/users/" + returnUser.getId())).entity(returnUser).build(); }