Produced by Araxis Merge on 6/9/2017 3:50:58 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | Fri Jun 9 19:50:58 2017 UTC | ||
| 2 | eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-server\src\main\java\gov\va\nvap\server\service\privacy\emailer | Emailer.java | Fri Apr 21 20:03:28 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 1 | 117 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | package go v.va.nvap. server.ser vice.priva cy.emailer ; | |||||
| 2 | ||||||
| 3 | import gov .va.nvap.s erver.serv ice.privac y.emailer. EmailBean; | |||||
| 4 | import jav a.util.Ite rator; | |||||
| 5 | import jav a.util.Lis t; | |||||
| 6 | import jav a.util.Map ; | |||||
| 7 | import jav a.util.Pro perties; | |||||
| 8 | import jav a.lang.Str ingBuffer; | |||||
| 9 | ||||||
| 10 | import jav ax.mail.Me ssage; | |||||
| 11 | import jav ax.mail.Me ssagingExc eption; | |||||
| 12 | import jav ax.mail.Pa sswordAuth entication ; | |||||
| 13 | import jav ax.mail.Se ssion; | |||||
| 14 | import jav ax.mail.Tr ansport; | |||||
| 15 | import jav ax.mail.in ternet.Int ernetAddre ss; | |||||
| 16 | import jav ax.mail.in ternet.Int ernetHeade rs; | |||||
| 17 | import jav ax.mail.in ternet.Mim eBodyPart; | |||||
| 18 | import jav ax.mail.in ternet.Mim eMultipart ; | |||||
| 19 | import jav ax.mail.in ternet.Mim eMessage; | |||||
| 20 | ||||||
| 21 | ||||||
| 22 | public cla ss Emailer { | |||||
| 23 | pr ivate fina l static S tring SMTP _AUTH = "m ail.smtp.a uth"; | |||||
| 24 | pr ivate fina l static S tring SMTP _STARTTLS = "mail.sm tp.starttl s.enable"; | |||||
| 25 | pr ivate fina l static S tring SMTP _HOST = "m ail.smtp.h ost"; | |||||
| 26 | pr ivate fina l static S tring SMTP _PORT = "m ail.smtp.p ort"; | |||||
| 27 | ||||||
| 28 | pr ivate fina l static S tring SUBJ ECT = "sub ject"; | |||||
| 29 | pr ivate fina l static S tring BODY = "body"; | |||||
| 30 | pr ivate fina l static S tring REPO RT_PATTERN = "%repor t%"; | |||||
| 31 | ||||||
| 32 | /** | |||||
| 33 | * @pa ram distri butionList List of e mail addre sses and/o r contact groups sep arated by semicolon | |||||
| 34 | * @pa ram messag eAttribute s Map of m essage att ributes, k eyed by at tribute na me. Curren tly suppor ted keys a re: | |||||
| 35 | * "subject " | |||||
| 36 | * "body" | |||||
| 37 | * @pa ram report List of i tems in th e report. If "body" attribute contains " %report%" stub, gene rated tabu lar repres entation | |||||
| 38 | * of the r eport will substitut e the stub ; otherwis e, it will be append ed at the end of the "body" at tribute. | |||||
| 39 | * @re turn true, if email messages a re sent co rrectly; | |||||
| 40 | * fals e, if at l east one s end operat ion fails | |||||
| 41 | */ | |||||
| 42 | final public boo lean email Report(Str ing distri butionList , Map<Stri ng, String > messageA ttributes, | |||||
| 43 | List <Map<Strin g, Object> > report) { | |||||
| 44 | bo olean retV alue = tru e; | |||||
| 45 | Em ailBean em ailBean = EmailBean. getInstanc e(); | |||||
| 46 | fi nal String username = emailBea n.getFrom( ); | |||||
| 47 | fi nal String password = emailBea n.getPassw ord(); | |||||
| 48 | fi nal String reportLin k = emailB ean.getLin k(); | |||||
| 49 | ||||||
| 50 | Pr operties p rops = new Propertie s(); | |||||
| 51 | pr ops.put(SM TP_AUTH, " true"); | |||||
| 52 | pr ops.put(SM TP_STARTTL S, "true") ; | |||||
| 53 | pr ops.put(SM TP_HOST, e mailBean.g etHost()); | |||||
| 54 | pr ops.put(SM TP_PORT, e mailBean.g etPort()); | |||||
| 55 | ||||||
| 56 | Se ssion sess ion = Sess ion.getIns tance(prop s, | |||||
| 57 | new javax. mail.Authe nticator() { | |||||
| 58 | prot ected Pass wordAuthen tication g etPassword Authentica tion() { | |||||
| 59 | return new Passwo rdAuthenti cation(use rname, pas sword); | |||||
| 60 | } | |||||
| 61 | }); | |||||
| 62 | ||||||
| 63 | tr y { | |||||
| 64 | Mime Message me ssage = ne w MimeMess age(sessio n); | |||||
| 65 | mess age.setFro m(new Inte rnetAddres s(emailBea n.getFrom( ))); | |||||
| 66 | addR ecipients( message, d istributio nList); | |||||
| 67 | ||||||
| 68 | mess age.setSub ject(messa geAttribut es.get(SUB JECT)); | |||||
| 69 | ||||||
| 70 | Mime BodyPart b odyText = new MimeBo dyPart(); | |||||
| 71 | ||||||
| 72 | ||||||
| 73 | Inte rnetHeader s headers = new Inte rnetHeader s(); | |||||
| 74 | head ers.addHea der("Conte nt-type", "text/html ; charset= UTF-8"); | |||||
| 75 | body Text.setTe xt(message Attributes .get(BODY) + reportL ink); | |||||
| 76 | Mime Multipart body = new MimeMulti part(); | |||||
| 77 | body .addBodyPa rt(bodyTex t); | |||||
| 78 | mess age.setCon tent(body) ; | |||||
| 79 | Tran sport.send (message); | |||||
| 80 | } catch (Mes sagingExce ption e) { | |||||
| 81 | retV alue = fal se; | |||||
| 82 | } | |||||
| 83 | re turn retVa lue; | |||||
| 84 | } | |||||
| 85 | ||||||
| 86 | /** | |||||
| 87 | * @pa ram distri butionList List of e mail addre sses and/o r contact groups sep arated by semicolon | |||||
| 88 | * @pa ram messag eAttribute s Map of m essage att ributes, k eyed by at tribute na me. Curren tly suppor ted keys a re: | |||||
| 89 | * "subject " | |||||
| 90 | * "body" | |||||
| 91 | */ | |||||
| 92 | privat e void add Recipients (MimeMessa ge message , String d istributio nList) | |||||
| 93 | thro ws Messagi ngExceptio n{ | |||||
| 94 | St ring[] lis t = distri butionList .split(";" ); | |||||
| 95 | fo r (int i=0 ; i<list.l ength; i++ ){ | |||||
| 96 | mes sage.addRe cipient(Me ssage.Reci pientType. TO, | |||||
| 97 | new Inter netAddress (list[i])) ; | |||||
| 98 | } | |||||
| 99 | } | |||||
| 100 | ||||||
| 101 | /** | |||||
| 102 | * @pa ram report List List of items i n the repo rt. If "bo dy" attrib ute contai ns "%repor t%" stub, generated tabular re presentati on | |||||
| 103 | * of the r eport will substitut e the stub ; otherwis e, it will be append ed at the end of the "body" at tribute. | |||||
| 104 | * @re turn The r eport; | |||||
| 105 | */ | |||||
| 106 | privat e String g etTabRepor t(List<Map <String, O bject>> re portList){ | |||||
| 107 | It erator<Map <String, O bject>> it er = repor tList.iter ator(); | |||||
| 108 | Stri ngBuffer r eport = ne w StringBu ffer(); | |||||
| 109 | wh ile(iter.h asNext()){ | |||||
| 110 | Map<St ring, Obje ct> map = iter.next( ); | |||||
| 111 | for(Ma p.Entry<St ring, Obje ct> entry : map.entr ySet()){ | |||||
| 112 | report.a ppend(entr y.getValue ().toStrin g()).appen d("\n"); | |||||
| 113 | } | |||||
| 114 | } | |||||
| 115 | re turn repor t.toString (); | |||||
| 116 | } | |||||
| 117 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.