/** {@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; }
/** {@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; }