示例#1
0
 @Override
 public void markForCleanup(long accountId) {
   AccountVO account = findByIdIncludingRemoved(accountId);
   if (!account.getNeedsCleanup()) {
     account.setNeedsCleanup(true);
     if (!update(accountId, account)) {
       s_logger.warn("Failed to mark account id=" + accountId + " for cleanup");
     }
   }
 }
示例#2
0
  @Override
  public void saveAccounts(List<AccountVO> accounts) {
    Transaction txn = Transaction.currentTxn();
    try {
      txn.start();
      String sql = INSERT_ACCOUNT;
      PreparedStatement pstmt = null;
      pstmt =
          txn.prepareAutoCloseStatement(
              sql); // in reality I just want CLOUD_USAGE dataSource connection
      for (AccountVO acct : accounts) {
        pstmt.setLong(1, acct.getId());
        pstmt.setString(2, acct.getAccountName());
        pstmt.setShort(3, acct.getType());
        pstmt.setLong(4, acct.getDomainId());

        Date removed = acct.getRemoved();
        if (removed == null) {
          pstmt.setString(5, null);
        } else {
          pstmt.setString(
              5, DateUtil.getDateDisplayString(TimeZone.getTimeZone("GMT"), acct.getRemoved()));
        }

        pstmt.setBoolean(6, acct.getNeedsCleanup());

        pstmt.addBatch();
      }
      pstmt.executeBatch();
      txn.commit();
    } catch (Exception ex) {
      txn.rollback();
      s_logger.error("error saving account to cloud_usage db", ex);
      throw new CloudRuntimeException(ex.getMessage());
    }
  }