diff options
author | Christian Klinger | 2016-08-08 12:43:23 +0200 |
---|---|---|
committer | Christian Klinger | 2016-08-08 12:43:23 +0200 |
commit | 97331661c3e0f3371056dcb592f072a8591b0230 (patch) | |
tree | b588be057e3ce4e8e41f607ca71a42514c8f95a1 /dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java | |
parent | [server] Supply netrules and runscript via webrpc (diff) | |
parent | changes. (diff) | |
download | tutor-module-97331661c3e0f3371056dcb592f072a8591b0230.tar.gz tutor-module-97331661c3e0f3371056dcb592f072a8591b0230.tar.xz tutor-module-97331661c3e0f3371056dcb592f072a8591b0230.zip |
Merge branch 'feature/mail-templates' into v1.1
Conflicts:
dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/database/mappers/DbConfiguration.java
Diffstat (limited to 'dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java')
-rw-r--r-- | dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java index 19cb787c..ef21919e 100644 --- a/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java +++ b/dozentenmodulserver/src/main/java/org/openslx/bwlp/sat/web/WebRpc.java @@ -8,17 +8,24 @@ import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; +import java.sql.SQLException; +import java.util.HashMap; import java.util.Map; import javax.security.auth.login.LoginException; import org.apache.commons.io.output.ByteArrayOutputStream; +import org.omg.CosNaming.NamingContextPackage.NotFound; +import org.openslx.bwlp.sat.database.mappers.DbConfiguration; +import org.openslx.bwlp.sat.mail.MailTemplate; import org.openslx.bwlp.sat.mail.SmtpMailer; import org.openslx.bwlp.sat.mail.SmtpMailer.EncryptionMode; import org.openslx.bwlp.sat.maintenance.DeleteOldImages; import org.openslx.bwlp.sat.maintenance.ImageValidCheck; import org.openslx.util.Util; +import com.btr.proxy.util.Logger; + import fi.iki.elonen.NanoHTTPD; import fi.iki.elonen.NanoHTTPD.Response; @@ -53,8 +60,7 @@ public class WebRpc { StringBuilder res = DeleteOldImages.hardDeleteImages(); if (res == null) return WebServer.internalServerError(); - return new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, "text/plain; charset=utf-8", - res.toString()); + return new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, "text/plain; charset=utf-8", res.toString()); } /** @@ -98,14 +104,25 @@ public class WebRpc { } smtpc = null; } + + boolean ret = false; - if (smtpc != null) { - ret = smtpc.send(recipient, "bwLehrpool Mail Test", "Test der Mailkonfiguration.\n\nHost: " - + host + ":" + port + "\nSSL: " + ssl.toString() + "\nLogin: " + username); + if (smtpc != null) { + + MailTemplate template = DbConfiguration.getMailTemplate("testMail"); + Map<String, String> templateArgs = new HashMap<>(); + templateArgs.put("host", host); + templateArgs.put("port", String.valueOf(port)); + templateArgs.put("ssl", ssl.toString()); + templateArgs.put("username", username); + + String msg = template.format(templateArgs); + + ret = smtpc.send(recipient, "bwLehrpool Mail Test", msg); } try { - baos.write(("\n\n-----------------------------------------\nTestergebnis: " - + (ret ? "" : "nicht ") + "erfolgreich").getBytes(StandardCharsets.UTF_8)); + baos.write(("\n\n-----------------------------------------\nTestergebnis: " + (ret ? "" : "nicht ") + + "erfolgreich").getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { } return new NanoHTTPD.Response(NanoHTTPD.Response.Status.OK, "text/plain; charset=utf-8", |