public void handle(Command command, String[] args, Application application) throws CommandException { if (command == Command.represent) { PersistentTradingClient client = application.getTradingClient(); PersistentTradingContext profile = client.getTradingContext(); if (args.length == 1) { System.out.println(); try { FundManager manager = new FundManager(args[0]); if (profile.hasProxy()) { if (profile.hasProxy(manager)) { client.representFundManager(manager); System.out.println("The proxy client is now representing " + manager); } else { System.out.println( "Invalid client username: "******"The proxy cannot represent " + manager); } } else { throw new CommandException("Current user is not a proxy client"); } } catch (TimeoutException e) { System.out.println(command + " failed: " + e); } catch (InterruptedException e) { System.out.println(command + " failed: " + e); } catch (ConnectionException e) { System.out.println(command + " failed: " + e); } catch (ProxyClientException e) { System.out.println(command + " failed: " + e); } System.out.println(); } else { throw new CommandException(); } } else { throw new AssertionError("Unknown proxy command: " + command); } }
public void handle(Command command, String[] args, Application application) throws CommandException { try { if (command == Command.ls) { PersistentTradingClient client = application.getTradingClient(); if (args.length == 0) { String[] outstandingOrders = client.getOutstandingOrders(); System.out.println(); CommandHelper.displayTradeTable(System.out, client, outstandingOrders); System.out.println(); CommandHelper.displayBlockTable(System.out, client, outstandingOrders); System.out.println(); } else if (args.length == 1) { String arg = args[0]; System.out.println(); if (arg.equals(TR_OPTION)) { CommandHelper.displayTradeTable(System.out, client, client.getOutstandingOrders()); } else if (arg.equals(BT_OPTION)) { CommandHelper.displayBlockTable(System.out, client, client.getOutstandingOrders()); } else { PersistentOrder order = client.load(arg); if (order != null) { CommandHelper.displayOrder(System.out, order); } else { System.out.println("Order not found: " + arg); } } System.out.println(); } else if (args.length == 2) { if (args[0].equals(ORDER_OPTION)) { String pmsId = args[1].equals("-") ? null : args[1]; System.out.println(); System.out.println("TRs: " + Arrays.toString(client.getPomsIds(pmsId))); System.out.println(); } else { throw new CommandException(); } } else { throw new CommandException(); } } else { throw new AssertionError("Unknown list command: " + command); } } catch (TimeoutException e) { System.out.println("Order not found: " + e); } }