@Test public void getSubscriberEmails() throws IOException, GitAPIException { ILockedRepository repo = globalRepoManager.createProjectCentralRepository("_subscriptions", false, user); register(repo); subscriptionStore.subscribe(PROJECT, BRANCH, PAGE, user); subscriptionStore.subscribe(PROJECT, BRANCH, PAGE, user2); assertEquals(Sets.newHashSet(EMAIL, EMAIL_2), subscriptionStore.getSubscriberEmails(PROJECT, BRANCH, PAGE)); }
public Set<String> getSubscriberEmails(String projectName, String branchName, String path) throws IOException { ILockedRepository repo = null; try { repo = globalRepositoryManager.getProjectCentralRepository(REPOSITORY_NAME, false); File workingDir = RepositoryUtil.getWorkingDir(repo.r()); FileFilter fileFilter = new FileFilter() { @Override public boolean accept(File file) { return file.isFile() && file.getName().endsWith(SUBSCRIPTIONS_SUFFIX); } }; List<File> files = Lists.newArrayList(workingDir.listFiles(fileFilter)); Function<File, String> loginNamesFunction = new Function<File, String>() { @Override public String apply(File file) { return StringUtils.removeEnd(file.getName(), SUBSCRIPTIONS_SUFFIX); } }; List<String> loginNames = Lists.transform(files, loginNamesFunction); Set<String> emails = Sets.newHashSet(); for (Iterator<String> iter = loginNames.iterator(); iter.hasNext();) { String loginName = iter.next(); User user = userStore.getUser(loginName); if (isSubscribed(projectName, branchName, path, user, repo)) { emails.add(user.getEmail()); } } log.debug("emails subscribed to {}/{}/{}: {}", projectName, branchName, Util.toUrlPagePath(path), emails); return emails; } finally { Util.closeQuietly(repo); } }
SubscriptionStore { public Set<String> getSubscriberEmails(String projectName, String branchName, String path) throws IOException { ILockedRepository repo = null; try { repo = globalRepositoryManager.getProjectCentralRepository(REPOSITORY_NAME, false); File workingDir = RepositoryUtil.getWorkingDir(repo.r()); FileFilter fileFilter = new FileFilter() { @Override public boolean accept(File file) { return file.isFile() && file.getName().endsWith(SUBSCRIPTIONS_SUFFIX); } }; List<File> files = Lists.newArrayList(workingDir.listFiles(fileFilter)); Function<File, String> loginNamesFunction = new Function<File, String>() { @Override public String apply(File file) { return StringUtils.removeEnd(file.getName(), SUBSCRIPTIONS_SUFFIX); } }; List<String> loginNames = Lists.transform(files, loginNamesFunction); Set<String> emails = Sets.newHashSet(); for (Iterator<String> iter = loginNames.iterator(); iter.hasNext();) { String loginName = iter.next(); User user = userStore.getUser(loginName); if (isSubscribed(projectName, branchName, path, user, repo)) { emails.add(user.getEmail()); } } log.debug("emails subscribed to {}/{}/{}: {}", projectName, branchName, Util.toUrlPagePath(path), emails); return emails; } finally { Util.closeQuietly(repo); } } }
SubscriptionStore { public Set<String> getSubscriberEmails(String projectName, String branchName, String path) throws IOException { ILockedRepository repo = null; try { repo = globalRepositoryManager.getProjectCentralRepository(REPOSITORY_NAME, false); File workingDir = RepositoryUtil.getWorkingDir(repo.r()); FileFilter fileFilter = new FileFilter() { @Override public boolean accept(File file) { return file.isFile() && file.getName().endsWith(SUBSCRIPTIONS_SUFFIX); } }; List<File> files = Lists.newArrayList(workingDir.listFiles(fileFilter)); Function<File, String> loginNamesFunction = new Function<File, String>() { @Override public String apply(File file) { return StringUtils.removeEnd(file.getName(), SUBSCRIPTIONS_SUFFIX); } }; List<String> loginNames = Lists.transform(files, loginNamesFunction); Set<String> emails = Sets.newHashSet(); for (Iterator<String> iter = loginNames.iterator(); iter.hasNext();) { String loginName = iter.next(); User user = userStore.getUser(loginName); if (isSubscribed(projectName, branchName, path, user, repo)) { emails.add(user.getEmail()); } } log.debug("emails subscribed to {}/{}/{}: {}", projectName, branchName, Util.toUrlPagePath(path), emails); return emails; } finally { Util.closeQuietly(repo); } }  }
SubscriptionStore { public Set<String> getSubscriberEmails(String projectName, String branchName, String path) throws IOException { ILockedRepository repo = null; try { repo = globalRepositoryManager.getProjectCentralRepository(REPOSITORY_NAME, false); File workingDir = RepositoryUtil.getWorkingDir(repo.r()); FileFilter fileFilter = new FileFilter() { @Override public boolean accept(File file) { return file.isFile() && file.getName().endsWith(SUBSCRIPTIONS_SUFFIX); } }; List<File> files = Lists.newArrayList(workingDir.listFiles(fileFilter)); Function<File, String> loginNamesFunction = new Function<File, String>() { @Override public String apply(File file) { return StringUtils.removeEnd(file.getName(), SUBSCRIPTIONS_SUFFIX); } }; List<String> loginNames = Lists.transform(files, loginNamesFunction); Set<String> emails = Sets.newHashSet(); for (Iterator<String> iter = loginNames.iterator(); iter.hasNext();) { String loginName = iter.next(); User user = userStore.getUser(loginName); if (isSubscribed(projectName, branchName, path, user, repo)) { emails.add(user.getEmail()); } } log.debug("emails subscribed to {}/{}/{}: {}", projectName, branchName, Util.toUrlPagePath(path), emails); return emails; } finally { Util.closeQuietly(repo); } }  void subscribe(String projectName, String branchName, String path, User user); void unsubscribe(String projectName, String branchName, String path, User user); boolean isSubscribed(String projectName, String branchName, String path, User user); Set<String> getSubscriberEmails(String projectName, String branchName, String path); @Subscribe void renameProject(ProjectRenamedEvent event); @Subscribe void deleteProject(ProjectDeletedEvent event); @Subscribe void deleteProjectBranch(ProjectBranchDeletedEvent event); @Subscribe void renameProjectBranch(ProjectBranchRenamedEvent event); }
SubscriptionStore { public Set<String> getSubscriberEmails(String projectName, String branchName, String path) throws IOException { ILockedRepository repo = null; try { repo = globalRepositoryManager.getProjectCentralRepository(REPOSITORY_NAME, false); File workingDir = RepositoryUtil.getWorkingDir(repo.r()); FileFilter fileFilter = new FileFilter() { @Override public boolean accept(File file) { return file.isFile() && file.getName().endsWith(SUBSCRIPTIONS_SUFFIX); } }; List<File> files = Lists.newArrayList(workingDir.listFiles(fileFilter)); Function<File, String> loginNamesFunction = new Function<File, String>() { @Override public String apply(File file) { return StringUtils.removeEnd(file.getName(), SUBSCRIPTIONS_SUFFIX); } }; List<String> loginNames = Lists.transform(files, loginNamesFunction); Set<String> emails = Sets.newHashSet(); for (Iterator<String> iter = loginNames.iterator(); iter.hasNext();) { String loginName = iter.next(); User user = userStore.getUser(loginName); if (isSubscribed(projectName, branchName, path, user, repo)) { emails.add(user.getEmail()); } } log.debug("emails subscribed to {}/{}/{}: {}", projectName, branchName, Util.toUrlPagePath(path), emails); return emails; } finally { Util.closeQuietly(repo); } }  void subscribe(String projectName, String branchName, String path, User user); void unsubscribe(String projectName, String branchName, String path, User user); boolean isSubscribed(String projectName, String branchName, String path, User user); Set<String> getSubscriberEmails(String projectName, String branchName, String path); @Subscribe void renameProject(ProjectRenamedEvent event); @Subscribe void deleteProject(ProjectDeletedEvent event); @Subscribe void deleteProjectBranch(ProjectBranchDeletedEvent event); @Subscribe void renameProjectBranch(ProjectBranchRenamedEvent event);  }