01: package de.schlund.pfixcore.example.bank.context;
02:
03: import java.net.URLEncoder;
04: import java.util.Collection;
05:
06: import org.w3c.dom.Element;
07:
08: import de.schlund.pfixcore.example.bank.AuthTokenManager;
09: import de.schlund.pfixcore.example.bank.BankApplication;
10: import de.schlund.pfixcore.example.bank.model.Account;
11: import de.schlund.pfixcore.example.bank.model.BankDAO;
12: import de.schlund.pfixcore.example.bank.model.Customer;
13: import de.schlund.pfixcore.workflow.Context;
14: import de.schlund.pfixxml.ResultDocument;
15:
16: public class ContextTestImpl implements ContextTest {
17:
18: public void init(Context context) throws Exception {
19: }
20:
21: public void insertStatus(ResultDocument resdoc, Element elem)
22: throws Exception {
23: BankDAO bankDAO = BankApplication.getInstance().getBankDAO();
24: Collection<Customer> customers = bankDAO.getCustomers();
25: for (Customer customer : customers) {
26: for (Account account : customer.getAccounts()) {
27: Element e = resdoc.createSubNode(elem, "authtoken");
28: String[] values = new String[] {
29: String.valueOf(customer.getCustomerId()),
30: String.valueOf(account.getAccountNo()) };
31: e.setAttribute("value", URLEncoder.encode(
32: AuthTokenManager.createAuthToken(values),
33: "UTF-8"));
34: }
35: }
36: }
37:
38: }
|