Visual improvements to root pom file.

Add license header to many files.
Add new strings to i18n.
Code refactoring.
Add few comments to classes.
Add new method for NotificationModel.
Optimizing imports.
Manually add constraints for email/username at E-mail connector page.
A lot of changes to SendEmail class.
This commit is contained in:
Vova Perebykivskiy 2015-11-09 13:05:43 +02:00 committed by Vova Perebykivskiy
parent 1cafd835d9
commit 821290f75a
21 changed files with 510 additions and 135 deletions

View file

@ -1,3 +1,22 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.business.email.daos;
import org.libreplan.business.common.daos.GenericDAOHibernate;
@ -7,6 +26,8 @@ import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Dao for {@link EmailNotification}
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
* on 19.10.15.
@ -18,4 +39,17 @@ public class EmailNotificationDAO extends GenericDAOHibernate<EmailNotification,
public List<EmailNotification> getAll() {
return list(EmailNotification.class);
}
@Override
public boolean deleteAll() {
List<EmailNotification> notifications = list(EmailNotification.class);
for (Object item : notifications){
getSession().delete(item);
}
getSession().getTransaction().commit();
if ( list(EmailNotification.class).size() == 0 ) return true;
return false;
}
}

View file

@ -1,3 +1,22 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.business.email.daos;
import org.libreplan.business.common.daos.GenericDAOHibernate;
@ -7,6 +26,8 @@ import org.springframework.stereotype.Repository;
import java.util.List;
/**
* DAO for {@link EmailTemplate}
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
* on 24.09.15.
@ -24,6 +45,7 @@ public class EmailTemplateDAO extends GenericDAOHibernate<EmailTemplate, Long> i
try{
List<EmailTemplate> emailTemplates = list(EmailTemplate.class);
for ( int i = 0; i < emailTemplates.size(); i++)
// language.ordinal.equals(3) - English
if ( emailTemplates.get(i).getType().ordinal() == 0 && emailTemplates.get(i).getLanguage().ordinal() == 3)
return emailTemplates.get(i).getContent();
}catch (Exception e){}
@ -36,6 +58,7 @@ public class EmailTemplateDAO extends GenericDAOHibernate<EmailTemplate, Long> i
try{
List<EmailTemplate> emailTemplates = list(EmailTemplate.class);
for ( int i = 0; i < emailTemplates.size(); i++)
// language.ordinal.equals(3) - English
if ( emailTemplates.get(i).getType().ordinal() == 0 && emailTemplates.get(i).getLanguage().ordinal() == 3)
return emailTemplates.get(i).getSubject();
}catch (Exception e){}

View file

@ -1,3 +1,22 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.business.email.daos;
import org.libreplan.business.common.daos.IGenericDAO;
@ -6,11 +25,13 @@ import org.libreplan.business.email.entities.EmailNotification;
import java.util.List;
/**
* Contract for {@link EmailNotificationDAO}
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
* on 19.10.15.
*
*/
public interface IEmailNotificationDAO extends IGenericDAO<EmailNotification, Long> {
List<EmailNotification> getAll();
boolean deleteAll();
}

View file

