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; |
} |
} |