Update how-to-start-with-IDEA

Changed quartz scheduler version
Add opportunity to Schedule E-mail class
Add opportunity to test E-mail connector
Minor changes to BaseCRUDController
Add new strings for i18n
Some changes to editJobScheduling form
This commit is contained in:
Vova Perebykivskiy 2015-10-15 17:54:14 +03:00 committed by Vova Perebykivskiy
parent 60a108f377
commit 9adff9de0b
10 changed files with 96 additions and 41 deletions

View file

@ -84,7 +84,7 @@ Configure project to run
http://localhost:8080/libreplan-webapp/ http://localhost:8080/libreplan-webapp/
Develop LibrePlan in Intellij IDEA using MySQL Develop LibrePlan in Intellij IDEA using MySQL
---------------------------------------- ----------------------------------------------
* This tutorial works properly with PostgreSQL, but if you want to develop * This tutorial works properly with PostgreSQL, but if you want to develop
LibrePlan using MySQL you have to do 2 small changes: LibrePlan using MySQL you have to do 2 small changes:

View file

@ -29,8 +29,9 @@ package org.libreplan.business.common.entities;
public enum JobClassNameEnum { public enum JobClassNameEnum {
IMPORT_ROSTER_FROM_TIM_JOB("org.libreplan.importers", "ImportRosterFromTimJob"), IMPORT_ROSTER_FROM_TIM_JOB("org.libreplan.importers", "ImportRosterFromTimJob"),
EXPORT_TIMESHEET_TO_TIM_JOB("org.libreplan.importers","ExportTimesheetToTimJob"), EXPORT_TIMESHEET_TO_TIM_JOB("org.libreplan.importers", "ExportTimesheetToTimJob"),
SYNC_ORDERELEMENTS_WITH_JIRA_ISSUES_JOB("org.libreplan.importers","JiraOrderElementSynchronizerJob"); SYNC_ORDERELEMENTS_WITH_JIRA_ISSUES_JOB("org.libreplan.importers", "JiraOrderElementSynchronizerJob"),
SEND_EMAIL_JOB("org.libreplan.importers", "SendEmailJob");
private String packageName; private String packageName;
private String name; private String name;

View file

@ -53,8 +53,10 @@ public class PredefinedConnectorProperties {
public static final String JIRA_CODE_PREFIX = "JIRA-"; public static final String JIRA_CODE_PREFIX = "JIRA-";
// Specific for E-mail // Specific for E-mail
public static String PROTOCOL = _("Protocol");
public static String HOST = _("Host"); public static String HOST = _("Host");
public static String USER_EMAIL = _("E-mail");
public static String PORT = _("Port"); public static String PORT = _("Port");
public static String EMAIL_USERNAME = _("Username (optional)");
public static String EMAIL_PASSWORD = _("Password (optional)");
} }

View file

@ -54,10 +54,12 @@ public enum PredefinedConnectors {
PredefinedConnectorProperties.JIRA_HOURS_TYPE, "Default")), PredefinedConnectorProperties.JIRA_HOURS_TYPE, "Default")),
EMAIL("E-mail", EMAIL("E-mail",
ConnectorProperty.create(PredefinedConnectorProperties.ACTIVATED, "N"), ConnectorProperty.create(PredefinedConnectorProperties.ACTIVATED, "N"),
ConnectorProperty.create(PredefinedConnectorProperties.PROTOCOL, ""),
ConnectorProperty.create(PredefinedConnectorProperties.HOST, ""), ConnectorProperty.create(PredefinedConnectorProperties.HOST, ""),
ConnectorProperty.create(PredefinedConnectorProperties.PORT, ""), ConnectorProperty.create(PredefinedConnectorProperties.PORT, ""),
ConnectorProperty.create(PredefinedConnectorProperties.USER_EMAIL, ""), ConnectorProperty.create(PredefinedConnectorProperties.EMAIL_USERNAME, ""),
ConnectorProperty.create(PredefinedConnectorProperties.PASSWORD, "") ConnectorProperty.create(PredefinedConnectorProperties.EMAIL_PASSWORD, "")
); );
private String name; private String name;

