Merge changes from topic "project-cache-get-optional"
* changes: Remove ProjectCache#strictGet(NameKey, boolean) Make ProjectCache#get return an Optional<ProjectState>
This commit is contained in:
@@ -32,12 +32,14 @@ import com.google.gerrit.index.query.QueryParseException;
|
|||||||
import com.google.gerrit.server.config.SitePaths;
|
import com.google.gerrit.server.config.SitePaths;
|
||||||
import com.google.gerrit.server.index.IndexUtils;
|
import com.google.gerrit.server.index.IndexUtils;
|
||||||
import com.google.gerrit.server.project.ProjectCache;
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
|
import com.google.gerrit.server.project.ProjectState;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
import com.google.inject.assistedinject.Assisted;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.elasticsearch.client.Response;
|
import org.elasticsearch.client.Response;
|
||||||
@@ -119,6 +121,10 @@ public class ElasticProjectIndex extends AbstractElasticIndex<Project.NameKey, P
|
|||||||
|
|
||||||
Project.NameKey nameKey =
|
Project.NameKey nameKey =
|
||||||
Project.nameKey(source.getAsJsonObject().get(ProjectField.NAME.getName()).getAsString());
|
Project.nameKey(source.getAsJsonObject().get(ProjectField.NAME.getName()).getAsString());
|
||||||
return projectCache.get().get(nameKey).toProjectData();
|
Optional<ProjectState> state = projectCache.get().get(nameKey);
|
||||||
|
if (!state.isPresent()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return state.get().toProjectData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.gpg;
|
package com.google.gerrit.gpg;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.entities.BooleanProjectConfig;
|
import com.google.gerrit.entities.BooleanProjectConfig;
|
||||||
@@ -87,7 +89,7 @@ class SignedPushModule extends AbstractModule {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Project.NameKey project, ReceivePack rp) {
|
public void init(Project.NameKey project, ReceivePack rp) {
|
||||||
ProjectState ps = projectCache.get(project);
|
ProjectState ps = projectCache.get(project).orElseThrow(illegalState(project));
|
||||||
if (!ps.is(BooleanProjectConfig.ENABLE_SIGNED_PUSH)) {
|
if (!ps.is(BooleanProjectConfig.ENABLE_SIGNED_PUSH)) {
|
||||||
rp.setSignedPushConfig(null);
|
rp.setSignedPushConfig(null);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -142,7 +142,6 @@ public class LuceneProjectIndex extends AbstractLuceneIndex<Project.NameKey, Pro
|
|||||||
@Override
|
@Override
|
||||||
protected ProjectData fromDocument(Document doc) {
|
protected ProjectData fromDocument(Document doc) {
|
||||||
Project.NameKey nameKey = Project.nameKey(doc.getField(NAME.getName()).stringValue());
|
Project.NameKey nameKey = Project.nameKey(doc.getField(NAME.getName()).stringValue());
|
||||||
ProjectState projectState = projectCache.get().get(nameKey);
|
return projectCache.get().get(nameKey).map(ProjectState::toProjectData).orElse(null);
|
||||||
return projectState == null ? null : projectState.toProjectData();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import static com.google.gerrit.extensions.client.ListChangesOption.DOWNLOAD_COM
|
|||||||
import static com.google.gerrit.extensions.client.ListChangesOption.PUSH_CERTIFICATES;
|
import static com.google.gerrit.extensions.client.ListChangesOption.PUSH_CERTIFICATES;
|
||||||
import static com.google.gerrit.extensions.client.ListChangesOption.WEB_LINKS;
|
import static com.google.gerrit.extensions.client.ListChangesOption.WEB_LINKS;
|
||||||
import static com.google.gerrit.server.CommonConverters.toGitPerson;
|
import static com.google.gerrit.server.CommonConverters.toGitPerson;
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
@@ -306,7 +307,7 @@ public class RevisionJson {
|
|||||||
}
|
}
|
||||||
out.commitWithFooters =
|
out.commitWithFooters =
|
||||||
mergeUtilFactory
|
mergeUtilFactory
|
||||||
.create(projectCache.get(project))
|
.create(projectCache.get(project).orElseThrow(illegalState(project)))
|
||||||
.createCommitMessageOnSubmit(commit, mergeTip, cd.notes(), in.id());
|
.createCommitMessageOnSubmit(commit, mergeTip, cd.notes(), in.id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.config;
|
package com.google.gerrit.server.config;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.noSuchProject;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.entities.Project;
|
import com.google.gerrit.entities.Project;
|
||||||
import com.google.gerrit.server.plugins.Plugin;
|
import com.google.gerrit.server.plugins.Plugin;
|
||||||
@@ -129,10 +131,8 @@ public class PluginConfigFactory implements ReloadPluginListener {
|
|||||||
*/
|
*/
|
||||||
public PluginConfig getFromProjectConfig(Project.NameKey projectName, String pluginName)
|
public PluginConfig getFromProjectConfig(Project.NameKey projectName, String pluginName)
|
||||||
throws NoSuchProjectException {
|
throws NoSuchProjectException {
|
||||||
ProjectState projectState = projectCache.get(projectName);
|
ProjectState projectState =
|
||||||
if (projectState == null) {
|
projectCache.get(projectName).orElseThrow(noSuchProject(projectName));
|
||||||
throw new NoSuchProjectException(projectName);
|
|
||||||
}
|
|
||||||
return getFromProjectConfig(projectState, pluginName);
|
return getFromProjectConfig(projectState, pluginName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,10 +363,8 @@ public class PluginConfigFactory implements ReloadPluginListener {
|
|||||||
|
|
||||||
private ProjectLevelConfig getPluginConfig(Project.NameKey projectName, String pluginName)
|
private ProjectLevelConfig getPluginConfig(Project.NameKey projectName, String pluginName)
|
||||||
throws NoSuchProjectException {
|
throws NoSuchProjectException {
|
||||||
ProjectState projectState = projectCache.get(projectName);
|
ProjectState projectState =
|
||||||
if (projectState == null) {
|
projectCache.get(projectName).orElseThrow(noSuchProject(projectName));
|
||||||
throw new NoSuchProjectException(projectName);
|
|
||||||
}
|
|
||||||
return projectState.getConfig(pluginName + EXTENSION);
|
return projectState.getConfig(pluginName + EXTENSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.google.gerrit.server.project.ProjectState;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/** Distributes Events to listeners if they are allowed to see them */
|
/** Distributes Events to listeners if they are allowed to see them */
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -146,8 +147,8 @@ public class EventBroker implements EventDispatcher {
|
|||||||
|
|
||||||
protected boolean isVisibleTo(Project.NameKey project, CurrentUser user) {
|
protected boolean isVisibleTo(Project.NameKey project, CurrentUser user) {
|
||||||
try {
|
try {
|
||||||
ProjectState state = projectCache.get(project);
|
Optional<ProjectState> state = projectCache.get(project);
|
||||||
if (state == null || !state.statePermitsRead()) {
|
if (!state.isPresent() || !state.get().statePermitsRead()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,8 +163,8 @@ public class EventBroker implements EventDispatcher {
|
|||||||
if (change == null) {
|
if (change == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ProjectState pe = projectCache.get(change.getProject());
|
Optional<ProjectState> pe = projectCache.get(change.getProject());
|
||||||
if (pe == null || !pe.statePermitsRead()) {
|
if (!pe.isPresent() || !pe.get().statePermitsRead()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -179,8 +180,8 @@ public class EventBroker implements EventDispatcher {
|
|||||||
|
|
||||||
protected boolean isVisibleTo(BranchNameKey branchName, CurrentUser user)
|
protected boolean isVisibleTo(BranchNameKey branchName, CurrentUser user)
|
||||||
throws PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
ProjectState pe = projectCache.get(branchName.project());
|
Optional<ProjectState> pe = projectCache.get(branchName.project());
|
||||||
if (pe == null || !pe.statePermitsRead()) {
|
if (!pe.isPresent() || !pe.get().statePermitsRead()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.base.Suppliers;
|
import com.google.common.base.Suppliers;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
@@ -24,6 +26,7 @@ import com.google.gerrit.entities.Account;
|
|||||||
import com.google.gerrit.entities.BranchNameKey;
|
import com.google.gerrit.entities.BranchNameKey;
|
||||||
import com.google.gerrit.entities.Change;
|
import com.google.gerrit.entities.Change;
|
||||||
import com.google.gerrit.entities.PatchSet;
|
import com.google.gerrit.entities.PatchSet;
|
||||||
|
import com.google.gerrit.entities.Project;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
import com.google.gerrit.exceptions.StorageException;
|
||||||
import com.google.gerrit.extensions.common.AccountInfo;
|
import com.google.gerrit.extensions.common.AccountInfo;
|
||||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||||
@@ -215,7 +218,9 @@ public class StreamEventsApiListener
|
|||||||
final Map<String, Short> approvals = convertApprovalsMap(newApprovals);
|
final Map<String, Short> approvals = convertApprovalsMap(newApprovals);
|
||||||
return Suppliers.memoize(
|
return Suppliers.memoize(
|
||||||
() -> {
|
() -> {
|
||||||
LabelTypes labelTypes = projectCache.get(change.getProject()).getLabelTypes();
|
Project.NameKey nameKey = change.getProject();
|
||||||
|
LabelTypes labelTypes =
|
||||||
|
projectCache.get(nameKey).orElseThrow(illegalState(nameKey)).getLabelTypes();
|
||||||
if (approvals.size() > 0) {
|
if (approvals.size() > 0) {
|
||||||
ApprovalAttribute[] r = new ApprovalAttribute[approvals.size()];
|
ApprovalAttribute[] r = new ApprovalAttribute[approvals.size()];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import static com.google.gerrit.server.git.receive.ReceiveConstants.PUSH_OPTION_
|
|||||||
import static com.google.gerrit.server.git.receive.ReceiveConstants.SAME_CHANGE_ID_IN_MULTIPLE_CHANGES;
|
import static com.google.gerrit.server.git.receive.ReceiveConstants.SAME_CHANGE_ID_IN_MULTIPLE_CHANGES;
|
||||||
import static com.google.gerrit.server.git.validators.CommitValidators.NEW_PATCHSET_PATTERN;
|
import static com.google.gerrit.server.git.validators.CommitValidators.NEW_PATCHSET_PATTERN;
|
||||||
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromFooters;
|
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromFooters;
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
@@ -1204,7 +1205,7 @@ class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projectCache.get(newParent) == null) {
|
if (!projectCache.get(newParent).isPresent()) {
|
||||||
reject(cmd, "invalid project configuration: parent does not exist");
|
reject(cmd, "invalid project configuration: parent does not exist");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1810,7 +1811,10 @@ class ReceiveCommits {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean privateByDefault =
|
boolean privateByDefault =
|
||||||
projectCache.get(project.getNameKey()).is(BooleanProjectConfig.PRIVATE_BY_DEFAULT);
|
projectCache
|
||||||
|
.get(project.getNameKey())
|
||||||
|
.orElseThrow(illegalState(project.getNameKey()))
|
||||||
|
.is(BooleanProjectConfig.PRIVATE_BY_DEFAULT);
|
||||||
setChangeAsPrivate =
|
setChangeAsPrivate =
|
||||||
magicBranch.isPrivate || (privateByDefault && !magicBranch.removePrivate);
|
magicBranch.isPrivate || (privateByDefault && !magicBranch.removePrivate);
|
||||||
|
|
||||||
@@ -2088,6 +2092,7 @@ class ReceiveCommits {
|
|||||||
start.getParentCount() == 1
|
start.getParentCount() == 1
|
||||||
&& projectCache
|
&& projectCache
|
||||||
.get(project.getNameKey())
|
.get(project.getNameKey())
|
||||||
|
.orElseThrow(illegalState(project.getNameKey()))
|
||||||
.is(BooleanProjectConfig.REJECT_IMPLICIT_MERGES)
|
.is(BooleanProjectConfig.REJECT_IMPLICIT_MERGES)
|
||||||
// Don't worry about implicit merges when creating changes for
|
// Don't worry about implicit merges when creating changes for
|
||||||
// already-merged commits; they're already in history, so it's too
|
// already-merged commits; they're already in history, so it's too
|
||||||
@@ -3091,7 +3096,8 @@ class ReceiveCommits {
|
|||||||
logger.atWarning().withCause(e).log(
|
logger.atWarning().withCause(e).log(
|
||||||
"Cannot evict from project cache, name key: %s", project.getName());
|
"Cannot evict from project cache, name key: %s", project.getName());
|
||||||
}
|
}
|
||||||
ProjectState ps = projectCache.get(project.getNameKey());
|
ProjectState ps =
|
||||||
|
projectCache.get(project.getNameKey()).orElseThrow(illegalState(project.getNameKey()));
|
||||||
try {
|
try {
|
||||||
logger.atFine().log("Updating project description");
|
logger.atFine().log("Updating project description");
|
||||||
repo.setGitwebDescription(ps.getProject().getDescription());
|
repo.setGitwebDescription(ps.getProject().getDescription());
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ public class MergeValidators {
|
|||||||
String.format(
|
String.format(
|
||||||
" %s must inherit from %s", allUsersName.get(), allProjectsName.get()));
|
" %s must inherit from %s", allUsersName.get(), allProjectsName.get()));
|
||||||
}
|
}
|
||||||
if (projectCache.get(newParent) == null) {
|
if (!projectCache.get(newParent).isPresent()) {
|
||||||
throw new MergeValidationException(PARENT_NOT_FOUND);
|
throw new MergeValidationException(PARENT_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.group.db;
|
package com.google.gerrit.server.group.db;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.common.data.GroupReference;
|
import com.google.gerrit.common.data.GroupReference;
|
||||||
import com.google.gerrit.entities.AccountGroup;
|
import com.google.gerrit.entities.AccountGroup;
|
||||||
@@ -85,7 +87,8 @@ class RenameGroupOp extends DefaultQueueOp {
|
|||||||
public void run() {
|
public void run() {
|
||||||
Iterable<Project.NameKey> names = tryingAgain ? retryOn : projectCache.all();
|
Iterable<Project.NameKey> names = tryingAgain ? retryOn : projectCache.all();
|
||||||
for (Project.NameKey projectName : names) {
|
for (Project.NameKey projectName : names) {
|
||||||
ProjectConfig config = projectCache.get(projectName).getConfig();
|
ProjectConfig config =
|
||||||
|
projectCache.get(projectName).orElseThrow(illegalState(projectName)).getConfig();
|
||||||
GroupReference ref = config.getGroup(uuid);
|
GroupReference ref = config.getGroup(uuid);
|
||||||
if (ref == null || newName.equals(ref.getName())) {
|
if (ref == null || newName.equals(ref.getName())) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.server.index.project;
|
package com.google.gerrit.server.index.project;
|
||||||
|
|
||||||
import static com.google.gerrit.server.git.QueueProvider.QueueType.BATCH;
|
import static com.google.gerrit.server.git.QueueProvider.QueueType.BATCH;
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
@@ -78,7 +79,8 @@ public class AllProjectsIndexer extends SiteIndexer<Project.NameKey, ProjectData
|
|||||||
() -> {
|
() -> {
|
||||||
try {
|
try {
|
||||||
projectCache.evict(name);
|
projectCache.evict(name);
|
||||||
index.replace(projectCache.get(name).toProjectData());
|
index.replace(
|
||||||
|
projectCache.get(name).orElseThrow(illegalState(name)).toProjectData());
|
||||||
verboseWriter.println("Reindexed " + desc);
|
verboseWriter.println("Reindexed " + desc);
|
||||||
done.incrementAndGet();
|
done.incrementAndGet();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import com.google.inject.assistedinject.Assisted;
|
|||||||
import com.google.inject.assistedinject.AssistedInject;
|
import com.google.inject.assistedinject.AssistedInject;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation for indexing a Gerrit-managed repository (project). The project will be loaded
|
* Implementation for indexing a Gerrit-managed repository (project). The project will be loaded
|
||||||
@@ -77,10 +78,10 @@ public class ProjectIndexerImpl implements ProjectIndexer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void index(Project.NameKey nameKey) {
|
public void index(Project.NameKey nameKey) {
|
||||||
ProjectState projectState = projectCache.get(nameKey);
|
Optional<ProjectState> projectState = projectCache.get(nameKey);
|
||||||
if (projectState != null) {
|
if (projectState.isPresent()) {
|
||||||
logger.atFine().log("Replace project %s in index", nameKey.get());
|
logger.atFine().log("Replace project %s in index", nameKey.get());
|
||||||
ProjectData projectData = projectState.toProjectData();
|
ProjectData projectData = projectState.get().toProjectData();
|
||||||
for (ProjectIndex i : getWriteIndexes()) {
|
for (ProjectIndex i : getWriteIndexes()) {
|
||||||
try (TraceTimer traceTimer =
|
try (TraceTimer traceTimer =
|
||||||
TraceContext.newTimer(
|
TraceContext.newTimer(
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.index.project;
|
package com.google.gerrit.server.index.project;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.MultimapBuilder;
|
import com.google.common.collect.MultimapBuilder;
|
||||||
import com.google.common.collect.SetMultimap;
|
import com.google.common.collect.SetMultimap;
|
||||||
@@ -57,7 +59,8 @@ public class StalenessChecker {
|
|||||||
* provided {@link com.google.gerrit.entities.Project.NameKey}.
|
* provided {@link com.google.gerrit.entities.Project.NameKey}.
|
||||||
*/
|
*/
|
||||||
public StalenessCheckResult check(Project.NameKey project) {
|
public StalenessCheckResult check(Project.NameKey project) {
|
||||||
ProjectData projectData = projectCache.get(project).toProjectData();
|
ProjectData projectData =
|
||||||
|
projectCache.get(project).orElseThrow(illegalState(project)).toProjectData();
|
||||||
ProjectIndex i = indexes.getSearchIndex();
|
ProjectIndex i = indexes.getSearchIndex();
|
||||||
if (i == null) {
|
if (i == null) {
|
||||||
return StalenessCheckResult
|
return StalenessCheckResult
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
|||||||
@Override
|
@Override
|
||||||
protected void init() throws EmailException {
|
protected void init() throws EmailException {
|
||||||
if (args.projectCache != null) {
|
if (args.projectCache != null) {
|
||||||
projectState = args.projectCache.get(change.getProject());
|
projectState = args.projectCache.get(change.getProject()).orElse(null);
|
||||||
} else {
|
} else {
|
||||||
projectState = null;
|
projectState = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_TAG;
|
|||||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_TOPIC;
|
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_TOPIC;
|
||||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_WORK_IN_PROGRESS;
|
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_WORK_IN_PROGRESS;
|
||||||
import static com.google.gerrit.server.notedb.NoteDbUtil.sanitizeFooter;
|
import static com.google.gerrit.server.notedb.NoteDbUtil.sanitizeFooter;
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static java.util.Comparator.naturalOrder;
|
import static java.util.Comparator.naturalOrder;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
||||||
@@ -169,7 +170,11 @@ public class ChangeUpdate extends AbstractChangeUpdate {
|
|||||||
notes,
|
notes,
|
||||||
user,
|
user,
|
||||||
when,
|
when,
|
||||||
projectCache.get(notes.getProjectName()).getLabelTypes().nameComparator(),
|
projectCache
|
||||||
|
.get(notes.getProjectName())
|
||||||
|
.orElseThrow(illegalState(notes.getProjectName()))
|
||||||
|
.getLabelTypes()
|
||||||
|
.nameComparator(),
|
||||||
noteUtil);
|
noteUtil);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,16 @@ public class ChildProjects {
|
|||||||
private Map<Project.NameKey, Project> readAllReadableProjects() {
|
private Map<Project.NameKey, Project> readAllReadableProjects() {
|
||||||
Map<Project.NameKey, Project> projects = new HashMap<>();
|
Map<Project.NameKey, Project> projects = new HashMap<>();
|
||||||
for (Project.NameKey name : projectCache.all()) {
|
for (Project.NameKey name : projectCache.all()) {
|
||||||
ProjectState c = projectCache.get(name);
|
|
||||||
|
ProjectState c =
|
||||||
|
projectCache
|
||||||
|
.get(name)
|
||||||
|
.orElseThrow(
|
||||||
|
() ->
|
||||||
|
new IllegalStateException(
|
||||||
|
"race while traversing projects. got "
|
||||||
|
+ name
|
||||||
|
+ " when loading all projects, but can't load it now"));
|
||||||
if (c != null && c.statePermitsRead()) {
|
if (c != null && c.statePermitsRead()) {
|
||||||
projects.put(c.getNameKey(), c.getProject());
|
projects.put(c.getNameKey(), c.getProject());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,28 @@ import com.google.gerrit.entities.AccountGroup;
|
|||||||
import com.google.gerrit.entities.Project;
|
import com.google.gerrit.entities.Project;
|
||||||
import com.google.gerrit.exceptions.StorageException;
|
import com.google.gerrit.exceptions.StorageException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/** Cache of project information, including access rights. */
|
/** Cache of project information, including access rights. */
|
||||||
public interface ProjectCache {
|
public interface ProjectCache {
|
||||||
|
/**
|
||||||
|
* Returns a supplier to be used as a short-hand when unwrapping an {@link Optional} returned from
|
||||||
|
* this cache.
|
||||||
|
*/
|
||||||
|
static Supplier<IllegalStateException> illegalState(Project.NameKey nameKey) {
|
||||||
|
return () -> new IllegalStateException("unable to find project " + nameKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a supplier to be used as a short-hand when unwrapping an {@link Optional} returned from
|
||||||
|
* this cache.
|
||||||
|
*/
|
||||||
|
static Supplier<NoSuchProjectException> noSuchProject(Project.NameKey nameKey) {
|
||||||
|
return () -> new NoSuchProjectException(nameKey);
|
||||||
|
}
|
||||||
|
|
||||||
/** @return the parent state for all projects on this server. */
|
/** @return the parent state for all projects on this server. */
|
||||||
ProjectState getAllProjects();
|
ProjectState getAllProjects();
|
||||||
|
|
||||||
@@ -34,11 +52,12 @@ public interface ProjectCache {
|
|||||||
* Get the cached data for a project by its unique name.
|
* Get the cached data for a project by its unique name.
|
||||||
*
|
*
|
||||||
* @param projectName name of the project.
|
* @param projectName name of the project.
|
||||||
* @return the cached data; null if no such project exists or the projectName is null
|
* @return an {@link Optional} wrapping the the cached data; {@code absent} if no such project
|
||||||
|
* exists or the projectName is null
|
||||||
* @throws StorageException when there was an error.
|
* @throws StorageException when there was an error.
|
||||||
* @see #checkedGet(com.google.gerrit.entities.Project.NameKey)
|
* @see #checkedGet(com.google.gerrit.entities.Project.NameKey)
|
||||||
*/
|
*/
|
||||||
ProjectState get(@Nullable Project.NameKey projectName) throws StorageException;
|
Optional<ProjectState> get(@Nullable Project.NameKey projectName) throws StorageException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the cached data for a project by its unique name.
|
* Get the cached data for a project by its unique name.
|
||||||
@@ -51,19 +70,6 @@ public interface ProjectCache {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
ProjectState checkedGet(@Nullable Project.NameKey projectName) throws IOException;
|
ProjectState checkedGet(@Nullable Project.NameKey projectName) throws IOException;
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the cached data for a project by its unique name.
|
|
||||||
*
|
|
||||||
* @param projectName name of the project.
|
|
||||||
* @param strict true when any error generates an exception
|
|
||||||
* @throws Exception in case of any error (strict = true) or only for I/O or other internal
|
|
||||||
* errors.
|
|
||||||
* @return the cached data or null when strict = false
|
|
||||||
* @deprecated use {@link #get(Project.NameKey)} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
ProjectState checkedGet(Project.NameKey projectName, boolean strict) throws Exception;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invalidate the cached information about the given project, and triggers reindexing for it
|
* Invalidate the cached information about the given project, and triggers reindexing for it
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.project;
|
package com.google.gerrit.server.project;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@@ -48,6 +49,7 @@ import com.google.inject.TypeLiteral;
|
|||||||
import com.google.inject.name.Named;
|
import com.google.inject.name.Named;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
@@ -125,29 +127,18 @@ public class ProjectCacheImpl implements ProjectCache {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProjectState getAllProjects() {
|
public ProjectState getAllProjects() {
|
||||||
ProjectState state = get(allProjectsName);
|
return get(allProjectsName).orElseThrow(illegalState(allProjectsName));
|
||||||
if (state == null) {
|
|
||||||
// This should never occur, the server must have this
|
|
||||||
// project to process anything.
|
|
||||||
throw new IllegalStateException("Missing project " + allProjectsName);
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProjectState getAllUsers() {
|
public ProjectState getAllUsers() {
|
||||||
ProjectState state = get(allUsersName);
|
return get(allUsersName).orElseThrow(illegalState(allUsersName));
|
||||||
if (state == null) {
|
|
||||||
// This should never occur.
|
|
||||||
throw new IllegalStateException("Missing project " + allUsersName);
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ProjectState get(Project.NameKey projectName) {
|
public Optional<ProjectState> get(Project.NameKey projectName) {
|
||||||
try {
|
try {
|
||||||
return checkedGet(projectName);
|
return Optional.ofNullable(checkedGet(projectName));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new StorageException("project state not available", e);
|
throw new StorageException("project state not available", e);
|
||||||
}
|
}
|
||||||
@@ -173,11 +164,6 @@ public class ProjectCacheImpl implements ProjectCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProjectState checkedGet(Project.NameKey projectName, boolean strict) throws Exception {
|
|
||||||
return strict ? strictCheckedGet(projectName) : checkedGet(projectName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ProjectState strictCheckedGet(Project.NameKey projectName) throws Exception {
|
private ProjectState strictCheckedGet(Project.NameKey projectName) throws Exception {
|
||||||
ProjectState state = byName.get(projectName.get());
|
ProjectState state = byName.get(projectName.get());
|
||||||
if (state != null && state.needsRefresh(clock.read())) {
|
if (state != null && state.needsRefresh(clock.read())) {
|
||||||
|
|||||||
@@ -53,7 +53,16 @@ public class ProjectCacheWarmer implements LifecycleListener {
|
|||||||
new Thread(
|
new Thread(
|
||||||
() -> {
|
() -> {
|
||||||
for (Project.NameKey name : cache.all()) {
|
for (Project.NameKey name : cache.all()) {
|
||||||
pool.execute(() -> cache.get(name));
|
pool.execute(
|
||||||
|
() ->
|
||||||
|
cache
|
||||||
|
.get(name)
|
||||||
|
.orElseThrow(
|
||||||
|
() ->
|
||||||
|
new IllegalStateException(
|
||||||
|
"race while traversing projects. got "
|
||||||
|
+ name
|
||||||
|
+ " when loading all projects, but can't load it now")));
|
||||||
}
|
}
|
||||||
pool.shutdown();
|
pool.shutdown();
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.project;
|
package com.google.gerrit.server.project;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.common.data.AccessSection;
|
import com.google.gerrit.common.data.AccessSection;
|
||||||
@@ -124,7 +126,7 @@ public class ProjectCreator {
|
|||||||
|
|
||||||
fire(nameKey, head);
|
fire(nameKey, head);
|
||||||
|
|
||||||
return projectCache.get(nameKey);
|
return projectCache.get(nameKey).orElseThrow(illegalState(nameKey));
|
||||||
}
|
}
|
||||||
} catch (RepositoryCaseMismatchException e) {
|
} catch (RepositoryCaseMismatchException e) {
|
||||||
throw new ResourceConflictException(
|
throw new ResourceConflictException(
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import com.google.gerrit.server.config.AllProjectsName;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -65,16 +66,16 @@ class ProjectHierarchyIterator implements Iterator<ProjectState> {
|
|||||||
private ProjectState computeNext(ProjectState n) {
|
private ProjectState computeNext(ProjectState n) {
|
||||||
Project.NameKey parentName = n.getProject().getParent();
|
Project.NameKey parentName = n.getProject().getParent();
|
||||||
if (parentName != null && visit(parentName)) {
|
if (parentName != null && visit(parentName)) {
|
||||||
ProjectState p = cache.get(parentName);
|
Optional<ProjectState> p = cache.get(parentName);
|
||||||
if (p != null) {
|
if (p.isPresent()) {
|
||||||
return p;
|
return p.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parent does not exist or was already visited.
|
// Parent does not exist or was already visited.
|
||||||
// Fall back to visit All-Projects exactly once.
|
// Fall back to visit All-Projects exactly once.
|
||||||
if (seen.add(allProjectsName)) {
|
if (seen.add(allProjectsName)) {
|
||||||
return cache.get(allProjectsName);
|
return cache.getAllProjects();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.project;
|
package com.google.gerrit.server.project;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.noSuchProject;
|
||||||
|
|
||||||
import com.google.common.collect.Streams;
|
import com.google.common.collect.Streams;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.common.data.SubmitRecord;
|
import com.google.gerrit.common.data.SubmitRecord;
|
||||||
@@ -108,17 +110,13 @@ public class SubmitRuleEvaluator {
|
|||||||
public List<SubmitRecord> evaluate(ChangeData cd) {
|
public List<SubmitRecord> evaluate(ChangeData cd) {
|
||||||
try (Timer0.Context ignored = submitRuleEvaluationLatency.start()) {
|
try (Timer0.Context ignored = submitRuleEvaluationLatency.start()) {
|
||||||
Change change;
|
Change change;
|
||||||
ProjectState projectState;
|
|
||||||
try {
|
try {
|
||||||
change = cd.change();
|
change = cd.change();
|
||||||
if (change == null) {
|
if (change == null) {
|
||||||
throw new StorageException("Change not found");
|
throw new StorageException("Change not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
projectState = projectCache.get(cd.project());
|
projectCache.get(cd.project()).orElseThrow(noSuchProject(cd.project()));
|
||||||
if (projectState == null) {
|
|
||||||
throw new NoSuchProjectException(cd.project());
|
|
||||||
}
|
|
||||||
} catch (StorageException | NoSuchProjectException e) {
|
} catch (StorageException | NoSuchProjectException e) {
|
||||||
return Collections.singletonList(ruleError("Error looking up change " + cd.getId(), e));
|
return Collections.singletonList(ruleError("Error looking up change " + cd.getId(), e));
|
||||||
}
|
}
|
||||||
@@ -154,10 +152,7 @@ public class SubmitRuleEvaluator {
|
|||||||
try (Timer0.Context ignored = submitTypeEvaluationLatency.start()) {
|
try (Timer0.Context ignored = submitTypeEvaluationLatency.start()) {
|
||||||
ProjectState projectState;
|
ProjectState projectState;
|
||||||
try {
|
try {
|
||||||
projectState = projectCache.get(cd.project());
|
projectState = projectCache.get(cd.project()).orElseThrow(noSuchProject(cd.project()));
|
||||||
if (projectState == null) {
|
|
||||||
throw new NoSuchProjectException(cd.project());
|
|
||||||
}
|
|
||||||
} catch (NoSuchProjectException e) {
|
} catch (NoSuchProjectException e) {
|
||||||
return typeError("Error looking up change " + cd.getId(), e);
|
return typeError("Error looking up change " + cd.getId(), e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.google.inject.Inject;
|
|||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -51,9 +52,9 @@ public class SuggestParentCandidates {
|
|||||||
private Set<Project.NameKey> readableParents() {
|
private Set<Project.NameKey> readableParents() {
|
||||||
Set<Project.NameKey> parents = new HashSet<>();
|
Set<Project.NameKey> parents = new HashSet<>();
|
||||||
for (Project.NameKey p : projectCache.all()) {
|
for (Project.NameKey p : projectCache.all()) {
|
||||||
ProjectState ps = projectCache.get(p);
|
Optional<ProjectState> ps = projectCache.get(p);
|
||||||
if (ps != null && ps.statePermitsRead()) {
|
if (ps.isPresent() && ps.get().statePermitsRead()) {
|
||||||
Project.NameKey parent = ps.getProject().getParent();
|
Project.NameKey parent = ps.get().getProject().getParent();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
parents.add(parent);
|
parents.add(parent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.query.change;
|
package com.google.gerrit.server.query.change;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
import static java.util.stream.Collectors.toMap;
|
import static java.util.stream.Collectors.toMap;
|
||||||
@@ -915,7 +916,9 @@ public class ChangeData {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String mergeStrategy =
|
String mergeStrategy =
|
||||||
mergeUtilFactory.create(projectCache.get(project())).mergeStrategyName();
|
mergeUtilFactory
|
||||||
|
.create(projectCache.get(project()).orElseThrow(illegalState(project())))
|
||||||
|
.mergeStrategyName();
|
||||||
mergeable =
|
mergeable =
|
||||||
mergeabilityCache.get(ps.commitId(), ref, str.type, mergeStrategy, c.getDest(), repo);
|
mergeabilityCache.get(ps.commitId(), ref, str.type, mergeStrategy, c.getDest(), repo);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.query.change;
|
|||||||
|
|
||||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
import static com.google.common.flogger.LazyArgs.lazy;
|
import static com.google.common.flogger.LazyArgs.lazy;
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.noSuchProject;
|
||||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
@@ -218,10 +219,7 @@ public class ConflictsPredicate {
|
|||||||
|
|
||||||
ProjectState getProjectState() throws NoSuchProjectException {
|
ProjectState getProjectState() throws NoSuchProjectException {
|
||||||
if (projectState == null) {
|
if (projectState == null) {
|
||||||
projectState = projectCache.get(cd.project());
|
projectState = projectCache.get(cd.project()).orElseThrow(noSuchProject(cd.project()));
|
||||||
if (projectState == null) {
|
|
||||||
throw new NoSuchProjectException(cd.project());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return projectState;
|
return projectState;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import com.google.gerrit.server.permissions.PermissionBackendException;
|
|||||||
import com.google.gerrit.server.project.ProjectCache;
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
import com.google.gerrit.server.project.ProjectState;
|
import com.google.gerrit.server.project.ProjectState;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class EqualsLabelPredicate extends ChangeIndexPredicate {
|
public class EqualsLabelPredicate extends ChangeIndexPredicate {
|
||||||
protected final ProjectCache projectCache;
|
protected final ProjectCache projectCache;
|
||||||
@@ -60,14 +61,14 @@ public class EqualsLabelPredicate extends ChangeIndexPredicate {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectState project = projectCache.get(c.getDest().project());
|
Optional<ProjectState> project = projectCache.get(c.getDest().project());
|
||||||
if (project == null) {
|
if (!project.isPresent()) {
|
||||||
// The project has disappeared.
|
// The project has disappeared.
|
||||||
//
|
//
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LabelType labelType = type(project.getLabelTypes(), label);
|
LabelType labelType = type(project.get().getLabelTypes(), label);
|
||||||
if (labelType == null) {
|
if (labelType == null) {
|
||||||
return false; // Label is not defined by this project.
|
return false; // Label is not defined by this project.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.google.gerrit.server.project.ProjectState;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class ParentProjectPredicate extends OrPredicate<ChangeData> {
|
public class ParentProjectPredicate extends OrPredicate<ChangeData> {
|
||||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||||
@@ -40,15 +41,15 @@ public class ParentProjectPredicate extends OrPredicate<ChangeData> {
|
|||||||
|
|
||||||
protected static List<Predicate<ChangeData>> predicates(
|
protected static List<Predicate<ChangeData>> predicates(
|
||||||
ProjectCache projectCache, ChildProjects childProjects, String value) {
|
ProjectCache projectCache, ChildProjects childProjects, String value) {
|
||||||
ProjectState projectState = projectCache.get(Project.nameKey(value));
|
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(value));
|
||||||
if (projectState == null) {
|
if (!projectState.isPresent()) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Predicate<ChangeData>> r = new ArrayList<>();
|
List<Predicate<ChangeData>> r = new ArrayList<>();
|
||||||
r.add(new ProjectPredicate(projectState.getName()));
|
r.add(new ProjectPredicate(projectState.get().getName()));
|
||||||
try {
|
try {
|
||||||
for (ProjectInfo p : childProjects.list(projectState.getNameKey())) {
|
for (ProjectInfo p : childProjects.list(projectState.get().getNameKey())) {
|
||||||
r.add(new ProjectPredicate(p.name));
|
r.add(new ProjectPredicate(p.name));
|
||||||
}
|
}
|
||||||
} catch (PermissionBackendException e) {
|
} catch (PermissionBackendException e) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.restapi.change;
|
package com.google.gerrit.server.restapi.change;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static com.google.gerrit.util.cli.Localizable.localizable;
|
import static com.google.gerrit.util.cli.Localizable.localizable;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
@@ -146,7 +147,7 @@ public class GetDiff implements RestReadView<FileResource> {
|
|||||||
psf.setLoadComments(context != DiffPreferencesInfo.WHOLE_FILE_CONTEXT);
|
psf.setLoadComments(context != DiffPreferencesInfo.WHOLE_FILE_CONTEXT);
|
||||||
PatchScript ps = psf.call();
|
PatchScript ps = psf.call();
|
||||||
Project.NameKey projectName = resource.getRevision().getChange().getProject();
|
Project.NameKey projectName = resource.getRevision().getChange().getProject();
|
||||||
ProjectState state = projectCache.get(projectName);
|
ProjectState state = projectCache.get(projectName).orElseThrow(illegalState(projectName));
|
||||||
DiffSide sideA =
|
DiffSide sideA =
|
||||||
DiffSide.create(
|
DiffSide.create(
|
||||||
ps.getFileInfoA(),
|
ps.getFileInfoA(),
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.restapi.change;
|
package com.google.gerrit.server.restapi.change;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static java.util.stream.Collectors.groupingBy;
|
import static java.util.stream.Collectors.groupingBy;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
@@ -78,7 +79,8 @@ public class GetFixPreview implements RestReadView<FixResource> {
|
|||||||
PatchSet patchSet = resource.getRevisionResource().getPatchSet();
|
PatchSet patchSet = resource.getRevisionResource().getPatchSet();
|
||||||
ChangeNotes notes = resource.getRevisionResource().getNotes();
|
ChangeNotes notes = resource.getRevisionResource().getNotes();
|
||||||
Change change = notes.getChange();
|
Change change = notes.getChange();
|
||||||
ProjectState state = projectCache.get(change.getProject());
|
ProjectState state =
|
||||||
|
projectCache.get(change.getProject()).orElseThrow(illegalState(change.getProject()));
|
||||||
Map<String, List<FixReplacement>> fixReplacementsPerFilePath =
|
Map<String, List<FixReplacement>> fixReplacementsPerFilePath =
|
||||||
resource.getFixReplacements().stream()
|
resource.getFixReplacements().stream()
|
||||||
.collect(groupingBy(fixReplacement -> fixReplacement.path));
|
.collect(groupingBy(fixReplacement -> fixReplacement.path));
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.restapi.change;
|
package com.google.gerrit.server.restapi.change;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
|
|
||||||
import com.google.gerrit.common.data.SubmitTypeRecord;
|
import com.google.gerrit.common.data.SubmitTypeRecord;
|
||||||
import com.google.gerrit.entities.Change;
|
import com.google.gerrit.entities.Change;
|
||||||
import com.google.gerrit.entities.PatchSet;
|
import com.google.gerrit.entities.PatchSet;
|
||||||
@@ -105,7 +107,8 @@ public class Mergeable implements RestReadView<RevisionResource> {
|
|||||||
try (Repository git = gitManager.openRepository(change.getProject())) {
|
try (Repository git = gitManager.openRepository(change.getProject())) {
|
||||||
ObjectId commit = ps.commitId();
|
ObjectId commit = ps.commitId();
|
||||||
Ref ref = git.getRefDatabase().exactRef(change.getDest().branch());
|
Ref ref = git.getRefDatabase().exactRef(change.getDest().branch());
|
||||||
ProjectState projectState = projectCache.get(change.getProject());
|
ProjectState projectState =
|
||||||
|
projectCache.get(change.getProject()).orElseThrow(illegalState(change.getProject()));
|
||||||
String strategy = mergeUtilFactory.create(projectState).mergeStrategyName();
|
String strategy = mergeUtilFactory.create(projectState).mergeStrategyName();
|
||||||
result.strategy = strategy;
|
result.strategy = strategy;
|
||||||
result.mergeable = isMergable(git, change, commit, ref, result.submitType, strategy);
|
result.mergeable = isMergable(git, change, commit, ref, result.submitType, strategy);
|
||||||
|
|||||||
@@ -75,10 +75,10 @@ public class TestSubmitRule implements RestModifyView<RevisionResource, TestSubm
|
|||||||
}
|
}
|
||||||
input.filters = MoreObjects.firstNonNull(input.filters, filters);
|
input.filters = MoreObjects.firstNonNull(input.filters, filters);
|
||||||
|
|
||||||
ProjectState projectState = projectCache.get(rsrc.getProject());
|
ProjectState projectState =
|
||||||
if (projectState == null) {
|
projectCache
|
||||||
throw new BadRequestException("project not found");
|
.get(rsrc.getProject())
|
||||||
}
|
.orElseThrow(() -> new BadRequestException("project not found " + rsrc.getProject()));
|
||||||
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
||||||
SubmitRecord record =
|
SubmitRecord record =
|
||||||
prologRule.evaluate(
|
prologRule.evaluate(
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -85,8 +86,8 @@ public class ListTasks implements RestReadView<ConfigResource> {
|
|||||||
Boolean visible = visibilityCache.get(task.projectName);
|
Boolean visible = visibilityCache.get(task.projectName);
|
||||||
if (visible == null) {
|
if (visible == null) {
|
||||||
Project.NameKey nameKey = Project.nameKey(task.projectName);
|
Project.NameKey nameKey = Project.nameKey(task.projectName);
|
||||||
ProjectState state = projectCache.get(nameKey);
|
Optional<ProjectState> state = projectCache.get(nameKey);
|
||||||
if (state == null || !state.statePermitsRead()) {
|
if (!state.isPresent() || !state.get().statePermitsRead()) {
|
||||||
visible = false;
|
visible = false;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ import com.google.gerrit.server.project.ProjectState;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class TasksCollection implements ChildCollection<ConfigResource, TaskResource> {
|
public class TasksCollection implements ChildCollection<ConfigResource, TaskResource> {
|
||||||
@@ -87,12 +88,12 @@ public class TasksCollection implements ChildCollection<ConfigResource, TaskReso
|
|||||||
Task<?> task = workQueue.getTask(taskId);
|
Task<?> task = workQueue.getTask(taskId);
|
||||||
if (task instanceof ProjectTask) {
|
if (task instanceof ProjectTask) {
|
||||||
Project.NameKey nameKey = ((ProjectTask<?>) task).getProjectNameKey();
|
Project.NameKey nameKey = ((ProjectTask<?>) task).getProjectNameKey();
|
||||||
ProjectState state = projectCache.get(nameKey);
|
Optional<ProjectState> state = projectCache.get(nameKey);
|
||||||
if (state == null) {
|
if (!state.isPresent()) {
|
||||||
throw new ResourceNotFoundException(String.format("project %s not found", nameKey));
|
throw new ResourceNotFoundException(String.format("project %s not found", nameKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
state.checkStatePermitsRead();
|
state.get().checkStatePermitsRead();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
permissionBackend.user(user).project(nameKey).check(ProjectPermission.ACCESS);
|
permissionBackend.user(user).project(nameKey).check(ProjectPermission.ACCESS);
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
@@ -610,7 +609,8 @@ public class ListProjects implements RestReadView<TopLevelResource> {
|
|||||||
private Stream<ProjectState> filter(PermissionBackend.WithUser perm) throws BadRequestException {
|
private Stream<ProjectState> filter(PermissionBackend.WithUser perm) throws BadRequestException {
|
||||||
return StreamSupport.stream(scan().spliterator(), false)
|
return StreamSupport.stream(scan().spliterator(), false)
|
||||||
.map(projectCache::get)
|
.map(projectCache::get)
|
||||||
.filter(Objects::nonNull)
|
.filter(Optional::isPresent)
|
||||||
|
.map(Optional::get)
|
||||||
.filter(p -> permissionCheck(p, perm));
|
.filter(p -> permissionCheck(p, perm));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,10 +156,14 @@ public class SetParent
|
|||||||
|
|
||||||
newParent = Strings.emptyToNull(newParent);
|
newParent = Strings.emptyToNull(newParent);
|
||||||
if (newParent != null) {
|
if (newParent != null) {
|
||||||
ProjectState parent = cache.get(Project.nameKey(newParent));
|
Project.NameKey newParentNameKey = Project.nameKey(newParent);
|
||||||
if (parent == null) {
|
ProjectState parent =
|
||||||
throw new UnprocessableEntityException("parent project " + newParent + " not found");
|
cache
|
||||||
}
|
.get(newParentNameKey)
|
||||||
|
.orElseThrow(
|
||||||
|
() ->
|
||||||
|
new UnprocessableEntityException(
|
||||||
|
"parent project " + newParentNameKey + " not found"));
|
||||||
|
|
||||||
if (parent.getName().equals(project.get())) {
|
if (parent.getName().equals(project.get())) {
|
||||||
throw new ResourceConflictException("cannot set parent to self");
|
throw new ResourceConflictException("cannot set parent to self");
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.server.rules;
|
package com.google.gerrit.server.rules;
|
||||||
|
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.common.data.LabelFunction;
|
import com.google.gerrit.common.data.LabelFunction;
|
||||||
@@ -63,11 +64,12 @@ public final class DefaultSubmitRule implements SubmitRule {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SubmitRecord> evaluate(ChangeData cd) {
|
public Optional<SubmitRecord> evaluate(ChangeData cd) {
|
||||||
ProjectState projectState = projectCache.get(cd.project());
|
ProjectState projectState =
|
||||||
|
projectCache.get(cd.project()).orElseThrow(illegalState(cd.project()));
|
||||||
|
|
||||||
// In case at least one project has a rules.pl file, we let Prolog handle it.
|
// In case at least one project has a rules.pl file, we let Prolog handle it.
|
||||||
// The Prolog rules engine will also handle the labels for us.
|
// The Prolog rules engine will also handle the labels for us.
|
||||||
if (projectState == null || projectState.hasPrologRules()) {
|
if (projectState.hasPrologRules()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.rules;
|
package com.google.gerrit.server.rules;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
|
|
||||||
import com.google.gerrit.common.data.SubmitRecord;
|
import com.google.gerrit.common.data.SubmitRecord;
|
||||||
import com.google.gerrit.common.data.SubmitTypeRecord;
|
import com.google.gerrit.common.data.SubmitTypeRecord;
|
||||||
import com.google.gerrit.server.project.ProjectCache;
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
@@ -36,9 +38,10 @@ public class PrologRule implements SubmitRule {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SubmitRecord> evaluate(ChangeData cd) {
|
public Optional<SubmitRecord> evaluate(ChangeData cd) {
|
||||||
ProjectState projectState = projectCache.get(cd.project());
|
ProjectState projectState =
|
||||||
|
projectCache.get(cd.project()).orElseThrow(illegalState(cd.project()));
|
||||||
// We only want to run the Prolog engine if we have at least one rules.pl file to use.
|
// We only want to run the Prolog engine if we have at least one rules.pl file to use.
|
||||||
if ((projectState == null || !projectState.hasPrologRules())) {
|
if (!projectState.hasPrologRules()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.server.rules;
|
package com.google.gerrit.server.rules;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static com.google.gerrit.server.project.SubmitRuleEvaluator.createRuleError;
|
import static com.google.gerrit.server.project.SubmitRuleEvaluator.createRuleError;
|
||||||
import static com.google.gerrit.server.project.SubmitRuleEvaluator.defaultRuleError;
|
import static com.google.gerrit.server.project.SubmitRuleEvaluator.defaultRuleError;
|
||||||
import static com.google.gerrit.server.project.SubmitRuleEvaluator.defaultTypeError;
|
import static com.google.gerrit.server.project.SubmitRuleEvaluator.defaultTypeError;
|
||||||
@@ -115,7 +116,7 @@ public class PrologRuleEvaluator {
|
|||||||
this.cd = cd;
|
this.cd = cd;
|
||||||
this.opts = options;
|
this.opts = options;
|
||||||
|
|
||||||
this.projectState = projectCache.get(cd.project());
|
this.projectState = projectCache.get(cd.project()).orElseThrow(illegalState(cd.project()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Term toListTerm(List<Term> terms) {
|
private static Term toListTerm(List<Term> terms) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.server.submit;
|
package com.google.gerrit.server.submit;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.noSuchProject;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
@@ -185,10 +186,7 @@ public class MergeOpRepoManager implements AutoCloseable {
|
|||||||
return openRepos.get(project);
|
return openRepos.get(project);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectState projectState = projectCache.get(project);
|
ProjectState projectState = projectCache.get(project).orElseThrow(noSuchProject(project));
|
||||||
if (projectState == null) {
|
|
||||||
throw new NoSuchProjectException(project);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
OpenRepo or = new OpenRepo(repoManager.openRepository(project), projectState);
|
OpenRepo or = new OpenRepo(repoManager.openRepository(project), projectState);
|
||||||
openRepos.put(project, or);
|
openRepos.put(project, or);
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.submit;
|
package com.google.gerrit.server.submit;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.noSuchProject;
|
||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
@@ -156,10 +157,6 @@ public class SubmitDryRun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ProjectState getProject(BranchNameKey branch) throws NoSuchProjectException {
|
private ProjectState getProject(BranchNameKey branch) throws NoSuchProjectException {
|
||||||
ProjectState p = projectCache.get(branch.project());
|
return projectCache.get(branch.project()).orElseThrow(noSuchProject(branch.project()));
|
||||||
if (p == null) {
|
|
||||||
throw new NoSuchProjectException(branch.project());
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.server.submit;
|
package com.google.gerrit.server.submit;
|
||||||
|
|
||||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@@ -200,9 +201,7 @@ public abstract class SubmitStrategy {
|
|||||||
this.dryrun = dryrun;
|
this.dryrun = dryrun;
|
||||||
|
|
||||||
this.project =
|
this.project =
|
||||||
requireNonNull(
|
projectCache.get(destBranch.project()).orElseThrow(illegalState(destBranch.project()));
|
||||||
projectCache.get(destBranch.project()),
|
|
||||||
() -> String.format("project not found: %s", destBranch.project()));
|
|
||||||
this.mergeSorter =
|
this.mergeSorter =
|
||||||
new MergeSorter(caller, rw, alreadyAccepted, canMergeFlag, queryProvider, incoming);
|
new MergeSorter(caller, rw, alreadyAccepted, canMergeFlag, queryProvider, incoming);
|
||||||
this.rebaseSorter =
|
this.rebaseSorter =
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.submit;
|
|||||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
@@ -486,7 +487,8 @@ abstract class SubmitStrategyOp implements BatchUpdateOp {
|
|||||||
// per project even if multiple changes to refs/meta/config are submitted.
|
// per project even if multiple changes to refs/meta/config are submitted.
|
||||||
if (RefNames.REFS_CONFIG.equals(getDest().branch())) {
|
if (RefNames.REFS_CONFIG.equals(getDest().branch())) {
|
||||||
args.projectCache.evict(getProject());
|
args.projectCache.evict(getProject());
|
||||||
ProjectState p = args.projectCache.get(getProject());
|
ProjectState p =
|
||||||
|
args.projectCache.get(getProject()).orElseThrow(illegalState(getProject()));
|
||||||
try (Repository git = args.repoManager.openRepository(getProject())) {
|
try (Repository git = args.repoManager.openRepository(getProject())) {
|
||||||
git.setGitwebDescription(p.getProject().getDescription());
|
git.setGitwebDescription(p.getProject().getDescription());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.submit;
|
package com.google.gerrit.server.submit;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
@@ -362,7 +363,11 @@ public class SubmoduleOp {
|
|||||||
logger.atFine().log("Calculating possible superprojects for %s", srcBranch);
|
logger.atFine().log("Calculating possible superprojects for %s", srcBranch);
|
||||||
Collection<SubmoduleSubscription> ret = new ArrayList<>();
|
Collection<SubmoduleSubscription> ret = new ArrayList<>();
|
||||||
Project.NameKey srcProject = srcBranch.project();
|
Project.NameKey srcProject = srcBranch.project();
|
||||||
for (SubscribeSection s : projectCache.get(srcProject).getSubscribeSections(srcBranch)) {
|
for (SubscribeSection s :
|
||||||
|
projectCache
|
||||||
|
.get(srcProject)
|
||||||
|
.orElseThrow(illegalState(srcProject))
|
||||||
|
.getSubscribeSections(srcBranch)) {
|
||||||
logger.atFine().log("Checking subscribe section %s", s);
|
logger.atFine().log("Checking subscribe section %s", s);
|
||||||
Collection<BranchNameKey> branches = getDestinationBranches(srcBranch, s);
|
Collection<BranchNameKey> branches = getDestinationBranches(srcBranch, s);
|
||||||
for (BranchNameKey targetBranch : branches) {
|
for (BranchNameKey targetBranch : branches) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.sshd.commands;
|
package com.google.gerrit.sshd.commands;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
import com.google.gerrit.entities.Project;
|
import com.google.gerrit.entities.Project;
|
||||||
@@ -37,6 +38,7 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.kohsuke.args4j.Argument;
|
import org.kohsuke.args4j.Argument;
|
||||||
import org.kohsuke.args4j.Option;
|
import org.kohsuke.args4j.Option;
|
||||||
@@ -117,7 +119,7 @@ final class SetParentCommand extends SshCommand {
|
|||||||
|
|
||||||
for (Project.NameKey nameKey : childProjects) {
|
for (Project.NameKey nameKey : childProjects) {
|
||||||
final String name = nameKey.get();
|
final String name = nameKey.get();
|
||||||
ProjectState project = projectCache.get(nameKey);
|
ProjectState project = projectCache.get(nameKey).orElseThrow(illegalState(nameKey));
|
||||||
try {
|
try {
|
||||||
setParent.apply(new ProjectResource(project, user), parentInput(newParentKey.get()));
|
setParent.apply(new ProjectResource(project, user), parentInput(newParentKey.get()));
|
||||||
} catch (AuthException e) {
|
} catch (AuthException e) {
|
||||||
@@ -177,10 +179,10 @@ final class SetParentCommand extends SshCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<Project.NameKey> getAllParents(Project.NameKey projectName) {
|
private Set<Project.NameKey> getAllParents(Project.NameKey projectName) {
|
||||||
ProjectState ps = projectCache.get(projectName);
|
Optional<ProjectState> ps = projectCache.get(projectName);
|
||||||
if (ps == null) {
|
if (!ps.isPresent()) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
return ps.parents().transform(ProjectState::getNameKey).toSet();
|
return ps.get().parents().transform(ProjectState::getNameKey).toSet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.sshd.commands;
|
package com.google.gerrit.sshd.commands;
|
||||||
|
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.util.Objects.requireNonNull;
|
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@@ -245,8 +245,8 @@ public class UploadArchive extends AbstractGitCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean canRead(ObjectId revId) throws IOException, PermissionBackendException {
|
private boolean canRead(ObjectId revId) throws IOException, PermissionBackendException {
|
||||||
ProjectState projectState = projectCache.get(projectName);
|
ProjectState projectState =
|
||||||
requireNonNull(projectState, () -> String.format("Failed to load project %s", projectName));
|
projectCache.get(projectName).orElseThrow(illegalState(projectName));
|
||||||
|
|
||||||
if (!projectState.statePermitsRead()) {
|
if (!projectState.statePermitsRead()) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -91,9 +91,9 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
// for more extensive coverage of the LabelTypeInfo.
|
// for more extensive coverage of the LabelTypeInfo.
|
||||||
assertThat(p.labels).hasSize(1);
|
assertThat(p.labels).hasSize(1);
|
||||||
|
|
||||||
ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
|
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
|
||||||
assertThat(projectState).isNotNull();
|
assertThat(projectState).isPresent();
|
||||||
assertProjectInfo(projectState.getProject(), p);
|
assertProjectInfo(projectState.get().getProject(), p);
|
||||||
assertHead(newProjectName, "refs/heads/master");
|
assertHead(newProjectName, "refs/heads/master");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,9 +167,9 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
String newProjectName = name("newProject");
|
String newProjectName = name("newProject");
|
||||||
ProjectInfo p = gApi.projects().create(newProjectName).get();
|
ProjectInfo p = gApi.projects().create(newProjectName).get();
|
||||||
assertThat(p.name).isEqualTo(newProjectName);
|
assertThat(p.name).isEqualTo(newProjectName);
|
||||||
ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
|
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
|
||||||
assertThat(projectState).isNotNull();
|
assertThat(projectState).isPresent();
|
||||||
assertProjectInfo(projectState.getProject(), p);
|
assertProjectInfo(projectState.get().getProject(), p);
|
||||||
assertHead(newProjectName, "refs/heads/master");
|
assertHead(newProjectName, "refs/heads/master");
|
||||||
assertThat(readProjectConfig(newProjectName))
|
assertThat(readProjectConfig(newProjectName))
|
||||||
.hasValue("[access]\n\tinheritFrom = All-Projects\n[submit]\n\taction = inherit\n");
|
.hasValue("[access]\n\tinheritFrom = All-Projects\n[submit]\n\taction = inherit\n");
|
||||||
@@ -180,9 +180,9 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
String newProjectName = name("newProject");
|
String newProjectName = name("newProject");
|
||||||
ProjectInfo p = gApi.projects().create(newProjectName + ".git").get();
|
ProjectInfo p = gApi.projects().create(newProjectName + ".git").get();
|
||||||
assertThat(p.name).isEqualTo(newProjectName);
|
assertThat(p.name).isEqualTo(newProjectName);
|
||||||
ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
|
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
|
||||||
assertThat(projectState).isNotNull();
|
assertThat(projectState).isPresent();
|
||||||
assertProjectInfo(projectState.getProject(), p);
|
assertProjectInfo(projectState.get().getProject(), p);
|
||||||
assertHead(newProjectName, "refs/heads/master");
|
assertHead(newProjectName, "refs/heads/master");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,9 +191,9 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
String newProjectName = name("newProject");
|
String newProjectName = name("newProject");
|
||||||
ProjectInfo p = gApi.projects().create(newProjectName + "/").get();
|
ProjectInfo p = gApi.projects().create(newProjectName + "/").get();
|
||||||
assertThat(p.name).isEqualTo(newProjectName);
|
assertThat(p.name).isEqualTo(newProjectName);
|
||||||
ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
|
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
|
||||||
assertThat(projectState).isNotNull();
|
assertThat(projectState).isPresent();
|
||||||
assertProjectInfo(projectState.getProject(), p);
|
assertProjectInfo(projectState.get().getProject(), p);
|
||||||
assertHead(newProjectName, "refs/heads/master");
|
assertHead(newProjectName, "refs/heads/master");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,9 +202,9 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
String newProjectName = name("newProject/newProject");
|
String newProjectName = name("newProject/newProject");
|
||||||
ProjectInfo p = gApi.projects().create(newProjectName).get();
|
ProjectInfo p = gApi.projects().create(newProjectName).get();
|
||||||
assertThat(p.name).isEqualTo(newProjectName);
|
assertThat(p.name).isEqualTo(newProjectName);
|
||||||
ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
|
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
|
||||||
assertThat(projectState).isNotNull();
|
assertThat(projectState).isPresent();
|
||||||
assertProjectInfo(projectState.getProject(), p);
|
assertProjectInfo(projectState.get().getProject(), p);
|
||||||
assertHead(newProjectName, "refs/heads/master");
|
assertHead(newProjectName, "refs/heads/master");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +221,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
in.requireChangeId = InheritableBoolean.TRUE;
|
in.requireChangeId = InheritableBoolean.TRUE;
|
||||||
ProjectInfo p = gApi.projects().create(in).get();
|
ProjectInfo p = gApi.projects().create(in).get();
|
||||||
assertThat(p.name).isEqualTo(newProjectName);
|
assertThat(p.name).isEqualTo(newProjectName);
|
||||||
Project project = projectCache.get(Project.nameKey(newProjectName)).getProject();
|
Project project = projectCache.get(Project.nameKey(newProjectName)).get().getProject();
|
||||||
assertProjectInfo(project, p);
|
assertProjectInfo(project, p);
|
||||||
assertThat(project.getDescription()).isEqualTo(in.description);
|
assertThat(project.getDescription()).isEqualTo(in.description);
|
||||||
assertThat(project.getConfiguredSubmitType()).isEqualTo(in.submitType);
|
assertThat(project.getConfiguredSubmitType()).isEqualTo(in.submitType);
|
||||||
@@ -247,7 +247,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
in.name = childName;
|
in.name = childName;
|
||||||
in.parent = parentName;
|
in.parent = parentName;
|
||||||
gApi.projects().create(in);
|
gApi.projects().create(in);
|
||||||
Project project = projectCache.get(Project.nameKey(childName)).getProject();
|
Project project = projectCache.get(Project.nameKey(childName)).get().getProject();
|
||||||
assertThat(project.getParentName()).isEqualTo(in.parent);
|
assertThat(project.getParentName()).isEqualTo(in.parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,12 +275,13 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
.getId()
|
.getId()
|
||||||
.get())); // by ID
|
.get())); // by ID
|
||||||
gApi.projects().create(in);
|
gApi.projects().create(in);
|
||||||
ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
|
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
|
||||||
Set<AccountGroup.UUID> expectedOwnerIds = Sets.newHashSetWithExpectedSize(3);
|
Set<AccountGroup.UUID> expectedOwnerIds = Sets.newHashSetWithExpectedSize(3);
|
||||||
expectedOwnerIds.add(SystemGroupBackend.ANONYMOUS_USERS);
|
expectedOwnerIds.add(SystemGroupBackend.ANONYMOUS_USERS);
|
||||||
expectedOwnerIds.add(SystemGroupBackend.REGISTERED_USERS);
|
expectedOwnerIds.add(SystemGroupBackend.REGISTERED_USERS);
|
||||||
expectedOwnerIds.add(groupUuid("Administrators"));
|
expectedOwnerIds.add(groupUuid("Administrators"));
|
||||||
assertProjectOwners(expectedOwnerIds, projectState);
|
assertThat(projectState).isPresent();
|
||||||
|
assertProjectOwners(expectedOwnerIds, projectState.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -367,7 +368,7 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createProjectWithCreateProjectCapabilityAndParentNotVisible() throws Exception {
|
public void createProjectWithCreateProjectCapabilityAndParentNotVisible() throws Exception {
|
||||||
Project parent = projectCache.get(allProjects).getProject();
|
Project parent = projectCache.get(allProjects).get().getProject();
|
||||||
parent.setState(com.google.gerrit.extensions.client.ProjectState.HIDDEN);
|
parent.setState(com.google.gerrit.extensions.client.ProjectState.HIDDEN);
|
||||||
projectOperations
|
projectOperations
|
||||||
.allProjectsForUpdate()
|
.allProjectsForUpdate()
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class GetChildProjectIT extends AbstractDaemonTest {
|
|||||||
Project.NameKey child = projectOperations.newProject().create();
|
Project.NameKey child = projectOperations.newProject().create();
|
||||||
ProjectInfo childInfo = gApi.projects().name(allProjects.get()).child(child.get()).get();
|
ProjectInfo childInfo = gApi.projects().name(allProjects.get()).child(child.get()).get();
|
||||||
|
|
||||||
assertProjectInfo(projectCache.get(child).getProject(), childInfo);
|
assertProjectInfo(projectCache.get(child).get().getProject(), childInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -67,7 +67,7 @@ public class GetChildProjectIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
ProjectInfo grandChildInfo =
|
ProjectInfo grandChildInfo =
|
||||||
gApi.projects().name(allProjects.get()).child(grandChild.get()).get(true);
|
gApi.projects().name(allProjects.get()).child(grandChild.get()).get(true);
|
||||||
assertProjectInfo(projectCache.get(grandChild).getProject(), grandChildInfo);
|
assertProjectInfo(projectCache.get(grandChild).get().getProject(), grandChildInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertChildNotFound(Project.NameKey parent, String child) throws Exception {
|
private void assertChildNotFound(Project.NameKey parent, String child) throws Exception {
|
||||||
|
|||||||
@@ -50,13 +50,13 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
|||||||
admin.newIdent(), testRepo, "Create Project Level Config", configName, cfg.toText());
|
admin.newIdent(), testRepo, "Create Project Level Config", configName, cfg.toText());
|
||||||
push.to(RefNames.REFS_CONFIG);
|
push.to(RefNames.REFS_CONFIG);
|
||||||
|
|
||||||
ProjectState state = projectCache.get(project);
|
ProjectState state = projectCache.get(project).get();
|
||||||
assertThat(state.getConfig(configName).get().toText()).isEqualTo(cfg.toText());
|
assertThat(state.getConfig(configName).get().toText()).isEqualTo(cfg.toText());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void nonExistingConfig() {
|
public void nonExistingConfig() {
|
||||||
ProjectState state = projectCache.get(project);
|
ProjectState state = projectCache.get(project).get();
|
||||||
assertThat(state.getConfig("test.config").get().toText()).isEqualTo("");
|
assertThat(state.getConfig("test.config").get().toText()).isEqualTo("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
|||||||
.to(RefNames.REFS_CONFIG)
|
.to(RefNames.REFS_CONFIG)
|
||||||
.assertOkStatus();
|
.assertOkStatus();
|
||||||
|
|
||||||
ProjectState state = projectCache.get(childProject);
|
ProjectState state = projectCache.get(childProject).get();
|
||||||
|
|
||||||
Config expectedCfg = new Config();
|
Config expectedCfg = new Config();
|
||||||
expectedCfg.setString("s1", null, "k1", "childValue1");
|
expectedCfg.setString("s1", null, "k1", "childValue1");
|
||||||
@@ -158,7 +158,7 @@ public class ProjectLevelConfigIT extends AbstractDaemonTest {
|
|||||||
.to(RefNames.REFS_CONFIG)
|
.to(RefNames.REFS_CONFIG)
|
||||||
.assertOkStatus();
|
.assertOkStatus();
|
||||||
|
|
||||||
ProjectState state = projectCache.get(childProject);
|
ProjectState state = projectCache.get(childProject).get();
|
||||||
|
|
||||||
Config expectedCfg = new Config();
|
Config expectedCfg = new Config();
|
||||||
expectedCfg.setStringList("s1", null, "k1", Arrays.asList("childValue1", "parentValue1"));
|
expectedCfg.setStringList("s1", null, "k1", Arrays.asList("childValue1", "parentValue1"));
|
||||||
|
|||||||
@@ -15,11 +15,13 @@
|
|||||||
package com.google.gerrit.acceptance.ssh;
|
package com.google.gerrit.acceptance.ssh;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static com.google.common.truth.Truth8.assertThat;
|
||||||
|
|
||||||
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
import com.google.gerrit.acceptance.AbstractDaemonTest;
|
||||||
import com.google.gerrit.acceptance.UseSsh;
|
import com.google.gerrit.acceptance.UseSsh;
|
||||||
import com.google.gerrit.entities.Project;
|
import com.google.gerrit.entities.Project;
|
||||||
import com.google.gerrit.server.project.ProjectState;
|
import com.google.gerrit.server.project.ProjectState;
|
||||||
|
import java.util.Optional;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@UseSsh
|
@UseSsh
|
||||||
@@ -33,8 +35,8 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
adminSshSession.exec(
|
adminSshSession.exec(
|
||||||
"gerrit create-project --branch master --owner " + newGroupName + " " + newProjectName);
|
"gerrit create-project --branch master --owner " + newGroupName + " " + newProjectName);
|
||||||
adminSshSession.assertSuccess();
|
adminSshSession.assertSuccess();
|
||||||
ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
|
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
|
||||||
assertThat(projectState).isNotNull();
|
assertThat(projectState).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -46,8 +48,8 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
adminSshSession.exec(
|
adminSshSession.exec(
|
||||||
"gerrit create-project --branch master --owner " + wrongGroupName + " " + newProjectName);
|
"gerrit create-project --branch master --owner " + wrongGroupName + " " + newProjectName);
|
||||||
adminSshSession.assertFailure();
|
adminSshSession.assertFailure();
|
||||||
ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
|
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
|
||||||
assertThat(projectState).isNull();
|
assertThat(projectState).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -62,9 +64,9 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
+ newProjectName
|
+ newProjectName
|
||||||
+ ".git");
|
+ ".git");
|
||||||
adminSshSession.assertSuccess();
|
adminSshSession.assertSuccess();
|
||||||
ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
|
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
|
||||||
assertThat(projectState).isNotNull();
|
assertThat(projectState).isPresent();
|
||||||
assertThat(projectState.getName()).isEqualTo(newProjectName);
|
assertThat(projectState.get().getName()).isEqualTo(newProjectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -79,8 +81,8 @@ public class CreateProjectIT extends AbstractDaemonTest {
|
|||||||
+ newProjectName
|
+ newProjectName
|
||||||
+ "/");
|
+ "/");
|
||||||
adminSshSession.assertSuccess();
|
adminSshSession.assertSuccess();
|
||||||
ProjectState projectState = projectCache.get(Project.nameKey(newProjectName));
|
Optional<ProjectState> projectState = projectCache.get(Project.nameKey(newProjectName));
|
||||||
assertThat(projectState).isNotNull();
|
assertThat(projectState).isPresent();
|
||||||
assertThat(projectState.getName()).isEqualTo(newProjectName);
|
assertThat(projectState.get().getName()).isEqualTo(newProjectName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import static com.google.gerrit.entities.RefNames.REFS_CONFIG;
|
|||||||
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
|
import static com.google.gerrit.server.group.SystemGroupBackend.ANONYMOUS_USERS;
|
||||||
import static com.google.gerrit.server.group.SystemGroupBackend.CHANGE_OWNER;
|
import static com.google.gerrit.server.group.SystemGroupBackend.CHANGE_OWNER;
|
||||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||||
|
import static com.google.gerrit.server.project.ProjectCache.illegalState;
|
||||||
import static com.google.gerrit.testing.GerritJUnit.assertThrows;
|
import static com.google.gerrit.testing.GerritJUnit.assertThrows;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@@ -1165,7 +1166,7 @@ public class RefControlTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ProjectState getProjectState(Project.NameKey nameKey) throws Exception {
|
private ProjectState getProjectState(Project.NameKey nameKey) throws Exception {
|
||||||
return projectCache.checkedGet(nameKey, true);
|
return projectCache.get(nameKey).orElseThrow(illegalState(nameKey));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProjectControl user(Project.NameKey localKey, AccountGroup.UUID... memberOf)
|
private ProjectControl user(Project.NameKey localKey, AccountGroup.UUID... memberOf)
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ public class CommitsCollectionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ProjectState readProjectState() throws Exception {
|
private ProjectState readProjectState() throws Exception {
|
||||||
return projectCache.get(project);
|
return projectCache.get(project).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUpPermissions() throws Exception {
|
private void setUpPermissions() throws Exception {
|
||||||
|
|||||||
Submodule plugins/delete-project updated: 180fd9dbd7...da0811ef34
Submodule plugins/gitiles updated: 825ca06ddd...22a607bdec
Submodule plugins/reviewnotes updated: 9bd38ec6ab...9e7fd9b420
Submodule plugins/webhooks updated: 570dacacc6...e503006700
Reference in New Issue
Block a user