Skip to content

Commit

Permalink
Handle boolean parameters in mail related attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Abyss777 committed Dec 15, 2017
1 parent 0c8bf88 commit 5debe74
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/org/traccar/notification/NotificationMail.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ private static Properties getProperties(PropertiesProvider provider) {
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.port", String.valueOf(provider.getInteger("mail.smtp.port", 25)));

String starttlsEnable = provider.getString("mail.smtp.starttls.enable");
Boolean starttlsEnable = provider.getBoolean("mail.smtp.starttls.enable");
if (starttlsEnable != null) {
properties.put("mail.smtp.starttls.enable", Boolean.parseBoolean(starttlsEnable));
properties.put("mail.smtp.starttls.enable", starttlsEnable);
}
String starttlsRequired = provider.getString("mail.smtp.starttls.required");
Boolean starttlsRequired = provider.getBoolean("mail.smtp.starttls.required");
if (starttlsRequired != null) {
properties.put("mail.smtp.starttls.required", Boolean.parseBoolean(starttlsRequired));
properties.put("mail.smtp.starttls.required", starttlsRequired);
}

String sslEnable = provider.getString("mail.smtp.ssl.enable");
Boolean sslEnable = provider.getBoolean("mail.smtp.ssl.enable");
if (sslEnable != null) {
properties.put("mail.smtp.ssl.enable", Boolean.parseBoolean(sslEnable));
properties.put("mail.smtp.ssl.enable", sslEnable);
}
String sslTrust = provider.getString("mail.smtp.ssl.trust");
if (sslTrust != null) {
Expand Down
17 changes: 17 additions & 0 deletions src/org/traccar/notification/PropertiesProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,21 @@ public int getInteger(String key, int defaultValue) {
}
}

public Boolean getBoolean(String key) {
if (config != null) {
if (config.hasKey(key)) {
return config.getBoolean(key);
} else {
return null;
}
} else {
Object result = extendedModel.getAttributes().get(key);
if (result != null) {
return result instanceof String ? Boolean.valueOf((String) result) : (Boolean) result;
} else {
return null;
}
}
}

}

0 comments on commit 5debe74

Please sign in to comment.