// ------------------------------
  private void initialize(
      String user, String hashed_password, String userIp, HttpServletResponse res)
      throws Exception {

    sessionId_m =
        HtCommandProcessor.instance()
            .get_HtSecurityProxy()
            .remote_startUserSessionWithHashedPassword(user, hashed_password, userIp);

    if (sessionId_m == null) {
      throw new HtException(getContext(), "initialize", "Invalid user or password");
    }

    for (int i = 0; i < eventTypes_m.size(); i++) {
      RtGlobalEventManager.instance()
          .resolveListenerThread(RtGlobalEventManager.instance().MAIN_THREAD)
          .subscribeForEvent(eventTypes_m.get(i), 30, this);
    }

    // push event
    XmlEvent syncevent = new XmlEvent();
    syncevent.setEventType(XmlEvent.ET_SynchronizationEvent);
    RtGlobalEventManager.instance().pushCommonEvent(syncevent);

    // here we need to wait until the pending event will come through database layer to make sure
    // that we can select all data
    HtCommandProcessor.instance()
        .get_HtDatabaseProxy()
        .remote_waitDatabaseManagerWritePendingEvents(
            syncevent.getSequenceNumber(), WAIT_DB_PEND_EVENTS_SEC);
  }