Commit 35b0b056 by Tuomas Riihimäki

Sähköpostijuttuja.

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