Produced by Araxis Merge on 11/14/2017 6:57:20 AM 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 | cbs.zip\cbs\cbs\src\main\java\gov\va\cpss\service\impl\si | SpringIntegrationSftpServiceImpl.java | Thu Nov 9 14:19:56 2017 UTC |
| 2 | cbs.zip\cbs\cbs\src\main\java\gov\va\cpss\service\impl\si | SpringIntegrationSftpServiceImpl.java | Tue Nov 14 12:27:18 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 1688 |
| 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 | package go v.va.cpss. service.im pl.si; | |
| 2 | ||
| 3 | //Remove s tub class if using i mplementat ion | |
| 4 | public cla ss SpringI ntegration SftpServic eImpl { | |
| 5 | } | |
| 6 | ||
| 7 | //Commenti ng to remo ve Spring Integratio n dependen cy from pr oject | |
| 8 | ||
| 9 | //import j ava.io.Fil e; | |
| 10 | //import j ava.io.Inp utStream; | |
| 11 | //import j ava.util.A rrayList; | |
| 12 | //import j ava.util.C ollections ; | |
| 13 | //import j ava.util.L ist; | |
| 14 | // | |
| 15 | //import o rg.apache. log4j.Logg er; | |
| 16 | //import o rg.springf ramework.i ntegration .channel.D irectChann el; | |
| 17 | //import o rg.springf ramework.i ntegration .file.remo te.FileInf o; | |
| 18 | //import o rg.springf ramework.i ntegration .file.remo te.session .Session; | |
| 19 | //import o rg.springf ramework.m essaging.M essage; | |
| 20 | //import o rg.springf ramework.m essaging.M essageHead ers; | |
| 21 | //import o rg.springf ramework.m essaging.P ollableCha nnel; | |
| 22 | //import o rg.springf ramework.m essaging.s upport.Gen ericMessag e; | |
| 23 | //import o rg.springf ramework.m essaging.s upport.Mes sageBuilde r; | |
| 24 | //import o rg.springf ramework.s tereotype. Service; | |
| 25 | // | |
| 26 | //import g ov.va.cpss .service.F ileData; | |
| 27 | //import g ov.va.cpss .service.S ftpService ; | |
| 28 | //import g ov.va.cpss .service.S ftpStreamS ession; | |
| 29 | // | |
| 30 | ///** | |
| 31 | // * Servi ce class f or handlin g activiti es relatin g to sftp. | |
| 32 | // * | |
| 33 | // * Conve rted to In terface/Im plementati on class t o support migration to Apache | |
| 34 | // * VFS - Brad Pick le 10/3/20 16 | |
| 35 | // * | |
| 36 | // * @auth or DN S BROWNL | |
| 37 | // */ | |
| 38 | //@Service | |
| 39 | //public c lass Sprin gIntegrati onSftpServ iceImpl im plements S ftpService { | |
| 40 | // | |
| 41 | // pr ivate stat ic final L ogger logg er = Logge r.getLogge r(SpringIn tegrationS ftpService Impl.class .getCanoni calName()) ;; | |
| 42 | // | |
| 43 | // pr ivate stat ic final S tring FTP_ RENAME_TO_ HEADER = " file_renam eTo"; | |
| 44 | // | |
| 45 | // pr ivate stat ic final S tring FTP_ TARGET_FIL E_TO_HEADE R = "targe tFile"; | |
| 46 | // | |
| 47 | // pr ivate stat ic final S tring FTP_ TARGET_DIR _TO_HEADER = "target Dir"; | |
| 48 | // | |
| 49 | // pr ivate stat ic final S tring FTP_ HEADER_FIL E_REMOTE_S ESSION = " file_remot eSession"; | |
| 50 | // | |
| 51 | // pr ivate Inte ger ftpTim eout; // f tp timeout | |
| 52 | // | |
| 53 | // pr ivate Dire ctChannel inboundGet Stream; // get reque st | |
| 54 | // | |
| 55 | // pr ivate Dire ctChannel inboundCha nnelLs; // ls reques t | |
| 56 | // | |
| 57 | // pr ivate Dire ctChannel inboundCha nnelSize; // ls size request | |
| 58 | // | |
| 59 | // pr ivate Dire ctChannel inboundCha nnelLsFile Info; // l s request | |
| 60 | // | |
| 61 | // pr ivate Dire ctChannel outboundCh annelPut; // put req uest | |
| 62 | // | |
| 63 | // pr ivate Dire ctChannel outboundCh annelMove; // move r equest | |
| 64 | // | |
| 65 | // pr ivate Dire ctChannel outboundCh annelRemov e; // remo ve request | |
| 66 | // | |
| 67 | // pr ivate Poll ableChanne l stream; // reply a s stream | |
| 68 | // | |
| 69 | // pr ivate Poll ableChanne l output; // reply a s message | |
| 70 | // | |
| 71 | // pu blic Sprin gIntegrati onSftpServ iceImpl() { | |
| 72 | // } | |
| 73 | // | |
| 74 | // pu blic Integ er getFtpT imeout() { | |
| 75 | // retu rn ftpTime out; | |
| 76 | // } | |
| 77 | // | |
| 78 | // pu blic void setFtpTime out(Intege r ftpTimeo ut) { | |
| 79 | // this .ftpTimeou t = ftpTim eout; | |
| 80 | // } | |
| 81 | // | |
| 82 | // pu blic Direc tChannel g etInboundG etStream() { | |
| 83 | // retu rn inbound GetStream; | |
| 84 | // } | |
| 85 | // | |
| 86 | // pu blic void setInbound GetStream( DirectChan nel inboun dGetStream ) { | |
| 87 | // this .inboundGe tStream = inboundGet Stream; | |
| 88 | // } | |
| 89 | // | |
| 90 | // pu blic Direc tChannel g etInboundC hannelLs() { | |
| 91 | // retu rn inbound ChannelLs; | |
| 92 | // } | |
| 93 | // | |
| 94 | // pu blic void setInbound ChannelLs( DirectChan nel inboun dChannelLs ) { | |
| 95 | // this .inboundCh annelLs = inboundCha nnelLs; | |
| 96 | // } | |
| 97 | // | |
| 98 | // pu blic Direc tChannel g etInboundC hannelSize () { | |
| 99 | // retu rn inbound ChannelSiz e; | |
| 100 | // } | |
| 101 | // | |
| 102 | // pu blic void setInbound ChannelSiz e(DirectCh annel inbo undChannel Size) { | |
| 103 | // this .inboundCh annelSize = inboundC hannelSize ; | |
| 104 | // } | |
| 105 | // | |
| 106 | // pu blic Direc tChannel g etInboundC hannelLsFi leInfo() { | |
| 107 | // retu rn inbound ChannelLsF ileInfo; | |
| 108 | // } | |
| 109 | // | |
| 110 | // pu blic void setInbound ChannelLsF ileInfo(Di rectChanne l inboundC hannelLsFi leInfo) { | |
| 111 | // this .inboundCh annelLsFil eInfo = in boundChann elLsFileIn fo; | |
| 112 | // } | |
| 113 | // | |
| 114 | // pu blic Direc tChannel g etOutbound ChannelPut () { | |
| 115 | // retu rn outboun dChannelPu t; | |
| 116 | // } | |
| 117 | // | |
| 118 | // pu blic void setOutboun dChannelPu t(DirectCh annel outb oundChanne lPut) { | |
| 119 | // this .outboundC hannelPut = outbound ChannelPut ; | |
| 120 | // } | |
| 121 | // | |
| 122 | // pu blic Direc tChannel g etOutbound ChannelMov e() { | |
| 123 | // retu rn outboun dChannelMo ve; | |
| 124 | // } | |
| 125 | // | |
| 126 | // pu blic void setOutboun dChannelMo ve(DirectC hannel out boundChann elMove) { | |
| 127 | // this .outboundC hannelMove = outboun dChannelMo ve; | |
| 128 | // } | |
| 129 | // | |
| 130 | // pu blic Direc tChannel g etOutbound ChannelRem ove() { | |
| 131 | // retu rn outboun dChannelRe move; | |
| 132 | // } | |
| 133 | // | |
| 134 | // pu blic void setOutboun dChannelRe move(Direc tChannel o utboundCha nnelRemove ) { | |
| 135 | // this .outboundC hannelRemo ve = outbo undChannel Remove; | |
| 136 | // } | |
| 137 | // | |
| 138 | // pu blic Polla bleChannel getStream () { | |
| 139 | // retu rn stream; | |
| 140 | // } | |
| 141 | // | |
| 142 | // pu blic void setStream( PollableCh annel stre am) { | |
| 143 | // this .stream = stream; | |
| 144 | // } | |
| 145 | // | |
| 146 | // pu blic Polla bleChannel getOutput () { | |
| 147 | // retu rn output; | |
| 148 | // } | |
| 149 | // | |
| 150 | // pu blic void setOutput( PollableCh annel outp ut) { | |
| 151 | // this .output = output; | |
| 152 | // } | |
| 153 | // | |
| 154 | // /* * | |
| 155 | // * Transfer the specif ied file p ath to the default d irectory o n the serv er. | |
| 156 | // * If the fi lepath is to a file the file w ill be sen t to the d efault | |
| 157 | // * directory on the se rver. IF t he filepat h is a dir ectory the n all file s | |
| 158 | // * will be s ent to the default d irectory o n the serv er. | |
| 159 | // * | |
| 160 | // * @param fi lepath | |
| 161 | // * The path of the fi le or dire ctory to s end to the server. | |
| 162 | // * | |
| 163 | // * @return B oolean fla g indicati ng success or failur e. | |
| 164 | // * / | |
| 165 | // @O verride | |
| 166 | // pu blic boole an ftpFile ToServer(f inal Strin g filepath ) { | |
| 167 | // retu rn ftpFile ToServer(f ilepath, " ."); | |
| 168 | // } | |
| 169 | // | |
| 170 | // /* * | |
| 171 | // * Transfer the specif ied file p ath to the specified directory on the | |
| 172 | // * server. I f the file path is to a file th e file wil l be sent to the def ault | |
| 173 | // * directory on the se rver. IF t he filepat h is a dir ectory the n all file s | |
| 174 | // * will be s ent to the default d irectory o n the serv er. | |
| 175 | // * | |
| 176 | // * @param fi lepath | |
| 177 | // * The path of the fi le or dire ctory to s end to the server. | |
| 178 | // * @param ta rgetDirect ory | |
| 179 | // * The rela tive targe t director y on the s erver. | |
| 180 | // * @return B oolean fla g indicati ng success or failur e. | |
| 181 | // * / | |
| 182 | // @O verride | |
| 183 | // pu blic boole an ftpFile ToServer(f inal Strin g filepath , final St ring targe tDirectory ) { | |
| 184 | // | |
| 185 | // bool ean succes sful = fal se; | |
| 186 | // | |
| 187 | // try { | |
| 188 | // | |
| 189 | // File f ile = new File(filep ath); | |
| 190 | // | |
| 191 | // if (ou tboundChan nelPut | |
| 192 | // .send(Mess ageBuilder .withPaylo ad(file).s etHeader(F TP_TARGET_ DIR_TO_HEA DER, targe tDirectory ) | |
| 193 | // .set Header(FTP _TARGET_FI LE_TO_HEAD ER, file.g etName()). build(), f tpTimeout) ) { | |
| 194 | // | |
| 195 | // Message< ?> msgs = output.rec eive(ftpTi meout); | |
| 196 | // | |
| 197 | // if (msgs != null) { | |
| 198 | // | |
| 199 | // Object pay load = msg s.getPaylo ad(); | |
| 200 | // | |
| 201 | // if (payloa d instance of String) { | |
| 202 | // | |
| 203 | // fi nal String mL = (Str ing) paylo ad; | |
| 204 | // if (mL.conta ins(file.g etName())) { | |
| 205 | // succ essful = t rue; | |
| 206 | // } | |
| 207 | // | |
| 208 | // } else if (payload i nstanceof List) { | |
| 209 | // | |
| 210 | // @S uppressWar nings("unc hecked") | |
| 211 | // fi nal List<S tring> mL = (List<St ring>) pay load; | |
| 212 | // if (file.isD irectory() ) { | |
| 213 | // if ( mL.size() == file.li st().lengt h) { | |
| 214 | // succes sful = tru e; | |
| 215 | // } | |
| 216 | // } | |
| 217 | // } else { | |
| 218 | // lo gger.error ("Unexpect ed type of payload") ; | |
| 219 | // } | |
| 220 | // } | |
| 221 | // } | |
| 222 | // | |
| 223 | // } ca tch (Excep tion e) { | |
| 224 | // logger .error("Un expected e xception d uring ftp put: " + e .getMessag e()); | |
| 225 | // } | |
| 226 | // | |
| 227 | // retu rn success ful; | |
| 228 | // } | |
| 229 | // | |
| 230 | // /* * | |
| 231 | // * Sent the specified local file path to th e server a s the spec ified targ et | |
| 232 | // * filename in the tar get direct ory on the server. | |
| 233 | // * | |
| 234 | // * @param fi lepath | |
| 235 | // * The loca l filepath to send. | |
| 236 | // * @param ta rgetFilena me | |
| 237 | // * The targ et filenam e on the s erver. | |
| 238 | // * @param ta rgetDirect ory | |
| 239 | // * The targ et directo ry for the target fi lename on the server . | |
| 240 | // * @return B oolean fla g indicati ng if succ essful or not. | |
| 241 | // * / | |
| 242 | // @O verride | |
| 243 | // pu blic boole an ftpFile ToServerWi thName(fin al String filepath, final Stri ng targetF ilename, | |
| 244 | // final String tar getDirecto ry) { | |
| 245 | // | |
| 246 | // bool ean succes sful = fal se; | |
| 247 | // | |
| 248 | // try { | |
| 249 | // | |
| 250 | // File f ile = new File(filep ath); | |
| 251 | // | |
| 252 | // if (ou tboundChan nelPut | |
| 253 | // .send(Mess ageBuilder .withPaylo ad(file).s etHeader(F TP_TARGET_ DIR_TO_HEA DER, targe tDirectory ) | |
| 254 | // .set Header(FTP _TARGET_FI LE_TO_HEAD ER, target Filename). build(), f tpTimeout) ) { | |
| 255 | // | |
| 256 | // Message< ?> msgs = output.rec eive(ftpTi meout); | |
| 257 | // | |
| 258 | // if (msgs != null) { | |
| 259 | // | |
| 260 | // Object pay load = msg s.getPaylo ad(); | |
| 261 | // | |
| 262 | // if (payloa d instance of String) { | |
| 263 | // | |
| 264 | // fi nal String mL = (Str ing) paylo ad; | |
| 265 | // if (mL.conta ins(target Filename)) { | |
| 266 | // succ essful = t rue; | |
| 267 | // } | |
| 268 | // | |
| 269 | // } else if (payload i nstanceof List) { | |
| 270 | // | |
| 271 | // @S uppressWar nings("unc hecked") | |
| 272 | // fi nal List<S tring> mL = (List<St ring>) pay load; | |
| 273 | // if (file.isD irectory() ) { | |
| 274 | // if ( mL.size() == file.li st().lengt h) { | |
| 275 | // succes sful = tru e; | |
| 276 | // } | |
| 277 | // } | |
| 278 | // } else { | |
| 279 | // lo gger.error ("Unexpect ed type of payload") ; | |
| 280 | // } | |
| 281 | // } | |
| 282 | // } | |
| 283 | // | |
| 284 | // } ca tch (Excep tion e) { | |
| 285 | // logger .error("Un expected e xception d uring ftp put: " + e .getMessag e()); | |
| 286 | // } | |
| 287 | // | |
| 288 | // retu rn success ful; | |
| 289 | // } | |
| 290 | // | |
| 291 | // /* * | |
| 292 | // * Send an e mpty file to the sft p server i n the spec ified targ et directo ry | |
| 293 | // * with the specified name. | |
| 294 | // * | |
| 295 | // * @param ta rgetFilena me | |
| 296 | // * The name of the re sulting em pty file o n the sftp server. | |
| 297 | // * @param ta rgetDirect ory | |
| 298 | // * The targ et directo ry on the sftp serve r. | |
| 299 | // * @return B oolean fla g indicati ng success ful or not . | |
| 300 | // * / | |
| 301 | // @O verride | |
| 302 | // pu blic boole an ftpEmpt yFileToSer verWithNam e(final St ring targe tFilename, final Str ing target Directory) { | |
| 303 | // retu rn ftpStri ngAsFileTo ServerWith Name("", t argetFilen ame, targe tDirectory ); | |
| 304 | // } | |
| 305 | // | |
| 306 | // /* * | |
| 307 | // * Send the specified string con tent as th e specifie d file con tent to th e | |
| 308 | // * sftp serv er int he specified target dir ectory wit h the spec ified name . | |
| 309 | // * | |
| 310 | // * @param co ntent | |
| 311 | // * The cont ent of the target fi le. | |
| 312 | // * @param ta rgetFilena me | |
| 313 | // * The name of the re sulting fi le on the sftp serve r. | |
| 314 | // * @param ta rgetDirect ory | |
| 315 | // * The targ et directo ry on the sftp serve r. | |
| 316 | // * @return B oolean fla g indicati ng success ful or not . | |
| 317 | // * / | |
| 318 | // @O verride | |
| 319 | // pu blic boole an ftpStri ngAsFileTo ServerWith Name(final String co ntent, fin al String targetFile name, | |
| 320 | // final String tar getDirecto ry) { | |
| 321 | // | |
| 322 | // bool ean succes sful = fal se; | |
| 323 | // | |
| 324 | // try { | |
| 325 | // | |
| 326 | // if (ou tboundChan nelPut | |
| 327 | // .send(Mess ageBuilder .withPaylo ad(content ).setHeade r(FTP_TARG ET_DIR_TO_ HEADER, ta rgetDirect ory) | |
| 328 | // .set Header(FTP _TARGET_FI LE_TO_HEAD ER, target Filename). build(), f tpTimeout) ) { | |
| 329 | // | |
| 330 | // Message< ?> msgs = output.rec eive(ftpTi meout); | |
| 331 | // | |
| 332 | // if (msgs != null) { | |
| 333 | // | |
| 334 | // Object pay load = msg s.getPaylo ad(); | |
| 335 | // | |
| 336 | // if (payloa d instance of String) { | |
| 337 | // | |
| 338 | // fi nal String mL = (Str ing) paylo ad; | |
| 339 | // if (mL.conta ins(target Filename)) { | |
| 340 | // succ essful = t rue; | |
| 341 | // } | |
| 342 | // | |
| 343 | // } else { | |
| 344 | // lo gger.error ("Unexpect ed type of payload f or empty f ile put"); | |
| 345 | // } | |
| 346 | // } | |
| 347 | // } | |
| 348 | // | |
| 349 | // } ca tch (Excep tion e) { | |
| 350 | // logger .error("Un expected e xception d uring ftp put empty file: " + e.getMessa ge()); | |
| 351 | // } | |
| 352 | // | |
| 353 | // retu rn success ful; | |
| 354 | // } | |
| 355 | // | |
| 356 | // /* * | |
| 357 | // * Remove th e specifie d filename from the specified target dir ectory on the | |
| 358 | // * server. | |
| 359 | // * | |
| 360 | // * @param fi lename | |
| 361 | // * The name of the fi le to remo ve. | |
| 362 | // * @param ta rgetDirect ory | |
| 363 | // * The dire ctory path where the file shou ld reside. | |
| 364 | // * @return B oolean fla g indicati ng success or failur e. | |
| 365 | // * / | |
| 366 | // @O verride | |
| 367 | // pu blic boole an ftpRemo veFileFrom Directory( final Stri ng filenam e, final S tring targ etDirector y) { | |
| 368 | // | |
| 369 | // bool ean succes sful = fal se; | |
| 370 | // | |
| 371 | // fina l String r emovedFile Path = tar getDirecto ry + "/" + filename; | |
| 372 | // | |
| 373 | // try { | |
| 374 | // | |
| 375 | // if (ou tboundChan nelRemove. send(Messa geBuilder. withPayloa d(removedF ilePath).b uild(), ft pTimeout)) { | |
| 376 | // | |
| 377 | // Message< ?> msgs = output.rec eive(ftpTi meout); | |
| 378 | // | |
| 379 | // if (msgs != null) { | |
| 380 | // successful = (Boolea n) msgs.ge tPayload() ; | |
| 381 | // } | |
| 382 | // } | |
| 383 | // | |
| 384 | // } ca tch (Excep tion e) { | |
| 385 | // logger .error("Un expected e xception d uring ftp remove: " + e.getMes sage()); | |
| 386 | // } | |
| 387 | // | |
| 388 | // retu rn success ful; | |
| 389 | // } | |
| 390 | // | |
| 391 | // /* * | |
| 392 | // * Move the specified filename t o the spec ified targ et directo ry. | |
| 393 | // * | |
| 394 | // * @param or iginalFile name | |
| 395 | // * The name of the fi le to move . | |
| 396 | // * @param ta rgetDirect ory | |
| 397 | // * The dire ctory path to move t he file. | |
| 398 | // * @return B oolean fla g indicati ng success or failur e. | |
| 399 | // * / | |
| 400 | // @O verride | |
| 401 | // pu blic boole an ftpMove FileToDire ctory(fina l String o riginalFil ename, fin al String targetDire ctory) { | |
| 402 | // | |
| 403 | // bool ean succes sful = fal se; | |
| 404 | // | |
| 405 | // fina l String m ovedFilePa th = targe tDirectory + "/" + o riginalFil ename; | |
| 406 | // | |
| 407 | // try { | |
| 408 | // | |
| 409 | // if (ou tboundChan nelMove.se nd( | |
| 410 | // MessageBui lder.withP ayload(ori ginalFilen ame).setHe ader(FTP_R ENAME_TO_H EADER, mov edFilePath ).build(), | |
| 411 | // ftpTimeout )) { | |
| 412 | // | |
| 413 | // Message< ?> msgs = output.rec eive(ftpTi meout); | |
| 414 | // | |
| 415 | // if (msgs != null) { | |
| 416 | // successful = (Boolea n) msgs.ge tPayload() ; | |
| 417 | // } | |
| 418 | // } | |
| 419 | // | |
| 420 | // } ca tch (Excep tion e) { | |
| 421 | // logger .error("Un expected e xception d uring ftp move: " + e.getMessa ge()); | |
| 422 | // } | |
| 423 | // | |
| 424 | // retu rn success ful; | |
| 425 | // } | |
| 426 | // | |
| 427 | // /* * | |
| 428 | // * Move the specified filename t o the spec ified targ et directo ry. | |
| 429 | // * | |
| 430 | // * @param or iginalFile name | |
| 431 | // * The name of the fi le to move . | |
| 432 | // * @param ta rgetDirect ory | |
| 433 | // * The dire ctory path to move t he file. | |
| 434 | // * @return B oolean fla g indicati ng success or failur e. | |
| 435 | // * / | |
| 436 | // @O verride | |
| 437 | // pu blic boole an ftpMove FileFromDi rectoryToD irectory(f inal Strin g original Filename, final Stri ng origina lDirectory , | |
| 438 | // final String tar getDirecto ry) { | |
| 439 | // | |
| 440 | // bool ean succes sful = fal se; | |
| 441 | // | |
| 442 | // fina l String o riginalFil ePath = or iginalDire ctory + "/ " + origin alFilename ; | |
| 443 | // fina l String m ovedFilePa th = targe tDirectory + "/" + o riginalFil ename; | |
| 444 | // | |
| 445 | // try { | |
| 446 | // | |
| 447 | // if (ou tboundChan nelMove.se nd( | |
| 448 | // MessageBui lder.withP ayload(ori ginalFileP ath).setHe ader(FTP_R ENAME_TO_H EADER, mov edFilePath ).build(), | |
| 449 | // ftpTimeout )) { | |
| 450 | // | |
| 451 | // Message< ?> msgs = output.rec eive(ftpTi meout); | |
| 452 | // | |
| 453 | // if (msgs != null) { | |
| 454 | // successful = (Boolea n) msgs.ge tPayload() ; | |
| 455 | // } | |
| 456 | // } | |
| 457 | // | |
| 458 | // } ca tch (Excep tion e) { | |
| 459 | // logger .error("Un expected e xception d uring ftp move: " + e.getMessa ge()); | |
| 460 | // } | |
| 461 | // | |
| 462 | // retu rn success ful; | |
| 463 | // } | |
| 464 | // | |
| 465 | // /* * | |
| 466 | // * Rename th e specifie d filename with the new filena me in the specified | |
| 467 | // * target di rectory on the serve r. | |
| 468 | // * | |
| 469 | // * @param or iginalFile name | |
| 470 | // * The orig inal filen ame on the server. | |
| 471 | // * @param ne wFilename | |
| 472 | // * The new filename o n the serv er. | |
| 473 | // * @param ta rgetDirect ory | |
| 474 | // * The targ et directo ry where t he files r eside on t he server. | |
| 475 | // * @return B oolean fla g indicati ng success ful rename or not. | |
| 476 | // * / | |
| 477 | // @O verride | |
| 478 | // pu blic boole an ftpRena meFileInDi rectory(fi nal String originalF ilename, f inal Strin g newFilen ame, | |
| 479 | // final String tar getDirecto ry) { | |
| 480 | // | |
| 481 | // bool ean succes sful = fal se; | |
| 482 | // | |
| 483 | // fina l String o riginalFil ePath = ta rgetDirect ory + "/" + original Filename; | |
| 484 | // fina l String m ovedFilePa th = targe tDirectory + "/" + n ewFilename ; | |
| 485 | // | |
| 486 | // try { | |
| 487 | // | |
| 488 | // if (ou tboundChan nelMove.se nd( | |
| 489 | // MessageBui lder.withP ayload(ori ginalFileP ath).setHe ader(FTP_R ENAME_TO_H EADER, mov edFilePath ).build(), | |
| 490 | // ftpTimeout )) { | |
| 491 | // | |
| 492 | // Message< ?> msgs = output.rec eive(ftpTi meout); | |
| 493 | // | |
| 494 | // if (msgs != null) { | |
| 495 | // successful = (Boolea n) msgs.ge tPayload() ; | |
| 496 | // } | |
| 497 | // } | |
| 498 | // | |
| 499 | // } ca tch (Excep tion e) { | |
| 500 | // logger .error("Un expected e xception d uring ftp rename: " + e.getMes sage()); | |
| 501 | // } | |
| 502 | // | |
| 503 | // retu rn success ful; | |
| 504 | // } | |
| 505 | // | |
| 506 | // /* * | |
| 507 | // * Get a lis t of files that resi de in the specified directory path. | |
| 508 | // * | |
| 509 | // * @param ta rgetDirect ory | |
| 510 | // * The dire ctory path to get as sociated f ile listin g. | |
| 511 | // * @return B oolean fla g indicati ng success or failur e. | |
| 512 | // * / | |
| 513 | // @O verride | |
| 514 | // pu blic List< String> ft pGetFileLi stInDirect ory(final String tar getDirecto ry) { | |
| 515 | // retu rn ftpGetF ileListInD irectory(t argetDirec tory, fals e); | |
| 516 | // } | |
| 517 | // | |
| 518 | // /* * | |
| 519 | // * Get a lis t of files that resi de in the specified directory path. | |
| 520 | // * | |
| 521 | // * @param ta rgetDirect ory | |
| 522 | // * The dire ctory path to get as sociated f ile listin g. | |
| 523 | // * @param th rowExcepti ons | |
| 524 | // * If true, any excep tions will be re-thr own after being logg ed. | |
| 525 | // * @return B oolean fla g indicati ng success or failur e. | |
| 526 | // * / | |
| 527 | // @O verride | |
| 528 | // pu blic List< String> ft pGetFileLi stInDirect ory(final String tar getDirecto ry, boolea n throwExc eptions) { | |
| 529 | // | |
| 530 | // try { | |
| 531 | // | |
| 532 | // inboun dChannelLs .send(new GenericMes sage<Strin g>(targetD irectory), ftpTimeou t); | |
| 533 | // | |
| 534 | // Messag e<?> msgs = output.r eceive(ftp Timeout); | |
| 535 | // | |
| 536 | // @Suppr essWarning s("uncheck ed") | |
| 537 | // List<S tring> fil eL = (List <String>) msgs.getPa yload(); | |
| 538 | // | |
| 539 | // return fileL; | |
| 540 | // | |
| 541 | // } ca tch (Excep tion e) { | |
| 542 | // logger .error("Un expected e xception d uring ftp list: " + e.getMessa ge()); | |
| 543 | // if (th rowExcepti ons) | |
| 544 | // throw (e ); | |
| 545 | // } | |
| 546 | // | |
| 547 | // retu rn null; | |
| 548 | // } | |
| 549 | // | |
| 550 | // /* * | |
| 551 | // * Get a lis t of files that resi de in the specified directory path that have | |
| 552 | // * the speci fied exten sion. The extension check will ignore ca se. | |
| 553 | // * | |
| 554 | // * @param ta rgetDirect ory | |
| 555 | // * The dire ctory path to get as sociated f ile listin g. | |
| 556 | // * @return B oolean fla g indicati ng success or failur e. | |
| 557 | // * / | |
| 558 | // @O verride | |
| 559 | // pu blic List< String> ft pGetFileLi stWithExte nsionInDir ectory(fin al String targetDire ctory, fin al String extension) { | |
| 560 | // retu rn ftpGetF ileListWit hExtension InDirector y(targetDi rectory, e xtension, false); | |
| 561 | // } | |
| 562 | // | |
| 563 | // /* * | |
| 564 | // * Get a lis t of files that resi de in the specified directory path that have | |
| 565 | // * the speci fied exten sion. The extension check will ignore ca se. | |
| 566 | // * | |
| 567 | // * @param ta rgetDirect ory | |
| 568 | // * The dire ctory path to get as sociated f ile listin g. | |
| 569 | // * @param th rowExcepti ons | |
| 570 | // * If true, any excep tions will be re-thr own after being logg ed. | |
| 571 | // * @return L ist of fil e names so rted by th eir modifi ed dates | |
| 572 | // * / | |
| 573 | // @O verride | |
| 574 | // pu blic List< String> ft pGetFileLi stWithExte nsionInDir ectory(fin al String targetDire ctory, fin al String extension, | |
| 575 | // boolea n throwExc eptions) { | |
| 576 | // | |
| 577 | // try { | |
| 578 | // | |
| 579 | // inboun dChannelLs FileInfo.s end(new Ge nericMessa ge<String> (targetDir ectory), f tpTimeout) ; | |
| 580 | // | |
| 581 | // Messag e<?> msgs = output.r eceive(ftp Timeout); | |
| 582 | // | |
| 583 | // @Suppr essWarning s("uncheck ed") | |
| 584 | // List<F ileInfo<?> > fileL = (List<File Info<?>>) msgs.getPa yload(); | |
| 585 | // | |
| 586 | // if ((f ileL != nu ll) && !fi leL.isEmpt y()) { | |
| 587 | // List<Fil eData> dat aList = ne w ArrayLis t<FileData >(); | |
| 588 | // for (Fil eInfo<?> f ile : file L) { | |
| 589 | // if (file.g etFilename ().toUpper Case().end sWith(exte nsion.toUp perCase()) ) { | |
| 590 | // da taList.add (new FileD ata(file.g etFilename (), file.g etModified ())); | |
| 591 | // } | |
| 592 | // } | |
| 593 | // // Sort the list b y date mod ified | |
| 594 | // Collecti ons.sort(d ataList); | |
| 595 | // List<Str ing> retur nL = new A rrayList<S tring>(); | |
| 596 | // for (Fil eData file Data : dat aList) { | |
| 597 | // returnL.ad d(fileData .getFileNa me()); | |
| 598 | // } | |
| 599 | // return r eturnL; | |
| 600 | // } | |
| 601 | // | |
| 602 | // return null; | |
| 603 | // | |
| 604 | // } ca tch (Excep tion e) { | |
| 605 | // logger .error("Un expected e xception d uring ftp list: " + e.getMessa ge()); | |
| 606 | // if (th rowExcepti ons) | |
| 607 | // throw (e ); | |
| 608 | // } | |
| 609 | // | |
| 610 | // retu rn null; | |
| 611 | // } | |
| 612 | // | |
| 613 | // // /** | |
| 614 | // // * Get a l ist of fil es that re side in th e specifie d director y path. | |
| 615 | // // * | |
| 616 | // // * @param targetDire ctory | |
| 617 | // // * The dir ectory pat h to get a ssociated file listi ng. | |
| 618 | // // * @return FileInfo list indic ating the files on t he FTP ser ver | |
| 619 | // // */ | |
| 620 | // // public Li st<FileInf o<?>> ftpG etFileInfo ListInDire ctory(fina l String | |
| 621 | // // targetDir ectory) { | |
| 622 | // // return ft pGetFileIn foListInDi rectory(ta rgetDirect ory, false ); | |
| 623 | // // } | |
| 624 | // // | |
| 625 | // // /** | |
| 626 | // // * Get a l ist of fil es that re side in th e specifie d director y path. | |
| 627 | // // * | |
| 628 | // // * @param targetDire ctory | |
| 629 | // // * The dir ectory pat h to get a ssociated file listi ng. | |
| 630 | // // * @param throwExcep tions | |
| 631 | // // * If true , any exce ptions wil l be re-th rown after being log ged. | |
| 632 | // // * @return FileInfo list indic ating the files on t he FTP ser ver | |
| 633 | // // */ | |
| 634 | // // public Li st<FileInf o<?>> ftpG etFileInfo ListInDire ctory(fina l String | |
| 635 | // // targetDir ectory, fi nal boolea n throwExc eptions) { | |
| 636 | // // try { | |
| 637 | // // | |
| 638 | // // inboundCh annelLsFil eInfo.send (new | |
| 639 | // // GenericMe ssage<Stri ng>(target Directory) , ftpTimeo ut); | |
| 640 | // // | |
| 641 | // // Message<? > msgs = o utput.rece ive(ftpTim eout); | |
| 642 | // // | |
| 643 | // // @Suppress Warnings(" unchecked" ) | |
| 644 | // // List<File Info<?>> f ileL = (Li st<FileInf o<?>>) msg s.getPaylo ad(); | |
| 645 | // // return fi leL; | |
| 646 | // // | |
| 647 | // // } catch ( Exception e) { | |
| 648 | // // logger.er ror("Unexp ected exce ption duri ng ftp fil e info lis t: " + | |
| 649 | // // e.getMess age()); | |
| 650 | // // if (throw Exceptions ) | |
| 651 | // // throw (e) ; | |
| 652 | // // } | |
| 653 | // // | |
| 654 | // // return nu ll; | |
| 655 | // // } | |
| 656 | // // | |
| 657 | // // /** | |
| 658 | // // * Get a l ist of fil es that re side in th e specifie d director y path tha t | |
| 659 | // // have | |
| 660 | // // * the spe cified ext ension. Th e extensio n check wi ll ignore case. | |
| 661 | // // * | |
| 662 | // // * @param targetDire ctory | |
| 663 | // // * The dir ectory pat h to get a ssociated file listi ng. | |
| 664 | // // * @param throwExcep tions | |
| 665 | // // * If true , any exce ptions wil l be re-th rown after being log ged. | |
| 666 | // // * @return FileInfo list indic ating the files on t he FTP ser ver | |
| 667 | // // */ | |
| 668 | // // public Li st<FileInf o<?>> ftpG etFileInfo ListWithEx tensionInD irectory(f inal | |
| 669 | // // String ta rgetDirect ory, final String ex tension) { | |
| 670 | // // return ft pGetFileIn foListWith ExtensionI nDirectory (targetDir ectory, | |
| 671 | // // extension , false); | |
| 672 | // // } | |
| 673 | // // | |
| 674 | // // /** | |
| 675 | // // * Get a l ist of fil es that re side in th e specifie d director y path tha t | |
| 676 | // // have | |
| 677 | // // * the spe cified ext ension. Th e extensio n check wi ll ignore case. | |
| 678 | // // * | |
| 679 | // // * @param targetDire ctory | |
| 680 | // // * The dir ectory pat h to get a ssociated file listi ng. | |
| 681 | // // * @param extension | |
| 682 | // // * The spe cified ext ension to filter for . | |
| 683 | // // * @param throwExcep tions | |
| 684 | // // * If true , any exce ptions wil l be re-th rown after being log ged. | |
| 685 | // // * @return FileInfo list indic ating the files on t he FTP ser ver | |
| 686 | // // */ | |
| 687 | // // public Li st<FileInf o<?>> ftpG etFileInfo ListWithEx tensionInD irectory( | |
| 688 | // // final Str ing target Directory, final Str ing extens ion, final boolean | |
| 689 | // // throwExce ptions) { | |
| 690 | // // | |
| 691 | // // try { | |
| 692 | // // inboundCh annelLsFil eInfo.send (new | |
| 693 | // // GenericMe ssage<Stri ng>(target Directory) , ftpTimeo ut); | |
| 694 | // // | |
| 695 | // // Message<? > msgs = o utput.rece ive(ftpTim eout); | |
| 696 | // // | |
| 697 | // // @Suppress Warnings(" unchecked" ) | |
| 698 | // // List<File Info<?>> f ileL = (Li st<FileInf o<?>>) msg s.getPaylo ad(); | |
| 699 | // // | |
| 700 | // // if ((file L != null) && !fileL .isEmpty() ) { | |
| 701 | // // List<File Info<?>> r eturnL = n ew ArrayLi st<>(); | |
| 702 | // // for (File Info<?> fi le : fileL ) { | |
| 703 | // // if (file. getFilenam e().toUppe rCase().en dsWith(ext ension.toU pperCase() )) { | |
| 704 | // // returnL.a dd(file); | |
| 705 | // // } | |
| 706 | // // } | |
| 707 | // // return re turnL; | |
| 708 | // // } | |
| 709 | // // | |
| 710 | // // return fi leL; | |
| 711 | // // | |
| 712 | // // } catch ( Exception e) { | |
| 713 | // // logger.er ror("Unexp ected exce ption duri ng ftp lis t: " + e.g etMessage( )); | |
| 714 | // // if (throw Exceptions ) | |
| 715 | // // throw (e) ; | |
| 716 | // // } | |
| 717 | // // | |
| 718 | // // return nu ll; | |
| 719 | // // } | |
| 720 | // | |
| 721 | // /* * | |
| 722 | // * Check if the specif ied filena me exists in the tar get direct ory. | |
| 723 | // * | |
| 724 | // * @param fi lename | |
| 725 | // * The name of the fi le to chec k existenc e. | |
| 726 | // * @param ta rgetDirect ory | |
| 727 | // * The targ et directo ry path to check for the speci fied file. | |
| 728 | // * @return B oolean fla g indicati ng success or failur e. | |
| 729 | // * / | |
| 730 | // @O verride | |
| 731 | // pu blic boole an ftpFile ExistsInDi rectory(fi nal String filename, final Str ing target Directory) { | |
| 732 | // retu rn ftpFile ExistsInDi rectory(fi lename, ta rgetDirect ory, false ); | |
| 733 | // } | |
| 734 | // | |
| 735 | // /* * | |
| 736 | // * Check if the specif ied filena me exists in the tar get direct ory. | |
| 737 | // * | |
| 738 | // * @param fi lename | |
| 739 | // * The name of the fi le to chec k existenc e. | |
| 740 | // * @param ta rgetDirect ory | |
| 741 | // * The targ et directo ry path to check for the speci fied file. | |
| 742 | // * @param th rowExcepti ons | |
| 743 | // * If true, any excep tions will be re-thr own after being logg ed. | |
| 744 | // * @return B oolean fla g indicati ng success or failur e. | |
| 745 | // * / | |
| 746 | // @O verride | |
| 747 | // pu blic boole an ftpFile ExistsInDi rectory(fi nal String filename, final Str ing target Directory, | |
| 748 | // boolea n throwExc eptions) { | |
| 749 | // | |
| 750 | // bool ean succes sful = fal se; | |
| 751 | // | |
| 752 | // List <String> f ileL = ftp GetFileLis tInDirecto ry(targetD irectory, throwExcep tions); | |
| 753 | // | |
| 754 | // if ( fileL != n ull) { | |
| 755 | // succes sful = fil eL.contain s(filename ); | |
| 756 | // } | |
| 757 | // | |
| 758 | // retu rn success ful; | |
| 759 | // } | |
| 760 | // | |
| 761 | // /* * | |
| 762 | // * Get the s ize of the specified file or n ull if doe s not exis t. | |
| 763 | // * | |
| 764 | // * @param ta rgetDirect ory | |
| 765 | // * The dire ctory path to get as sociated f ile listin g. | |
| 766 | // * @return L ong Size o f the file or null i f does not exist. | |
| 767 | // * / | |
| 768 | // @O verride | |
| 769 | // pu blic Long ftpGetFile SizeInDire ctory(fina l String f ilename, f inal Strin g targetDi rectory) { | |
| 770 | // | |
| 771 | // Long size = nu ll; | |
| 772 | // | |
| 773 | // try { | |
| 774 | // | |
| 775 | // inboun dChannelSi ze.send(ne w GenericM essage<Str ing>(targe tDirectory ), ftpTime out); | |
| 776 | // | |
| 777 | // Messag e<?> msgs = output.r eceive(ftp Timeout); | |
| 778 | // | |
| 779 | // @Suppr essWarning s("uncheck ed") | |
| 780 | // List<F ileInfo<?> > fIL = (L ist<FileIn fo<?>>) ms gs.getPayl oad(); | |
| 781 | // | |
| 782 | // for (F ileInfo<?> fI : fIL) { | |
| 783 | // String f N = fI.get Filename() ; | |
| 784 | // Long fS = fI.getSi ze(); | |
| 785 | // if (file name.equal s(fN)) { | |
| 786 | // size = fS; | |
| 787 | // break; | |
| 788 | // } | |
| 789 | // } | |
| 790 | // | |
| 791 | // } ca tch (Excep tion e) { | |
| 792 | // logger .error("Un expected e xception d uring ftp get size: " + e.getM essage()); | |
| 793 | // } | |
| 794 | // | |
| 795 | // retu rn size; | |
| 796 | // } | |
| 797 | // | |
| 798 | // /* * | |
| 799 | // * Open a st ream for t he specifi ed file. | |
| 800 | // * | |
| 801 | // * @param fi lename | |
| 802 | // * The file to open. | |
| 803 | // * @return S ftpStreamS ession bea n that con tains the session an d input st ream | |
| 804 | // * o r null if error. | |
| 805 | // * @throws E xception | |
| 806 | // * / | |
| 807 | // @O verride | |
| 808 | // pu blic SftpS treamSessi on openFil eStream(fi nal String filename, final Str ing direct ory) throw s Exceptio n { | |
| 809 | // | |
| 810 | // Sftp StreamSess ion sss = null; | |
| 811 | // | |
| 812 | // // S end get re quest to d ownload fi le as stre am. | |
| 813 | // if ( inboundGet Stream.sen d(MessageB uilder.wit hPayload(d irectory + "/" + fil ename).bui ld(), ftpT imeout)) { | |
| 814 | // | |
| 815 | // // If sent get r equest was successfu l, then at tempt to o btain the | |
| 816 | // // inp ut stream and sessio n from the message. | |
| 817 | // Messag e<?> msgs = stream.r eceive(ftp Timeout); | |
| 818 | // | |
| 819 | // if (ms gs != null ) { | |
| 820 | // | |
| 821 | // // The p ayload fro m the mess age is the input str eam with t he | |
| 822 | // // data. | |
| 823 | // InputStr eam is = ( InputStrea m) msgs.ge tPayload() ; | |
| 824 | // | |
| 825 | // // The m essage hea der will c ontain the sftp sess ion. | |
| 826 | // MessageH eaders mH = msgs.get Headers(); | |
| 827 | // Session< ?> session = (Sessio n<?>) mH.g et(FTP_HEA DER_FILE_R EMOTE_SESS ION); | |
| 828 | // | |
| 829 | // if ((ses sion != nu ll) && (is != null)) { | |
| 830 | // sss = new SftpStream Session(ne w SpringIn tegrationS ftpSession Impl(sessi on), is); | |
| 831 | // } else { | |
| 832 | // // Unexpec ted state so close r esources a s appropri ate. | |
| 833 | // if (is != null) { | |
| 834 | // is .close(); | |
| 835 | // } else if (session ! = null) { | |
| 836 | // se ssion.clos e(); | |
| 837 | // } | |
| 838 | // } | |
| 839 | // } | |
| 840 | // } | |
| 841 | // | |
| 842 | // retu rn sss; | |
| 843 | // } | |
| 844 | // | |
| 845 | //} |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.