"gitblit", null, "preReceiveScript")));\r
model.postReceiveScripts = new ArrayList<String>(Arrays.asList(config.getStringList(\r
"gitblit", null, "postReceiveScript")));\r
+ model.mailRecipients = new ArrayList<String>(Arrays.asList(config.getStringList(\r
+ "gitblit", null, "mailRecipient")));\r
}\r
r.close();\r
return model;\r
config.setString("gitblit", null, "federationStrategy",\r
repository.federationStrategy.name());\r
config.setBoolean("gitblit", null, "isFederated", repository.isFederated);\r
- config.setStringList("gitblit", null, "preReceiveScript", repository.preReceiveScripts);\r
- config.setStringList("gitblit", null, "postReceiveScript", repository.postReceiveScripts);\r
+ if (repository.preReceiveScripts != null) {\r
+ config.setStringList("gitblit", null, "preReceiveScript", repository.preReceiveScripts);\r
+ }\r
+ if (repository.postReceiveScripts != null) {\r
+ config.setStringList("gitblit", null, "postReceiveScript",\r
+ repository.postReceiveScripts);\r
+ }\r
+ if (repository.mailRecipients != null) {\r
+ config.setStringList("gitblit", null, "mailRecipient", repository.mailRecipients);\r
+ }\r
try {\r
config.save();\r
} catch (IOException e) {\r
InternetAddress from = new InternetAddress(fromAddress, "Gitblit");\r
message.setFrom(from);\r
\r
- Set<String> uniques = new HashSet<String>(toAddresses);\r
+ // determine unique set of addresses\r
+ Set<String> uniques = new HashSet<String>();\r
+ for (String address : toAddresses) {\r
+ uniques.add(address.toLowerCase());\r
+ }\r
+ \r
Pattern validEmail = Pattern\r
.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$");\r
List<InternetAddress> tos = new ArrayList<InternetAddress>();\r
} catch (Throwable t) {\r
}\r
}\r
- }\r
- message.setRecipients(Message.RecipientType.TO,\r
+ } \r
+ message.setRecipients(Message.RecipientType.BCC,\r
tos.toArray(new InternetAddress[tos.size()]));\r
message.setSentDate(new Date());\r
} catch (Exception e) {\r
import com.gitblit.Constants.AccessRestrictionType;\r
import com.gitblit.Constants.FederationStrategy;\r
import com.gitblit.models.RepositoryModel;\r
-import com.gitblit.models.TeamModel;\r
import com.gitblit.utils.StringUtils;\r
\r
/**\r
private JCheckBox skipSummaryMetrics;\r
\r
private JCheckBox isFrozen;\r
+ \r
+ private JTextField mailRecipientsField;\r
\r
private JComboBox accessRestriction;\r
\r
anRepository.skipSummaryMetrics);\r
isFrozen = new JCheckBox(Translation.get("gb.isFrozenDescription"), anRepository.isFrozen);\r
\r
+ mailRecipientsField = new JTextField(anRepository.mailRecipients == null ? ""\r
+ : StringUtils.flattenStrings(anRepository.mailRecipients, " "), 50);\r
+ \r
accessRestriction = new JComboBox(AccessRestrictionType.values());\r
accessRestriction.setRenderer(new AccessRestrictionRenderer());\r
accessRestriction.setSelectedItem(anRepository.accessRestriction);\r
fieldsPanel\r
.add(newFieldPanel(Translation.get("gb.skipSummaryMetrics"), skipSummaryMetrics));\r
fieldsPanel.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen));\r
+ fieldsPanel.add(newFieldPanel(Translation.get("gb.mailRecipients"), mailRecipientsField));\r
\r
usersPalette = new JPalette<String>();\r
JPanel accessPanel = new JPanel(new BorderLayout(5, 5));\r
repository.skipSizeCalculation = skipSizeCalculation.isSelected();\r
repository.skipSummaryMetrics = skipSummaryMetrics.isSelected();\r
repository.isFrozen = isFrozen.isSelected();\r
+ \r
+ repository.mailRecipients = StringUtils.getStringsFromValue(mailRecipientsField.getText().trim(), " ");\r
\r
repository.accessRestriction = (AccessRestrictionType) accessRestriction.getSelectedItem();\r
repository.federationStrategy = (FederationStrategy) federationStrategy.getSelectedItem();\r
public String size;\r
public List<String> preReceiveScripts;\r
public List<String> postReceiveScripts;\r
+ public List<String> mailRecipients;\r
\r
public RepositoryModel() {\r
this("", "", "", new Date(0));\r
gb.newTeam = new team\r
gb.permittedTeams = permitted teams\r
gb.emptyRepository = empty repository\r
-gb.repositoryUrl = repository url
\ No newline at end of file
+gb.repositoryUrl = repository url\r
+gb.mailRecipients = mail recipients\r
+gb.mailRecipientsDescription = space-delimited, used by sendemail Groovy hook
\ No newline at end of file
<tr><th><wicket:message key="gb.skipSizeCalculation"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="skipSizeCalculation" tabindex="9" /> <i><wicket:message key="gb.skipSizeCalculationDescription"></wicket:message></i></td></tr>\r
<tr><th><wicket:message key="gb.skipSummaryMetrics"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="skipSummaryMetrics" tabindex="10" /> <i><wicket:message key="gb.skipSummaryMetricsDescription"></wicket:message></i></td></tr>\r
<tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="isFrozen" tabindex="11" /> <i><wicket:message key="gb.isFrozenDescription"></wicket:message></i></td></tr>\r
+ <tr><th><wicket:message key="gb.mailRecipients"></wicket:message></th><td class="edit"><input class="span9" type="text" wicket:id="mailRecipients" size="40" tabindex="12" /> <i><wicket:message key="gb.mailRecipientsDescription"></wicket:message></i></td></tr>\r
<tr><td colspan="2"><hr></hr></td></tr>\r
- <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span6" wicket:id="accessRestriction" tabindex="12" /></td></tr> \r
+ <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span6" wicket:id="accessRestriction" tabindex="13" /></td></tr> \r
<tr><th style="vertical-align: top;"><wicket:message key="gb.permittedUsers"></wicket:message></th><td style="padding:2px;"><span wicket:id="users"></span></td></tr>\r
<tr><th style="vertical-align: top;"><wicket:message key="gb.permittedTeams"></wicket:message></th><td style="padding:2px;"><span wicket:id="teams"></span></td></tr>\r
<tr><td colspan="2"><hr></hr></td></tr> \r
- <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span6" wicket:id="federationStrategy" tabindex="13" /></td></tr>\r
+ <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span6" wicket:id="federationStrategy" tabindex="14" /></td></tr>\r
<tr><th style="vertical-align: top;"><wicket:message key="gb.federationSets"></wicket:message></th><td style="padding:2px;"><span wicket:id="federationSets"></span></td></tr>\r
- <tr><th></th><td class="editButton"><input class="btn" type="submit" value="Cancel" wicket:message="value:gb.cancel" wicket:id="cancel" tabindex="14" /> <input class="btn primary" type="submit" value="Save" wicket:message="value:gb.save" wicket:id="save" tabindex="15" /> </td></tr>\r
+ <tr><th></th><td class="editButton"><input class="btn" type="submit" value="Cancel" wicket:message="value:gb.cancel" wicket:id="cancel" tabindex="15" /> <input class="btn primary" type="submit" value="Save" wicket:message="value:gb.save" wicket:id="save" tabindex="16" /> </td></tr>\r
</tbody>\r
</table>\r
</form> \r
import org.apache.wicket.markup.html.form.IChoiceRenderer;\r
import org.apache.wicket.markup.html.form.TextField;\r
import org.apache.wicket.model.CompoundPropertyModel;\r
+import org.apache.wicket.model.IModel;\r
+import org.apache.wicket.model.Model;\r
import org.apache.wicket.model.util.CollectionModel;\r
import org.apache.wicket.model.util.ListModel;\r
\r
\r
private boolean isAdmin;\r
\r
+ private IModel<String> mailRecipients;\r
+\r
public EditRepositoryPage() {\r
// create constructor\r
super();\r
Collections.sort(repositoryUsers);\r
}\r
federationSets.addAll(repositoryModel.federationSets);\r
- } \r
- \r
+ }\r
\r
final String oldName = repositoryModel.name;\r
// users palette\r
}\r
}\r
\r
+ // set mail recipients\r
+ String ml = mailRecipients.getObject();\r
+ if (!StringUtils.isEmpty(ml)) {\r
+ List<String> list = StringUtils.getStringsFromValue(ml.trim(), " ");\r
+ repositoryModel.mailRecipients = list;\r
+ }\r
+\r
// save the repository\r
GitBlit.self().updateRepositoryModel(oldName, repositoryModel, isCreate);\r
\r
repositoryUsers.add(repositoryModel.owner);\r
}\r
GitBlit.self().setRepositoryUsers(repositoryModel, repositoryUsers);\r
- \r
+\r
// save the team access list\r
Iterator<String> teams = teamsPalette.getSelectedChoices();\r
List<String> repositoryTeams = new ArrayList<String>();\r
form.add(new CheckBox("showReadme"));\r
form.add(new CheckBox("skipSizeCalculation"));\r
form.add(new CheckBox("skipSummaryMetrics"));\r
+ mailRecipients = new Model<String>(repositoryModel.mailRecipients == null ? ""\r
+ : StringUtils.flattenStrings(repositoryModel.mailRecipients, " "));\r
+ form.add(new TextField<String>("mailRecipients", mailRecipients));\r
form.add(usersPalette);\r
form.add(teamsPalette);\r
form.add(federationSetsPalette);\r