public void process() { // throws IOException, Exception { try { Vector updateQueue = new Vector(); URL url = getECommerceURL(); String urlStr = ""; // String result = ""; connectToDatabase(); urlStr = url.toString(); m_LogFile.log("URL for Http Connection: " + urlStr); if (m_DataQuery != null && connectionID > 0) { sendBAAUpdate(BAA_SIGNED_UPDATE, urlStr); sendPracRegUpdate(PRACTICE_REGISTRATION_UPDATE, urlStr); sendUserUpdate(USER_UPDATE, urlStr); } else { m_LogFile.log("In process(): Cannot connect to database...."); } } catch (Exception e) { m_LogFile.log("Error in process(): " + e); e.printStackTrace(); } finally { m_LogFile.log("disconnect in process.."); disconnectFromDatabase(); } }
private void sendUserUpdate(String update_type, String urlStr) { m_LogFile.log("Finding pending data, where update type = " + update_type + "......."); try { Vector uQueue = findUpdates(update_type); if (uQueue != null && uQueue.size() > 0) { int qsize = uQueue.size(); System.out.println("send User Update====" + qsize); for (int x = 0; x < qsize; x++) { System.out.println("####################User Update: " + x); try { ECommerceUpdate oneUpdate = (ECommerceUpdate) uQueue.elementAt(x); String request = ""; String result = ""; try { request = buildUserRequest(oneUpdate); String requestMAC = JSUtils.ReqAddMAC_Hex(request, secretPattern); int attempt = 0; do { WebQuery query = new WebQuery(urlStr); System.out.println("aaaaaaaaarequestMAC====" + requestMAC); m_LogFile.log("requestMAC====" + requestMAC); try { result = query.query(requestMAC); attempt = m_RetryNum; } catch (Exception whoa) { whoa.printStackTrace(); result = "Result=301&error=from ecommerce: " + whoa.getMessage(); attempt++; try { Thread.sleep(m_RetryInterval); } catch (InterruptedException e1) { } } } while (attempt < m_RetryNum); } catch (IllegalArgumentException e) { result = "Result=301&error=from Rcopia: " + e.getMessage(); e.printStackTrace(); } System.out.println("aaaaaaresult========" + result); m_LogFile.log("result============" + result); recordStatus(oneUpdate, result); } catch (Exception e) { e.printStackTrace(); m_LogFile.log(e); } } } } catch (Exception e) { e.printStackTrace(); } }
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; } } }