Merge "Evict project in user cache on save of project meta data"
This commit is contained in:
@@ -21,11 +21,12 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
|||||||
import com.google.gerrit.server.git.MetaDataUpdate;
|
import com.google.gerrit.server.git.MetaDataUpdate;
|
||||||
import com.google.gerrit.server.git.ProjectConfig;
|
import com.google.gerrit.server.git.ProjectConfig;
|
||||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||||
import com.google.gerrit.server.project.ProjectCache;
|
import com.google.gerrit.server.project.PerRequestProjectControlCache;
|
||||||
import com.google.gerrit.server.project.ProjectControl;
|
import com.google.gerrit.server.project.ProjectControl;
|
||||||
import com.google.gwtorm.client.OrmConcurrencyException;
|
import com.google.gwtorm.client.OrmConcurrencyException;
|
||||||
import com.google.gwtorm.client.OrmException;
|
import com.google.gwtorm.client.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Provider;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||||
@@ -40,9 +41,9 @@ class ChangeProjectSettings extends Handler<ProjectDetail> {
|
|||||||
|
|
||||||
private final ProjectDetailFactory.Factory projectDetailFactory;
|
private final ProjectDetailFactory.Factory projectDetailFactory;
|
||||||
private final ProjectControl.Factory projectControlFactory;
|
private final ProjectControl.Factory projectControlFactory;
|
||||||
private final ProjectCache projectCache;
|
|
||||||
private final GitRepositoryManager mgr;
|
private final GitRepositoryManager mgr;
|
||||||
private final MetaDataUpdate.User metaDataUpdateFactory;
|
private final MetaDataUpdate.User metaDataUpdateFactory;
|
||||||
|
private final Provider<PerRequestProjectControlCache> userCache;
|
||||||
|
|
||||||
private final Project update;
|
private final Project update;
|
||||||
|
|
||||||
@@ -50,13 +51,14 @@ class ChangeProjectSettings extends Handler<ProjectDetail> {
|
|||||||
ChangeProjectSettings(
|
ChangeProjectSettings(
|
||||||
final ProjectDetailFactory.Factory projectDetailFactory,
|
final ProjectDetailFactory.Factory projectDetailFactory,
|
||||||
final ProjectControl.Factory projectControlFactory,
|
final ProjectControl.Factory projectControlFactory,
|
||||||
final ProjectCache projectCache, final GitRepositoryManager mgr,
|
final GitRepositoryManager mgr,
|
||||||
final MetaDataUpdate.User metaDataUpdateFactory,
|
final MetaDataUpdate.User metaDataUpdateFactory,
|
||||||
|
final Provider<PerRequestProjectControlCache> uc,
|
||||||
@Assisted final Project update) {
|
@Assisted final Project update) {
|
||||||
this.projectDetailFactory = projectDetailFactory;
|
this.projectDetailFactory = projectDetailFactory;
|
||||||
this.projectControlFactory = projectControlFactory;
|
this.projectControlFactory = projectControlFactory;
|
||||||
this.projectCache = projectCache;
|
|
||||||
this.mgr = mgr;
|
this.mgr = mgr;
|
||||||
|
this.userCache = uc;
|
||||||
this.metaDataUpdateFactory = metaDataUpdateFactory;
|
this.metaDataUpdateFactory = metaDataUpdateFactory;
|
||||||
|
|
||||||
this.update = update;
|
this.update = update;
|
||||||
@@ -83,7 +85,7 @@ class ChangeProjectSettings extends Handler<ProjectDetail> {
|
|||||||
md.setMessage("Modified project settings\n");
|
md.setMessage("Modified project settings\n");
|
||||||
if (config.commit(md)) {
|
if (config.commit(md)) {
|
||||||
mgr.setProjectDescription(projectName, update.getDescription());
|
mgr.setProjectDescription(projectName, update.getDescription());
|
||||||
projectCache.evict(config.getProject());
|
userCache.get().evict(config.getProject());
|
||||||
} else {
|
} else {
|
||||||
throw new OrmConcurrencyException("Cannot update " + projectName);
|
throw new OrmConcurrencyException("Cannot update " + projectName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,4 +49,9 @@ public class PerRequestProjectControlCache {
|
|||||||
}
|
}
|
||||||
return ctl;
|
return ctl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void evict(Project project) {
|
||||||
|
projectCache.evict(project);
|
||||||
|
controls.remove(project.getNameKey());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user