From 6bb3b233c8a73d4fe4e5024794029fdc75a9f1bb Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Fri, 14 Sep 2012 09:36:46 -0400
Subject: [PATCH] Expose ReceivePack to Groovy hooks (issue 125)
---
src/com/gitblit/wicket/pages/EditRepositoryPage.java | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java
index 572f650..505cb54 100644
--- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java
+++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -36,6 +36,8 @@
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
+import org.apache.wicket.markup.html.form.Radio;
+import org.apache.wicket.markup.html.form.RadioGroup;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
@@ -47,6 +49,7 @@
import com.gitblit.Constants;
import com.gitblit.Constants.AccessRestrictionType;
+import com.gitblit.Constants.AuthorizationControl;
import com.gitblit.Constants.FederationStrategy;
import com.gitblit.GitBlit;
import com.gitblit.GitBlitException;
@@ -75,6 +78,8 @@
RepositoryModel model = new RepositoryModel();
String restriction = GitBlit.getString(Keys.git.defaultAccessRestriction, null);
model.accessRestriction = AccessRestrictionType.fromName(restriction);
+ String authorization = GitBlit.getString(Keys.git.defaultAuthorizationControl, null);
+ model.authorizationControl = AuthorizationControl.fromName(authorization);
setupPage(model);
}
@@ -212,6 +217,9 @@
if (repositoryModel.name.contains("/../")) {
error(getString("gb.illegalRelativeSlash"));
return;
+ }
+ if (repositoryModel.name.endsWith("/")) {
+ repositoryModel.name = repositoryModel.name.substring(0, repositoryModel.name.length() - 1);
}
// confirm valid characters in repository name
@@ -367,14 +375,22 @@
: StringUtils.flattenStrings(repositoryModel.mailingLists, " "));
form.add(new TextField<String>("mailingLists", mailingLists));
form.add(indexedBranchesPalette);
+
+ RadioGroup<AuthorizationControl> group = new RadioGroup<AuthorizationControl>("authorizationControl");
+ Radio<AuthorizationControl> allowAuthenticated = new Radio<AuthorizationControl>("allowAuthenticated", new Model<AuthorizationControl>(AuthorizationControl.AUTHENTICATED));
+ Radio<AuthorizationControl> allowNamed = new Radio<AuthorizationControl>("allowNamed", new Model<AuthorizationControl>(AuthorizationControl.NAMED));
+ group.add(allowAuthenticated);
+ group.add(allowNamed);
+ form.add(group);
+
form.add(usersPalette);
form.add(teamsPalette);
form.add(federationSetsPalette);
form.add(preReceivePalette);
- form.add(new BulletListPanel("inheritedPreReceive", "inherited", GitBlit.self()
+ form.add(new BulletListPanel("inheritedPreReceive", getString("gb.inherited"), GitBlit.self()
.getPreReceiveScriptsInherited(repositoryModel)));
form.add(postReceivePalette);
- form.add(new BulletListPanel("inheritedPostReceive", "inherited", GitBlit.self()
+ form.add(new BulletListPanel("inheritedPostReceive", getString("gb.inherited"), GitBlit.self()
.getPostReceiveScriptsInherited(repositoryModel)));
WebMarkupContainer customFieldsSection = new WebMarkupContainer("customFieldsSection");
@@ -414,13 +430,13 @@
if (authenticateAdmin) {
if (user == null) {
// No Login Available
- error("Administration requires a login", true);
+ error(getString("gb.errorAdminLoginRequired"), true);
}
if (isCreate) {
// Create Repository
if (!user.canAdmin) {
// Only Administrators May Create
- error("Only an administrator may create a repository", true);
+ error(getString("gb.errorOnlyAdminMayCreateRepository"), true);
}
} else {
// Edit Repository
@@ -431,14 +447,14 @@
} else {
if (!model.owner.equalsIgnoreCase(user.username)) {
// User is not an Admin nor Owner
- error("Only an administrator or the owner may edit a repository", true);
+ error(getString("gb.errorOnlyAdminOrOwnerMayEditRepository"), true);
}
}
}
}
} else {
// No Administration Permitted
- error("Administration is disabled", true);
+ error(getString("gb.errorAdministrationDisabled"), true);
}
}
--
Gitblit v1.9.1