public static void main(String[] args) throws IOException, SolrServerException {
    if (args.length != 1) {
      System.out.println("Usage : ");
      System.exit(0);
    }
    Map<String, String> configMap = ConfigurationManager.readConfiguration(args[0]);
    System.out.println("Read from configuration file...");
    String ids[] = configMap.get("ids").split(",");

    Integer maxNoOfProducts = new Integer(configMap.get("maxnoofproducts"));
    MongoHandler mongoHandler =
        new MongoHandler(
            configMap.get("mongodb"),
            configMap.get("mongohost"),
            new Integer(configMap.get("mongoport")));
    SolrHandler solrHandler = new SolrHandler(configMap.get("url"), maxNoOfProducts);

    // Initialize user objects
    List<User> users = new ArrayList<User>();
    for (String userEmail : configMap.get("recipients").split(",")) {
      User user = new User(userEmail, maxNoOfProducts);
      users.add(user);
    }
    System.out.println("Users initialized");

    // Iterate over all categories
    outer:
    for (String id : ids) {
      // Find all leaf categories for id
      System.out.println("Finding leaves for category " + id);
      List<Category> leaves = mongoHandler.findLeaves(id);
      // Get Next User
      User currentUser = UserService.getNextUser(users);

      CircularIterator<Category> leafCircularIterator = new CircularIterator(leaves, users.size());
      while (leafCircularIterator.hasNext()) {
        Category leaf = leafCircularIterator.next();
        List<Product> productsByLeafCategory =
            solrHandler.findProductsByLeafCategory(leaf, currentUser.getRemainingNoOfProducts());
        boolean isCurrentUserFinished = currentUser.addProducts(productsByLeafCategory);
        if (UserService.allUsersAssigned(users)) break;
        if (isCurrentUserFinished) {
          currentUser = UserService.getNextUser(users);
          continue;
        }
        if (!leafCircularIterator.failSafeCheck()) {
          System.out.println(
              "Could not assign enough products for all persons. Please check the generated sheet...");
          break outer;
        }
      }
    }

    SpreadsheetHandler spreadsheetHandler =
        new SpreadsheetHandler(users, maxNoOfProducts, configMap.get("outfolder"));
    spreadsheetHandler.generateFromUsers();
    ;
    spreadsheetHandler.saveSheet();
    System.out.println("Complete...");
  }