Emit ref-updated event when editing project access via web UI

Bug: Issue 2564
Change-Id: I9426f6969a234b081f72197ed0cb061512bc6e09
This commit is contained in:
Jay Soffian 2014-03-20 16:48:55 -04:00
parent f56a8c687f
commit 3daa739e13

View File

@ -14,11 +14,15 @@
package com.google.gerrit.httpd.rpc.project;
import com.google.gerrit.common.ChangeHooks;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.data.ProjectAccess;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.gerrit.server.git.MetaDataUpdate;
import com.google.gerrit.server.git.ProjectConfig;
import com.google.gerrit.server.project.NoSuchProjectException;
@ -29,6 +33,7 @@ import com.google.inject.assistedinject.Assisted;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.revwalk.RevCommit;
import java.io.IOException;
import java.util.List;
@ -41,6 +46,8 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
@Nullable @Assisted String message);
}
private final ChangeHooks hooks;
private final IdentifiedUser user;
private final ProjectAccessFactory.Factory projectAccessFactory;
private final ProjectCache projectCache;
@ -49,6 +56,7 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
final ProjectControl.Factory projectControlFactory,
final ProjectCache projectCache, final GroupBackend groupBackend,
final MetaDataUpdate.User metaDataUpdateFactory,
ChangeHooks hooks, IdentifiedUser user,
@Assisted final Project.NameKey projectName,
@Nullable @Assisted final ObjectId base,
@ -58,12 +66,19 @@ class ChangeProjectAccess extends ProjectAccessHandler<ProjectAccess> {
projectName, base, sectionList, message, true);
this.projectAccessFactory = projectAccessFactory;
this.projectCache = projectCache;
this.hooks = hooks;
this.user = user;
}
@Override
protected ProjectAccess updateProjectConfig(ProjectConfig config,
MetaDataUpdate md) throws IOException, NoSuchProjectException, ConfigInvalidException {
config.commit(md);
RevCommit commit = config.commit(md);
hooks.doRefUpdatedHook(
new Branch.NameKey(config.getProject().getNameKey(), GitRepositoryManager.REF_CONFIG),
base, commit.getId(), user.getAccount());
projectCache.evict(config.getProject());
return projectAccessFactory.create(projectName).call();
}