View file

@ -227,9 +227,8 @@ public abstract class BaseCRUDController<T extends IHumanIdentifiable> extends
*/ */
private void saveCommonActions() throws ValidationException { private void saveCommonActions() throws ValidationException {
beforeSaving(); beforeSaving();
messagesForUser.clearMessages();
save(); save();
messagesForUser.showMessage( messagesForUser.showMessage(
Level.INFO, Level.INFO,
_("{0} \"{1}\" saved", getEntityType(), getEntityBeingEdited() _("{0} \"{1}\" saved", getEntityType(), getEntityBeingEdited()

View file

@ -65,6 +65,7 @@ import org.zkoss.zk.ui.event.SelectEvent;
import org.zkoss.zk.ui.util.GenericForwardComposer; import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.Button; import org.zkoss.zul.Button;
import org.zkoss.zul.Combobox; import org.zkoss.zul.Combobox;
import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Constraint; import org.zkoss.zul.Constraint;
import org.zkoss.zul.Grid; import org.zkoss.zul.Grid;
import org.zkoss.zul.Intbox; import org.zkoss.zul.Intbox;
@ -131,6 +132,8 @@ public class ConfigurationController extends GenericForwardComposer {
private Connector selectedConnector; private Connector selectedConnector;
private Combobox protocolsCombobox;
@Override @Override
public void doAfterCompose(Component comp) throws Exception { public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp); super.doAfterCompose(comp);
@ -309,9 +312,10 @@ public class ConfigurationController extends GenericForwardComposer {
} else if( selectedConnector.getName().equals( } else if( selectedConnector.getName().equals(
PredefinedConnectors.EMAIL.getName()) ){ PredefinedConnectors.EMAIL.getName()) ){
String host = properties.get(PredefinedConnectorProperties.HOST); String host = properties.get(PredefinedConnectorProperties.HOST);
String email = properties.get(PredefinedConnectorProperties.USER_EMAIL); username = properties.get(PredefinedConnectorProperties.EMAIL_USERNAME);
password = properties.get(PredefinedConnectorProperties.EMAIL_PASSWORD);
String port = properties.get(PredefinedConnectorProperties.PORT); String port = properties.get(PredefinedConnectorProperties.PORT);
testEmailConnection(host, port, email, password); testEmailConnection(host, port, username, password);
} else { } else {
throw new RuntimeException("Unknown connector"); throw new RuntimeException("Unknown connector");
} }
@ -381,43 +385,36 @@ public class ConfigurationController extends GenericForwardComposer {
* the host * the host
* @param port * @param port
* the port * the port
* @param email * @param username
* the email * the username
* @param password * @param password
* the password * the password
*/ */
private void testEmailConnection(String host, String port, String email, String password){ private void testEmailConnection(String host, String port, String username, String password){
String[] hostWords = host.split("\\.");
// + "s" means that protocol coming with SSL
String protocol = hostWords[0] + "s";
Properties props = System.getProperties(); Properties props = System.getProperties();
Transport transport = null;
if ( hostWords[0].equals("pop") ){
protocol = "pop3s";
props.setProperty("mail.pop3s.port", port);
}
else if ( hostWords[0].equals("smtp") ){ props.setProperty("mail.smtps.port", port); }
else if ( hostWords[0].equals("imap") ){ props.setProperty("mail.imaps.port", port); }
try { try {
Session session = Session.getInstance(props, null); if ( protocolsCombobox.getSelectedItem().getLabel().equals("SMTP") ){
session.setDebug(true); props.setProperty("mail.smtp.port", port);
props.setProperty("mail.smtp.host", host);
Session session = Session.getInstance(props, null);
if ( hostWords[0].equals("pop") || hostWords[0].equals("imap") ){ transport = session.getTransport("smtp");
Store store = session.getStore(protocol); if ( username.equals("") && password == null ) transport.connect();
store.connect(host, email, password);
messages.clearMessages();
if ( store.isConnected() ) messages.showMessage(Level.INFO, _("Connection successful!"));
} }
else if ( hostWords[0].equals("smtp") ){ else if ( protocolsCombobox.getSelectedItem().getLabel().equals("STARTTLS") ) {
Transport transport = session.getTransport(protocol); props.setProperty("mail.smtps.port", port);
transport.connect(host, email, password); props.setProperty("mail.smtps.host", host);
messages.clearMessages(); Session session = Session.getInstance(props, null);
if ( transport.isConnected() ) messages.showMessage(Level.INFO, _("Connection successful!"));
transport = session.getTransport("smtps");
if ( !username.equals("") && password != null ) transport.connect(host, username, password);
} }
messages.clearMessages();
if ( transport.isConnected() ) messages.showMessage(Level.INFO, _("Connection successful!"));
} }
catch (AuthenticationFailedException e){ catch (AuthenticationFailedException e){
LOG.error(e); LOG.error(e);
@ -1155,6 +1152,28 @@ public class ConfigurationController extends GenericForwardComposer {
private void appendValueTextbox(Row row, private void appendValueTextbox(Row row,
final ConnectorProperty property) { final ConnectorProperty property) {
if (property.getKey().equals(
PredefinedConnectorProperties.PROTOCOL
)){
final Combobox combobox = new Combobox();
combobox.setWidth("400px");
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;
}
final Textbox textbox = new Textbox(); final Textbox textbox = new Textbox();
textbox.setWidth("400px"); textbox.setWidth("400px");
textbox.setConstraint(checkPropertyValue(property)); textbox.setConstraint(checkPropertyValue(property));
@ -1172,8 +1191,10 @@ public class ConfigurationController extends GenericForwardComposer {
property.setValue(value); property.setValue(value);
} }
}); });
if (property.getKey().equals( if ( property.getKey().equals(
PredefinedConnectorProperties.PASSWORD)) { PredefinedConnectorProperties.PASSWORD) ||
property.getKey().equals(
PredefinedConnectorProperties.EMAIL_PASSWORD) ) {
textbox.setType("password"); textbox.setType("password");
} }

View file

@ -19,6 +19,7 @@
package org.libreplan.web.common; package org.libreplan.web.common;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.libreplan.business.common.daos.IConnectorDAO; import org.libreplan.business.common.daos.IConnectorDAO;
@ -34,6 +35,7 @@ import org.libreplan.importers.IImportRosterFromTim;
import org.libreplan.importers.IJiraOrderElementSynchronizer; import org.libreplan.importers.IJiraOrderElementSynchronizer;
import org.libreplan.importers.ISchedulerManager; import org.libreplan.importers.ISchedulerManager;
import org.libreplan.importers.SynchronizationInfo; import org.libreplan.importers.SynchronizationInfo;
import org.libreplan.importers.ISendEmail;
import org.libreplan.web.common.concurrentdetection.OnConcurrentModification; import org.libreplan.web.common.concurrentdetection.OnConcurrentModification;
import org.quartz.SchedulerException; import org.quartz.SchedulerException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -42,6 +44,8 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import static org.libreplan.web.I18nHelper._;
/** /**
* Model for UI operations related to {@link JobSchedulerConfiguration}. * Model for UI operations related to {@link JobSchedulerConfiguration}.
* *
@ -75,6 +79,9 @@ public class JobSchedulerModel implements IJobSchedulerModel {
private List<SynchronizationInfo> synchronizationInfos; private List<SynchronizationInfo> synchronizationInfos;
@Autowired
private ISendEmail email;
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public List<JobSchedulerConfiguration> getJobSchedulerConfigurations() { public List<JobSchedulerConfiguration> getJobSchedulerConfigurations() {
@ -105,6 +112,13 @@ public class JobSchedulerModel implements IJobSchedulerModel {
.syncOrderElementsWithJiraIssues(); .syncOrderElementsWithJiraIssues();
return; return;
} }
if ( name.equals(JobClassNameEnum.SEND_EMAIL_JOB.getName()) ) {
synchronizationInfos = new ArrayList<SynchronizationInfo>();
synchronizationInfos.add(new SynchronizationInfo(_("Send E-mail")));
email.sendEmail();
return;
}
throw new RuntimeException("Unknown action"); throw new RuntimeException("Unknown action");
} }

View file

@ -9230,3 +9230,7 @@ msgstr ""
#: libreplan-business/src/main/java/org/libreplan/business/common/entities/PredefinedConnectorProperties.java:57 #: libreplan-business/src/main/java/org/libreplan/business/common/entities/PredefinedConnectorProperties.java:57
msgid "Port" msgid "Port"
msgstr "" msgstr ""
#: libreplan-business/src/main/java/org/libreplan/business/common/entities/PredefinedConnectorProperties.java:56
msgid "Protocol"
msgstr ""

View file

@ -97,39 +97,51 @@
<columns> <columns>
<column label="${i18n:_('Field')}" width="150px"/> <column label="${i18n:_('Field')}" width="150px"/>
<column label="${i18n:_('Allowed values')}" /> <column label="${i18n:_('Allowed values')}" />
<column label="${i18n:_('Allowed Special Characters')}" />
</columns> </columns>
<rows> <rows>
<row> <row>
<label value="${i18n:_('Seconds')}"/> <label value="${i18n:_('Seconds')}"/>
<label value="0-59"/> <label value="0-59"/>
<label value=", - * /"/>
</row> </row>
<row> <row>
<label value="${i18n:_('Minutes')}"/> <label value="${i18n:_('Minutes')}"/>
<label value="0-59"/> <label value="0-59"/>
<label value=", - * /"/>
</row> </row>
<row> <row>
<label value="${i18n:_('Hours')}"/> <label value="${i18n:_('Hours')}"/>
<label value="0-23"/> <label value="0-23"/>
<label value=", - * /"/>
</row> </row>
<row> <row>
<label value="${i18n:_('Day of month')}"/> <label value="${i18n:_('Day of month')}"/>
<label value="1-31"/> <label value="1-31"/>
<label value=", - * ? / L W"/>
</row> </row>
<row> <row>
<label value="${i18n:_('Month')}"/> <label value="${i18n:_('Month')}"/>
<span>1-12 (<label value="${i18n:_('or names')}"/> [JAN-DEC])</span> <span>1-12 (<label value="${i18n:_('or names')}"/> [JAN-DEC])</span>
<label value=", - *"/>
</row> </row>
<row> <row>
<label value="${i18n:_('Day of week')}"/> <label value="${i18n:_('Day of week')}"/>
<span>0-7 (<label value="${i18n:_('0 or 7 is Sunday, or use names')}"/> [SUN-SAT])</span> <span>1-7 (<label value="${i18n:_('1 or 7 is Sunday, or use names')}"/> [SUN-SAT])</span>
<label value=", - * ? / L #"/>
</row> </row>
<row> <row>
<label value="${i18n:_('Year (optional)')}"/> <label value="${i18n:_('Year (optional)')}"/>
<label value="1970-2099"/> <label value="1970-2099"/>
<label value=", - *"/>
</row> </row>
</rows> </rows>
</grid> </grid>
<div> <div>
<div>
${i18n:_("The '?' character is allowed for the day-of-month and day-of-week fields. It is used to specify “no specific value”. ")}
</div>
${i18n:_("For more details on cron expression click")} ${i18n:_("For more details on cron expression click")}
<a href="http://www.manpagez.com/man/5/crontab/">${i18n:_('here')}.</a> <a href="http://www.manpagez.com/man/5/crontab/">${i18n:_('here')}.</a>
</div> </div>

View file

@ -600,7 +600,7 @@
<dependency> <dependency>
<groupId>org.quartz-scheduler</groupId> <groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId> <artifactId>quartz</artifactId>
<version>1.8.0</version> <version>1.8.6</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>