Subversion Repositories bacoAlunos

Compare Revisions

Ignore whitespace Rev 1427 → Rev 1429

/branches/v3/impl/src/java/pt/estgp/estgweb/utils/EmailPersonalizedCertificated.java
New file
0,0 → 1,131
package pt.estgp.estgweb.utils;
 
import org.apache.log4j.Logger;
import pt.estgp.estgweb.Globals;
 
import javax.mail.Message;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
 
/**
* @author Jorge Machado
* @date 20/Mar/2008
* @time 18:32:21
* @see pt.estgp.estgweb.utils
*/
public class EmailPersonalizedCertificated extends Email implements Serializable
{
 
 
private static final Logger logger = Logger.getLogger(EmailPersonalizedCertificated.class);
 
 
/**FIELDS FOR PERSONALIZED EMAILS**/
private String urlPatternWithoutCetificate = null;
private List<Long> userIds = null;
 
 
 
public EmailPersonalizedCertificated cloneEmailForJob(){
EmailPersonalizedCertificated email = new EmailPersonalizedCertificated(subject, from, emailTemplateName, arguments);
email = (EmailPersonalizedCertificated) super.cloneEmailForJob(email);
email.urlPatternWithoutCetificate = this.urlPatternWithoutCetificate;
if(this.userIds != null)
{
email.userIds = new ArrayList<Long>();
email.userIds.addAll(this.userIds);
}
return email;
}
 
public EmailPersonalizedCertificated()
{
}
 
public EmailPersonalizedCertificated(String urlPatternWithoutCetificate,
List<Long> userIds)
{
this.urlPatternWithoutCetificate = urlPatternWithoutCetificate;
this.userIds = filterUserIds(userIds);
}
 
 
public EmailPersonalizedCertificated(String subject, String from, String mailTemplateName, List<String> arguments)
{
super( subject, new ArrayList<String>(), from, mailTemplateName, arguments, Message.RecipientType.TO);
}
 
public EmailPersonalizedCertificated(String subject, String from, String mailTemplateName, List<String> arguments,
String urlPatternWithoutCetificate,
List<Long> userIds)
{
super( subject, new ArrayList<String>(), from, mailTemplateName, arguments, Message.RecipientType.TO);
this.urlPatternWithoutCetificate = urlPatternWithoutCetificate;
this.userIds = filterUserIds(userIds);
}
 
 
 
public boolean isSystemAssumingTestEmail() {
return systemAssumingTestEmail;
}
 
public String getFromName() {
return fromName;
}
 
public void setFromName(String fromName) {
this.fromName = fromName;
}
 
public String getSubject()
{
return subject;
}
 
public List<String> getRecipients()
{
return recipients;
}
 
public void setRecipients(List<String> recipients)
{
systemAssumingTestEmail = true;//ja nao estao sobre
this.recipients = filterRecipients(recipients);
 
}
 
public String getUrlPatternWithoutCetificate() {
return urlPatternWithoutCetificate;
}
 
public void setUrlPatternWithoutCetificate(String urlPatternWithoutCetificate) {
this.urlPatternWithoutCetificate = urlPatternWithoutCetificate;
}
 
public List<Long> getUserIds() {
return userIds;
}
 
public void setUserIds(List<Long> userIds) {
this.userIds = filterUserIds(userIds);
}
 
/**
* Garante que os users Idss não são usados em testes
 
* @return
*/
 
 
protected List<Long> filterUserIds(List<Long> userIds)
{
if(Globals.TEST_ENVIRONEMENT)
{
userIds = new ArrayList<Long>();
userIds.add(new Long(1));//Adding super user
}
return userIds;
}
}
/branches/v3/impl/src/java/pt/estgp/estgweb/utils/Email.java
23,19 → 23,27
 
private static final Logger logger = Logger.getLogger(Email.class);
 
private boolean systemAssumingTestEmail = false;
private boolean isHtml = false;
private String subject;
private List<String> recipients;
private Message.RecipientType type = Message.RecipientType.TO;
private String from;
private String emailTemplateName;
private List<String> arguments;
private String fromName = null;
protected boolean systemAssumingTestEmail = false;
protected boolean isHtml = false;
protected String subject;
protected List<String> recipients;
protected List<String> recipientsCC = null;
protected Message.RecipientType type = Message.RecipientType.TO;
protected String from;
protected String emailTemplateName;
protected List<String> arguments;
protected String fromName = null;
 
 
 
 
 
public Email cloneEmailForJob(){
Email email = new Email(subject,recipients,from,emailTemplateName,arguments,type);
return cloneEmailForJob(email);
}
public Email cloneEmailForJob(Email email){
 
email.systemAssumingTestEmail = this.systemAssumingTestEmail;
email.isHtml = this.isHtml;
email.subject = this.subject;
57,6 → 65,9
isHtml = html;
}
 
public Email() {
}
 
public Email(String subject, List<String> recipients, String from, String mailTemplateName, List<String> arguments)
{
this.subject = subject;
78,7 → 89,7
 
}
 
private List<String> filterRecipients(List<String> recipients,List<String> arguments,String template)
protected List<String> filterRecipients(List<String> recipients,List<String> arguments,String template)
{
if(Globals.TEST_ENVIRONEMENT)
{
93,7 → 104,7
}
return recipients;
}
private List<String> filterRecipients(List<String> recipients)
protected List<String> filterRecipients(List<String> recipients)
{
if(Globals.TEST_ENVIRONEMENT)
{
190,4 → 201,11
}
 
 
public List<String> getRecipientsCC() {
return recipientsCC;
}
 
public void setRecipientsCC(List<String> recipientsCC) {
this.recipientsCC = recipientsCC;
}
}