Merge branch 'stable-3.1'
* stable-3.1:
Remove standalone build mode
Change-Id: I3e6edf20633534d988ff667ca6d46ad341bc9ec2
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) {