@Test public void getRepository_browseOnly() throws Exception { configurePermissions(repository, PERMIT_BROWSE); assertThat(underTest.getRepository(REPOSITORY_NAME), is(repository)); }
@Override public Repository getRepository(final String repositoryId) { if (repositoryId == null) { throw new WebApplicationException("repositoryId is required.", UNPROCESSABLE_ENTITY); } Repository repository = ofNullable(repositoryManager.get(repositoryId)) .orElseThrow(() -> new NotFoundException("Unable to locate repository with id " + repositoryId)); if (repositoryPermissionChecker.userCanBrowseRepository(repository)) { return repository; } else { throw new WebApplicationException(FORBIDDEN); } }
RepositoryManagerRESTAdapterImpl implements RepositoryManagerRESTAdapter { @Override public Repository getRepository(final String repositoryId) { if (repositoryId == null) { throw new WebApplicationException("repositoryId is required.", UNPROCESSABLE_ENTITY); } Repository repository = ofNullable(repositoryManager.get(repositoryId)) .orElseThrow(() -> new NotFoundException("Unable to locate repository with id " + repositoryId)); if (repositoryPermissionChecker.userCanBrowseRepository(repository)) { return repository; } else { throw new WebApplicationException(FORBIDDEN); } } }
RepositoryManagerRESTAdapterImpl implements RepositoryManagerRESTAdapter { @Override public Repository getRepository(final String repositoryId) { if (repositoryId == null) { throw new WebApplicationException("repositoryId is required.", UNPROCESSABLE_ENTITY); } Repository repository = ofNullable(repositoryManager.get(repositoryId)) .orElseThrow(() -> new NotFoundException("Unable to locate repository with id " + repositoryId)); if (repositoryPermissionChecker.userCanBrowseRepository(repository)) { return repository; } else { throw new WebApplicationException(FORBIDDEN); } } @Inject  RepositoryManagerRESTAdapterImpl(final RepositoryManager repositoryManager,
                                          final RepositoryPermissionChecker repositoryPermissionChecker); }
RepositoryManagerRESTAdapterImpl implements RepositoryManagerRESTAdapter { @Override public Repository getRepository(final String repositoryId) { if (repositoryId == null) { throw new WebApplicationException("repositoryId is required.", UNPROCESSABLE_ENTITY); } Repository repository = ofNullable(repositoryManager.get(repositoryId)) .orElseThrow(() -> new NotFoundException("Unable to locate repository with id " + repositoryId)); if (repositoryPermissionChecker.userCanBrowseRepository(repository)) { return repository; } else { throw new WebApplicationException(FORBIDDEN); } } @Inject  RepositoryManagerRESTAdapterImpl(final RepositoryManager repositoryManager,
                                          final RepositoryPermissionChecker repositoryPermissionChecker); @Override Repository getRepository(final String repositoryId); @Override List<Repository> getRepositories(); @Override List<String> findContainingGroups(final String repositoryName); }
RepositoryManagerRESTAdapterImpl implements RepositoryManagerRESTAdapter { @Override public Repository getRepository(final String repositoryId) { if (repositoryId == null) { throw new WebApplicationException("repositoryId is required.", UNPROCESSABLE_ENTITY); } Repository repository = ofNullable(repositoryManager.get(repositoryId)) .orElseThrow(() -> new NotFoundException("Unable to locate repository with id " + repositoryId)); if (repositoryPermissionChecker.userCanBrowseRepository(repository)) { return repository; } else { throw new WebApplicationException(FORBIDDEN); } } @Inject  RepositoryManagerRESTAdapterImpl(final RepositoryManager repositoryManager,
                                          final RepositoryPermissionChecker repositoryPermissionChecker); @Override Repository getRepository(final String repositoryId); @Override List<Repository> getRepositories(); @Override List<String> findContainingGroups(final String repositoryName);  }