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\job | CbssProcessFileCleanupTasklet.java | Thu Nov 9 14:19:48 2017 UTC |
| 2 | cbs.zip\cbs\cbs\src\main\java\gov\va\cpss\job | CbssProcessFileCleanupTasklet.java | Tue Nov 14 12:25:57 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 228 |
| 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. job; | |
| 2 | ||
| 3 | import jav a.io.File; | |
| 4 | import jav a.util.Lis t; | |
| 5 | ||
| 6 | import org .springfra mework.bat ch.core.sc ope.contex t.ChunkCon text; | |
| 7 | ||
| 8 | import gov .va.cpss.s ervice.Sft pService; | |
| 9 | ||
| 10 | /** | |
| 11 | * Remove any partia lly transf erred file s on the s ftp server that have the | |
| 12 | * tempora ry name. L og errors but contin ue process ing. | |
| 13 | * | |
| 14 | * @author DN S BROWNL | |
| 15 | */ | |
| 16 | public cla ss CbssPro cessFileCl eanupTaskl et extends CbssJobBa seTransact ionTasklet { | |
| 17 | ||
| 18 | pr ivate Stri ng tempFil enamePostf ix; | |
| 19 | ||
| 20 | pr ivate Stri ng serverT argetDirec tory; | |
| 21 | ||
| 22 | pr ivate Sftp Service sf tpService; | |
| 23 | ||
| 24 | pr ivate Stri ng staging Directory; | |
| 25 | ||
| 26 | pu blic Strin g getTempF ilenamePos tfix() { | |
| 27 | retu rn tempFil enamePostf ix; | |
| 28 | } | |
| 29 | ||
| 30 | pu blic void setTempFil enamePostf ix(String tempFilena mePostfix) { | |
| 31 | this .tempFilen amePostfix = tempFil enamePostf ix; | |
| 32 | } | |
| 33 | ||
| 34 | pu blic Strin g getServe rTargetDir ectory() { | |
| 35 | retu rn serverT argetDirec tory; | |
| 36 | } | |
| 37 | ||
| 38 | pu blic void setServerT argetDirec tory(Strin g serverTa rgetDirect ory) { | |
| 39 | this .serverTar getDirecto ry = serve rTargetDir ectory; | |
| 40 | } | |
| 41 | ||
| 42 | pu blic SftpS ervice get SftpServic e() { | |
| 43 | retu rn sftpSer vice; | |
| 44 | } | |
| 45 | ||
| 46 | pu blic void setSftpSer vice(SftpS ervice sft pService) { | |
| 47 | this .sftpServi ce = sftpS ervice; | |
| 48 | } | |
| 49 | ||
| 50 | pu blic Strin g getStagi ngDirector y() { | |
| 51 | retu rn staging Directory; | |
| 52 | } | |
| 53 | ||
| 54 | pu blic void setStaging Directory( String sta gingDirect ory) { | |
| 55 | this .stagingDi rectory = stagingDir ectory; | |
| 56 | } | |
| 57 | ||
| 58 | @O verride | |
| 59 | pr otected bo olean exec uteLogic(C hunkContex t chunkCon text) { | |
| 60 | ||
| 61 | bool ean succes sful = tru e; | |
| 62 | ||
| 63 | task letLogger. info("File Cleanup T asklet Run ning!"); | |
| 64 | ||
| 65 | // D elete any files on t he target sftp serve r that mig ht be left over | |
| 66 | // f rom a prev iously fai led batch run. | |
| 67 | List <String> s erverFileL = sftpSer vice.ftpGe tFileListI nDirectory (serverTar getDirecto ry); | |
| 68 | ||
| 69 | if ( (serverFil eL != null ) && !serv erFileL.is Empty()) { | |
| 70 | ||
| 71 | // Loo p through and delete any old f iles. | |
| 72 | for (S tring temp File : ser verFileL) { | |
| 73 | if (temp File.toLow erCase().e ndsWith(te mpFilename Postfix)) { | |
| 74 | ||
| 75 | if (sftpSe rvice.ftpR emoveFileF romDirecto ry(tempFil e, serverT argetDirec tory)) { | |
| 76 | ta skletLogge r.warn("Cl eaning up old tempor ary file o n server: " + tempFi le); | |
| 77 | } else { | |
| 78 | su ccessful = false; | |
| 79 | ta skletLogge r.error("E rror clean ing up old temporary file on s erver: " + tempFile) ; | |
| 80 | } | |
| 81 | } | |
| 82 | } | |
| 83 | } | |
| 84 | ||
| 85 | // D elete any files on t he local t hat might be left ov er from a | |
| 86 | // p reviously failed bat ch run. | |
| 87 | File stagingFo lder = new File(stag ingDirecto ry); | |
| 88 | File [] tempFil eL = stagi ngFolder.l istFiles() ; | |
| 89 | if ( tempFileL == null) { | |
| 90 | taskle tLogger.er ror("Stagi ng Directo ry does no t exist or is not a folder:" + stagingDi rectory); | |
| 91 | succes sful = fal se; | |
| 92 | } el se { | |
| 93 | for (F ile tempFi le : tempF ileL) { | |
| 94 | if (temp File.isFil e()) { | |
| 95 | if (tempFi le.delete( )) { | |
| 96 | ta skletLogge r.warn("Cl eaning up old tempor ary file o n local: " + tempFil e.getAbsol utePath()) ; | |
| 97 | } else { | |
| 98 | su ccessful = false; | |
| 99 | ta skletLogge r.error("E rror clean ing up old temporary file on l ocal: " + tempFile.g etAbsolute Path()); | |
| 100 | } | |
| 101 | } | |
| 102 | } | |
| 103 | } | |
| 104 | ||
| 105 | // L og a messa ge but con tinue proc essing if unsuccessf ul. | |
| 106 | if ( successful ) { | |
| 107 | taskle tLogger.in fo("File C leanup was Successfu l"); | |
| 108 | } el se { | |
| 109 | taskle tLogger.er ror("File Cleanup Ta sklet Dete cted an Er ror but Pr ocessing w ill Contin ue"); | |
| 110 | } | |
| 111 | ||
| 112 | retu rn success ful; | |
| 113 | } | |
| 114 | ||
| 115 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.