From a48c33a76f3497d33e0c3d0d3cf1a59aef23679f Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Wed, 11 Jan 2012 16:35:11 -0500
Subject: [PATCH] Fixed missing gbapi ant tag dependency in build process

---
 src/com/gitblit/wicket/pages/EditRepositoryPage.java |   76 +++++++++++++++++++++++++++++++++++--
 1 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java
index 1a5ec3d..7d2d64c 100644
--- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java
+++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java
@@ -19,9 +19,11 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.wicket.PageParameters;
 import org.apache.wicket.extensions.markup.html.form.palette.Palette;
@@ -33,6 +35,8 @@
 import org.apache.wicket.markup.html.form.IChoiceRenderer;
 import org.apache.wicket.markup.html.form.TextField;
 import org.apache.wicket.model.CompoundPropertyModel;
+import org.apache.wicket.model.IModel;
+import org.apache.wicket.model.Model;
 import org.apache.wicket.model.util.CollectionModel;
 import org.apache.wicket.model.util.ListModel;
 
@@ -43,15 +47,19 @@
 import com.gitblit.Keys;
 import com.gitblit.models.RepositoryModel;
 import com.gitblit.models.UserModel;
+import com.gitblit.utils.ArrayUtils;
 import com.gitblit.utils.StringUtils;
 import com.gitblit.wicket.GitBlitWebSession;
 import com.gitblit.wicket.WicketUtils;
+import com.gitblit.wicket.panels.BulletListPanel;
 
 public class EditRepositoryPage extends RootSubPage {
 
 	private final boolean isCreate;
 
 	private boolean isAdmin;
+
+	private IModel<String> mailingLists;
 
 	public EditRepositoryPage() {
 		// create constructor
@@ -76,6 +84,9 @@
 		List<String> federationSets = new ArrayList<String>();
 		List<String> repositoryUsers = new ArrayList<String>();
 		List<String> repositoryTeams = new ArrayList<String>();
+		List<String> preReceiveScripts = new ArrayList<String>();
+		List<String> postReceiveScripts = new ArrayList<String>();
+
 		if (isCreate) {
 			super.setupPage(getString("gb.newRepository"), "");
 		} else {
@@ -86,8 +97,7 @@
 				Collections.sort(repositoryUsers);
 			}
 			federationSets.addAll(repositoryModel.federationSets);
-		}		
-		
+		}
 
 		final String oldName = repositoryModel.name;
 		// users palette
@@ -98,13 +108,31 @@
 		// teams palette
 		final Palette<String> teamsPalette = new Palette<String>("teams", new ListModel<String>(
 				repositoryTeams), new CollectionModel<String>(GitBlit.self().getAllTeamnames()),
-				new ChoiceRenderer<String>("", ""), 10, false);
+				new ChoiceRenderer<String>("", ""), 5, false);
 
 		// federation sets palette
 		List<String> sets = GitBlit.getStrings(Keys.federation.sets);
 		final Palette<String> federationSetsPalette = new Palette<String>("federationSets",
 				new ListModel<String>(federationSets), new CollectionModel<String>(sets),
-				new ChoiceRenderer<String>("", ""), 10, false);
+				new ChoiceRenderer<String>("", ""), 5, false);
+
+		// pre-receive palette
+		if (!ArrayUtils.isEmpty(repositoryModel.preReceiveScripts)) {
+			preReceiveScripts.addAll(repositoryModel.preReceiveScripts);
+		}
+		final Palette<String> preReceivePalette = new Palette<String>("preReceiveScripts",
+				new ListModel<String>(preReceiveScripts), new CollectionModel<String>(GitBlit
+						.self().getPreReceiveScriptsUnused(repositoryModel)),
+				new ChoiceRenderer<String>("", ""), 12, true);
+
+		// post-receive palette
+		if (!ArrayUtils.isEmpty(repositoryModel.postReceiveScripts)) {
+			postReceiveScripts.addAll(repositoryModel.postReceiveScripts);
+		}
+		final Palette<String> postReceivePalette = new Palette<String>("postReceiveScripts",
+				new ListModel<String>(postReceiveScripts), new CollectionModel<String>(GitBlit
+						.self().getPostReceiveScriptsUnused(repositoryModel)),
+				new ChoiceRenderer<String>("", ""), 12, true);
 
 		CompoundPropertyModel<RepositoryModel> model = new CompoundPropertyModel<RepositoryModel>(
 				repositoryModel);
@@ -169,6 +197,35 @@
 						}
 					}
 
+					// set mailing lists
+					String ml = mailingLists.getObject();
+					if (!StringUtils.isEmpty(ml)) {
+						Set<String> list = new HashSet<String>();
+						for (String address : ml.split("(,|\\s)")) {
+							if (StringUtils.isEmpty(address)) {
+								continue;
+							}
+							list.add(address.toLowerCase());
+						}
+						repositoryModel.mailingLists = new ArrayList<String>(list);
+					}
+
+					// pre-receive scripts
+					List<String> preReceiveScripts = new ArrayList<String>();
+					Iterator<String> pres = preReceivePalette.getSelectedChoices();
+					while (pres.hasNext()) {
+						preReceiveScripts.add(pres.next());
+					}
+					repositoryModel.preReceiveScripts = preReceiveScripts;
+
+					// post-receive scripts
+					List<String> postReceiveScripts = new ArrayList<String>();
+					Iterator<String> post = postReceivePalette.getSelectedChoices();
+					while (post.hasNext()) {
+						postReceiveScripts.add(post.next());
+					}
+					repositoryModel.postReceiveScripts = postReceiveScripts;
+
 					// save the repository
 					GitBlit.self().updateRepositoryModel(oldName, repositoryModel, isCreate);
 
@@ -186,7 +243,7 @@
 							repositoryUsers.add(repositoryModel.owner);
 						}
 						GitBlit.self().setRepositoryUsers(repositoryModel, repositoryUsers);
-						
+
 						// save the team access list
 						Iterator<String> teams = teamsPalette.getSelectedChoices();
 						List<String> repositoryTeams = new ArrayList<String>();
@@ -230,9 +287,18 @@
 		form.add(new CheckBox("showReadme"));
 		form.add(new CheckBox("skipSizeCalculation"));
 		form.add(new CheckBox("skipSummaryMetrics"));
+		mailingLists = new Model<String>(ArrayUtils.isEmpty(repositoryModel.mailingLists) ? ""
+				: StringUtils.flattenStrings(repositoryModel.mailingLists, " "));
+		form.add(new TextField<String>("mailingLists", mailingLists));
 		form.add(usersPalette);
 		form.add(teamsPalette);
 		form.add(federationSetsPalette);
+		form.add(preReceivePalette);
+		form.add(new BulletListPanel("inheritedPreReceive", "inherited", GitBlit.self()
+				.getPreReceiveScriptsInherited(repositoryModel)));
+		form.add(postReceivePalette);
+		form.add(new BulletListPanel("inheritedPostReceive", "inherited", GitBlit.self()
+				.getPostReceiveScriptsInherited(repositoryModel)));
 
 		form.add(new Button("save"));
 		Button cancel = new Button("cancel") {

--
Gitblit v1.9.1