示例#1
0
  public CacheFileNames getCacheFileNames(final UserAccount user) {

    SecureHashKeyResult toRet =
        executeWithConnection(
            new ConnectionExecuteFunction<SecureHashKeyResult>() {
              public SecureHashKeyResult execute(Connection c) throws SQLException {
                return getSecureHashKey(user, c);
              }
            });

    if (toRet == null) {
      // A DB error should have been logged.
      return null;
    }

    // EMSDEV-7854.  Signal file manipulation is done outside of a DB transaction.
    String stateFile = null;
    String newmailFile = null;
    ClientHashSupport hash = null;
    byte[] key = toRet.getKey();
    if (key != null) {
      hash = new ClientHashSupport();
      hash.setCustomerId(user.getCustomerID());
      hash.setHashKey(key);
      hash.setUserId(user.getUserID());
      hash.getStateCachePath();
      hash.setLastActivationId(user.getLastActivationId());

      // Lines below don't hit the spindle.
      File stateFileF = new File(getCacheBase(), hash.getStateCachePath());
      stateFile = stateFileF.getAbsolutePath();

      File newmailFileF = new File(getCacheBase(), hash.getNewMailCachePath());
      newmailFile = newmailFileF.getAbsolutePath();

      if (toRet.isJustCreated()) {
        // If Webmail doesn't find the signal file, it polls the database,
        // so ensure the files are there.
        updateSignalFiles(hash, user.getUserState(), user.isDeleted());
      }
    }
    return new CacheFileNames(stateFile, newmailFile);
  }