/**
  * Add Deal to the user's publicKey. If deal is empty, it will abort. If the publicKey isn't an
  * user's publicKey known, it will abort.
  *
  * @param publicKey
  * @param deal
  */
 public void addDeal(String publicKey, Contrat deal) {
   if (deal == null) {
     Printer.printError(this, "addDeal", "deal is empty");
     return;
   }
   if (manager.getUserManager().getUser(publicKey) == null) {
     Printer.printError(this, "addDeal", "user is unknow");
     return;
   }
   if (!deals.containsKey(publicKey)) deals.put(publicKey, new ArrayList<Contrat>());
   deals.get(publicKey).add(deal);
 }
 /**
  * Create a new empty Deal for the current User
  *
  * @param title
  */
 public Contrat newDeal(String title) {
   User currentUser = manager.getUserManager().getCurrentUser();
   if (currentUser == null) {
     Printer.printError(this, "newDeal", "No user logged");
     return null;
   }
   String publicKey = currentUser.getKeys().getPublicKey().toString(16);
   if (!deals.containsKey(publicKey)) deals.put(publicKey, new ArrayList<Contrat>());
   Contrat deal = new Contrat(title, currentUser);
   deals.get(publicKey).add(deal);
   return deal;
 }
  public boolean addItem(String contratID, Item item) {
    Contrat contrat = null;

    User currentUser = manager.getUserManager().getCurrentUser();
    if (currentUser == null) {
      System.err.println("no user logged");
      return false;
    }
    String publicKey = currentUser.getKeys().getPublicKey().toString(16);

    for (Contrat c : deals.get(publicKey)) {
      if (c.getId().equals(contratID)) {
        contrat = c;
        break;
      }
    }
    if (contrat == null) {
      Printer.printError(this, "addItem", "Contrat doesn't exist !");
      return false;
    }
    return contrat.addItem(item);
  }