aboutsummaryrefslogtreecommitdiff
path: root/gerrit-sshd
diff options
context:
space:
mode:
authorShawn O. Pearce <sop@google.com>2011-06-16 18:49:26 -0700
committerShawn O. Pearce <sop@google.com>2011-06-16 18:49:26 -0700
commit9dbd055b52e9641774aa7098c97de537a15fcf7e (patch)
tree3d94c4a4f67b6696cbe6a772c7bef33b43bedd61 /gerrit-sshd
parent98ce43f10706112bddc56f1e1e1023f840ead7fc (diff)
downloadgerrit-9dbd055b52e9641774aa7098c97de537a15fcf7e.tar.gz
Cleanup check for 'Create Group' capability
This should be done only once, inside of the common PerformCreateGroup object and not by both the HTTP and SSH interface glue. Change-Id: I6f774fe318412a7220206b99d7279d5b061355ad
Diffstat (limited to 'gerrit-sshd')
-rw-r--r--gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java40
1 files changed, 15 insertions, 25 deletions
diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java
index 76eca2a2..05e6e59a 100644
--- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java
+++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/CreateGroupCommand.java
@@ -15,12 +15,11 @@
package com.google.gerrit.sshd.commands;
import com.google.gerrit.common.errors.NameAlreadyUsedException;
+import com.google.gerrit.common.errors.PermissionDeniedException;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.AccountGroup;
-import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.PerformCreateGroup;
import com.google.gerrit.sshd.BaseCommand;
-import com.google.gwtorm.client.OrmException;
import com.google.inject.Inject;
import org.apache.sshd.server.Environment;
@@ -63,9 +62,6 @@ final class CreateGroupCommand extends BaseCommand {
}
@Inject
- private IdentifiedUser currentUser;
-
- @Inject
private PerformCreateGroup.Factory performCreateGroupFactory;
@Override
@@ -73,27 +69,21 @@ final class CreateGroupCommand extends BaseCommand {
startThread(new CommandRunnable() {
@Override
public void run() throws Exception {
- if (!currentUser.getCapabilities().canCreateGroup()) {
- String msg = String.format(
- "fatal: %s does not have \"Create Group\" capability.",
- currentUser.getUserName());
- throw new UnloggedFailure(BaseCommand.STATUS_NOT_ADMIN, msg);
- }
-
parseCommandLine();
- createGroup();
+ try {
+ performCreateGroupFactory.create().createGroup(groupName,
+ groupDescription,
+ visibleToAll,
+ ownerGroupId,
+ initialMembers,
+ initialGroups);
+ } catch (PermissionDeniedException e) {
+ throw die(e);
+
+ } catch (NameAlreadyUsedException e) {
+ throw die(e);
+ }
}
});
}
-
- private void createGroup() throws OrmException, UnloggedFailure {
- final PerformCreateGroup performCreateGroup =
- performCreateGroupFactory.create();
- try {
- performCreateGroup.createGroup(groupName, groupDescription, visibleToAll,
- ownerGroupId, initialMembers, initialGroups);
- } catch (NameAlreadyUsedException e) {
- throw die(e);
- }
- }
-} \ No newline at end of file
+}