예제 #1
0
  @Override
  public List<String> getPendingChatRoomUser() {
    updateSessionManager();
    String user = getThreadLocalRequest().getRemoteUser();
    List<String> pendingRooms = new ArrayList<String>();

    if (user != null) {
      int countCycle = 0;

      // Persistence connection = DELAY * CYCLES
      do {
        pendingRooms = manager.getPendingChatRoomUser(user);
        countCycle++;

        try {
          Thread.sleep(DELAY);
        } catch (InterruptedException e) {
          // Ignore
        }
      } while (pendingRooms.isEmpty()
          && (countCycle < CYCLES)
          && manager.getLoggedUsers().contains(user));
    }

    return pendingRooms;
  }
예제 #2
0
  @Override
  public List<String> getPendingMessage(String room) throws OKMException {
    updateSessionManager();
    String user = getThreadLocalRequest().getRemoteUser();
    List<String> pendingMessages = new ArrayList<String>();

    try {
      if (user != null) {
        int countCycle = 0;

        // Persistence connection = DELAY * CYCLES
        do {
          pendingMessages = manager.getPendingMessage(user, room);
          countCycle++;

          try {
            Thread.sleep(DELAY);
          } catch (InterruptedException e) {
            // Ignore
          }
        } while (pendingMessages.isEmpty()
            && (countCycle < CYCLES)
            && manager.getLoggedUsers().contains(user));
      }
    } catch (PrincipalAdapterException e) {
      log.error(e.getMessage(), e);
      throw new OKMException(
          ErrorCode.get(ErrorCode.ORIGIN_OKMChatService, ErrorCode.CAUSE_PrincipalAdapter),
          e.getMessage());
    }

    return pendingMessages;
  }
예제 #3
0
  @Override
  public void logout() throws OKMException {
    updateSessionManager();
    String user = getThreadLocalRequest().getRemoteUser();

    if (user != null) {
      manager.logout(user);
    }
  }
예제 #4
0
 @Override
 public void addUserToChatRoom(String room, String user) throws OKMException {
   updateSessionManager();
   try {
     manager.addUserToChatRoom(user, room);
   } catch (PrincipalAdapterException e) {
     log.error(e.getMessage(), e);
     throw new OKMException(
         ErrorCode.get(ErrorCode.ORIGIN_OKMChatService, ErrorCode.CAUSE_PrincipalAdapter),
         e.getMessage());
   }
 }
예제 #5
0
 @Override
 public String createNewChatRoom(String user) throws OKMException {
   updateSessionManager();
   try {
     String actualUser = getThreadLocalRequest().getRemoteUser();
     return manager.createNewChatRoom(actualUser, user);
   } catch (PrincipalAdapterException e) {
     log.error(e.getMessage(), e);
     throw new OKMException(
         ErrorCode.get(ErrorCode.ORIGIN_OKMChatService, ErrorCode.CAUSE_PrincipalAdapter),
         e.getMessage());
   }
 }
예제 #6
0
  @Override
  public List<String> getUsersInRoom(String room) throws OKMException {
    updateSessionManager();

    try {
      return manager.getUsersInRoom(room);
    } catch (PrincipalAdapterException e) {
      log.error(e.getMessage(), e);
      throw new OKMException(
          ErrorCode.get(ErrorCode.ORIGIN_OKMChatService, ErrorCode.CAUSE_PrincipalAdapter),
          e.getMessage());
    }
  }
예제 #7
0
  @Override
  public void closeRoom(String room) throws OKMException {
    updateSessionManager();
    String user = getThreadLocalRequest().getRemoteUser();

    try {
      if (user != null) {
        manager.closeRoom(user, room);
      }
    } catch (PrincipalAdapterException e) {
      log.error(e.getMessage(), e);
      throw new OKMException(
          ErrorCode.get(ErrorCode.ORIGIN_OKMChatService, ErrorCode.CAUSE_PrincipalAdapter),
          e.getMessage());
    }
  }
예제 #8
0
 @Override
 public List<GWTUser> getLoggedUsers() throws OKMException {
   List<GWTUser> users = new ArrayList<GWTUser>();
   updateSessionManager();
   try {
     for (String userId : manager.getLoggedUsers()) {
       GWTUser user = new GWTUser();
       user.setId(userId);
       user.setUsername(OKMAuth.getInstance().getName(null, userId));
       users.add(user);
     }
   } catch (PrincipalAdapterException e) {
     log.error(e.getMessage(), e);
     throw new OKMException(
         ErrorCode.get(ErrorCode.ORIGIN_OKMChatService, ErrorCode.CAUSE_PrincipalAdapter),
         e.getMessage());
   }
   return users;
 }