コード例 #1
0
 /**
  * Returns the {@link ClientConnection} that owns a viewport.
  *
  * @param userId The ID of the user who owns the connection
  * @param viewportId The ID of the viewport
  * @return The connection
  * @throws DataNotFoundException If there is no viewport with the specified ID, the connection
  *     doesn't own viewport, the user ID is invalid or if the client connection isn't owned by the
  *     specified user.
  */
 private ClientConnection getConnectionByViewportId(String userId, String viewportId) {
   ClientConnection connection = _connectionsByViewportId.get(viewportId);
   if (connection == null) {
     throw new DataNotFoundException("Unknown viewport ID: " + viewportId);
   }
   if (!Objects.equal(userId, connection.getUserId())) {
     throw new DataNotFoundException(
         "User ID " + userId + " is not associated with viewport " + viewportId);
   }
   return connection;
 }
コード例 #2
0
 /**
  * Returns the {@link ClientConnection} corresponding to a client ID.
  *
  * @param userId The ID of the user who owns the connection
  * @param clientId The client ID
  * @return The connection
  * @throws DataNotFoundException If there is no connection for the specified ID, the user ID is
  *     invalid or if the client and user IDs don't correspond
  */
 private ClientConnection getConnectionByClientId(String userId, String clientId) {
   // TODO user logins
   // ArgumentChecker.notEmpty(userId, "userId");
   ArgumentChecker.notEmpty(clientId, "clientId");
   ClientConnection connection = _connectionsByClientId.get(clientId);
   if (connection == null) {
     throw new DataNotFoundException("Unknown client ID: " + clientId);
   }
   if (!Objects.equal(userId, connection.getUserId())) {
     throw new DataNotFoundException(
         "User ID " + userId + " is not associated with client ID " + clientId);
   }
   return connection;
 }