final ProjectControl pc;
try {
pc = projectControlFactory.controlFor(new Project.NameKey(projectName));
} catch (NoSuchProjectException err) {
throw new RepositoryNotFoundException(projectName);
}
if (!pc.isVisible()) {
if (pc.getCurrentUser() instanceof AnonymousUser) {
throw new ServiceNotAuthorizedException();
} else {
throw new ServiceNotEnabledException();
}
}
req.setAttribute(ATT_CONTROL, pc);
try {
return manager.openRepository(pc.getProject().getNameKey());
} catch (IOException e) {
throw new RepositoryNotFoundException(
pc.getProject().getNameKey().get(), e);
}
}