public ReturnTuple<Integer> newCustomer(int id, Timestamp timestamp) throws RemoteException, TransactionAbortedException, InvalidTransactionException { if (!isMaster) { System.out.println("Slave retransmitting newCustomer to master"); return this.getMaster().newCustomer(id, timestamp); } else { timestamp.stamp(); int rid = Integer.parseInt( String.valueOf(id) + String.valueOf(Calendar.getInstance().get(Calendar.MILLISECOND)) + String.valueOf(Math.round(Math.random() * 100 + 1))); NewCustomerWithIdRMICommand nc = new NewCustomerWithIdRMICommand(carGroup, flightGroup, roomGroup, id, rid); nc.setTimestampObject(timestamp); ReturnTuple<Integer> result = null; try { overseer.validTransaction(id); lm.Lock(id, Customer.getKey(rid), nc.getRequiredLock()); nc.execute(); result = new ReturnTuple<Integer>(rid, nc.success.timestamp); overseer.addCommandToTransaction(id, nc); } catch (DeadlockException d) { timestamp.stamp(); overseer.abort(id); timestamp.stamp(); throw new TransactionAbortedException(timestamp); } catch (TransactionAbortedException tae) { tae.t = timestamp; throw tae; } catch (InvalidTransactionException ite) { ite.t = timestamp; throw ite; } result.timestamp.stamp(); return result; } }
public void deposit(String accountNum, String depositAmount) { // actually deposits the appropriate amount into the account double deposit = Double.parseDouble( depositAmount); // the balance in the Account class is saved as a double so it must be // converted here boolean accountFound = customer.addMoney(deposit, accountNum); if (accountFound == true) { // create the log file timestamp = date.getTime(); String customerID = customer.returnID(); AdminLog newTransaction = new AdminLog(timestamp, transaction_counter, customerID, accountNum, deposit); adminLogs.add(newTransaction); transaction_counter++; add_interest(); String infoMessage = customer.builderToString(); jf.displayInfo(infoMessage); try { saveFile(cust, DBfile); saveFile(adminLogs, logFile); } catch (IOException e) { e.printStackTrace(); } } else { jf.errorMessage( "We cannot find that account number in our database"); // pops up an error message if the // account was not found } customer = null; // resets the customer and account after each transaction pin = null; }
@Override public Customer findCustomerById(long customerId) { Customer customer = customerRepository.findOne(customerId); if (null == customer) throw new CustomerNotFoundException(customerId); Hibernate.initialize(customer.getUser()); return customer; }
public void withdraw(String withdrawAmount, String accountNum) { // actually performs the withdrawal service double withdrawal = Double.parseDouble(withdrawAmount); boolean accountFound = customer.removeMoney(withdrawal, accountNum); if (accountFound == true) { // creates the log file double logAmount = -withdrawal; timestamp = date.getTime(); String customerID = customer.returnID(); AdminLog newTransaction = new AdminLog(timestamp, transaction_counter, customerID, accountNum, logAmount); adminLogs.add(newTransaction); transaction_counter++; add_interest(); String infoMessage = customer.builderToString(); jf.displayInfo(infoMessage); try { saveFile(cust, DBfile); saveFile(adminLogs, logFile); } catch (IOException e) { e.printStackTrace(); } } else { jf.errorMessage( "We cannot find that account number in our database"); // pops up an error message if the // account was not found } customer = null; // resets the customer and account after each transaction pin = null; }
public void open_account(boolean save) { // actually opens the account customer.addAccount( starting_account_number, save); // addAccount will create a new account based on whether it is savings/checkings StringBuilder text = new StringBuilder(); text.append("<html>Account created!<br>"); String result = customer.returnInfo(); String subResult = result.substring(6); text.append(subResult); String infoText = text.toString(); jf.displayInfo(infoText); transaction_counter++; add_interest(); try { saveFile(cust, DBfile); saveFile(adminLogs, logFile); } catch (IOException e) { e.printStackTrace(); } customer = null; // resets the customer and account after each transaction pin = null; }
public void printAllAccounts(String customerID) { // Sorts the customer based on ID, then prints the accounts information // change the withdrawal funcitons and deposit functions too ajf.dispose(); ajf = new AdminRunningFrame(this); Collections.sort(cust, Customer.CompareIDs); String searchString = ajf.getCustomerID(); StringBuilder stringResults = new StringBuilder(); String header = header(); stringResults.append(header); for (Customer customer : cust) { String id = customer.returnID(); String name = customer.getName().toUpperCase(); String pin = customer.returnPin(); if (searchString.equals(id)) { ArrayList<Account> accounts = customer.getAccounts(); if (!accounts.isEmpty()) { for (Account account : accounts) { if (account.checkActive()) { String accountNumber = account.returnNumber(); double balance = account.returnBalance(); String balanceAsString = formatter.format(balance); String customerInfo = printAdminInfo(name, id, accountNumber, pin, balanceAsString); stringResults.append(customerInfo); } } } } } String resultsAsString = stringResults.toString(); ajf.printInfo(resultsAsString); }
@Override public Customer removeCustomer(long userId, long customerId) { User user = userRepository.findOne(userId); Customer customer = customerRepository.findOne(customerId); user.getCustomers().remove(customer); this.userRepository.save(user); customer.setUser(null); this.customerRepository.delete(customer); return customer; }
public static void main(String[] args) throws Exception { System.out.println("hello from Customer.java"); EntityManagerFactory factory = Persistence.createEntityManagerFactory("customerPU"); EntityManager manager = factory.createEntityManager(); Query q1 = manager.createQuery("SELECT COUNT(c) FROM Customer c"); Long count = (Long) q1.getSingleResult(); if (count == 0) { // record is empty, read from data.txst System.out.println("record empty, read from data.txt..."); // try { FileReader fr = new FileReader("data.txt"); BufferedReader br = new BufferedReader(fr); String s; while ((s = br.readLine()) != null) { // System.out.println(s); // split the string s Object[] items = s.split("\\|"); // store in string list // List<String> itemList= new ArrayList<String>(Arrays.asList(items)); // string list converted to array // Object[] itemArray = itemList.toArray(); // insert data into database table manager.getTransaction().begin(); Customer c = new Customer(); // add email c.setEmail((String) items[0]); // add pass c.setPass((String) items[1]); // add name c.setName((String) items[2]); // add address c.setAddress((String) items[3]); // add yob c.setYob((String) items[4]); // change to managed state manager.persist(c); manager.getTransaction().commit(); } fr.close(); } // display the records Query q2 = manager.createNamedQuery("Customer.findAll"); List<Customer> customers = q2.getResultList(); for (Customer c : customers) { System.out.println(c.getName() + ", " + c.getEmail()); } manager.close(); factory.close(); }
public void model_transfer(String customerID, String customerPIN) { // calls the transfer screen from the RunningFrame class validate_info(customerID, customerPIN); if (customer != null) { jf.dispose(); jf = new RunningFrame(this); String result = customer.returnInfo(); ArrayList<String> allAccounts = customer.getAllAccounts(); jf.transferScreen(result, allAccounts); } }
@Override public Collection<Customer> loadCustomerAccounts(long userId) { List<Customer> customersList = this.customerRepository.findByUserId(userId); ArrayList<Customer> customers = new ArrayList<Customer>(); for (Customer c : customersList) { Hibernate.initialize(c); User user = new User(userId); c.setUser(user); customers.add(c); } return Collections.unmodifiableList(customers); }
public void model_printAllAccounts() { ArrayList<String> cusIDs = new ArrayList<String>(100); cusIDs.add("Accounts:"); Collections.sort(cust, Customer.CompareIDs); for (Customer c : cust) { String id = c.returnID(); cusIDs.add(id); } if (ajf != null) { ajf.dispose(); } ajf = new AdminRunningFrame(this); ajf.showOneCustomerScreen(cusIDs); }
public void create_account(String name, String newPin) { // Actually creates the customer account Customer customer = new Customer(starting_customer_number, newPin, name); cust.add(customer); String newCusID = customer.returnID(); String idString = String.format("Your new Customer ID is: %s\n", newCusID); transaction_counter++; add_interest(); try { saveFile(cust, DBfile); } catch (IOException e) { e.printStackTrace(); } jf.displayInfo(idString); }
// Deletes customer from the database. public ReturnTuple<Boolean> deleteCustomer(int id, int customerID, Timestamp timestamp) throws RemoteException, TransactionAbortedException, InvalidTransactionException { if (!isMaster) { System.out.println("Slave retransmitting deleteCustomer to master"); return this.getMaster().deleteCustomer(id, customerID, timestamp); } else { timestamp.stamp(); DeleteCustomerRMICommand dc = new DeleteCustomerRMICommand(carGroup, flightGroup, roomGroup, id, customerID); dc.setTimestampObject(timestamp); ReturnTuple<Boolean> result = null; try { overseer.validTransaction(id); lm.Lock(id, Customer.getKey(customerID), dc.getRequiredLock()); dc.execute(); result = dc.success; if (result.result) overseer.addCommandToTransaction(id, dc); } catch (DeadlockException d) { timestamp.stamp(); overseer.abort(id); timestamp.stamp(); throw new TransactionAbortedException(timestamp); } catch (TransactionAbortedException tae) { tae.t = timestamp; throw tae; } catch (InvalidTransactionException ite) { ite.t = timestamp; throw ite; } result.timestamp.stamp(); return result; } }
// Adds flight reservation to this customer. public ReturnTuple<Boolean> reserveFlight( int id, int customerID, int flightNum, Timestamp timestamp) throws RemoteException, TransactionAbortedException, InvalidTransactionException { if (!isMaster) { System.out.println("Slave retransmitting reserveFlight to master"); return this.getMaster().reserveFlight(id, customerID, flightNum, timestamp); } else { timestamp.stamp(); ReserveFlightRMICommand rf = new ReserveFlightRMICommand(flightGroup, id, customerID, flightNum); rf.setTimestampObject(timestamp); ReturnTuple<Boolean> result = null; try { overseer.validTransaction(id); lm.Lock(id, Customer.getKey(customerID), rf.getRequiredLock()); lm.Lock(id, Flight.getKey(flightNum), rf.getRequiredLock()); rf.execute(); result = rf.success; if (result.result) overseer.addCommandToTransaction(id, rf); } catch (DeadlockException d) { timestamp.stamp(); overseer.abort(id); timestamp.stamp(); throw new TransactionAbortedException(timestamp); } catch (TransactionAbortedException tae) { tae.t = timestamp; throw tae; } catch (InvalidTransactionException ite) { ite.t = timestamp; throw ite; } result.timestamp.stamp(); return result; } }
/** * Get an order to put in the database * * @param id for the order * @param warehouse for the order * @param station for the order * @param customer for the the order * @return order */ public Order getOrder(int id, Warehouse warehouse, Station station, Customer customer) { Order order = new Order(); order.setOrderID(id); order.setCustomerID(customer.getCustomerID()); order.setWarehouseID(warehouse.getWarehouseID()); order.setStationID(station.getStationID()); order.setDateOrdered(randDate()); order.setCompleted(1); // set as completed by default order.setNumLineItems(randInt(3, 10)); // number of line items per order customer.setDeliveriesReceived(customer.getDeliveriesReceived() + 1); customer.setNumPayments(customer.getNumPayments() + 1); return order; }
/** Writes user state information to the shared filesystem */ private void updateStateCache( final Customer customer, final int transitionId, final CustomerState newState, Latch dbLatch) { try { dbLatch.acquire(); } catch (InterruptedException e) { m_logCategory.fatal( "Unable to acquire database latch to write state info for customer " + customer.getCustID() + " and transition " + transitionId, e); return; } blockHereIfBadNfs(); executeWithConnection( new ConnectionExecuteFunction<Object>() { public Object execute(Connection c) throws SQLException { // below does read-only DB and nfs. // It iterates multiple users and returning a list here could be // detrimental to scalability. updateStateCache(customer, transitionId, newState, c); return null; } }); }
public void customerSorting() { for (int p = 0; p < this.customer.size(); p++) { Customer customer1 = this.customer.get(p); for (int i = 0; i < this.customer.size(); i++) { Customer customer2 = this.customer.get(i); int compare = customer1.compareTo(customer2); if (compare % 10 < 2) { int customer1Index = this.customer.indexOf(customer1); this.customer.remove(i); this.customer.add(i, customer1); this.customer.remove(customer1Index); this.customer.add(customer1Index, customer2); customer1 = customer2; } } } }
public void model_close_account(String customerID, String customerPIN) { // calls the transfer screen from the RunningFrame class validate_info(customerID, customerPIN); if (customer != null) { jf.dispose(); jf = new RunningFrame(this); ArrayList<String> allAccounts = customer.getAllAccounts(); jf.closeAccountScreen(allAccounts); } }
public void model_account_info(String customerID, String customerPIN) { // calls the transfer screen from the RunningFrame class validate_info(customerID, customerPIN); if (customer != null) { jf.dispose(); jf = new RunningFrame(this); String text = customer.printAccountInfo(); jf.accountInfoScreen(text, adminLogs, customerID); } }
public String close_account(String accountNum) { // actually closes the customer's account and returns a dialog box customer.removeAccount(accountNum); String cusInfo = customer.returnInfo(); StringBuilder result = new StringBuilder(); result.append("<html>Deleted account!<br>Updated information:<br>"); String subCusInfo = cusInfo.substring(7, cusInfo.length()); // removes the last html tag from returnInfo() result.append(subCusInfo); try { saveFile(cust, DBfile); } catch (IOException e) { e.printStackTrace(); } customer = null; // resets the customer and account after each transaction pin = null; return result.toString(); }
public void transfer(String transferAmount, String accountFrom, String accountTo) { // actually transfers the model double transferDouble = Double.parseDouble(transferAmount); boolean accountFromFound = customer.removeMoney(transferDouble, accountFrom); boolean accountToFound = customer.addMoney(transferDouble, accountTo); if (accountFromFound == true && accountToFound == true) { // creates the log file double logAmount = -transferDouble; timestamp = date.getTime(); String customerID = customer.returnID(); AdminLog firstTransaction = new AdminLog(timestamp, transaction_counter, customerID, accountFrom, transferDouble); timestamp = date.getTime(); AdminLog secondTransaction = new AdminLog(timestamp, transaction_counter, customerID, accountTo, logAmount); adminLogs.add(firstTransaction); adminLogs.add(secondTransaction); for (AdminLog a : adminLogs) { long timestampe = a.getTimestamp(); } transaction_counter++; add_interest(); String infoMessage = customer.transferMessage(accountFrom, accountTo, transferDouble); jf.displayInfo(infoMessage); try { saveFile(cust, DBfile); saveFile(adminLogs, logFile); } catch (IOException e) { e.printStackTrace(); } } else { jf.errorMessage( "We cannot find that account number in our database"); // pops up an error message if the // account was not found } customer = null; // resets the customer and account after each transaction pin = null; }
public void addCustomer(Customer customer) throws IllegalArgumentException { if (!(this.customer.contains(customer))) this.customer.add(customer); else if (this.customer.contains(customer)) throw new IllegalArgumentException( "There are already an exist customer: " + customer.getName() + "\nCustomer name can not be duplicate!"); for (int p = 0; p < this.customer.size(); p++) { customer = this.customer.get(p); customerSorting(); } }
/** * Get a line item to put in the database * * @param id for the line item * @param warehouse for the station * @param Station station * @param Customer customer * @param Order order * @param ArrayList<Item> itemList * @return lineItem */ public LineItem getLineItem( int id, Warehouse warehouse, Station station, Customer customer, Order order, ArrayList<Item> itemList) { LineItem lineItem = new LineItem(); Item item = itemList.get(randInt(0, itemList.size())); int numOrdered = randInt(1, 5); if (item.getCurrentStock() < numOrdered) return null; lineItem.setLineItemID(id); lineItem.setOrderID(order.getOrderID()); lineItem.setItemID(item.getItemID()); lineItem.setCustomerID(customer.getCustomerID()); lineItem.setWarehouseID(warehouse.getWarehouseID()); lineItem.setStationID(station.getStationID()); lineItem.setNumOrdered(numOrdered); lineItem.setAmountDue(item.getPrice().multiply(new BigDecimal(lineItem.getNumOrdered()))); lineItem.setAmountDue( lineItem.getAmountDue().add(station.getSalesTax().multiply(lineItem.getAmountDue()))); lineItem.setAmountDue( lineItem.getAmountDue().subtract(customer.getDiscount().multiply(lineItem.getAmountDue()))); lineItem.setDateDelivered(randDate()); item.setNumLineItems(item.getNumLineItems() + 1); item.setNumSold(item.getNumSold() + lineItem.getNumOrdered()); // item.setCurrentStock(item.getCurrentStock() - lineItem.getNumOrdered()); don't modify stock // counts for random generation customer.setTotalPaid(customer.getTotalPaid().add(lineItem.getAmountDue())); station.setTotalSales(station.getTotalSales().add(lineItem.getAmountDue())); warehouse.setTotalSales(warehouse.getTotalSales().add(lineItem.getAmountDue())); return lineItem; }
public void printByCustomerName() { // Prints the database info by customer's name in ascending order Collections.sort(cust, Customer.CompareName); ajf.dispose(); ajf = new AdminRunningFrame(this); StringBuilder stringResults = new StringBuilder(); String header = header(); stringResults.append(header); if (!cust.isEmpty()) { for (Customer customer : cust) { String id = customer.returnID(); String name = customer.getName().toUpperCase(); String pin = customer.returnPin(); ArrayList<Account> accounts = customer.getAccounts(); if (!accounts.isEmpty()) { for (Account account : accounts) { if (account.checkActive()) { String accountNumber = account.returnNumber(); double balance = account.returnBalance(); String balanceAsString = formatter.format(balance); String customerInfo = printAdminInfo(name, id, accountNumber, pin, balanceAsString); stringResults.append(customerInfo); } } } else { // Still prints customers who have created customer accounts but not set up any // checking/savings String noAccounts = String.format("%-20s %-9s %-10s\n", name, id, pin); stringResults.append(noAccounts); } } } String resultsAsString = stringResults.toString(); ajf.printInfo(resultsAsString); }
private void validate_info(String newUserID, String newPin) { // validates that the customer has put in the correct Customer name and PIN if (newPin == null || newPin.length() != 4) { // returns the Customer object right away if the pin number is wrong, which will cause // the functions defined below to just pass through without doing anything pin = newPin; } else { // Validate user information for (Customer c : cust) { // Checks to see if the customer is already in the database String possibleCustID = c.returnID(); if (possibleCustID.equals(newUserID)) { found = true; String possibleCustPIN = c.returnPin(); // Sets possible customer PIN for validation if (possibleCustPIN.equals(newPin)) { customer = c; pin = newPin; } pin = newPin; // so if customer ends up being null but the pin still has value, then the pin // was incorrect } } } if (!found) { // calls the correct warning message if either the customer or pin is not correct if (pin == null) { jf.errorMessage("That customer is not in our database."); } else { jf.errorMessage( "Invalid PIN number."); // if the customer has not been found but the pin has been set // that means the pin was invalid } } }
public void add_interest() { if ((transaction_counter % 5) == 0) { for (Customer c : cust) { ArrayList<Tuple> accountsAddedTo = new ArrayList<>(100); accountsAddedTo = c.addInterestToSavings(interest_rate); timestamp = date.getTime(); if (!accountsAddedTo.isEmpty()) { String customerID = c.returnID(); for (Tuple tuple : accountsAddedTo) { String accountNumber = tuple.getFirst(); double logAmount = tuple.getSecond(); AdminLog newTransaction = new AdminLog(timestamp, transaction_counter, customerID, accountNumber, logAmount); adminLogs.add(newTransaction); } } try { saveFile(cust, DBfile); } catch (IOException e) { e.printStackTrace(); } } } }
/* reserve an itinerary */ public ReturnTuple<Boolean> itinerary( int id, int customer, Vector flightNumbers, String location, boolean Car, boolean Room, Timestamp timestamp) throws RemoteException, TransactionAbortedException, InvalidTransactionException { if (!isMaster) { System.out.println("Slave retransmitting itinerary to master"); return this.getMaster() .itinerary(id, customer, flightNumbers, location, Car, Room, timestamp); } else { timestamp.stamp(); ItineraryRMICommand i = new ItineraryRMICommand( carGroup, flightGroup, roomGroup, id, customer, flightNumbers, location, Car, Room); i.setTimestampObject(timestamp); ReturnTuple<Boolean> result = null; try { overseer.validTransaction(id); lm.Lock(id, Customer.getKey(customer), i.getRequiredLock()); lm.Lock(id, ResImpl.Car.getKey(location), i.getRequiredLock()); lm.Lock(id, Hotel.getKey(location), i.getRequiredLock()); for (Object flightNo : flightNumbers) { int flightNum = Integer.parseInt((String) flightNo); lm.Lock(id, Flight.getKey(flightNum), i.getRequiredLock()); } i.execute(); result = i.success; if (result.result && !i.error()) overseer.addCommandToTransaction(id, i); } catch (DeadlockException d) { timestamp.stamp(); overseer.abort(id); timestamp.stamp(); throw new TransactionAbortedException(timestamp); } catch (TransactionAbortedException tae) { tae.t = timestamp; throw tae; } catch (InvalidTransactionException ite) { ite.t = timestamp; throw ite; } result.timestamp.stamp(); return result; } }
// return a bill public ReturnTuple<String> queryCustomerInfo(int id, int customerID, Timestamp timestamp) throws RemoteException, TransactionAbortedException, InvalidTransactionException { if (!isMaster) { System.out.println("Slave retransmitting queryCustomerInfo to master"); return this.getMaster().queryCustomerInfo(id, customerID, timestamp); } else { timestamp.stamp(); QueryCustomerInfoRMICommand qci = new QueryCustomerInfoRMICommand(carGroup, flightGroup, roomGroup, id, customerID); qci.setTimestampObject(timestamp); ReturnTuple<String> result = null; try { Vector<Integer> flightNos; Vector<String> locations; overseer.validTransaction(id); lm.Lock(id, Customer.getKey(customerID), qci.getRequiredLock()); qci.execute(); flightNos = qci.getCustomerFlightReservations(); for (int flightNo : flightNos) { lm.Lock(id, Flight.getKey(flightNo), qci.getRequiredLock()); } locations = qci.getCustomerRoomReservations(); for (String location : locations) { lm.Lock(id, Hotel.getKey(location), qci.getRequiredLock()); } locations = qci.getCustomerCarReservations(); for (String location : locations) { lm.Lock(id, Car.getKey(location), qci.getRequiredLock()); } qci.execute(); result = qci.customerInfo; } catch (DeadlockException d) { timestamp.stamp(); overseer.abort(id); timestamp.stamp(); throw new TransactionAbortedException(timestamp); } catch (TransactionAbortedException tae) { tae.t = timestamp; throw tae; } catch (InvalidTransactionException ite) { ite.t = timestamp; throw ite; } result.timestamp.stamp(); return result; } }
public void printHighestBalance() { // prints the accounts from highest amount to lowest, with those who have empty accounts last ajf.dispose(); ajf = new AdminRunningFrame(this); StringBuilder stringResults = new StringBuilder(); String header = header(); stringResults.append(header); if (!cust.isEmpty()) { ArrayList<Account> allAccounts = new ArrayList<Account>(); ArrayList<Customer> CustomersNoAccounts = new ArrayList<Customer>(); for (Customer c : cust) { ArrayList<Account> accounts = c.getAccounts(); if (!accounts.isEmpty()) { // Concatenates all the accounts together for easy sorting allAccounts.addAll(accounts); } // Adds customers without accounts to a separate list to be printed at the end of all the // others else { CustomersNoAccounts.add(c); } } if (!allAccounts.isEmpty()) { Collections.sort(allAccounts, Account.CompareBalances); for (Account a : allAccounts) { if (a.checkActive()) { String id = a.getID(); String name = a.getName().toUpperCase(); String pin = a.getPin(); String accountNumber = a.returnNumber(); double balance = a.returnBalance(); String balanceAsString = formatter.format(balance); String customerInfo = printAdminInfo(name, id, accountNumber, pin, balanceAsString); stringResults.append(customerInfo); } } } if (!CustomersNoAccounts.isEmpty()) { Collections.sort(CustomersNoAccounts, Customer.CompareName); for (Customer c : CustomersNoAccounts) { String id = c.returnID(); String name = c.getName().toUpperCase(); String pin = c.returnPin(); String noAccounts = String.format("%-20s %-9s %-10s\n", name, id, pin); stringResults.append(noAccounts); } } String resultsAsString = stringResults.toString(); ajf.printInfo(resultsAsString); } }
/** Writes user state information to the shared filesystem */ private void updateStateCache( Customer customer, int transitionId, CustomerState newState, Connection c) throws SQLException { PreparedStatement pst = null; ResultSet rs = null; try { pst = c.prepareStatement( "SELECT u.secure_hash_key, u.object_id, u.user_state, u.is_deleted, u.last_activation_id " + "FROM dat_user_account u, dat_transition_users tr " + "WHERE u.object_id = tr.user_id AND u.customer_id=? " + "AND tr.transition_id=?;"); // The state files are used by Outlook, BB, and maybe future clients. pst.setInt(1, customer.getCustID()); pst.setInt(2, transitionId); rs = pst.executeQuery(); while (rs.next()) { int i = 0; byte[] key = rs.getBytes(++i); int userId = rs.getInt(++i); CustomerState state = CustomerState.fromInt(rs.getInt(++i)); int isDeletedInt = rs.getInt(++i); int lastActivationId = rs.getInt(++i); // If the user is marked deleted but has a key, we'll try cleaning // up state files. boolean isDeleted = isDeletedInt != IUserManager.USER_NOT_DELETED; if (key == null || key.length == 0) { LogMessageGen lmg = new LogMessageGen(); lmg.setSubject("dat_user_account.secure_hash_key not set"); lmg.param(LoggingConsts.USER_ID, userId); m_logCategory.info(lmg.toString()); // Without a key, we can't determine the signal filenames // so no cleanup is possible. continue; } ClientHashSupport hash = null; hash = new ClientHashSupport(); hash.setCustomerId(customer.getCustID()); hash.setUserId(userId); hash.setHashKey(key); hash.setLastActivationId(lastActivationId); if (m_logCategory.isInfoEnabled()) { LogMessageGen lmg = new LogMessageGen(); lmg.setSubject("Updating signal files"); lmg.param(LoggingConsts.USER_ID, userId); m_logCategory.info(lmg.toString()); } // wrt EMSDEV-7854 nfs calls and database transactions. // Above is only doing a select; no locks are taken and this // method is private. updateSignalFiles(hash, state, isDeleted); } // each row. } finally { DbUtils.safeClose(rs); DbUtils.safeClose(pst); } }