public ProjectDetail call() throws NoSuchProjectException, IOException {
final ProjectControl pc =
projectControlFactory.validateFor(projectName, ProjectControl.OWNER
| ProjectControl.VISIBLE);
final ProjectState projectState = pc.getProjectState();
final ProjectDetail detail = new ProjectDetail();
detail.setProject(projectState.getProject());
final boolean userIsOwner = pc.isOwner();
final boolean userIsOwnerAnyRef = pc.isOwnerAnyRef();
detail.setCanModifyAccess(userIsOwnerAnyRef);
detail.setCanModifyAgreements(userIsOwner);
detail.setCanModifyDescription(userIsOwner);
detail.setCanModifyMergeType(userIsOwner);
detail.setCanModifyState(userIsOwner);
final Project.NameKey projectName = projectState.getProject().getNameKey();
Repository git;
try {
git = gitRepositoryManager.openRepository(projectName);
} catch (RepositoryNotFoundException err) {
throw new NoSuchProjectException(projectName);
}
try {
Ref head = git.getRef(Constants.HEAD);
if (head != null && head.isSymbolic()
&& GitRepositoryManager.REF_CONFIG.equals(head.getLeaf().getName())) {
detail.setPermissionOnly(true);
}
} catch (IOException err) {
throw new NoSuchProjectException(projectName);
} finally {
git.close();