Merge branch 'stable-3.1'
* stable-3.1:
Switch to latest stable-3.1 bazlets and release API
Upgrade bazlets to latest stable-3.0
Upgrade bazlets to latest stable-2.16
Change-Id: I22e046aea65b5156a796828ba5dcd7d6ec0ff9e9
diff --git a/WORKSPACE b/WORKSPACE
index ade0398..872b0e9 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,27 +3,27 @@
load("//:bazlets.bzl", "load_bazlets")
load_bazlets(
- commit = "65536a2b01b0097ee3237bb48a805ed97ca51467",
+ commit = "f30a992da9fc855dce819875afb59f9dd6f860cd",
#local_path = "/home/<user>/projects/bazlets",
)
# Release Plugin API
-load(
- "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
- "gerrit_api",
-)
-
-# Snapshot Plugin API
#load(
-# "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
-# "gerrit_api_maven_local",
+# "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
+# "gerrit_api",
#)
+# Snapshot Plugin API
+load(
+ "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
+ "gerrit_api_maven_local",
+)
+
# Load release Plugin API
-gerrit_api()
+#gerrit_api()
# Load snapshot Plugin API
-#gerrit_api_maven_local()
+gerrit_api_maven_local()
load(":external_plugin_deps.bzl", "external_plugin_deps")
diff --git a/src/main/java/com/googlesource/gerrit/plugins/lfs/LfsApiServlet.java b/src/main/java/com/googlesource/gerrit/plugins/lfs/LfsApiServlet.java
index 772a536..59d4e97 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/lfs/LfsApiServlet.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/lfs/LfsApiServlet.java
@@ -31,6 +31,7 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.googlesource.gerrit.plugins.lfs.auth.LfsAuthUserProvider;
+import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.jgit.lfs.errors.LfsException;
@@ -82,13 +83,14 @@
}
String projName = matcher.group(1);
Project.NameKey project = Project.nameKey(ProjectUtil.stripGitSuffix(projName));
- ProjectState state = projectCache.get(project);
- if (state == null || state.getProject().getState() == HIDDEN) {
+ Optional<ProjectState> state = projectCache.get(project);
+ if (!state.isPresent() || state.get().getProject().getState() == HIDDEN) {
throw new LfsRepositoryNotFound(project.get());
}
- authorizeUser(userProvider.getUser(auth, projName, request.getOperation()), state, request);
+ authorizeUser(
+ userProvider.getUser(auth, projName, request.getOperation()), state.get(), request);
- if (request.isUpload() && state.getProject().getState() == READ_ONLY) {
+ if (request.isUpload() && state.get().getProject().getState() == READ_ONLY) {
throw new LfsRepositoryReadOnly(project.get());
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/lfs/locks/LfsLocksAction.java b/src/main/java/com/googlesource/gerrit/plugins/lfs/locks/LfsLocksAction.java
index b8a6f14..e8d46c2 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/lfs/locks/LfsLocksAction.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/lfs/locks/LfsLocksAction.java
@@ -35,6 +35,7 @@
import com.googlesource.gerrit.plugins.lfs.auth.LfsAuthUserProvider;
import com.googlesource.gerrit.plugins.lfs.locks.LfsLocksHandler.LfsLockExistsException;
import java.io.IOException;
+import java.util.Optional;
import org.eclipse.jgit.lfs.errors.LfsException;
import org.eclipse.jgit.lfs.errors.LfsRepositoryNotFound;
import org.eclipse.jgit.lfs.errors.LfsUnauthorized;
@@ -72,12 +73,12 @@
String name = getProjectName();
ProjectState project = getProject(name);
CurrentUser user = getUser(name);
- ProjectState state = projectCache.get(project.getNameKey());
- if (state == null) {
+ Optional<ProjectState> state = projectCache.get(project.getNameKey());
+ if (!state.isPresent()) {
throw new LfsRepositoryNotFound(project.getNameKey().get());
}
try {
- authorizeUser(permissionBackend.user(user).project(state.getNameKey()));
+ authorizeUser(permissionBackend.user(user).project(state.get().getNameKey()));
} catch (AuthException | PermissionBackendException e) {
throwUnauthorizedOp(getAction(), project, user);
}
@@ -105,11 +106,11 @@
protected ProjectState getProject(String name) throws LfsRepositoryNotFound {
Project.NameKey project = Project.nameKey(ProjectUtil.stripGitSuffix(name));
- ProjectState state = projectCache.get(project);
- if (state == null || state.getProject().getState() == HIDDEN) {
+ Optional<ProjectState> state = projectCache.get(project);
+ if (!state.isPresent() || state.get().getProject().getState() == HIDDEN) {
throw new LfsRepositoryNotFound(project.get());
}
- return state;
+ return state.get();
}
protected CurrentUser getUser(String project) {