@ -1,3 +1,22 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.business.email.daos;
import org.libreplan.business.common.daos.IGenericDAO;
@ -7,6 +26,7 @@ import java.util.List;
/**
* DAO interface for the <code>EmailTemplate</code> entity.
* Contract for {@link EmailTemplateDAO}
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>

View file

@ -1,3 +1,22 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.business.email.entities;
import org.libreplan.business.common.BaseEntity;
@ -5,11 +24,12 @@ import org.libreplan.business.common.BaseEntity;
import org.libreplan.business.planner.entities.TaskElement;
import org.libreplan.business.resources.entities.Resource;
import java.util.Date;
/**
* EmailNotification entity representing table: notification_queue
* EmailNotification entity representing table: notification_queue.
* This class is intended to work as a Hibernate component.
* It represents the Email notification to be send to user.
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>

View file

@ -1,3 +1,22 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.business.email.entities;
import org.libreplan.business.common.BaseEntity;
@ -5,6 +24,8 @@ import org.libreplan.business.settings.entities.Language;
/**
* EmailTemplate entity, represents a template that LibrePlan user may use.
* This class is intended to work as a Hibernate component.
* It represents the E-mail template to be modified by admin and send to user.
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>

View file

@ -1,9 +1,28 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.business.email.entities;
import static org.libreplan.business.i18n.I18nHelper._;
/**
* Available E-mail templates
* Available E-mail templates.
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>

View file

@ -11,6 +11,7 @@
<name>LibrePlan Web Client Module</name>
<profiles>
<profile>
<id>reports</id>
<activation>
@ -71,6 +72,7 @@
</plugins>
</build>
</profile>
<profile>
<id>userguide</id>
<activation>
@ -195,6 +197,7 @@
</plugins>
</build>
</profile>
<profile>
<id>i18n</id>
<activation>

View file

@ -1,15 +1,33 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.importers;
import java.util.List;
/**
* Sends E-mail to users with data that storing in notification_queue table
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
* on 13.10.15.
*
*/
public interface ISendEmail {
void sendEmail();
}

View file

