Produced by Araxis Merge on 10/4/2017 8:04:36 AM Central 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 | rdk.zip\rdk\product\production\rdk\src\utils | connect-jds.js | Mon Aug 21 12:51:00 2017 UTC |
| 2 | rdk.zip\rdk\product\production\rdk\src\utils | connect-jds.js | Tue Oct 3 17:18:45 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 590 |
| 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 | 'use stric t'; | |
| 2 | ||
| 3 | /*! | |
| 4 | * connect -jds | |
| 5 | * Agilex Technologi es | |
| 6 | * | |
| 7 | */ | |
| 8 | ||
| 9 | /** | |
| 10 | * Module dependenci es | |
| 11 | */ | |
| 12 | var _ = re quire('lod ash'); | |
| 13 | var rdk = require('. ./core/rdk '); | |
| 14 | var httpUt il = rdk.u tils.http; | |
| 15 | ||
| 16 | /** | |
| 17 | * Default options | |
| 18 | */ | |
| 19 | var defaul tOptions = { | |
| 20 | jdsSer ver: { | |
| 21 | baseUrl: ' http:// IP ' | |
| 22 | }, | |
| 23 | defaul tExpiratio nTime: 100 0 * 60 * 6 0 * 24 * 1 4 | |
| 24 | }; | |
| 25 | ||
| 26 | /** | |
| 27 | * Default function export for the conne ct.session .Store | |
| 28 | */ | |
| 29 | module.exp orts = fun ction(sess ion) { | |
| 30 | /** | |
| 31 | * Exp ress's ses sion Store . | |
| 32 | */ | |
| 33 | var St ore = sess ion.Store; | |
| 34 | var my logger; | |
| 35 | ||
| 36 | /** | |
| 37 | * Ini tialize JD SStore wit h the give n `options `. | |
| 38 | * | |
| 39 | * @pa ram {Objec t} options | |
| 40 | * @ap i public | |
| 41 | * @pa ram logger | |
| 42 | * @pa ram app | |
| 43 | */ | |
| 44 | functi on JDSStor e(options, logger, a pp) { | |
| 45 | op tions = op tions || { }; | |
| 46 | St ore.call(t his, optio ns); | |
| 47 | ||
| 48 | th is.default Expiration Time = opt ions.defau ltExpirati onTime || defaultOpt ions.defau ltExpirati onTime; | |
| 49 | th is.jdsServ er = optio ns.jdsServ er || defa ultOptions .jdsServer ; | |
| 50 | th is.app = a pp; | |
| 51 | my logger = l ogger; | |
| 52 | } | |
| 53 | ||
| 54 | ||
| 55 | /** | |
| 56 | * Inh erit from `Store` fo r JDSStore , and igno re the non -standard use of __p roto__. | |
| 57 | */ | |
| 58 | /* jsh int ignore :start */ | |
| 59 | JDSSto re.prototy pe.__proto __ = Store .prototype ; | |
| 60 | /* jsh int ignore : end */ | |
| 61 | ||
| 62 | /** | |
| 63 | * Att empt to fe tch sessio n by the g iven `sid` . | |
| 64 | * | |
| 65 | * @pa ram {Strin g} sid | |
| 66 | * @pa ram {Funct ion} callb ack | |
| 67 | * @ap i public | |
| 68 | */ | |
| 69 | JDSSto re.prototy pe.get = f unction(si d, callbac k) { | |
| 70 | my logger.deb ug({sid: s id}, 'In c onnect-jds .get metho d with pas sed in sid :' + sid); | |
| 71 | if (!sid) { | |
| 72 | return s etImmediat e(callback ); | |
| 73 | } | |
| 74 | ||
| 75 | va r jdsServe r = this.j dsServer; //Get the JDS Server that we w ill do the HTTP Get from | |
| 76 | ||
| 77 | va r jdsResou rce = '/se ssion/get' ; //The co rrect endp oint from the JDS fo r GET whic h is part of VPRJSES global | |
| 78 | ||
| 79 | va r jdsOptio ns = _.ext end({}, jd sServer, { | |
| 80 | url: jds Resource + '/' + sid , //JDS te am decided to just a ppend sit to URL for get | |
| 81 | timeout: 120000, | |
| 82 | logger: mylogger.c hild({sid: sid}), | |
| 83 | json: tr ue | |
| 84 | }) ; | |
| 85 | my logger.deb ug({sid: s id}, 'In c onnect-jds .get metho d with pas sed in sid : %s. Befo re httpUti l.get call ', sid); | |
| 86 | ht tpUtil.get (jdsOption s, | |
| 87 | function (err, resp onse, body ) { | |
| 88 | if ( !err && _. get(respon se, 'statu sCode') >= 300) { | |
| 89 | err = _.ge t(body, 'e rror') || response.s tatusCode; | |
| 90 | } | |
| 91 | if ( err) { | |
| 92 | mylogger.d ebug({sid: sid, erro r: err}, ' In connect -jds.get m ethod with passed in sid: %s. After http Util.get c all with e rror', sid ); | |
| 93 | if (callba ck) { | |
| 94 | callba ck(err, nu ll); | |
| 95 | } | |
| 96 | return; | |
| 97 | } | |
| 98 | if ( body.sessi on) { | |
| 99 | //Always r eturn the session. W e will lea ve it up t o the call ing app to call dest roy if ses sion has e xpired. | |
| 100 | mylogger.d ebug({sid: sid, body : body}, ' In connect -jds.get m ethod with passed in sid: %s. After http Util.get c all with r eturned se ssion.', s id); | |
| 101 | callback(n ull, body. session); | |
| 102 | } el se { | |
| 103 | mylogger.d ebug({sid: sid, resp onse: resp onse}, 'In connect-j ds.get met hod with p assed in s id: %s. Af ter httpUt il.get cal l without returned s ession.', sid); | |
| 104 | if (callba ck) { | |
| 105 | callba ck(); | |
| 106 | } | |
| 107 | } | |
| 108 | } | |
| 109 | ); | |
| 110 | }; | |
| 111 | ||
| 112 | ||
| 113 | /** | |
| 114 | * Com mit the gi ven `sess` object as sociated w ith the gi ven `sid`. | |
| 115 | * | |
| 116 | * @pa ram {Strin g} sid | |
| 117 | * @pa ram {Sessi on} sessio n | |
| 118 | * @pa ram {Funct ion} callb ack | |
| 119 | * @ap i public | |
| 120 | */ | |
| 121 | ||
| 122 | JDSSto re.prototy pe.set = f unction(si d, session , callback ) { | |
| 123 | my logger.deb ug({sid: s id}, 'In c onnect-jds .set metho d with pas sed in sid :' + sid); | |
| 124 | ||
| 125 | va r s = { | |
| 126 | _id: sid , | |
| 127 | session: session | |
| 128 | }; | |
| 129 | if (session && session .cookie && session.c ookie.expi res) { | |
| 130 | s.expire s = new Da te(session .cookie.ex pires); | |
| 131 | } else { | |
| 132 | // If th ere's no e xpiration date speci fied, it i s | |
| 133 | // brows er-session cookie or there is no cookie at all, | |
| 134 | // as pe r the conn ect docs. | |
| 135 | // | |
| 136 | // So we set the e xpiration to two-wee ks from no w | |
| 137 | // - as is common practice i n the indu stry (e.g Django) - | |
| 138 | // or th e default specified in the opt ions. | |
| 139 | var toda y = new Da te(); | |
| 140 | s.expire s = new Da te(today.g etTime() + this.defa ultExpirat ionTime); | |
| 141 | } | |
| 142 | ||
| 143 | ||
| 144 | va r jdsServe r = this.j dsServer; //Get the JDS Server that we w ill do the HTTP Get from | |
| 145 | va r jdsResou rce = '/se ssion/set/ this'; //T he correct endpoint from the J DS for SET which is part of VP RJSES glob al | |
| 146 | va r jdsOptio ns = _.ext end({}, jd sServer, { | |
| 147 | url: jds Resource, | |
| 148 | timeout: 120000, | |
| 149 | logger: mylogger.c hild({sid: sid}), | |
| 150 | body: s, | |
| 151 | json: tr ue | |
| 152 | }) ; | |
| 153 | my logger.deb ug({sid: s id, sessio n: s}, 'In connect-j ds.set met hod with p assed in s id:' + sid + ' and s ession. Be fore httpU til.post c all'); | |
| 154 | ht tpUtil.pos t(jdsOptio ns, | |
| 155 | function (err, res ponse, dat a) { | |
| 156 | if ( !err && _. get(respon se, 'statu sCode') >= 300) { | |
| 157 | err = _.ge t(data, 'e rror') || response.s tatusCode; | |
| 158 | } | |
| 159 | if ( err) { | |
| 160 | mylogger.d ebug({sid: sid, erro r: err}, ' In connect -jds.set m ethod with passed in sid:' + s id + '. Er ror on pos tJSONObjec t'); | |
| 161 | if (callba ck) { | |
| 162 | callba ck(err); | |
| 163 | } | |
| 164 | return; | |
| 165 | } | |
| 166 | mylo gger.debug ({sid: sid }, 'In con nect-jds.s et method with passe d in sid:' + sid + ' . Success on postJSO NObject.') ; | |
| 167 | if ( callback) { | |
| 168 | callback(n ull, data) ; | |
| 169 | } | |
| 170 | ||
| 171 | } | |
| 172 | ); | |
| 173 | }; | |
| 174 | ||
| 175 | /** | |
| 176 | * Des troy the s ession ass ociated wi th the giv en `sid`. | |
| 177 | * | |
| 178 | * @pa ram {Strin g} sid | |
| 179 | * @pa ram {Funct ion} callb ack | |
| 180 | * @ap i public | |
| 181 | */ | |
| 182 | JDSSto re.prototy pe.destroy = functio n(sid, cal lback) { | |
| 183 | my logger.deb ug({sid: s id}, 'In c onnect-jds .destroy m ethod with passed in sid:' + s id); | |
| 184 | ||
| 185 | if (!sid) { | |
| 186 | return s etImmediat e(callback ); | |
| 187 | } | |
| 188 | va r jdsServe r = this.j dsServer; //Get the JDS Server that we w ill do the HTTP Get from | |
| 189 | va r jdsResou rce = '/se ssion/dest roy'; //Th e correct endpoint f rom the JD S for DEST ROY which is part of VPRJSES g lobal | |
| 190 | va r jdsOptio ns = _.ext end({}, jd sServer, { | |
| 191 | url: jds Resource + '/' + sid , //JDS Te am decided to just a ppend the SID onto t he URL as it made th ings easie r for them | |
| 192 | timeout: 120000, | |
| 193 | logger: mylogger.c hild({ sid : sid }), | |
| 194 | json: tr ue | |
| 195 | }) ; | |
| 196 | my logger.deb ug({sid: s id}, 'In c onnect-jds .destroy m ethod with passed in sid:' + s id + '. Be fore httpU til.get ca ll'); | |
| 197 | ht tpUtil.get (jdsOption s, | |
| 198 | function (err, resp onse, body ) { | |
| 199 | if ( !err && _. get(respon se, 'statu sCode') >= 300) { | |
| 200 | err = _.ge t(body, 'e rror') || response.s tatusCode; | |
| 201 | } | |
| 202 | if ( err) { | |
| 203 | mylogger.d ebug({sid: sid, erro r: err}, ' In connect -jds.destr oy method with passe d in sid:' + sid + ' . After ht tpUtil.get call with error'); | |
| 204 | if (callba ck) { | |
| 205 | callba ck(err); | |
| 206 | } | |
| 207 | return; | |
| 208 | } | |
| 209 | mylo gger.debug ({sid: sid }, 'In con nect-jds.d estroy met hod with p assed in s id:' + sid + '. Afte r httpUtil .get call with succe ss.'); | |
| 210 | if ( callback) { | |
| 211 | callback(n ull); | |
| 212 | } | |
| 213 | } | |
| 214 | ); | |
| 215 | }; | |
| 216 | ||
| 217 | ||
| 218 | /** | |
| 219 | * Fet ch number of JDS ses sions. | |
| 220 | * | |
| 221 | * @pa ram {Funct ion} callb ack | |
| 222 | * @ap i public | |
| 223 | */ | |
| 224 | JDSSto re.prototy pe.length = function (callback) { | |
| 225 | my logger.deb ug('In con nect-jds.l ength meth od'); | |
| 226 | ||
| 227 | va r jdsServe r = this.j dsServer; //Get the JDS Server that we w ill do the HTTP Get from | |
| 228 | va r jdsResou rce = '/se ssion/leng th/this'; //The corr ect endpoi nt from th e JDS for LENGTH whi ch is part of VPRJSE S global | |
| 229 | va r jdsOptio ns = _.ext end({}, jd sServer, { | |
| 230 | url: jds Resource, | |
| 231 | timeout: 120000, | |
| 232 | logger: mylogger, | |
| 233 | json: tr ue | |
| 234 | }) ; | |
| 235 | my logger.deb ug('In con nect-jds.l ength meth od. Before httpUtil. get call') ; | |
| 236 | ht tpUtil.get (jdsOption s, | |
| 237 | function (err, resp onse, leng th) { | |
| 238 | if ( !err && _. get(respon se, 'statu sCode') >= 300) { | |
| 239 | err = _.ge t(length, 'error') | | response .statusCod e; | |
| 240 | } | |
| 241 | if ( err) { | |
| 242 | mylogger.d ebug({erro r: err}, ' In connect -jds.lengt h method. After http Util.get c all with e rror'); | |
| 243 | if (callba ck) { | |
| 244 | callba ck(err, nu ll); | |
| 245 | } | |
| 246 | return; | |
| 247 | } | |
| 248 | mylo gger.debug ('In conne ct-jds.len gth method . After ht tpUtil.get call succ ess.'); | |
| 249 | if ( callback) { | |
| 250 | callback(n ull, lengt h); | |
| 251 | } | |
| 252 | } | |
| 253 | ); | |
| 254 | }; | |
| 255 | ||
| 256 | /** | |
| 257 | * Cle ar all ses sions. | |
| 258 | * | |
| 259 | * @pa ram {Funct ion} callb ack | |
| 260 | * @ap i public | |
| 261 | */ | |
| 262 | JDSSto re.prototy pe.clear = function( callback) { | |
| 263 | my logger.deb ug('In con nect-jds.c lear metho d'); | |
| 264 | ||
| 265 | va r jdsServe r = this.j dsServer; //Get the JDS Server that we w ill do the HTTP Get from | |
| 266 | va r jdsResou rce = '/se ssion/clea r/this'; / /The corre ct endpoin t from the JDS for C LEAR which is part o f VPRJSES global | |
| 267 | va r jdsOptio ns = _.ext end({}, jd sServer, { | |
| 268 | url: jds Resource, | |
| 269 | timeout: 120000, | |
| 270 | logger: mylogger, | |
| 271 | json: tr ue | |
| 272 | }) ; | |
| 273 | ||
| 274 | my logger.deb ug('In con nect-jds.c lear metho d. Before httpUtil.g et call'); | |
| 275 | ht tpUtil.get (jdsOption s, | |
| 276 | function (err, resp onse, body ) { | |
| 277 | if ( !err && _. get(respon se, 'statu sCode') >= 300) { | |
| 278 | err = _.ge t(body, 'e rror') || response.s tatusCode; | |
| 279 | } | |
| 280 | if ( err) { | |
| 281 | mylogger.d ebug({erro r: err}, ' In connect -jds.clear method. A fter httpU til.get ca ll with er ror'); | |
| 282 | if (callba ck) { | |
| 283 | callba ck(err); | |
| 284 | } | |
| 285 | return; | |
| 286 | } | |
| 287 | mylo gger.debug ('In conne ct-jds.cle ar method. After htt pUtil.get call with success.') ; | |
| 288 | if ( callback) { | |
| 289 | callback(n ull); | |
| 290 | } | |
| 291 | } | |
| 292 | ); | |
| 293 | }; | |
| 294 | ||
| 295 | return JDSStore; | |
| 296 | }; |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.