Produced by Araxis Merge on 12/5/2017 12:06:43 PM Central Standard 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 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingCommon\main\src\java\gov\va\med\imaging\notifications\email | NotificationEmailConfiguration.java | Mon Dec 4 21:35:06 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\ImagingCommon\main\src\java\gov\va\med\imaging\notifications\email | NotificationEmailConfiguration.java | Mon Dec 4 22:02:04 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 562 |
| Changed | 2 | 6 |
| Inserted | 0 | 0 |
| 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 | /* | |
| 2 | * To chan ge this te mplate, ch oose Tools | Templat es | |
| 3 | * and ope n the temp late in th e editor. | |
| 4 | */ | |
| 5 | ||
| 6 | package go v.va.med.i maging.not ifications .email; | |
| 7 | ||
| 8 | import gov .va.med.im aging.Stri ngUtil; | |
| 9 | import gov .va.med.im aging.faca de.configu ration.Abs tractBaseF acadeConfi guration; | |
| 10 | import gov .va.med.im aging.faca de.configu ration.Fac adeConfigu rationFact ory; | |
| 11 | import gov .va.med.im aging.faca de.configu ration.exc eptions.Ca nnotLoadCo nfiguratio nException ; | |
| 12 | import gov .va.med.im aging.noti fications. Notificati onTypes; | |
| 13 | ||
| 14 | import jav a.net.URI; | |
| 15 | import jav a.net.URIS yntaxExcep tion; | |
| 16 | import jav a.util.Arr ayList; | |
| 17 | import jav a.util.Has hMap; | |
| 18 | import jav a.util.Lis t; | |
| 19 | ||
| 20 | import jav ax.mail.in ternet.Add ressExcept ion; | |
| 21 | import jav ax.mail.in ternet.Int ernetAddre ss; | |
| 22 | ||
| 23 | import org .apache.lo gging.log4 j.LogManag er; | |
| 24 | import org .apache.lo gging.log4 j.Logger; | |
| 25 | ||
| 26 | /** | |
| 27 | * | |
| 28 | * @author Jon Louth ian | |
| 29 | */ | |
| 30 | public cla ss Notific ationEmail Configurat ion extend s Abstract BaseFacade Configurat ion | |
| 31 | { | |
| 32 | pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(Noti ficationEm ailConfigu ration.cla ss); | |
| 33 | public sta tic final String DEF AULT_RECIP IENT_ADDRE SS = " PII "; | |
| 34 | privat e static f inal int M AXMSGCOUNT PEREMAIL = 100; // s et here fo r not conf igured inp ut only | |
| 35 | privat e static f inal int M AXMSGBYTES IZEPEREMAI L = 5*1024 *1024; // sets upper limi t (5 MB), size is co nfigurable by user, | |
| 36 | // works lik e upper li mit guard; used for not config ured input also | |
| 37 | privat e URI smtp ServerUri; | |
| 38 | privat e Internet Address se nderAddres s; | |
| 39 | privat e int maxi mumMessage CountPerEm ail = MAXM SGCOUNTPER EMAIL; | |
| 40 | privat e int maxi mumByteSiz ePerEmail = MAXMSGBY TESIZEPERE MAIL; | |
| 41 | ||
| 42 | pr ivate Hash Map<Notifi cationType s, List<In ternetAddr ess>> noti ficationTy peToRecipi entsMap = new HashMa p<Notifica tionTypes, List<Inte rnetAddres s>>(); | |
| 43 | ||
| 44 | privat e static N otificatio nEmailConf iguration config = n ull; | |
| 45 | ||
| 46 | /** | |
| 47 | * @re turn the s mtpHost | |
| 48 | */ | |
| 49 | public URI getSm tpServerUr i() { | |
| 50 | re turn smtpS erverUri; | |
| 51 | } | |
| 52 | ||
| 53 | /** | |
| 54 | * @pa ram smtpHo st the smt pHost to s et | |
| 55 | */ | |
| 56 | public void setS mtpServerU ri(URI smt pServerUri ) { | |
| 57 | th is.smtpSer verUri = s mtpServerU ri; | |
| 58 | } | |
| 59 | ||
| 60 | /** | |
| 61 | * @re turn the s enderAddre ss | |
| 62 | */ | |
| 63 | public InternetA ddress get SenderAddr ess() { | |
| 64 | re turn sende rAddress; | |
| 65 | } | |
| 66 | ||
| 67 | /** | |
| 68 | * @pa ram sender Address th e senderAd dress to s et | |
| 69 | */ | |
| 70 | public void setS enderAddre ss(Interne tAddress s enderAddre ss) { | |
| 71 | th is.senderA ddress = s enderAddre ss; | |
| 72 | } | |
| 73 | ||
| 74 | /** | |
| 75 | * @re turn the n otificatio nTypeToRec ipientsMap | |
| 76 | */ | |
| 77 | public HashMap<N otificatio nTypes, Li st<Interne tAddress>> getNotifi cationType ToRecipien tsMap() | |
| 78 | { | |
| 79 | re turn notif icationTyp eToRecipie ntsMap; | |
| 80 | } | |
| 81 | ||
| 82 | /** | |
| 83 | * @pa ram notifi cationType ToRecipien tsMap the notificati onTypeToRe cipientsMa p to set | |
| 84 | */ | |
| 85 | public void setN otificatio nTypeToRec ipientsMap (HashMap<N otificatio nTypes, Li st<Interne tAddress>> notificat ionTypeToR ecipientsM ap) { | |
| 86 | th is.notific ationTypeT oRecipient sMap = not ificationT ypeToRecip ientsMap; | |
| 87 | } | |
| 88 | ||
| 89 | ||
| 90 | public List<Inte rnetAddres s> getReci pientsForN otificatio nType(Noti ficationTy pes type) | |
| 91 | { | |
| 92 | // Start wit h an empty arraylist of recipi ents, and only overw rite it | |
| 93 | // if there is a key f or the typ e, and the key has m apped reci pients, | |
| 94 | // This way we never r eturn null | |
| 95 | Li st<Interne tAddress> recipients = new Arr ayList<Int ernetAddre ss>(); | |
| 96 | ||
| 97 | if (getNotif icationTyp eToRecipie ntsMap().c ontainsKey (type) && (getNotifi cationType ToRecipien tsMap().ge t(type) != null)) | |
| 98 | { | |
| 99 | recipien ts = getNo tification TypeToReci pientsMap( ).get(type ); | |
| 100 | } | |
| 101 | ||
| 102 | // If there are no rec ipients co nfigured, add the de fault reci pient | |
| 103 | // to the li st. | |
| 104 | if (recipien ts==null | | recipien ts.size() == 0) | |
| 105 | { | |
| 106 | recipien ts = new A rrayList<I nternetAdd ress>(); | |
| 107 | try | |
| 108 | { | |
| 109 | reci pients.add (new Inter netAddress (DEFAULT_R ECIPIENT_A DDRESS)); | |
| 110 | } | |
| 111 | catch (A ddressExce ption e) | |
| 112 | { | |
| 113 | logg er.error(" Error crea ting the I nternetAdd ress for e mail notif ication's default re cipient.", e); | |
| 114 | } | |
| 115 | } | |
| 116 | ||
| 117 | re turn recip ients; | |
| 118 | } | |
| 119 | ||
| 120 | ||
| 121 | public void setR ecipientsF orNotifica tionType(N otificatio nTypes not ificationT ype, Strin g commaSep aratedReci pientAddre sses) | |
| 122 | { | |
| 123 | // Create a new list o f recipien ts | |
| 124 | Li st<Interne tAddress> recipientA ddressList = new Arr ayList<Int ernetAddre ss>(); | |
| 125 | ||
| 126 | // Split the comma sep arated str ing into a n array | |
| 127 | St ring[] rec ipientAddr esses = St ringUtil.s plit(comma SeparatedR ecipientAd dresses, S tringUtil. COMMA); | |
| 128 | ||
| 129 | // Add each address to the list of interne t addresse s | |
| 130 | fo r (String recipientA ddress : r ecipientAd dresses) | |
| 131 | { | |
| 132 | try | |
| 133 | { | |
| 134 | recipi entAddress List.add(n ew Interne tAddress(r ecipientAd dress)); | |
| 135 | } | |
| 136 | catc h(AddressE xception e ) | |
| 137 | { | |
| 138 | logg er.error(" Error crea ting an In ternetAddr ess.", e); | |
| 139 | } | |
| 140 | } | |
| 141 | ||
| 142 | // Set the n ew list fo r the give n notifica tion type | |
| 143 | no tification TypeToReci pientsMap. put(notifi cationType , recipien tAddressLi st); | |
| 144 | } | |
| 145 | ||
| 146 | ||
| 147 | @Overr ide | |
| 148 | public AbstractB aseFacadeC onfigurati on loadDef aultConfig uration() | |
| 149 | { | |
| 150 | // create de fault reci pient mapp ings for n otificatio n types | |
| 151 | tr y | |
| 152 | { | |
| 153 | // Set t he sender and smtp h ost | |
| 154 | this.setSe nderAddres s(new Inte rnetAddres s(" PII ")); | |
| 155 | this.setSm tpServerUr i(new URI( " DNS ")); | |
| 156 | this.max imumMessag eCountPerE mail = MAX MSGCOUNTPE REMAIL; | |
| 157 | this.max imumByteSi zePerEmail = MAXMSGB YTESIZEPER EMAIL; | |
| 158 | ||
| 159 | ArrayLis t<Internet Address> d efaultReci pients = n ew ArrayLi st<Interne tAddress>( ); | |
| 160 | defaultR ecipients. add(new In ternetAddr ess(DEFAUL T_RECIPIEN T_ADDRESS) ); | |
| 161 | ||
| 162 | getNotif icationTyp eToRecipie ntsMap().p ut(Notific ationTypes .GenericNo tification , defaultR ecipients) ; | |
| 163 | getNotif icationTyp eToRecipie ntsMap().p ut(Notific ationTypes .VixStarte d, default Recipients ); | |
| 164 | } | |
| 165 | ca tch (URISy ntaxExcept ion e) | |
| 166 | { | |
| 167 | logger.e rror("Erro r creating URI - bad address f or the smt p server." , e); | |
| 168 | } | |
| 169 | ca tch(Addres sException e) | |
| 170 | { | |
| 171 | logg er.error(" Error crea ting an In ternetAddr ess.", e); | |
| 172 | } | |
| 173 | ||
| 174 | re turn this; | |
| 175 | } | |
| 176 | ||
| 177 | public synchroni zed static Notificat ionEmailCo nfiguratio n getConfi guration() | |
| 178 | { | |
| 179 | tr y | |
| 180 | { | |
| 181 | retu rn FacadeC onfigurati onFactory. getConfigu rationFact ory().getC onfigurati on( | |
| 182 | Notifica tionEmailC onfigurati on.class); | |
| 183 | } | |
| 184 | ca tch(Cannot LoadConfig urationExc eption clc X) | |
| 185 | { | |
| 186 | retu rn null; | |
| 187 | } | |
| 188 | } | |
| 189 | ||
| 190 | public static vo id main(St ring[] arg s) | |
| 191 | { | |
| 192 | ||
| 193 | // If there are 0 or 1 arguments , we're fi ne. Otherw ise, print usage. | |
| 194 | if ( args.lengt h < 2) | |
| 195 | { | |
| 196 | // G et the adm in email a ddress for invalid s ervice acc ount crede ntials | |
| 197 | Stri ng adminEm ailAddress = getAdmi nEmailAddr ess(args); | |
| 198 | ||
| 199 | // S et it in t he config file | |
| 200 | Noti ficationEm ailConfigu ration con fig = Noti ficationEm ailConfigu ration.get Configurat ion(); | |
| 201 | conf ig.setReci pientsForN otificatio nType(Noti ficationTy pes.Invali dServiceAc countCrede ntials, ad minEmailAd dress); | |
| 202 | getConfi guration() .storeConf iguration( ); | |
| 203 | } | |
| 204 | el se | |
| 205 | { | |
| 206 | System.o ut.println ("This pro gram requi res zero o r one argu ment. If o ne argumen t is provi ded, it mu st be:"); | |
| 207 | System.o ut.println (" * An e mail addre ss (or add resses, se parated by commas) f or the ind ividual(s) to"); | |
| 208 | System.o ut.println (" noti fy if the service ha s invalid service ac count cred entials"); | |
| 209 | } | |
| 210 | } | |
| 211 | ||
| 212 | /** | |
| 213 | * Get s the admi n email ad dress for invalid se rvice acco unt creden tials. If no args | |
| 214 | * are passed in , the defa ult email is used. O therwise, the passed -in argume nt is used | |
| 215 | * @pa ram args | |
| 216 | * @re turn | |
| 217 | */ | |
| 218 | pr ivate stat ic String getAdminEm ailAddress (String[] args) | |
| 219 | { | |
| 220 | if ( args.lengt h == 0) | |
| 221 | { | |
| 222 | return DEFAULT_R ECIPIENT_A DDRESS; | |
| 223 | } | |
| 224 | else | |
| 225 | { | |
| 226 | return args[0]; | |
| 227 | } | |
| 228 | } | |
| 229 | ||
| 230 | pu blic Strin g getRecip ientsForNo tification TypeAsDeli mitedStrin g(Notifica tionTypes notificati onType) | |
| 231 | { | |
| 232 | List <InternetA ddress> ad dresses = getRecipie ntsForNoti ficationTy pe(notific ationType) ; | |
| 233 | ||
| 234 | int count = 1; | |
| 235 | ||
| 236 | Stri ng delimit edAddressS tring = "" ; | |
| 237 | ||
| 238 | for( InternetAd dress addr ess : addr esses) | |
| 239 | { | |
| 240 | if (co unt > 1) | |
| 241 | { | |
| 242 | delimite dAddressSt ring += ", "; | |
| 243 | } | |
| 244 | ||
| 245 | delimi tedAddress String += address.ge tAddress() ; | |
| 246 | count+ +; | |
| 247 | } | |
| 248 | ||
| 249 | retu rn delimit edAddressS tring; | |
| 250 | } | |
| 251 | ||
| 252 | /* * | |
| 253 | * @return t he maximum MessageCou ntPerEmail | |
| 254 | * / | |
| 255 | pu blic int g etMaximumM essageCoun tPerEmail( ) { | |
| 256 | retu rn maximum MessageCou ntPerEmail ; | |
| 257 | } | |
| 258 | ||
| 259 | /* * | |
| 260 | * @param ma ximumMessa geCountPer Email the maximumMes sageCountP erEmail to set | |
| 261 | * / | |
| 262 | pu blic void setMaximum MessageCou ntPerEmail (int maxim umMessageC ountPerEma il) { | |
| 263 | this .maximumMe ssageCount PerEmail = maximumMe ssageCount PerEmail; | |
| 264 | } | |
| 265 | ||
| 266 | /* * | |
| 267 | * @return t he maximum ByteSizePe rEmail | |
| 268 | * / | |
| 269 | public int getMa ximumByteS izePerEmai l() { | |
| 270 | retu rn maximum ByteSizePe rEmail; | |
| 271 | } | |
| 272 | ||
| 273 | /** | |
| 274 | * @param ma ximumMessa geSizePerE mail the m aximumByte SizeCountP erEmail to set | |
| 275 | * / | |
| 276 | pu blic void setMaximum ByteSizePe rEmail(int maximumBy teSizePerE mail) { | |
| 277 | if ( (maximumBy teSizePerE mail < MAX MSGBYTESIZ EPEREMAIL) && (maxim umByteSize PerEmail > 0)) | |
| 278 | this.m aximumByte SizePerEma il = maxim umByteSize PerEmail; | |
| 279 | else { | |
| 280 | this.m aximumByte SizePerEma il = MAXMS GBYTESIZEP EREMAIL; | |
| 281 | // TOD O log: inv alid e-mai l byte siz e in confi guration f ile sh ould be be tween 0 an d MAXMSGBY TESIZEPERE MAIL | |
| 282 | } | |
| 283 | } | |
| 284 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.