@ -1,5 +1,23 @@
package org.libreplan.importers;
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.importers;
import org.libreplan.business.common.daos.IConnectorDAO;
import org.libreplan.business.common.entities.Connector;
@ -21,15 +39,21 @@ import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
// TODO not importing all packages
import javax.mail.*;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Transport;
import javax.mail.Session;
import javax.mail.PasswordAuthentication;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
// TODO not importing all packages
import java.util.*;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
/**
* Sends E-mail to users with data that storing in notification_queue table
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
* on 13.10.15.
@ -54,16 +78,8 @@ public class SendEmail implements ISendEmail {
private List<EmailTemplate> emailTemplates;
@Override
public void sendEmail() {
/*
// TODO
1. check all added classes to identity (Licenses, annotations, comments, ...)
2. the mvn compile flags -Ddefault.passwordsControl=false -Ddefault.exampleUsersDisabled=false are used to compile the demo version of LibrePlan.
There must also be a flag like "sendingEmail" that can be set to false to make sure that the demo edition will not become the worlds biggest spammer.
*/
notifications = emailNotificationModel.getAll();
@ -90,7 +106,6 @@ public class SendEmail implements ISendEmail {
// Modify text that will be composed
//List<String> predefinedCommandsForTemplateTaskAssignedToResource;
String text = currentEmailTemplate.getContent();
if ( type.equals(EmailTemplateEnum.TEMPLATE_TASK_ASSIGNED_TO_RESOURCE) ){
@ -115,7 +130,6 @@ public class SendEmail implements ISendEmail {
String psswrd = null;
for (int i = 0; i < emailConnectorProperties.size(); i++){
if (emailConnectorProperties.get(i).getValue() != null)
switch (i){
case 1: {
protocol = emailConnectorProperties.get(1).getValue();
@ -148,15 +162,14 @@ public class SendEmail implements ISendEmail {
Properties properties = new Properties();
if ( protocol.equals("STARTTLS") ) {
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.socketFactory.port", "465");
properties.put("mail.smtp.socketFactory.port", port);
properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.port", "465");
properties.put("mail.smtp.port", port);
}
else if ( protocol.equals("SMTP") ) {
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.port", port);
}
@ -164,7 +177,8 @@ public class SendEmail implements ISendEmail {
final String username = usrnme;
final String password = psswrd;
Session mailSession = Session.getDefaultInstance(properties,
/* It is very important to use Session.getInstance instead of Session.getDefaultInstance */
Session mailSession = Session.getInstance(properties,
new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
@ -172,28 +186,27 @@ public class SendEmail implements ISendEmail {
});
// Send message
try{
MimeMessage message = new MimeMessage(mailSession);
// TODO check from field
message.setFrom(new InternetAddress(sender));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(receiver));
try{
MimeMessage message = new MimeMessage(mailSession);
String subject = currentEmailTemplate.getSubject();
message.setSubject(subject);
message.setFrom(new InternetAddress(sender));
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(receiver));
message.setText(text);
String subject = currentEmailTemplate.getSubject();
message.setSubject(subject);
// TODO delete me
mailSession.setDebug(true);
message.setText(text);
Transport.send(message);
Transport.send(message);
}catch (MessagingException e){throw new RuntimeException(e);}
}catch (MessagingException e){throw new RuntimeException(e);}
}
private void deleteAllNotificationsAfterSending(){
emailNotificationModel.deleteAll();
}
private List<ConnectorProperty> getEmailConnectorProperties() {
Connector connector = connectorDAO.findUniqueByName("E-mail");
@ -202,6 +215,7 @@ public class SendEmail implements ISendEmail {
return properties;
}
private EmailTemplate findCurrentEmailTemplate(EmailTemplateEnum templateEnum, Locale locale){
emailTemplates = emailTemplateModel.getAll();
for (EmailTemplate item : emailTemplates)
@ -209,6 +223,7 @@ public class SendEmail implements ISendEmail {
return item;
return null;
}
private Worker getCurrentWorker(Long resourceID){
List<Worker> workerList = workerModel.getWorkers();
for(int i = 0; i < workerList.size(); i++)

View file

@ -1,3 +1,22 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.importers;
import org.quartz.JobExecutionContext;
@ -6,6 +25,8 @@ import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.quartz.QuartzJobBean;
/**
* Sends E-mail to users with data that storing in notification_queue table
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
* on 13.10.15.

View file

@ -23,9 +23,23 @@ package org.libreplan.web.common;
import static org.libreplan.web.I18nHelper._;
import java.util.*;
// TODO not importing all packages
import javax.mail.*;
import java.util.List;
import java.util.ConcurrentModificationException;
import java.util.Comparator;
import java.util.Properties;
import java.util.ArrayList;
import java.util.Set;
import java.util.Map;
import java.util.Collections;
import java.util.HashSet;
import java.util.Arrays;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.AuthenticationFailedException;
import javax.mail.MessagingException;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
@ -63,8 +77,27 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.SelectEvent;
import org.zkoss.zk.ui.util.GenericForwardComposer;
// TODO not importing all packages
import org.zkoss.zul.*;
import org.zkoss.zul.ListitemRenderer;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Grid;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.Intbox;
import org.zkoss.zul.Textbox;
import org.zkoss.zul.Radiogroup;
import org.zkoss.zul.Listitem;
import org.zkoss.zul.Row;
import org.zkoss.zul.Constraint;
import org.zkoss.zul.RowRenderer;
import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Radio;
import org.zkoss.zul.Button;
import org.zkoss.zul.Label;
import org.zkoss.zul.Rows;
import org.zkoss.zul.SimpleListModel;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.api.Window;
import org.zkoss.zul.impl.InputElement;
@ -118,6 +151,10 @@ public class ConfigurationController extends GenericForwardComposer {
private Combobox protocolsCombobox;
private Textbox emailUsernameTextbox;
private Textbox emailPasswordTextbox;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
@ -202,32 +239,38 @@ public class ConfigurationController extends GenericForwardComposer {
}
public void save() throws InterruptedException {
ConstraintChecker.isValid(configurationWindow);
if (checkValidEntitySequenceRows()) {
try {
configurationModel.confirm();
configurationModel.init();
messages.showMessage(Level.INFO, _("Changes saved"));
if (getSelectedConnector() != null
&& !configurationModel
.scheduleOrUnscheduleJobs(getSelectedConnector())) {
messages.showMessage(
Level.ERROR,
_("Scheduling or unscheduling of jobs for this connector is not completed"));
if ( getSelectedConnector().getName().equals("E-mail") && emailUsernamePasswordIsEmpty() == true) {
messages.showMessage(Level.ERROR, _("E-mail username/password - empty"));
} else {
ConstraintChecker.isValid(configurationWindow);
if (checkValidEntitySequenceRows()) {
try {
configurationModel.confirm();
configurationModel.init();
messages.showMessage(Level.INFO, _("Changes saved"));
if (getSelectedConnector() != null
&& !configurationModel
.scheduleOrUnscheduleJobs(getSelectedConnector())) {
messages.showMessage(
Level.ERROR,
_("Scheduling or unscheduling of jobs for this connector is not completed"));
}
reloadWindow();
reloadEntitySequences();
reloadConnectors();
} catch (ValidationException e) {
messages.showInvalidValues(e);
} catch (ConcurrentModificationException e) {
messages.showMessage(Level.ERROR, e.getMessage());
configurationModel.init();
reloadWindow();
reloadEntitySequences();
reloadConnectors();
}
reloadWindow();
reloadEntitySequences();
reloadConnectors();
} catch (ValidationException e) {
messages.showInvalidValues(e);
} catch (ConcurrentModificationException e) {
messages.showMessage(Level.ERROR, e.getMessage());
configurationModel.init();
reloadWindow();
reloadEntitySequences();
reloadConnectors();
}
}
}
public void cancel() throws InterruptedException {
@ -1132,7 +1175,7 @@ public class ConfigurationController extends GenericForwardComposer {
Util.appendLabel(row, _(property.getKey()));
// FIXME this is not perfect solution for future
// FIXME this is not perfect solution
if ( property.getKey().equals("Protocol") ) appendValueCombobox(row, property);
else appendValueTextbox(row, property);
}
@ -1157,6 +1200,7 @@ public class ConfigurationController extends GenericForwardComposer {
property.setValue(value);
}
});
if ( property.getKey().equals(
PredefinedConnectorProperties.PASSWORD) ||
property.getKey().equals(
@ -1164,6 +1208,13 @@ public class ConfigurationController extends GenericForwardComposer {
textbox.setType("password");
}
// Need for method emailUsernamePasswordIsEmpty()
if ( property.getKey().equals(
PredefinedConnectorProperties.EMAIL_USERNAME) ) emailUsernameTextbox = textbox;
if ( property.getKey().equals(
PredefinedConnectorProperties.EMAIL_PASSWORD) ) emailPasswordTextbox = textbox;
row.appendChild(textbox);
}
@ -1218,49 +1269,7 @@ public class ConfigurationController extends GenericForwardComposer {
row.appendChild(combobox);
// Need for testing E-mail connection
protocolsCombobox= combobox;
/*final Combobox combobox = new Combobox();
combobox.setWidth("400px");
// TODO make get/set
Util.bind(combobox, new Util.Getter<Comboitem>() {
@Override
public Comboitem get() {
Comboitem comboitem = new Comboitem();
comboitem.setLabel("SMTP");
return comboitem;
}
}, new Util.Setter<Comboitem>() {
@Override
public void set(Comboitem value) {
property.setValue("comboitem" *//*value.getLabel()*//*);
value.setLabel(property.getValue());
}
});
Comboitem comboitem = new Comboitem();
comboitem.setLabel("SMTP");
Comboitem comboitem1 = new Comboitem();
comboitem1.setLabel("STARTTLS");
combobox.getItems().add(comboitem);
combobox.getItems().add(comboitem1);
combobox.setSelectedIndex(0);
row.appendChild(combobox);
// Need for testing E-mail connection
protocolsCombobox= combobox;*/
protocolsCombobox = combobox;
}
public Constraint checkPropertyValue(
@ -1269,27 +1278,33 @@ public class ConfigurationController extends GenericForwardComposer {
return new Constraint() {
@Override
public void validate(Component comp, Object value) {
if (key.equals(PredefinedConnectorProperties.ACTIVATED)) {
if (!((String) value).equalsIgnoreCase("Y")
&& !((String) value).equalsIgnoreCase("N")) {
if ( key.equals(PredefinedConnectorProperties.ACTIVATED) ) {
if ( !((String) value).equalsIgnoreCase("Y")
&& !((String) value).equalsIgnoreCase("N") ) {
throw new WrongValueException(comp, _(
"Only {0} allowed", "Y/N"));
}
} else if (key
} else if ( key
.equals(PredefinedConnectorProperties.SERVER_URL)
|| key.equals(PredefinedConnectorProperties.USERNAME)
|| key.equals(PredefinedConnectorProperties.PASSWORD)
|| key.equals(PredefinedConnectorProperties.JIRA_HOURS_TYPE)) {
|| key.equals(PredefinedConnectorProperties.JIRA_HOURS_TYPE) ) {
((InputElement) comp).setConstraint("no empty:"
+ _("cannot be empty"));
} else if (key
} else if ( key
.equals(PredefinedConnectorProperties.TIM_NR_DAYS_TIMESHEET)
|| key.equals(PredefinedConnectorProperties.TIM_NR_DAYS_ROSTER)) {
if (!isNumeric((String) value)) {
|| key.equals(PredefinedConnectorProperties.TIM_NR_DAYS_ROSTER) ) {
if ( !isNumeric((String) value) ) {
throw new WrongValueException(comp,
_("Only digits allowed"));
}
}
// Validate E-mail connector
if ( key.equals(PredefinedConnectorProperties.HOST) ||
key.equals(PredefinedConnectorProperties.PORT) ||
key.equals(PredefinedConnectorProperties.EMAIL_SENDER) )
((InputElement) comp).setConstraint("no empty:" + _("cannot be empty"));
}
};
}
@ -1306,4 +1321,16 @@ public class ConfigurationController extends GenericForwardComposer {
};
}
private boolean emailUsernamePasswordIsEmpty(){
if ( protocolsCombobox.getSelectedItem().getLabel().equals("STARTTLS") &&
emailUsernameTextbox.getValue() != null &&
emailPasswordTextbox.getValue() != null &&
emailUsernameTextbox.getValue().length() != 0 &&
emailPasswordTextbox.getValue().length() != 0 )
return false;
else return true;
}
}

View file

@ -1,12 +1,31 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.web.email;
import org.libreplan.business.common.exceptions.ValidationException;
import org.libreplan.business.email.daos.EmailNotificationDAO;
import org.libreplan.business.email.daos.IEmailNotificationDAO;
import org.libreplan.business.email.entities.EmailTemplate;
import org.libreplan.business.email.entities.EmailTemplateEnum;
import org.libreplan.business.email.entities.EmailNotification;
import org.libreplan.business.planner.entities.Task;
import org.libreplan.business.planner.entities.TaskElement;
import org.libreplan.business.resources.entities.Resource;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,10 +38,11 @@ import java.util.Date;
import java.util.List;
/**
* Model for operations related to {@link EmailNotification}.
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
* on 21.10.15.
*
*/
@Service
@ -56,6 +76,11 @@ public class EmailNotificationModel implements IEmailNotificationModel {
return emailNotificationDAO.getAll();
}
@Override
public boolean deleteAll() {
return emailNotificationDAO.deleteAll();
}
@Override
public void setType(EmailTemplateEnum type) {
this.emailNotification.setType(type);

View file

@ -1,3 +1,22 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.web.email;
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
@ -18,8 +37,10 @@ import org.zkoss.zul.Listitem;
import org.zkoss.zul.ListitemRenderer;
import org.zkoss.zul.Textbox;
// TODO not importing all packages
import java.util.*;
import java.util.List;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import static org.libreplan.web.I18nHelper._;
@ -85,6 +106,7 @@ public class EmailTemplateController extends GenericForwardComposer{
public Language getSelectedLanguage() {
return emailTemplateModel.getLanguage();
}
public void setSelectedLanguage(Language language){
emailTemplateModel.setLanguage(language);

View file

@ -1,3 +1,22 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.web.email;
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
@ -15,6 +34,8 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* Model for operations related to {@link EmailTemplate}.
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
* on 25.09.15.

View file

@ -1,9 +1,27 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.web.email;
import org.libreplan.business.common.exceptions.ValidationException;
import org.libreplan.business.email.entities.EmailTemplateEnum;
import org.libreplan.business.email.entities.EmailNotification;
import org.libreplan.business.planner.entities.Task;
import org.libreplan.business.planner.entities.TaskElement;
import org.libreplan.business.resources.entities.Resource;
@ -11,6 +29,8 @@ import java.util.Date;
import java.util.List;
/**
* Contract for {@link EmailNotification}
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>
* on 21.10.15.
@ -21,6 +41,8 @@ public interface IEmailNotificationModel {
List<EmailNotification> getAll();
boolean deleteAll();
void setType(EmailTemplateEnum type);
void setUpdated(Date date);
void setResource(Resource resource);

View file

@ -1,3 +1,22 @@
/*
* This file is part of LibrePlan
*
* Copyright (C) 2015 LibrePlan
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.libreplan.web.email;
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
@ -9,7 +28,7 @@ import org.libreplan.business.email.entities.EmailTemplateEnum;
import java.util.List;
/**
* Model E-mail Templates
* Contract for {@link EmailTemplate}
*
* Created by
* @author Vova Perebykivskiy <vova@libreplan-enterprise.com>

View file

@ -85,7 +85,6 @@ import org.zkoss.zk.ui.util.Composer;
public class MultipleTabsPlannerController implements Composer,
IGlobalViewEntryPoints {
// TODO i18n
public static String WELCOME_URL = "-- no URL provided --";
private final class TabWithLoadingFeedback extends TabProxy {

View file

@ -433,7 +433,7 @@ public class TaskPropertiesController extends GenericForwardComposer {
}
public void accept() {
addNewRowToEmailNotificationeWithEmailTemplateTypeOne();
EmailNotificationAddNewWithTaskAssignedToResource();
boolean ok = true;
if (currentTaskElement instanceof ITaskPositionConstrained) {
@ -730,8 +730,7 @@ public class TaskPropertiesController extends GenericForwardComposer {
return Util.getMoneyFormat();
}
private void addNewRowToEmailNotificationeWithEmailTemplateTypeOne(){
private void EmailNotificationAddNewWithTaskAssignedToResource(){
if ( allocationResult != null ) {
@ -771,7 +770,6 @@ public class TaskPropertiesController extends GenericForwardComposer {
emailNotificationModel.confirmSave();
}
}
}
}

View file

@ -9233,4 +9233,12 @@ msgstr ""
#: libreplan-business/src/main/java/org/libreplan/business/common/entities/PredefinedConnectorProperties.java:56
msgid "Protocol"
msgstr ""
msgstr ""
#: libreplan-webapp/src/main/webapp/email/email_templates.zul:56
msgid "Possible content values:"
msgstr ""
#: libreplan-webapp/src/main/webapp/java/org/libreplan/web/planner/tabs/MultipleTabsPlannerController:90
msgid "-- no URL provided --"
msgstr ""

View file

@ -1,3 +1,23 @@
<!--
This file is part of LibrePlan
Copyright (C) 2015 LibrePlan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<?page id="editEmailTemplate" title="${i18n:_('LibrePlan: Email Templates')}" ?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
@ -55,7 +75,6 @@
rows="15" width="400px;"
tabindex="11"/>
<vbox>
<!--//TODO i18n-->
<label value="${i18n:_('Possible content values:')}"/>
<label value="${i18n:_('{username}')}"/>
<label value="${i18n:_('{firstname}')}"/>