Edit and store per-repository mail recipients in site and RPC
| | |
| | | "gitblit", null, "preReceiveScript")));
|
| | | model.postReceiveScripts = new ArrayList<String>(Arrays.asList(config.getStringList(
|
| | | "gitblit", null, "postReceiveScript")));
|
| | | model.mailRecipients = new ArrayList<String>(Arrays.asList(config.getStringList(
|
| | | "gitblit", null, "mailRecipient")));
|
| | | }
|
| | | r.close();
|
| | | return model;
|
| | |
| | | config.setString("gitblit", null, "federationStrategy",
|
| | | repository.federationStrategy.name());
|
| | | config.setBoolean("gitblit", null, "isFederated", repository.isFederated);
|
| | | config.setStringList("gitblit", null, "preReceiveScript", repository.preReceiveScripts);
|
| | | config.setStringList("gitblit", null, "postReceiveScript", repository.postReceiveScripts);
|
| | | if (repository.preReceiveScripts != null) {
|
| | | config.setStringList("gitblit", null, "preReceiveScript", repository.preReceiveScripts);
|
| | | }
|
| | | if (repository.postReceiveScripts != null) {
|
| | | config.setStringList("gitblit", null, "postReceiveScript",
|
| | | repository.postReceiveScripts);
|
| | | }
|
| | | if (repository.mailRecipients != null) {
|
| | | config.setStringList("gitblit", null, "mailRecipient", repository.mailRecipients);
|
| | | }
|
| | | try {
|
| | | config.save();
|
| | | } catch (IOException e) {
|
| | |
| | | InternetAddress from = new InternetAddress(fromAddress, "Gitblit");
|
| | | message.setFrom(from);
|
| | |
|
| | | Set<String> uniques = new HashSet<String>(toAddresses);
|
| | | // determine unique set of addresses
|
| | | Set<String> uniques = new HashSet<String>();
|
| | | for (String address : toAddresses) {
|
| | | uniques.add(address.toLowerCase());
|
| | | }
|
| | | |
| | | Pattern validEmail = Pattern
|
| | | .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})(\\]?)$");
|
| | | List<InternetAddress> tos = new ArrayList<InternetAddress>();
|
| | |
| | | } catch (Throwable t) {
|
| | | }
|
| | | }
|
| | | }
|
| | | message.setRecipients(Message.RecipientType.TO,
|
| | | } |
| | | message.setRecipients(Message.RecipientType.BCC,
|
| | | tos.toArray(new InternetAddress[tos.size()]));
|
| | | message.setSentDate(new Date());
|
| | | } catch (Exception e) {
|
| | |
| | | import com.gitblit.Constants.AccessRestrictionType;
|
| | | import com.gitblit.Constants.FederationStrategy;
|
| | | import com.gitblit.models.RepositoryModel;
|
| | | import com.gitblit.models.TeamModel;
|
| | | import com.gitblit.utils.StringUtils;
|
| | |
|
| | | /**
|
| | |
| | | private JCheckBox skipSummaryMetrics;
|
| | |
|
| | | private JCheckBox isFrozen;
|
| | | |
| | | private JTextField mailRecipientsField;
|
| | |
|
| | | private JComboBox accessRestriction;
|
| | |
|
| | |
| | | anRepository.skipSummaryMetrics);
|
| | | isFrozen = new JCheckBox(Translation.get("gb.isFrozenDescription"), anRepository.isFrozen);
|
| | |
|
| | | mailRecipientsField = new JTextField(anRepository.mailRecipients == null ? ""
|
| | | : StringUtils.flattenStrings(anRepository.mailRecipients, " "), 50);
|
| | | |
| | | accessRestriction = new JComboBox(AccessRestrictionType.values());
|
| | | accessRestriction.setRenderer(new AccessRestrictionRenderer());
|
| | | accessRestriction.setSelectedItem(anRepository.accessRestriction);
|
| | |
| | | fieldsPanel
|
| | | .add(newFieldPanel(Translation.get("gb.skipSummaryMetrics"), skipSummaryMetrics));
|
| | | fieldsPanel.add(newFieldPanel(Translation.get("gb.isFrozen"), isFrozen));
|
| | | fieldsPanel.add(newFieldPanel(Translation.get("gb.mailRecipients"), mailRecipientsField));
|
| | |
|
| | | usersPalette = new JPalette<String>();
|
| | | JPanel accessPanel = new JPanel(new BorderLayout(5, 5));
|
| | |
| | | repository.skipSizeCalculation = skipSizeCalculation.isSelected();
|
| | | repository.skipSummaryMetrics = skipSummaryMetrics.isSelected();
|
| | | repository.isFrozen = isFrozen.isSelected();
|
| | | |
| | | repository.mailRecipients = StringUtils.getStringsFromValue(mailRecipientsField.getText().trim(), " ");
|
| | |
|
| | | repository.accessRestriction = (AccessRestrictionType) accessRestriction.getSelectedItem();
|
| | | repository.federationStrategy = (FederationStrategy) federationStrategy.getSelectedItem();
|
| | |
| | | public String size;
|
| | | public List<String> preReceiveScripts;
|
| | | public List<String> postReceiveScripts;
|
| | | public List<String> mailRecipients;
|
| | |
|
| | | public RepositoryModel() {
|
| | | this("", "", "", new Date(0));
|
| | |
| | | gb.newTeam = new team
|
| | | gb.permittedTeams = permitted teams
|
| | | gb.emptyRepository = empty repository
|
| | | gb.repositoryUrl = repository url |
| | | gb.repositoryUrl = repository url
|
| | | gb.mailRecipients = mail recipients
|
| | | gb.mailRecipientsDescription = space-delimited, used by sendemail Groovy hook |
| | |
| | | <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>
|
| | | <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>
|
| | | <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>
|
| | | <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>
|
| | | <tr><td colspan="2"><hr></hr></td></tr>
|
| | | <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span6" wicket:id="accessRestriction" tabindex="12" /></td></tr> |
| | | <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span6" wicket:id="accessRestriction" tabindex="13" /></td></tr> |
| | | <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>
|
| | | <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>
|
| | | <tr><td colspan="2"><hr></hr></td></tr>
|
| | | <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span6" wicket:id="federationStrategy" tabindex="13" /></td></tr>
|
| | | <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span6" wicket:id="federationStrategy" tabindex="14" /></td></tr>
|
| | | <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>
|
| | | <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>
|
| | | <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>
|
| | | </tbody>
|
| | | </table>
|
| | | </form>
|
| | |
| | | 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;
|
| | |
|
| | |
| | | private final boolean isCreate;
|
| | |
|
| | | private boolean isAdmin;
|
| | |
|
| | | private IModel<String> mailRecipients;
|
| | |
|
| | | public EditRepositoryPage() {
|
| | | // create constructor
|
| | |
| | | Collections.sort(repositoryUsers);
|
| | | }
|
| | | federationSets.addAll(repositoryModel.federationSets);
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | final String oldName = repositoryModel.name;
|
| | | // users palette
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // set mail recipients
|
| | | String ml = mailRecipients.getObject();
|
| | | if (!StringUtils.isEmpty(ml)) {
|
| | | List<String> list = StringUtils.getStringsFromValue(ml.trim(), " ");
|
| | | repositoryModel.mailRecipients = list;
|
| | | }
|
| | |
|
| | | // save the repository
|
| | | GitBlit.self().updateRepositoryModel(oldName, repositoryModel, isCreate);
|
| | |
|
| | |
| | | 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>();
|
| | |
| | | form.add(new CheckBox("showReadme"));
|
| | | form.add(new CheckBox("skipSizeCalculation"));
|
| | | form.add(new CheckBox("skipSummaryMetrics"));
|
| | | mailRecipients = new Model<String>(repositoryModel.mailRecipients == null ? ""
|
| | | : StringUtils.flattenStrings(repositoryModel.mailRecipients, " "));
|
| | | form.add(new TextField<String>("mailRecipients", mailRecipients));
|
| | | form.add(usersPalette);
|
| | | form.add(teamsPalette);
|
| | | form.add(federationSetsPalette);
|