@Override
public ChangeDetail call() throws OrmException, NoSuchEntityException,
PatchSetInfoNotAvailableException, NoSuchChangeException,
RepositoryNotFoundException, IOException {
control = changeControlFactory.validateFor(changeId);
final Change change = control.getChange();
final PatchSet patch = db.patchSets().get(change.currentPatchSetId());
if (patch == null) {
throw new NoSuchEntityException();
}
aic.want(change.getOwner());
detail = new ChangeDetail();
detail.setChange(change);
detail.setAllowsAnonymous(control.forUser(anonymousUser).isVisible(db));
detail.setCanAbandon(change.getStatus() != Change.Status.DRAFT && change.getStatus().isOpen() && control.canAbandon());
detail.setCanPublish(control.canPublish(db));
detail.setCanRestore(change.getStatus() == Change.Status.ABANDONED
&& control.canRestore()
&& ProjectUtil.branchExists(repoManager, change.getDest()));
detail.setCanDeleteDraft(control.canDeleteDraft(db));
detail.setStarred(control.getCurrentUser().getStarredChanges().contains(
changeId));
detail.setCanRevert(change.getStatus() == Change.Status.MERGED && control.canAddPatchSet());
detail.setCanRebase(detail.getChange().getStatus().isOpen() && control.canRebase());
detail.setCanEdit(control.getRefControl().canWrite());
List<SubmitRecord> submitRecords = control.getSubmitRecords(db, patch);
for (SubmitRecord rec : submitRecords) {
if (rec.labels != null) {
for (SubmitRecord.Label lbl : rec.labels) {
aic.want(lbl.appliedBy);
}
}
if (detail.getChange().getStatus().isOpen()
&& rec.status == SubmitRecord.Status.OK
&& control.getRefControl().canSubmit()
&& ProjectUtil.branchExists(repoManager, change.getDest())) {
detail.setCanSubmit(true);
}
}
detail.setSubmitRecords(submitRecords);
patchsetsById = new HashMap<PatchSet.Id, PatchSet>();
loadPatchSets();
loadMessages();
if (change.currentPatchSetId() != null) {
loadCurrentPatchSet();
}
load();
detail.setAccounts(aic.create());
return detail;