aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-02-25 09:28:49 +0500
committerAbyss777 <abyss@fox5.ru>2017-02-25 09:28:49 +0500
commite8500e8f6c440277d60e0418ab6a82f4bf80b887 (patch)
tree51c48c1e9dfc5302c3b7386b210930ef8bb1df4a /src/org/traccar
parentd0ae83ef94f1e4a89b27b70ebbc60150f1c83b31 (diff)
downloadtraccar-server-e8500e8f6c440277d60e0418ab6a82f4bf80b887.tar.gz
traccar-server-e8500e8f6c440277d60e0418ab6a82f4bf80b887.tar.bz2
traccar-server-e8500e8f6c440277d60e0418ab6a82f4bf80b887.zip
Pass path to getTemplate
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/notification/NotificationFormatter.java18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/org/traccar/notification/NotificationFormatter.java b/src/org/traccar/notification/NotificationFormatter.java
index df7d73683..cec238548 100644
--- a/src/org/traccar/notification/NotificationFormatter.java
+++ b/src/org/traccar/notification/NotificationFormatter.java
@@ -51,20 +51,14 @@ public final class NotificationFormatter {
return velocityContext;
}
- private static Template getTemplate(Event event, boolean mail) {
+ private static Template getTemplate(Event event, String path) {
Template template;
- String subPath = "";
- if (mail) {
- subPath = Context.getConfig().getString("mail.templatesPath", "mail") + "/";
- } else {
- subPath = Context.getConfig().getString("sms.templatesPath", "sms") + "/";
- }
try {
- template = Context.getVelocityEngine().getTemplate(subPath + event.getType() + ".vm",
+ template = Context.getVelocityEngine().getTemplate(path + event.getType() + ".vm",
StandardCharsets.UTF_8.name());
} catch (ResourceNotFoundException error) {
Log.warning(error);
- template = Context.getVelocityEngine().getTemplate(subPath + "unknown.vm",
+ template = Context.getVelocityEngine().getTemplate(path + "unknown.vm",
StandardCharsets.UTF_8.name());
}
return template;
@@ -73,14 +67,16 @@ public final class NotificationFormatter {
public static MailMessage formatMailMessage(long userId, Event event, Position position) {
VelocityContext velocityContext = prepareContext(userId, event, position);
StringWriter writer = new StringWriter();
- getTemplate(event, true).merge(velocityContext, writer);
+ getTemplate(event, Context.getConfig().getString("mail.templatesPath", "mail") + "/")
+ .merge(velocityContext, writer);
return new MailMessage((String) velocityContext.get("subject"), writer.toString());
}
public static String formatSmsMessage(long userId, Event event, Position position) {
VelocityContext velocityContext = prepareContext(userId, event, position);
StringWriter writer = new StringWriter();
- getTemplate(event, false).merge(velocityContext, writer);
+ getTemplate(event, Context.getConfig().getString("sms.templatesPath", "sms") + "/")
+ .merge(velocityContext, writer);
return writer.toString();
}
}