Commit 35b0b056 by Tuomas Riihimäki

Sähköpostijuttuja.

1 parent 9d9eefd1
...@@ -25,43 +25,45 @@ import fi.insomnia.bortal.util.MailMessage; ...@@ -25,43 +25,45 @@ import fi.insomnia.bortal.util.MailMessage;
* *
*/ */
@MessageDriven( @MessageDriven(
activationConfig = { @ActivationConfigProperty( propertyName = "destinationType", propertyValue = "javax.jms.Queue" ) }, activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue") },
mappedName = "jms/mailque") mappedName = "jms/mailque")
public class MailMessageBean implements MessageListener { public class MailMessageBean implements MessageListener {
@Resource(name = "mail/lanbortal")
private Session mailSession;
private static final Logger logger = LoggerFactory.getLogger(MailMessageBean.class);
/** @Resource(name = "mail/lanbortal")
* Default constructor. private Session mailSession;
*/ private static final Logger logger = LoggerFactory.getLogger(MailMessageBean.class);
public MailMessageBean() {
// TODO Auto-generated constructor stub
}
/** /**
* @see MessageListener#onMessage(Message) * Default constructor.
*/ */
public void onMessage(Message message) { public MailMessageBean() {
// TODO Auto-generated constructor stub
}
MailMessage mailmsg = null; /**
try { * @see MessageListener#onMessage(Message)
mailmsg = (MailMessage) ((ObjectMessage) message).getObject(); */
logger.debug("Got message {}", mailmsg.getToName()); @Override
MimeMessage msg = new MimeMessage(mailSession); public void onMessage(Message message) {
msg.setSubject(mailmsg.getSubject());
msg.setFrom(mailmsg.getFrom());
msg.setRecipient(RecipientType.TO, mailmsg.getTo());
msg.setText(mailmsg.getMessage(), mailmsg.getCharset());
Transport.send(msg);
} catch (JMSException e) { MailMessage mailmsg = null;
logger.debug("Error receiving jms for {}", mailmsg, e); try {
} catch (MessagingException e) { mailmsg = (MailMessage) ((ObjectMessage) message).getObject();
logger.debug("Unsupported encoding exception while sending mail to {}", mailmsg, e); logger.debug("Got message {}", mailmsg.getToName());
} catch (UnsupportedEncodingException e) { MimeMessage msg = new MimeMessage(mailSession);
logger.debug("Unsupported encoding exception while sending mail to {}", mailmsg, e); msg.setSubject(mailmsg.getSubject());
} msg.setFrom(mailmsg.getFrom());
msg.setRecipient(RecipientType.TO, mailmsg.getTo());
msg.setText(mailmsg.getMessage(), mailmsg.getCharset());
Transport.send(msg);
} } catch (JMSException e) {
logger.debug("Error receiving jms for {}", mailmsg, e);
} catch (MessagingException e) {
logger.debug("Unsupported encoding exception while sending mail to {}", mailmsg, e);
} catch (UnsupportedEncodingException e) {
logger.debug("Unsupported encoding exception while sending mail to {}", mailmsg, e);
}
}
} }
package fi.insomnia.bortal.beans.mail;
import javax.ejb.Local;
@Local
public interface MailBeanLocal {
}
...@@ -8,105 +8,105 @@ import javax.mail.internet.InternetAddress; ...@@ -8,105 +8,105 @@ import javax.mail.internet.InternetAddress;
import fi.insomnia.bortal.model.User; import fi.insomnia.bortal.model.User;
public class MailMessage implements Serializable { public class MailMessage implements Serializable {
/** /**
* *
*/ */
private static final long serialVersionUID = -4769468394850407107L; private static final long serialVersionUID = -4769468394850407107L;
private static final String DEFAULT_MAIL_CHARSET = "iso-8859-1"; private static final String DEFAULT_MAIL_CHARSET = "iso-8859-1";
private String subject; private String subject;
private String fromName = "Insomnia lippukauppa"; private String fromName = "Insomnia lippukauppa";
private String fromAddress = "info@insomnia.fi"; private String fromAddress = "info@insomnia.fi";
private String toName; private String toName;
private String toAddress; private String toAddress;
private String message; private String message;
private String charset = DEFAULT_MAIL_CHARSET; private String charset = DEFAULT_MAIL_CHARSET;
public InternetAddress getTo() throws UnsupportedEncodingException { public InternetAddress getTo() throws UnsupportedEncodingException {
return new InternetAddress(toAddress, toName, getCharset()); return new InternetAddress(toAddress, toName, getCharset());
} }
public InternetAddress getFrom() throws UnsupportedEncodingException { public InternetAddress getFrom() throws UnsupportedEncodingException {
return new InternetAddress(fromAddress, fromName, getCharset()); return new InternetAddress(fromAddress, fromName, getCharset());
} }
public String getSubject() { public String getSubject() {
return subject; return subject;
} }
public void setSubject(String subject) { public void setSubject(String subject) {
this.subject = subject; this.subject = subject;
} }
public String getFromName() { public String getFromName() {
return fromName; return fromName;
} }
public void setFromName(String fromName) { public void setFromName(String fromName) {
this.fromName = fromName; this.fromName = fromName;
} }
public String getFromAddress() { public String getFromAddress() {
return fromAddress; return fromAddress;
} }
public void setFromAddress(String fromAddress) { public void setFromAddress(String fromAddress) {
this.fromAddress = fromAddress; this.fromAddress = fromAddress;
} }
public String getToName() { public String getToName() {
return toName; return toName;
} }
public void setToName(String toName) { public void setToName(String toName) {
this.toName = toName; this.toName = toName;
} }
public String getToAddress() { public String getToAddress() {
return toAddress; return toAddress;
} }
public void setToAddress(String toAddress) { public void setToAddress(String toAddress) {
this.toAddress = toAddress; this.toAddress = toAddress;
} }
public String getMessage() { public String getMessage() {
return message; return message;
} }
public void setMessage(Object... msgpart) { public void setMessage(Object... msgpart) {
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();
for (Object o : msgpart) { for (Object o : msgpart) {
msg.append(o); msg.append(o);
} }
message = msg.toString(); message = msg.toString();
} }
public void setMessage(String message) { public void setMessage(String message) {
this.message = message; this.message = message;
} }
public static String getDefaultMailCharset() { public static String getDefaultMailCharset() {
return DEFAULT_MAIL_CHARSET; return DEFAULT_MAIL_CHARSET;
} }
public void setCharset(String charset) { public void setCharset(String charset) {
this.charset = charset; this.charset = charset;
} }
public String getCharset() { public String getCharset() {
return charset; return charset;
} }
public void setTo(User user) { public void setTo(User user) {
setToName(user.getWholeName()); setToName(user.getWholeName());
setToAddress(user.getEmail()); setToAddress(user.getEmail());
} }
@Override @Override
public String toString() { public String toString() {
return new StringBuilder("fi.insomnia.bortal.util.MailMessage[to=").append(toAddress).append("]").toString(); return new StringBuilder("fi.insomnia.bortal.util.MailMessage[to=").append(toAddress).append("]").toString();
} }
} }
...@@ -14,6 +14,7 @@ public class GenericEntity extends EntityEquals implements ModelInterface<Intege ...@@ -14,6 +14,7 @@ public class GenericEntity extends EntityEquals implements ModelInterface<Intege
private static final long serialVersionUID = -9041737052951021560L; private static final long serialVersionUID = -9041737052951021560L;
public static final String ID_COLUMN = "id"; public static final String ID_COLUMN = "id";
@Id @Id
@Column(name = ID_COLUMN, nullable = false) @Column(name = ID_COLUMN, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
......
...@@ -47,7 +47,6 @@ public class User extends GenericEntity { ...@@ -47,7 +47,6 @@ public class User extends GenericEntity {
private static final long serialVersionUID = -1632200627103418206L; private static final long serialVersionUID = -1632200627103418206L;
@Column(name = "created", nullable = false) @Column(name = "created", nullable = false)
// , columnDefinition = "timestamptz default now()")
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Calendar created = Calendar.getInstance(); private Calendar created = Calendar.getInstance();
......
...@@ -23,14 +23,19 @@ ...@@ -23,14 +23,19 @@
</h:inputText> </h:inputText>
<h:outputLabel value="#{i18n['bill.billNumber']}:" /> <h:outputLabel value="#{i18n['bill.billNumber']}:" />
<h:inputText value="#{billEditView.bill.billNumber}" /> <h:inputText value="#{billEditView.bill.billNumber}" />
<h:outputLabel value="#{i18n['bill.addr1']}:" /> <h:outputLabel value="#{i18n['bill.addr1']}:" />
<h:inputText value="#{billEditView.bill.addr1}" /> <h:inputText value="#{billEditView.bill.addr1}" />
<h:outputLabel value="#{i18n['bill.addr2']}:" /> <h:outputLabel value="#{i18n['bill.addr2']}:" />
<h:inputText value="#{billEditView.bill.addr2}" /> <h:inputText value="#{billEditView.bill.addr2}" />
<h:outputLabel value="#{i18n['bill.addr3']}:" /> <h:outputLabel value="#{i18n['bill.addr3']}:" />
<h:inputText value="#{billEditView.bill.addr3}" /> <h:inputText value="#{billEditView.bill.addr3}" />
<h:outputLabel value="#{i18n['bill.addr4']}:" /> <h:outputLabel value="#{i18n['bill.addr4']}:" />
<h:inputText value="#{billEditView.bill.addr4}" /> <h:inputText value="#{billEditView.bill.addr4}" />
<h:outputLabel value="#{i18n['bill.addr5']}:" /> <h:outputLabel value="#{i18n['bill.addr5']}:" />
<h:inputText value="#{billEditView.bill.addr5}" /> <h:inputText value="#{billEditView.bill.addr5}" />
......
...@@ -42,6 +42,7 @@ public class UserView extends GenericCDIView { ...@@ -42,6 +42,7 @@ public class UserView extends GenericCDIView {
private CroppedImage croppedImage; private CroppedImage croppedImage;
private User user; private User user;
@Inject @Inject
private transient Conversation conversation; private transient Conversation conversation;
...@@ -56,6 +57,7 @@ public class UserView extends GenericCDIView { ...@@ -56,6 +57,7 @@ public class UserView extends GenericCDIView {
private boolean canSave = false; private boolean canSave = false;
private String password; private String password;
private String passwordcheck; private String passwordcheck;
@EJB @EJB
private CardTemplateBeanLocal cardBean; private CardTemplateBeanLocal cardBean;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!