Ejemplo n.º 1
0
  /** Starts thread to update user state cache used by the Outlook plugin */
  public void startStateCacheUpdate(
      final Customer customer,
      final int transitionId,
      final CustomerState newState,
      final Latch dbLatch,
      ThreadMonitor threadMonitor) {
    Thread thd =
        new Thread(
            new Runnable() {
              public void run() {
                // TODO:  Use EEngine.
                updateStateCache(customer, transitionId, newState, dbLatch);
              }
            },
            "State cache update " + transitionId);
    thd.start();

    if (threadMonitor != null && CustomerState.ACTIVE.equals(newState)) {
      try {
        threadMonitor.addThread(thd);
      } catch (IllegalArgumentException iae) {
        LOGGER.warn("failed to add (null) thread to monitor?", iae);
      }
    }
  }
Ejemplo n.º 2
0
  // Use this to set headers that are required on all responses.
  protected void setResponseHeaders(
      ActionForm actionForm, HttpServletResponse response, UserAccount user, Device device)
      throws IOException {

    // The url is static across all devices in a customer.
    ICustomerManager customerManager = ManagementContainer.getInstance().getCustomerManager();
    Customer cust = customerManager.getCustomer(user.getCustomerID());
    IRimManager rimManager = ManagementContainer.getInstance().getRimManager();
    String cappUrl = cust.getCappUrl();
    if (m_devDebug) { // Our dev boxes use http and specifcy a port, this conflicts with the https
      // assumption of getCappUrl()
      cappUrl = "http://turbodog.austin.messageone.com:8080/";
    }

    URL url = null;
    try {
      url = new URL(cappUrl);
    } catch (MalformedURLException e) {

      LogMessageGen lmg = new LogMessageGen();
      lmg.setSubject("Bad URL");
      lmg.param(LoggingConsts.URL, cappUrl);
      lmg.param(LoggingConsts.USER_ID, device.getUserId());
      lmg.param(LoggingConsts.CUSTOMER_ID, device.getCustomerId());
      lmg.param(LoggingConsts.PIN, device.getPin());

      // This would come from the customer config, so it's bad.
      m_logCategory.error(lmg.toString(), e);
      response.setHeader(SUCCESS, "false");
      return;
    }
    int deviceCheckin =
        cust.getCapabilities().getIntCapability(Capabilities.CAP_RIM_DEVICE_PERIODIC_CHECKIN, 30);

    response.setHeader("rim-access-url-protocol", url.getProtocol());
    response.setHeader("rim-access-url-hostname", url.getHost());
    if (url.getPort() > 0) {
      response.setHeader("rim-access-url-port", Integer.toString(url.getPort()));
    }

    response.setHeader(EMS_RIM_DISPLAY_NAME, device.getDisplayName());
    response.setHeader("get-mail-path", "wfe/getRimMail.do");
    response.setHeader("send-mail-path", "wfe/sendRimMail.do");
    response.setHeader("get-display-name-path", "wfe/rimGetDisplayName.do");
    response.setHeader("checkin-path", "wfe/rimCheckin.do");

    response.setHeader("periodic-checkin", Integer.toString(deviceCheckin));

    CustomerState state = user.getUserState();
    String stateString = "ready";
    if (CustomerState.ACTIVE.equals(state) || CustomerState.TEST.equals(state)) {
      stateString = "active";

      String activationId = rimManager.getActivationId(device.getPin());
      if (StringUtils.isEmptyOrNull(activationId)) {
        // EMSDEV-4722
        // If an old agent is installed during activation, the dat_rim_user_connection_status
        // won't exist and thus no activation ID.  If needed, create one on the fly.
        // Incidently, this will fix most of the problems we've had with activationId's
        // disappearing for various reasons.
        LogMessageGen.log(
                "Old agent activationId not found; will create one on the fly", m_logCategory)
            .param(LoggingConsts.PIN, device.getPin())
            .param(LoggingConsts.USER_ID, device.getUserId())
            .info();

        activationId = rimManager.activateOldAgent(device.getPin(), device.getCustomerId());

        // Try again.
        if (StringUtils.isEmptyOrNull(activationId)) {

          LogMessageGen.log("Unable to create activationId for old agent", m_logCategory)
              .param(LoggingConsts.PIN, device.getPin())
              .param(LoggingConsts.USER_ID, device.getUserId())
              .error();
        }
      } // no activationId

      response.setHeader("activation-id", activationId);
    } // active.
    response.setHeader("application-state", stateString);

    response.setHeader(SUCCESS, "true");
  }