ing
This commit is contained in:
parent
53d88c758c
commit
b372ba40d2
16
pom.xml
16
pom.xml
|
@ -23,16 +23,17 @@
|
||||||
<jedis.version>2.9.0</jedis.version>
|
<jedis.version>2.9.0</jedis.version>
|
||||||
<caffeine.version>2.5.6</caffeine.version>
|
<caffeine.version>2.5.6</caffeine.version>
|
||||||
<protoc.version>3.5.1</protoc.version>
|
<protoc.version>3.5.1</protoc.version>
|
||||||
<spring.version>4.3.9.RELEASE</spring.version>
|
<spring.version>5.0.6.RELEASE</spring.version>
|
||||||
<spring.data.jpa.version>1.11.4.RELEASE</spring.data.jpa.version>
|
<spring.data.jpa.version>2.0.7.RELEASE</spring.data.jpa.version>
|
||||||
<spring.data.redis.version>1.8.7.RELEASE</spring.data.redis.version>
|
<spring.data.redis.version>2.0.7.RELEASE</spring.data.redis.version>
|
||||||
<spring.crypto.version>4.2.3.RELEASE</spring.crypto.version>
|
<spring.crypto.version>5.0.5.RELEASE</spring.crypto.version>
|
||||||
<!-- <gson.version>2.8.2</gson.version> -->
|
<!-- <gson.version>2.8.2</gson.version> -->
|
||||||
<jackson.mapper.version>1.9.13</jackson.mapper.version>
|
<jackson.mapper.version>1.9.13</jackson.mapper.version>
|
||||||
<hibernate.version>5.2.10.Final</hibernate.version>
|
<hibernate.version>5.2.10.Final</hibernate.version>
|
||||||
<javax.mail.version>1.4.7</javax.mail.version>
|
<javax.mail.version>1.4.7</javax.mail.version>
|
||||||
<javax.mail-api.version>1.6.0</javax.mail-api.version>
|
<javax.mail-api.version>1.6.0</javax.mail-api.version>
|
||||||
<apache.velocity.version>1.7</apache.velocity.version>
|
<apache.velocity.version>1.7</apache.velocity.version>
|
||||||
|
<apache.velocity-tools.version>2.0</apache.velocity-tools.version>
|
||||||
<docker.registry.name>docker.loafle.net/overflow</docker.registry.name>
|
<docker.registry.name>docker.loafle.net/overflow</docker.registry.name>
|
||||||
<googleauth.version>1.1.2</googleauth.version>
|
<googleauth.version>1.1.2</googleauth.version>
|
||||||
<fasterxml.uuid.verion>3.1.5</fasterxml.uuid.verion>
|
<fasterxml.uuid.verion>3.1.5</fasterxml.uuid.verion>
|
||||||
|
@ -176,6 +177,13 @@
|
||||||
<artifactId>velocity</artifactId>
|
<artifactId>velocity</artifactId>
|
||||||
<version>${apache.velocity.version}</version>
|
<version>${apache.velocity.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.velocity</groupId>
|
||||||
|
<artifactId>velocity-tools</artifactId>
|
||||||
|
<version>${apache.velocity-tools.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
|
<!-- https://mvnrepository.com/artifact/commons-codec/commons-codec -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-codec</groupId>
|
<groupId>commons-codec</groupId>
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.loafle.overflow.central.commons.utils;
|
package com.loafle.overflow.central.commons.utils;
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
import org.apache.velocity.Template;
|
||||||
|
import org.apache.velocity.VelocityContext;
|
||||||
import org.apache.velocity.app.VelocityEngine;
|
import org.apache.velocity.app.VelocityEngine;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
@ -9,7 +11,6 @@ import org.springframework.mail.javamail.JavaMailSender;
|
||||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||||
import org.springframework.mail.javamail.MimeMessagePreparator;
|
import org.springframework.mail.javamail.MimeMessagePreparator;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.ui.velocity.VelocityEngineUtils;
|
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.spec.IvParameterSpec;
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
|
@ -19,6 +20,7 @@ import javax.mail.internet.MimeMessage;
|
||||||
|
|
||||||
import com.loafle.overflow.core.model.Mail;
|
import com.loafle.overflow.core.model.Mail;
|
||||||
|
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,7 +38,6 @@ public class EmailSender {
|
||||||
private String key = "loafle@RandomKey";
|
private String key = "loafle@RandomKey";
|
||||||
private String initVector = "loafleInitVector";
|
private String initVector = "loafleInitVector";
|
||||||
|
|
||||||
|
|
||||||
public void sendSimpleEmail(final Mail mail) throws MailException {
|
public void sendSimpleEmail(final Mail mail) throws MailException {
|
||||||
|
|
||||||
MimeMessagePreparator preparator = mimeMessage -> {
|
MimeMessagePreparator preparator = mimeMessage -> {
|
||||||
|
@ -60,8 +61,9 @@ public class EmailSender {
|
||||||
helper.setSubject(mail.getMailSubject());
|
helper.setSubject(mail.getMailSubject());
|
||||||
helper.setText(mail.getMailContent());
|
helper.setText(mail.getMailContent());
|
||||||
helper.setFrom("geek@loafle.com");
|
helper.setFrom("geek@loafle.com");
|
||||||
// FileSystemResource file = new FileSystemResource(new File(mail.getAttachments()));
|
// FileSystemResource file = new FileSystemResource(new
|
||||||
// helper.addAttachment("Invoice", file);
|
// File(mail.getAttachments()));
|
||||||
|
// helper.addAttachment("Invoice", file);
|
||||||
|
|
||||||
mailSender.send(message);
|
mailSender.send(message);
|
||||||
}
|
}
|
||||||
|
@ -76,8 +78,7 @@ public class EmailSender {
|
||||||
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
|
cipher.init(Cipher.ENCRYPT_MODE, skeySpec, iv);
|
||||||
|
|
||||||
byte[] encrypted = cipher.doFinal(value.getBytes());
|
byte[] encrypted = cipher.doFinal(value.getBytes());
|
||||||
System.out.println("encrypted string: "
|
System.out.println("encrypted string: " + Base64.encodeBase64String(encrypted));
|
||||||
+ Base64.encodeBase64String(encrypted));
|
|
||||||
|
|
||||||
return Base64.encodeBase64String(encrypted);
|
return Base64.encodeBase64String(encrypted);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -106,22 +107,31 @@ public class EmailSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getContentFromTemplate(Map<String, Object> model, Mail mail) {
|
private String getContentFromTemplate(Map<String, Object> model, Mail mail) {
|
||||||
StringBuffer content = new StringBuffer();
|
StringWriter writer = new StringWriter();
|
||||||
|
VelocityContext context = new VelocityContext();
|
||||||
|
|
||||||
// Template template = this.velocityEngine.getTemplate("./local/vmtemplates/signup-email.vm");
|
Template template = this.velocityEngine.getTemplate(mail.getTemplateLoacation(), "UTF-8");
|
||||||
try {
|
|
||||||
content.append(VelocityEngineUtils.mergeTemplateIntoString
|
model.forEach((key, value) -> {
|
||||||
(velocityEngine,
|
context.put(key, value);
|
||||||
mail.getTemplateLoacation(), "UTF-8", model));
|
});
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
template.merge(context, writer);
|
||||||
}
|
|
||||||
return content.toString();
|
// try {
|
||||||
|
|
||||||
|
// template.merge(this.velocityEngine, content);
|
||||||
|
// // content.append(VelocityEngineUtils.mergeTemplateIntoString
|
||||||
|
// // (velocityEngine,
|
||||||
|
// // mail.getTemplateLoacation(), "UTF-8", model));
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
return writer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// SimpleMailMessage message1 = new SimpleMailMessage();
|
// SimpleMailMessage message1 = new SimpleMailMessage();
|
||||||
// message1.setTo(mail.getMailTo());
|
// message1.setTo(mail.getMailTo());
|
||||||
// message1.setSubject(mail.getMailSubject());
|
// message1.setSubject(mail.getMailSubject());
|
||||||
|
@ -129,7 +139,6 @@ public class EmailSender {
|
||||||
// message1.setFrom("geek@loafle.com");
|
// message1.setFrom("geek@loafle.com");
|
||||||
// mailSender.send(message1);
|
// mailSender.send(message1);
|
||||||
|
|
||||||
|
|
||||||
// MimeMessage msg = this.mailSender.createMimeMessage();
|
// MimeMessage msg = this.mailSender.createMimeMessage();
|
||||||
//
|
//
|
||||||
// try {
|
// try {
|
||||||
|
@ -138,7 +147,8 @@ public class EmailSender {
|
||||||
// helper.setFrom("geek@loafle.com");
|
// helper.setFrom("geek@loafle.com");
|
||||||
// helper.setSubject(mail.getMailSubject());
|
// helper.setSubject(mail.getMailSubject());
|
||||||
// helper.setText(getContentFromTemplate(mail.getModel(), mail), true);
|
// helper.setText(getContentFromTemplate(mail.getModel(), mail), true);
|
||||||
// helper.addInline("company-logo", new ClassPathResource("/vmtemplates/overFlow_logo.png"));
|
// helper.addInline("company-logo", new
|
||||||
|
// ClassPathResource("/vmtemplates/overFlow_logo.png"));
|
||||||
// this.mailSender.send(msg);
|
// this.mailSender.send(msg);
|
||||||
// } catch (MessagingException e) {
|
// } catch (MessagingException e) {
|
||||||
// e.printStackTrace();
|
// e.printStackTrace();
|
||||||
|
|
|
@ -28,6 +28,6 @@ public class CentralMetaHistoryTypeService implements MetaHistoryTypeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MetaHistoryType> registAll(List<MetaHistoryType> metaHistoryTypes) throws OverflowException {
|
public List<MetaHistoryType> registAll(List<MetaHistoryType> metaHistoryTypes) throws OverflowException {
|
||||||
return this.hisotyTypeDAO.save(metaHistoryTypes);
|
return (List<MetaHistoryType>)this.hisotyTypeDAO.save(metaHistoryTypes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,6 @@ public class CentralMetaSensorItemTypeService implements MetaSensorItemTypeServi
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MetaSensorItemType> registAll(List<MetaSensorItemType> list) throws OverflowException {
|
public List<MetaSensorItemType> registAll(List<MetaSensorItemType> list) throws OverflowException {
|
||||||
return this.sensorItemTypeDAO.save(list);
|
return (List<MetaSensorItemType>)this.sensorItemTypeDAO.save(list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class CentralProbeService implements ProbeService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Probe> regist(List<Probe> probes) throws OverflowException {
|
public List<Probe> regist(List<Probe> probes) throws OverflowException {
|
||||||
return this.probeDAO.save(probes);
|
return (List<Probe>)this.probeDAO.save(probes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Probe> readAllByDomainID(Long domainID) throws OverflowException {
|
public List<Probe> readAllByDomainID(Long domainID) throws OverflowException {
|
||||||
|
|
|
@ -7,7 +7,6 @@ import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||||
import org.springframework.ui.velocity.VelocityEngineFactory;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user