Produced by Araxis Merge on 12/8/2017 1:33:39 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 | PC_CP4_CiF.zip\FPPS_Backend\fpps_app\src\main\java\gov\va\med\fee\service\impl | UserRequestServiceImpl.java | Fri Dec 8 17:53:48 2017 UTC |
| 2 | PC_CP4_CiF.zip\FPPS_Backend\fpps_app\src\main\java\gov\va\med\fee\service\impl | UserRequestServiceImpl.java | Fri Dec 8 18:29:38 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 440 |
| Changed | 1 | 4 |
| 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 | package go v.va.med.f ee.service .impl; | |
| 2 | ||
| 3 | import jav a.util.Arr ayList; | |
| 4 | import jav a.util.Lis t; | |
| 5 | ||
| 6 | import jav ax.mail.Me ssagingExc eption; | |
| 7 | import jav ax.mail.in ternet.Add ressExcept ion; | |
| 8 | ||
| 9 | import org .apache.lo gging.log4 j.LogManag er; | |
| 10 | import org .apache.lo gging.log4 j.Logger; | |
| 11 | import org .springfra mework.bea ns.factory .annotatio n.Autowire d; | |
| 12 | import org .springfra mework.htt p.HttpStat us; | |
| 13 | import org .springfra mework.ste reotype.Se rvice; | |
| 14 | import org .springfra mework.tra nsaction.a nnotation. Transactio nal; | |
| 15 | ||
| 16 | import gov .va.med.do main.fee.A ppUser; | |
| 17 | import gov .va.med.do main.fee.A ppUserRequ est; | |
| 18 | import gov .va.med.fe e.dao.IApp UserReposi tory; | |
| 19 | import gov .va.med.fe e.dao.IUse rRequestRe positoryTe mplate; | |
| 20 | import gov .va.med.fe e.exceptio ns.Generic Exception; | |
| 21 | import gov .va.med.fe e.model.re quest.Stat ionRequest ; | |
| 22 | import gov .va.med.fe e.model.re quest.User ReqRequest ; | |
| 23 | import gov .va.med.fe e.model.re sponse.Use rReqRespon se; | |
| 24 | import gov .va.med.fe e.model.re sponse.Use rRoles; | |
| 25 | import gov .va.med.fe e.service. IUserReque stService; | |
| 26 | import gov .va.med.fe e.util.Ema il; | |
| 27 | ||
| 28 | @Service | |
| 29 | @Transacti onal | |
| 30 | public cla ss UserReq uestServic eImpl exte nds BaseSe rvice impl ements IUs erRequestS ervice { | |
| 31 | pr ivate stat ic final L ogger logg er = LogMa nager.getL ogger(User RequestSer viceImpl.c lass); | |
| 32 | ||
| 33 | @A utowired | |
| 34 | IU serRequest Repository Template u serRequest Repository Template; | |
| 35 | ||
| 36 | @A utowired | |
| 37 | IA ppUserRepo sitory app UserReposi tory; | |
| 38 | ||
| 39 | pr ivate stat ic final S tring USER _REQUEST_N OTIFICATIO N_FROM = " PII "; | |
| 40 | pr ivate stat ic final S tring USER _REQUEST_N OTIFICATIO N_RECIPIEN TS[] = { " PII " };// " PII " | |
| 41 | pr ivate stat ic final S tring[] ap pUserRoles = {"FEE_V ISN_PGM_MA NAGER", "F EE_SUPERVI SOR", "FPP S_HELP_DES K"}; | |
| 42 | ||
| 43 | @O verride | |
| 44 | pu blic AppUs erRequest requestExi st(String name) { | |
| 45 | AppU serRequest existingR equests = userReques tRepositor yTemplate. findReques tByAppUser Name(name) ; | |
| 46 | ||
| 47 | retu rn existin gRequests; | |
| 48 | } | |
| 49 | ||
| 50 | @O verride | |
| 51 | pu blic int r equestAddU ser(UserRe qRequest u serRequest ) throws G enericExce ption { | |
| 52 | ||
| 53 | if ( !hasRole(u serRequest .getCurren t_user_nam e(), appUs erRoles)) { | |
| 54 | logger .error("Us erRequestS erviceImpl .requestAd dUser() : invalid_in put_error for role " ); | |
| 55 | throw new Generi cException ("Add User Request e rror", "In valid role ", HttpSta tus.BAD_RE QUEST); | |
| 56 | } | |
| 57 | ||
| 58 | int rowInserte d = 0; | |
| 59 | AppU serRequest existingR equests = requestExi st(userReq uest.getWi ndow_nt_na me()); | |
| 60 | ||
| 61 | if(e xistingReq uests == n ull) { | |
| 62 | userRe quest.setR equest_typ e(0); //ty pe 0 = cre ate user r equest, ty pe 1 = mod ify user r equest | |
| 63 | rowIns erted = us erRequestR epositoryT emplate.re questCreat eUserReque st(userReq uest, user Request.ge tCurrent_u ser_name() ); | |
| 64 | ||
| 65 | if (ro wInserted > 0) { | |
| 66 | // inser t success then get c urrent app user info by curren t user nam e | |
| 67 | List<App User> user List = app UserReposi tory.findB yAppUserNa me(userReq uest.getCu rrent_user _name()); | |
| 68 | ||
| 69 | if (user List != nu ll && !use rList.isEm pty()) { | |
| 70 | sendEmailM essage(use rRequest, userList.g et(0), "FP PS Create User Reque st", "Crea te"); | |
| 71 | } | |
| 72 | } else { | |
| 73 | throw ne w GenericE xception(" Create new user requ est error" ,"Unable t o create n ew user re quest", Ht tpStatus.B AD_REQUEST ); | |
| 74 | } | |
| 75 | } | |
| 76 | retu rn rowInse rted; | |
| 77 | } | |
| 78 | ||
| 79 | /* Find curr ent existi ng App Use r Request by Window_ nt_name | |
| 80 | * Create ne w if not f ound, upda te otherwi se */ | |
| 81 | @O verride | |
| 82 | pu blic int r equestModi fyUser(Use rReqReques t userRequ est) throw s GenericE xception { | |
| 83 | ||
| 84 | if ( !hasRole(u serRequest .getCurren t_user_nam e(), appUs erRoles)) { | |
| 85 | logger .error("Us erRequestS erviceImpl .requestMo difyUser() : invalid _input_err or for rol e "); | |
| 86 | throw new Generi cException ("tModify User Reque st error", "Invalid role", Htt pStatus.BA D_REQUEST) ; | |
| 87 | } | |
| 88 | ||
| 89 | int rowInserte d = 0; | |
| 90 | AppU serRequest existingR equests = requestExi st(userReq uest.getWi ndow_nt_na me()); | |
| 91 | user Request.se tRequest_t ype(1); // type 0 = c reate user request, type 1 = m odify user request | |
| 92 | ||
| 93 | if(e xistingReq uests == n ull) { // insert | |
| 94 | rowIns erted = us erRequestR epositoryT emplate.re questCreat eUserReque st(userReq uest, user Request.ge tCurrent_u ser_name() ); | |
| 95 | ||
| 96 | } el se { //up date | |
| 97 | rowIns erted = us erRequestR epositoryT emplate.re questModif yUserReque st(userReq uest, user Request.ge tCurrent_u ser_name() ); | |
| 98 | } | |
| 99 | ||
| 100 | if ( rowInserte d > 0) { | |
| 101 | // ins ert/update success t hen get cu rrent app user info by current user name | |
| 102 | List<A ppUser> us erList = a ppUserRepo sitory.fin dByAppUser Name(userR equest.get Current_us er_name()) ; | |
| 103 | ||
| 104 | if (us erList != null && !u serList.is Empty()) { | |
| 105 | logger.d ebug("Send ing FPPS M odify User Request e mail here ..... "); | |
| 106 | sendEmai lMessage(u serRequest , userList .get(0), " FPPS Modif y User Req uest", "Mo dify"); | |
| 107 | } | |
| 108 | } el se { | |
| 109 | throw new Generi cException ("Modify u ser reques t error"," Unable to modify use r request" , HttpStat us.BAD_REQ UEST); | |
| 110 | } | |
| 111 | ||
| 112 | retu rn rowInse rted; | |
| 113 | } | |
| 114 | ||
| 115 | pr ivate void sendEmail Message(Us erReqReque st userToC reate, App User appUs er, String subject, String typ e) { | |
| 116 | Stri ng emailst atus = ""; | |
| 117 | Emai l email = new Email( ); | |
| 118 | try { | |
| 119 | String emailMess age = "The re is a ne w request to create an FPPS us er:<br />" + "Type: "+type+" < br />" | |
| 120 | + "User lo gon ID: " + (use rToCreate. getWindow_ nt_name() != null ? userToCrea te.getWind ow_nt_name () : "") + "<br />" | |
| 121 | + "First N ame: " + ( userToCrea te.getFirs t_name() ! = null ? u serToCreat e.getFirst _name() : "") + "<br />" | |
| 122 | + "Middle Name: "+ ( userToCrea te.getMidd le_name() != null ? userToCrea te.getMidd le_name() : "") + "< br />" | |
| 123 | + "Last Na me: " + (u serToCreat e.getLast_ name() != null ? use rToCreate. getLast_na me() : "") + "<br />" | |
| 124 | + "Phone: " + (userT oCreate.ge tPhone() ! = null ? u serToCreat e.getPhone () : "") + "<br />" | |
| 125 | + "Email: " + (userT oCreate.ge tEmail() ! = null ? u serToCreat e.getEmail () : "")+ "<br />" | |
| 126 | + "Request or: " | |
| 127 | + (appUser .getFirstN ame() != n ull ? appU ser.getFir stName().t rim().toUp perCase() : "") + " " | |
| 128 | + (appUser .getLastNa me() != nu ll ? appUs er.getLast Name().tri m().toUppe rCase() : "") + " (" | |
| 129 | + (appUser .getUserNa me() != nu ll ? appUs er.getUser Name().tri m().toUppe rCase() : "") + ")<b r />" | |
| 130 | + "Request or Phone: " + (appUs er.getPhon eNumber() != null ? appUser.ge tPhoneNumb er().trim( ).toUpperC ase() : "" ) + "<br / >" | |
| 131 | + "Request or Email: " + (appUs er.getEmai lAddress() != null ? appUser.g etEmailAdd ress().tri m().toUppe rCase() : "")+ "<br />" | |
| 132 | + "Request ed Role(s) : " + (use rToCreate. getRequest edRoles() != null ? userToCrea te.getRequ estedRoles () : "") + "<br />" | |
| 133 | + "Request ed Station (s): " + ( userToCrea te.getRequ estedFacil ities() != null ? us erToCreate .getReques tedFacilit ies():"") + "<br />" ; | |
| 134 | ||
| 135 | emails tatus = em ail.postMa il(USER_RE QUEST_NOTI FICATION_R ECIPIENTS, subject, | |
| 136 | emailMessa ge, USER_R EQUEST_NOT IFICATION_ FROM, fals e, ""); | |
| 137 | ||
| 138 | } ca tch (Addre ssExceptio n e1) { | |
| 139 | logger .error(e1. getMessage ()); | |
| 140 | } ca tch (Messa gingExcept ion e1) { | |
| 141 | logger .error(e1. getMessage ()); | |
| 142 | } | |
| 143 | ||
| 144 | logg er.debug(" ---------- ---------- ---------- --- email status: " + emailsta tus); | |
| 145 | } | |
| 146 | ||
| 147 | @O verride | |
| 148 | pu blic UserR eqResponse loadUserR equestForm () throws GenericExc eption { | |
| 149 | ||
| 150 | User ReqRespons e reqRespo nse = null ; | |
| 151 | try{ | |
| 152 | List<U serRoles> user_roles = userReq uestReposi toryTempla te.getRole sForReques t(); | |
| 153 | List<S tationRequ est> facil ities = us erRequestR epositoryT emplate.ge tFacilitie sForReques t(); | |
| 154 | ||
| 155 | List<S tring> ava ilable_rol es = new A rrayList<> (); | |
| 156 | for (U serRoles r ole : user _roles) { | |
| 157 | availabl e_roles.ad d(role.get RoleName() .replaceAl l("_", " " )); | |
| 158 | } | |
| 159 | ||
| 160 | List<S tring> ava ilable_fac ilities = getAvailab le_facilit ies(facili ties); | |
| 161 | reqRes ponse = ne w UserReqR esponse(av ailable_ro les, avail able_facil ities); | |
| 162 | ||
| 163 | } ca tch(Except ion e) { | |
| 164 | logger .info("Loa ding Creat e User Req uest fail" + e.getMe ssage()); | |
| 165 | throw new Generi cException ("Loading Create Use r Request fail","Fai l to load available roles and facilities ", HttpSta tus.INTERN AL_SERVER_ ERROR); | |
| 166 | } | |
| 167 | ||
| 168 | logg er.debug(" loadUserRe questForm: " + reqRe sponse.toS tring()); | |
| 169 | retu rn reqResp onse; | |
| 170 | } | |
| 171 | ||
| 172 | ||
| 173 | @O verride | |
| 174 | pu blic UserR eqResponse loadModif yUserReque stFormByNa me(String appUserNam e) throws GenericExc eption { | |
| 175 | logg er.debug(" loadModify UserReques tForm by a ppUserName : " + appU serName); | |
| 176 | List <AppUser> userList = appUserRe pository.f indByAppUs erName(app UserName); | |
| 177 | retu rn loadMod ifyUserReq uestForm(u serList.ge t(0)); | |
| 178 | } | |
| 179 | ||
| 180 | pr ivate User ReqRespons e loadModi fyUserRequ estForm(Ap pUser appU ser) throw s GenericE xception { | |
| 181 | User ReqRespons e reqRespo nse = null ; | |
| 182 | try{ | |
| 183 | List<U serRoles> userRoles = userRequ estReposit oryTemplat e.findUser RolesForMo dify(appUs er.getAppU serId()); | |
| 184 | List<S tationRequ est> userF acilities = userRequ estReposit oryTemplat e.findUser Facilities (appUser.g etAppUserI d()); | |
| 185 | List<S tring> rol esAvailabl eToUserFor UserModify Request = userReques tRepositor yTemplate. getRolesAv ailableToU serForUser ModifyRequ est(); | |
| 186 | List<S tationRequ est> facil itiesAvail ableToUser = userReq uestReposi toryTempla te.getFaci litiesAvai lableToUse r(); | |
| 187 | ||
| 188 | List<S tring> req uest_roles = new Arr ayList<>() ; //userRo lesForModi fy | |
| 189 | for(Us erRoles ro le : userR oles) { | |
| 190 | request_ roles.add( role.getRo leName()); //role_na me only | |
| 191 | } | |
| 192 | ||
| 193 | //form at VA faci lity to st rings like - "Visn: 16 / Facil ity: 520 ( BILOXI MS) " | |
| 194 | List<S tring> req uest_facil ities = ge tAvailable _facilitie s(userFaci lities); | |
| 195 | List<S tring> ava ilable_fac ilities = getAvailab le_facilit ies(facili tiesAvaila bleToUser) ; | |
| 196 | ||
| 197 | reqRes ponse = ne w UserReqR esponse(ap pUser.getU serName(), appUser.ge tLastName( ), appUser .getFirstN ame(), app User.getMi ddleName() , | |
| 198 | appUser.ge tPhoneNumb er(), appU ser.getEma ilAddress( ), appUser .getEnable d().equals IgnoreCase ("Y") ? tr ue : false , | |
| 199 | appUser.ge tDeactivat ionComment s(), reque st_roles, request_fa cilities); | |
| 200 | ||
| 201 | reqRes ponse.setA vailable_r oles(roles AvailableT oUserForUs erModifyRe quest); | |
| 202 | reqRes ponse.setA vailable_f acilities( available_ facilities ); | |
| 203 | } ca tch(Except ion e) { | |
| 204 | logger .info("Loa ding Modif y User Req uest fail" ); | |
| 205 | throw new Generi cException ("Loading Modify Use r Request fail","Fai l to load Modify Use r Request" , HttpStat us.NOT_FOU ND); | |
| 206 | } | |
| 207 | logg er.debug(" loadUserRe questForm: " + reqRe sponse.toS tring()); | |
| 208 | retu rn reqResp onse; | |
| 209 | } | |
| 210 | ||
| 211 | pr ivate List <String> g etAvailabl e_faciliti es(List<St ationReque st> facili ties){ | |
| 212 | List <String> a vailable_f acilities = new Arra yList<>(); | |
| 213 | ||
| 214 | for (StationRe quest req : faciliti es) { | |
| 215 | String shortName = req.get ShortName( ) != null ? " (" + r eq.getShor tName() + ")" : ""; | |
| 216 | String facLabel = "Visn: " + req.get VisnIdCd() + " / Fac ility: " + req.getVa FacilityCd () + short Name; | |
| 217 | availa ble_facili ties.add(f acLabel); | |
| 218 | } | |
| 219 | ||
| 220 | retu rn availab le_facilit ies; | |
| 221 | } | |
| 222 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.