Пример #1
0
  private Vector findUpdates(String update_type) throws Exception {
    Vector updateQueue = new Vector();

    String label = "RemsUpdater (" + new Date().toString() + ") ";
    System.out.println(label + "Checking for pending updates for eCommerce...");

    StringBuffer sqlBuf = new StringBuffer();
    String sqlFindPending = "";
    sqlBuf.append(
        "SELECT p.pending_item_id, d.username, to_char(p.action_date, 'MMDDYYHH24MISS') sign_date FROM ecommerce_pending p, drweb d WHERE ");
    sqlBuf.append(" p.status = ");
    sqlBuf.append(StringFunctions.quoteSQLQuote(STATUS_FLAG_PENDING));
    sqlBuf.append(" AND update_type = ");
    if (update_type.equals(PRACTICE_REGISTRATION_UPDATE)) {
      sqlBuf.append(StringFunctions.quoteSQLQuote(REGISTRATION_UPDATE));
      sqlBuf.append(" and p.practice_id is not null ");
      sqlBuf.append(" and p.user_id is null ");
    } else {
      sqlBuf.append(StringFunctions.quoteSQLQuote(update_type));
    }
    sqlBuf.append(" and p.practice_id = d.drwebid ");
    sqlBuf.append(" ORDER BY p.action_date ASC ");
    sqlFindPending = sqlBuf.toString();

    try {
      System.out.println("sqlFindPending is: " + sqlFindPending);
      System.out.println("connectionID is: " + connectionID);
      if (m_DataQuery != null && connectionID > 0) {
        Vector pendingUpdates = m_DataQuery.query(sqlFindPending, connectionID);

        if (pendingUpdates != null) {

          Integer pendingItemID = new Integer(-1);
          String username = "";
          String actionDate = "";
          StringBuffer updateBuf = new StringBuffer();
          int size = pendingUpdates.size();
          System.out.println("RemsUpdater: There are " + size + " updates to process...");
          int x = 0;
          for (x = 0; x < size; x++) {
            Vector v = (Vector) pendingUpdates.elementAt(x);
            pendingItemID = (Integer) v.elementAt(0);
            username = (String) v.elementAt(1);
            actionDate = (String) v.elementAt(2);

            ECommerceUpdate thisUpdate = new ECommerceUpdate(pendingItemID, username, actionDate);
            updateQueue.addElement(thisUpdate);
          }
        } else {
          System.out.println(label + " There are no records in the eCommerce queue right now...");
        }
      } else {
        System.out.println("RemsUpdater: can't get database connection");
      }
    } catch (IOException e) {
      e.printStackTrace(System.err);
      ErrorSender.notifySupport(this, "findUpdates", "RemoteException", e);
    }
    return updateQueue;
  }
Пример #2
0
  /**
   * Get the UserInfo of the current user from the session.
   *
   * @param request the HttpServletRequest object that contains the client's request.
   * @return the UserInfo of the current user from the session; or null if one cannot retrieve.
   */
  public static UserInfo getUserInfo(HttpServletRequest request) {

    HttpSession session;
    Object object;

    session = request.getSession(false);

    if (session != null) {

      object = session.getValue("USER");

      if (object != null) {
        try {
          return (UserInfo) object;
        } catch (ClassCastException e) {
          System.err.println(
              "WARNING: Somewhere in the system has put a non-UserInfo object in the session as \"USER\"");
          ErrorSender.notifySupport(new RequestUtil(), "getUserInfo", "", e);
          return null;
        }
      } else {
        return null;
      }

    } else {
      return null;
    }
  }
Пример #3
0
 private void disconnectFromDatabase() {
   if (m_DataQuery != null || connectionID > 0) {
     try {
       m_LogFile.log("Disconnect Connection ID...." + connectionID);
       m_DataQuery.disconnect(connectionID);
       connectionID = 0;
     } catch (RemoteException e) {
       System.err.println("RMI = " + e);
       ErrorSender.notifySupport(this, "RemsUpdater", "RemoteException", e);
     } finally {
       m_DataQuery = null;
     }
   }
 }
Пример #4
0
  private void recordStatus(ECommerceUpdate thisUpdate, String status) {
    StringBuffer sqlBuf = new StringBuffer();
    String sqlRecord = "";
    String statusFlag = "";
    String resultCode = "";
    String resultMsg = "";
    if (status != null && status.length() > 0) {
      status = status.toLowerCase();
      int codeStart = -1;
      try {
        codeStart = status.indexOf(RESULT_CODE_PREFIX.toLowerCase()) + RESULT_CODE_PREFIX.length();
        System.out.println("codeStart = " + codeStart);
      } catch (Exception any) {
        any.printStackTrace();
      }
      if (codeStart >= RESULT_CODE_PREFIX.length()) {
        int msgPrefixStart = status.indexOf(RESULT_MESSAGE_PREFIX.toLowerCase());
        System.out.println("msgPrefixStart = " + msgPrefixStart);
        if (msgPrefixStart > 0) {
          resultCode = status.substring(codeStart, codeStart + 3).trim();
          System.out.println("resultCode = " + resultCode);
          resultMsg = status.substring(msgPrefixStart + RESULT_MESSAGE_PREFIX.length()).trim();
          System.out.println("resultMsg = " + resultMsg);
        } else {
          System.out.println("status=============" + status);
          System.out.println("codeStart=============" + codeStart);
          System.out.println("status length=============" + status.length());
          resultCode = status.substring(codeStart, 10);
        }
      }

      if (resultCode != null && resultCode.equalsIgnoreCase(RESULT_CODE_SUCCESS)) {
        statusFlag = STATUS_FLAG_SUCCESS;
        resultMsg = "";
      } else if (resultCode != null && resultCode.equalsIgnoreCase(RESULT_CODE_ERROR)) {
        statusFlag = STATUS_FLAG_ERROR;
      } else {
        statusFlag = STATUS_FLAG_PENDING;
        resultMsg = status;
      }

      if (resultMsg != null) {
        int msgLength = resultMsg.length();
        if (msgLength > 200) resultMsg = resultMsg.substring(0, 200);
      } else {
        resultMsg = "";
      }

      sqlBuf.append("UPDATE ecommerce_pending SET ");
      sqlBuf.append("status = ");
      sqlBuf.append(StringFunctions.quoteSQLQuote(statusFlag));
      sqlBuf.append(", message = ");
      sqlBuf.append(StringFunctions.quoteSQLQuote(resultMsg));
      sqlBuf.append(", last_send_date = SYSDATE");
      if (statusFlag == STATUS_FLAG_SUCCESS)
        sqlBuf.append(", accepted_by_ecommerce_date = SYSDATE");
      sqlBuf.append(", lastupdatedate = SYSDATE");
      sqlBuf.append(" WHERE pending_item_id = ");
      sqlBuf.append(thisUpdate.getPendingItemID().toString());
      System.out.println(sqlBuf.toString());
      try {
        int dbStatus = m_DataQuery.executeUpdate(sqlBuf.toString(), connectionID);
        System.out.println("recordStatus, dbStatus is: " + dbStatus);
        if (dbStatus <= 0)
          // Need logging!
          System.out.println("Error updating database in recordStatus: " + dbStatus);
      } catch (RemoteException e) {
        e.printStackTrace(System.err);
        ErrorSender.notifySupport(this, "RemsUpdater.recordStatus", "RemoteException", e);
      }
    }
  }