@Override public Collection<CustomerBrokerNegotiation> getSales() throws CantGetSaleNegotiationException { try { HashSet<CustomerBrokerNegotiation> sales = new HashSet<>(); sales.addAll(saleNegotiationManager.getNegotiationsByBroker(identity)); return sales; } catch (CantGetListSaleNegotiationsException e) { throw new CantGetSaleNegotiationException( CantGetSaleNegotiationException.DEFAULT_MESSAGE, e, "", ""); } }
@Override public CustomerBrokerNegotiation createSale( ActorIdentity cryptoCustomer, Collection<Clause> clauses) throws CantCreateSaleNegotiationException { try { return saleNegotiationManager.createNegotiation( cryptoCustomer.getPublicKey(), identity.getPublicKey()); } catch (CantCreateCustomerBrokerSaleNegotiationException exception) { throw new CantCreateSaleNegotiationException( CantCreateSaleNegotiationException.DEFAULT_MESSAGE, exception, "", ""); } }
@Override public Collection<CustomerBrokerNegotiation> getSales(final NegotiationStatus status) throws CantGetSaleNegotiationException { try { HashSet<CustomerBrokerNegotiation> sales = new HashSet<>(); for (CustomerBrokerNegotiation sale : saleNegotiationManager.getNegotiationsByBroker(identity)) { if (sale.getStatus() == status) sales.add(sale); } return sales; } catch (CantGetListSaleNegotiationsException e) { throw new CantGetSaleNegotiationException( CantGetSaleNegotiationException.DEFAULT_MESSAGE, e, "", ""); } }
@Override public CustomerBrokerNegotiation getSale(final UUID negotiationId) throws CantGetSaleNegotiationException { try { for (CustomerBrokerNegotiation sale : saleNegotiationManager.getNegotiationsByBroker(identity)) { if (sale.getNegotiationId().equals(negotiationId)) return sale; } throw new CantGetSaleNegotiationException( CantGetSaleNegotiationException.DEFAULT_MESSAGE, null, "Negotiation ID: " + negotiationId.toString(), "NegotiationId not Found"); } catch (CantGetListSaleNegotiationsException e) { throw new CantGetSaleNegotiationException( CantGetSaleNegotiationException.DEFAULT_MESSAGE, e, "", ""); } }