Package com.changestuffs.server.utils

Examples of com.changestuffs.server.utils.UserBeanOAM


  @Validate
  public SendInvitationResult execute(@Valid SendInvitation action, ExecutionContext context) throws ActionException {
    boolean emailSent = true;
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    UserBeanOAM oam = provider.get();
    User newUser = new User(action.getEmail(), UserBeanOAM.AUTH_DOMAIN_NOT_REGISTERED, new BigInteger(130, random).toString(32));
    InfoLoginResult result = oam.persistUser(null, newUser, user.getEmail(), user.getEmail());
    if(result.isSendEmail()){
      try {
        String token = result.getToken();
        sendEmail(user.getEmail(), newUser.getEmail(), token);
      } catch (MessagingException|IOException e) {
View Full Code Here


  @Override
  public UpdateUserInfoResult execute(UpdateUserInfo action,
      ExecutionContext context) throws ActionException {
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    UserBeanOAM oam = provider.get();
    oam.updateUser(action, user.getEmail());
    return new UpdateUserInfoResult();
  }
View Full Code Here

  public void manage(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    ChannelService channelService = ChannelServiceFactory.getChannelService();
    ChannelPresence presence = channelService.parsePresence(req);
    String email = presence.clientId();
    UserBeanOAM oam = provider.get();
    oam.updateOnline(isOnline(), email);
    GetUserInfoResult result = oam.getGetUserInfoResult(email);
    for(String online : result.getOnline()){
      log.info(email+" is online = "+isOnline()+". Sending message to "+online);
      channelService.sendMessage(new ChannelMessage(online, getJson(email, online)));
    }
  }
View Full Code Here

  public void manage(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    if(user!=null){
      log.info("User is "+user);
          UserBeanOAM oam = provider.get();
          oam.persistUser(new Date(), user, req.getRemoteAddr(), null);
    }
    StringBuilder builder = new StringBuilder(UrlUtils.getBaseURL(req.getRequestURL().toString(), req.getRequestURI())).append("?");
    @SuppressWarnings("unchecked")
    Map<String,String[]> params = req.getParameterMap();
    boolean first=true;
View Full Code Here

  @Override
  public RemoveContactResult execute(@Valid RemoveContact action,
      ExecutionContext context) throws ActionException {
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    UserBeanOAM oam = provider.get();
    oam.removeContact(user.getEmail(), action.getEmail(), action.isPending());
    // Pending contacts exists only in one user, but contacts in two
    if(!action.isPending()){
      oam.removeContact(action.getEmail(), user.getEmail(), false);
      String json = toJson.getJson(null, user.getEmail(), MessageType.removeContact);
      ChannelService channelService = ChannelServiceFactory.getChannelService();
      channelService.sendMessage(new ChannelMessage(action.getEmail(), json));
    }
    return new RemoveContactResult();
View Full Code Here

  public AddFriendResult execute(@Valid AddFriend action,
      ExecutionContext context) throws ActionException {
    boolean result = false;
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    UserBeanOAM oam = provider.get();
    result = oam.addFriend(user.getEmail(), action.getEmail());
    // And the other has the same friend
    oam.addFriend(action.getEmail(), user.getEmail());
   
    String json = toJson.getJson(null, user.getEmail(), MessageType.addContact);
    ChannelService channelService = ChannelServiceFactory.getChannelService();
    channelService.sendMessage(new ChannelMessage(action.getEmail(), json));
    return new AddFriendResult(result);
View Full Code Here

  public GetUserInfoResult execute(GetUserInfo action, ExecutionContext context)
      throws ActionException {
    GetUserInfoResult result = null;
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    UserBeanOAM oam = provider.get();
    GetUserInfoResult myInfo = oam.getGetUserInfoResult(user.getEmail());
    if(action.getEmail() != null){
      if(myInfo.getFriends().contains(action.getEmail())){
        result = oam.getGetUserInfoResult(action.getEmail());
      }else{
        throw new IllegalArgumentException(action.getEmail()+" isn't friend of "+user.getEmail());
      }
    }else{
      result = myInfo;
View Full Code Here

  @Override
  @Logued
  public IsOnlineResult execute(IsOnline action, ExecutionContext context)
      throws ActionException {
    UserBeanOAM oam = provider.get();
    Set<String> emails = new HashSet<String>();
    emails.add(action.getEmail());
    return new IsOnlineResult(oam.getOnline(emails).contains(action.getEmail()));
  }
View Full Code Here

  @Override
  public void manage(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    String token = req.getParameter(RequestParams.token.name());
    log.info("Cancelling userId = "+token);
    UserBeanOAM oam = provider.get();
    String email = oam.updateNotify(token, false);
    log.info("Cancelling userId = "+token+". He is "+email);
    StringBuilder builder = new StringBuilder(UrlUtils.getBaseURL(req.getRequestURL().toString(), req.getRequestURI())).append("?#").append(NameTokens.dontNotify);
    log.info("Redirecting to "+builder.toString());
    resp.sendRedirect(builder.toString());
  }
View Full Code Here

  }
 
  @Test
  public void inviteAndRegister() throws ActionException, IOException{
    final String ravenWasInvitedBy = "the@owner.com";
    UserBeanOAM oam = injector.getInstance(UserBeanOAM.class);
    com.google.appengine.api.users.User user = new com.google.appengine.api.users.User(email, UserBeanOAM.AUTH_DOMAIN_NOT_REGISTERED, "anyUserId");
    oam.persistUser(new Date(0), user, ravenWasInvitedBy, ravenWasInvitedBy);
   
   
    RedirectImpl register = injector.getInstance(RedirectImpl.class);
   
    HttpServletRequest req = mock(HttpServletRequest.class);
View Full Code Here

TOP

Related Classes of com.changestuffs.server.utils.UserBeanOAM

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.