Exemplo n.º 1
0
  /** {@inheritDoc} */
  @Override
  public Hub add(Hub hub, User author) throws DuplicateHubNameException {
    if (hubDao.getByHubName(hub.getName()) != null) {
      throw new DuplicateHubNameException(hub.getName());
    }
    hub.setRating(0);
    hub.setAuthor(author);
    hubDao.save(hub);

    return hub;
  }
Exemplo n.º 2
0
  /** {@inheritDoc} */
  @Override
  public Set<String> getNamesOfHubsAvailableToUser(User user) {
    Set<String> publicHubs = new LinkedHashSet<String>();
    for (Hub hub : hubDao.getAllPublicHubs()) {
      publicHubs.add(hub.getName());
    }
    List<String> ownHubs = new ArrayList<String>();
    for (Hub hub : hubDao.getHubsOfUser(user.getUserName())) {
      ownHubs.add(hub.getName());
    }
    publicHubs.addAll(ownHubs);

    return publicHubs;
  }