Produced by Araxis Merge on 12/13/2018 10:35:31 AM Eastern 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 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\service\trigger | TriggerEvent.java | Fri Dec 7 17:36:38 2018 UTC |
| 2 | v12.5_iter_7_build 51.zip\TRM_Upgrade\src\main\java\gov\va\med\fw\service\trigger | TriggerEvent.java | Wed Dec 12 22:25:26 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 430 |
| Changed | 1 | 2 |
| 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 | * Copyrii ght 2005 V HA. All ri ghts reser ved | |
| 3 | ********* ********** ********** ********** ********** ********** *********/ | |
| 4 | package go v.va.med.f w.service. trigger; | |
| 5 | ||
| 6 | import jav a.io.Seria lizable; | |
| 7 | import jav a.util.Pro perties; | |
| 8 | ||
| 9 | import org .apache.co mmons.lang .builder.T oStringBui lder; | |
| 10 | import org .apache.co mmons.lang .builder.T oStringSty le; | |
| 11 | ||
| 12 | import gov .va.med.fw .model.Abs tractEntit y; | |
| 13 | import gov .va.med.fw .security. SecurityCo ntextHelpe r; | |
| 14 | import gov .va.med.fw .security. UserCreden tials; | |
| 15 | import gov .va.med.fw .service.C onfigurati onConstant s; | |
| 16 | ||
| 17 | /** | |
| 18 | * Base im plementati on for rep resenting a triggera ble event. | |
| 19 | * | |
| 20 | * @author DN S | |
| 21 | */ | |
| 22 | public cla ss Trigger Event exte nds Abstra ctEntity { | |
| 23 | pr ivate stat ic final S tring CONS UMER_ROUTI NG_KEY = C onfigurati onConstant s.DEFAULT_ MESSAGE_TY PE; | |
| 24 | ||
| 25 | pr ivate stat ic final S tring DEST INATION_TY PE = "Dest ination_Ty pe"; // ca n be | |
| 26 | // used | |
| 27 | // for | |
| 28 | // MDB | |
| 29 | // selector | |
| 30 | ||
| 31 | /* * | |
| 32 | * An instan ce of seri alVersionU ID | |
| 33 | * / | |
| 34 | pr ivate stat ic final l ong serial VersionUID = -591185 3568793978 39L; | |
| 35 | ||
| 36 | pr ivate Stri ng name; | |
| 37 | ||
| 38 | /* * | |
| 39 | * The limit ed securit y informat ion for th e initiate r that is triggering | |
| 40 | * this even t | |
| 41 | * / | |
| 42 | pr ivate User Credential s initiate r; | |
| 43 | ||
| 44 | /* * | |
| 45 | * Event met rics (shou ld not aff ect equals and hashC ode implem entations) | |
| 46 | * TODO: use JMX to tr ack the li fe of the TriggerEve nt | |
| 47 | * / | |
| 48 | pr ivate Trig gerEventMe trics even tMetrics; | |
| 49 | ||
| 50 | /* * | |
| 51 | * Potential ly complex data type that cont ains the e vent infor mation tha t is | |
| 52 | * not conte xtual (ie, for every event of the same t ype, this will be eq ual) | |
| 53 | * / | |
| 54 | pr ivate Trig gerIdentit y triggerI dentity; | |
| 55 | ||
| 56 | /* * | |
| 57 | * Contains the event informatio n that is contextual (ie, does not defin e | |
| 58 | * the type of event b ut rather what objec t is invol ved in the event) | |
| 59 | * / | |
| 60 | pr ivate Seri alizable p ayload; | |
| 61 | ||
| 62 | /* * | |
| 63 | * @return R eturns the initiater . | |
| 64 | * / | |
| 65 | pu blic UserC redentials getInitia ter() { | |
| 66 | retu rn initiat er; | |
| 67 | } | |
| 68 | ||
| 69 | /* * | |
| 70 | * @param in itiater | |
| 71 | * The init iater to s et. | |
| 72 | * / | |
| 73 | pu blic void setInitiat er(UserCre dentials i nitiater) { | |
| 74 | this .initiater = initiat er; | |
| 75 | } | |
| 76 | ||
| 77 | pu blic Trigg erEvent(St ring name, Serializa ble payloa d, Trigger Identity t riggerIden tity) { | |
| 78 | if ( name == nu ll) | |
| 79 | throw new Illega lArgumentE xception(" TriggerEve nt must ha ve non-nul l name"); | |
| 80 | ||
| 81 | this .name = na me; | |
| 82 | this .payload = payload; | |
| 83 | this .triggerId entity = t riggerIden tity; | |
| 84 | this .eventMetr ics = new TriggerEve ntMetrics( ); | |
| 85 | this .eventMetr ics.create dTimestamp = System. currentTim eMillis(); | |
| 86 | } | |
| 87 | ||
| 88 | pu blic Trigg erEvent(St ring name, Serializa ble payloa d) { | |
| 89 | this (name, pay load, crea teTriggerI dentity(Tr iggerIdent ity.Destin ationType. DEFAULT)); | |
| 90 | } | |
| 91 | ||
| 92 | pu blic Trigg erEvent(St ring name) { | |
| 93 | this (name, nul l); | |
| 94 | } | |
| 95 | ||
| 96 | pu blic Trigg erEvent(Tr iggerIdent ity trigge rIdentity) { | |
| 97 | this ((triggerI dentity != null ? tr iggerIdent ity.getNam e() : null ), null, t riggerIden tity); | |
| 98 | } | |
| 99 | ||
| 100 | pu blic stati c final Tr iggerIdent ity create TriggerIde ntity( | |
| 101 | Trigge rIdentity. Destinatio nType dest Type) { | |
| 102 | retu rn new Bas eTriggerId entity(des tType); | |
| 103 | } | |
| 104 | ||
| 105 | /* * | |
| 106 | * @return R eturns the name. | |
| 107 | * / | |
| 108 | pu blic Strin g getName( ) { | |
| 109 | retu rn name; | |
| 110 | } | |
| 111 | ||
| 112 | /* * | |
| 113 | * @param na me | |
| 114 | * The name to set. | |
| 115 | * / | |
| 116 | pu blic void setName(St ring name) { | |
| 117 | if ( name == nu ll) | |
| 118 | throw new Illega lArgumentE xception(" TriggerEve nt must ha ve non-nul l name"); | |
| 119 | ||
| 120 | this .name = na me; | |
| 121 | } | |
| 122 | ||
| 123 | pr otected vo id buildTo String(ToS tringBuild er builder ) { | |
| 124 | buil der.append ("name", n ame); | |
| 125 | buil der.append ("payload" , payload) ; | |
| 126 | buil der.append ("initiate r", initia ter); | |
| 127 | buil der.append ("triggerI dentity", triggerIde ntity); | |
| 128 | buil der.append ("eventMet rics", eve ntMetrics) ; | |
| 129 | } | |
| 130 | ||
| 131 | /* * | |
| 132 | * @return R eturns the triggerId entity. | |
| 133 | * / | |
| 134 | pu blic Trigg erIdentity getTrigge rIdentity( ) { | |
| 135 | retu rn trigger Identity; | |
| 136 | } | |
| 137 | ||
| 138 | /* singular method for defining the Trigge rEvent con text */ | |
| 139 | pu blic Strin g getTrigg erContext( ) { | |
| 140 | ToSt ringBuilde r builder = new ToSt ringBuilde r(this, To StringStyl e.MULTI_LI NE_STYLE); | |
| 141 | ||
| 142 | this .buildCont extString( builder); | |
| 143 | ||
| 144 | retu rn builder .toString( ); | |
| 145 | ||
| 146 | } | |
| 147 | ||
| 148 | pr otected vo id buildCo ntextStrin g(ToString Builder bu ilder) { | |
| 149 | buil der.append ("name", n ame); | |
| 150 | buil der.append ("initiate r", Securi tyContextH elper.getU serName(in itiater)); | |
| 151 | } | |
| 152 | ||
| 153 | /* * | |
| 154 | * @param tr iggerIdent ity | |
| 155 | * The trig gerIdentit y to set. | |
| 156 | * / | |
| 157 | pu blic void setTrigger Identity(T riggerIden tity trigg erIdentity ) { | |
| 158 | this .triggerId entity = t riggerIden tity; | |
| 159 | } | |
| 160 | ||
| 161 | pu blic final void preT riggerInit () { | |
| 162 | if ( eventMetri cs != null ) { | |
| 163 | eventM etrics.rou tedTimesta mp = Syste m.currentT imeMillis( ); | |
| 164 | } | |
| 165 | preT rigger(); | |
| 166 | } | |
| 167 | ||
| 168 | pu blic long getCreatio nDate() { | |
| 169 | retu rn eventMe trics != n ull ? even tMetrics.c reatedTime stamp : 0; | |
| 170 | } | |
| 171 | ||
| 172 | /* * Can be o verridden by subclas ses */ | |
| 173 | pr otected vo id preTrig ger() { | |
| 174 | // d o nothing | |
| 175 | } | |
| 176 | ||
| 177 | pr otected vo id preCons umedInit() { | |
| 178 | if ( eventMetri cs != null ) { | |
| 179 | eventM etrics.con sumedTimes tamp = Sys tem.curren tTimeMilli s(); | |
| 180 | } | |
| 181 | } | |
| 182 | ||
| 183 | pu blic Strin g getConsu merRouting Key() { | |
| 184 | // r outing is used for c ommunicati ng to the consumer w hat servic e should | |
| 185 | // b e invoked | |
| 186 | Stri ng routing Key = (get TriggerIde ntity() != null && g etTriggerI dentity() | |
| 187 | .isUsedF orConsumer Routing()) ? getTrig gerIdentit y().getCla ss().getNa me() | |
| 188 | : getNam e(); | |
| 189 | if ( routingKey == null) | |
| 190 | throw new Illega lStateExce ption( | |
| 191 | "Invalid T riggerEven t; getCons umerRoutin gKey() can not retur n null"); | |
| 192 | retu rn routing Key; | |
| 193 | } | |
| 194 | ||
| 195 | pu blic Prope rties getR outingProp erties() { | |
| 196 | Prop erties pro ps = new P roperties( ); | |
| 197 | prop s.put(DEST INATION_TY PE, getTri ggerIdenti ty().getDe stinationT ype().getN ame()); | |
| 198 | prop s.put(CONS UMER_ROUTI NG_KEY, ge tConsumerR outingKey( )); | |
| 199 | retu rn props; | |
| 200 | } | |
| 201 | ||
| 202 | /* * | |
| 203 | * @return t he payload | |
| 204 | * / | |
| 205 | pu blic Seria lizable ge tPayload() { | |
| 206 | retu rn payload ; | |
| 207 | } | |
| 208 | ||
| 209 | /* * | |
| 210 | * @param pa yload | |
| 211 | * the payl oad to set | |
| 212 | * / | |
| 213 | pu blic void setPayload (Serializa ble payloa d) { | |
| 214 | this .payload = payload; | |
| 215 | } | |
| 216 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.