4346. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/9/2017 3:51:30 PM Eastern 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.

4346.1 Files compared

# Location File Last Modified
1 Fri Jun 9 19:51:30 2017 UTC
2 eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-web\src\main\java\gov\va\nvap\web\util\xls ScheduledExports.java Fri Apr 21 20:15:58 2017 UTC

4346.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 1 148
Removed 0 0

4346.3 Comparison options

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

4346.4 Active regular expressions

No regular expressions were active.

4346.5 Comparison detail

        1   package go v.va.nvap. web.util.x ls;
        2  
        3   import gov .va.nvap.c ommon.vali dation.Ass ert;
        4   import gov .va.nvap.c ommon.vali dation.Nul lChecker;
        5   import gov .va.nvap.w eb.dao.Use rDocumentD AO;
        6   import gov .va.nvap.w eb.user.Us erHelper;
        7   import gov .va.nvap.w eb.user.do cument.Use rDocument;
        8  
        9   import jav a.io.IOExc eption;
        10   import jav a.io.Strin gWriter;
        11   import jav a.text.Par seExceptio n;
        12   import jav a.text.Sim pleDateFor mat;
        13   import jav a.util.Arr ayList;
        14   import jav a.util.Col lection;
        15   import jav a.util.Dat e;
        16   import jav a.util.Has hMap;
        17   import jav a.util.Lis t;
        18   import jav a.util.log ging.Level ;
        19   import jav a.util.log ging.Logge r;
        20   import jav ax.servlet .ServletEx ception;
        21   import jav ax.servlet .ServletOu tputStream ;
        22   import jav ax.servlet .http.Http ServletReq uest;
        23   import jav ax.servlet .http.Http ServletRes ponse;
        24   import jav ax.servlet .http.Http Session;
        25   import org .json.JSON Exception;
        26   import org .json.JSON Object;
        27  
        28   /**
        29    *
        30    * @author  Zachary T ubb
        31    */
        32   public cla ss Schedul edExports  extends go v.va.nvap. web.app.Re sponseDisp atcherHttp Servlet {
        33  
        34       privat e final Si mpleDateFo rmat df =  new Simple DateFormat ("yyyyMMdd _hhmmss");
        35  
        36       privat e String e ncodeToJSO N(HashMap  results, S tring draw ) throws P arseExcept ion {
        37           tr y {
        38                StringWr iter json  = new Stri ngWriter() ;
        39                JSONObje ct obj = n ew JSONObj ect();
        40                List<Lis t> data =  new ArrayL ist<List>( ); //overa rching "da ta"
        41                SimpleDa teFormat d t = new Si mpleDateFo rmat("yyyy -MM-dd kk: mm:ss.S");
        42                SimpleDa teFormat f inalDate =  new Simpl eDateForma t("MM/dd/y yyy hh:mm  a");
        43                List<Use rDocument>  documents  = (List<U serDocumen t>) result s.get("res ults");
        44                Long cou nt = (Long ) results. get("count ");
        45  
        46                for (Use rDocument  doc : docu ments) {
        47                    List <String> d ataItem =  new ArrayL ist<String >();
        48                    data Item.add(d oc.getTitl e());
        49                    data Item.add(d oc.getForm at());
        50                    Date  date = dt .parse(doc .getCreati onDate().t oString()) ;
        51                    data Item.add(f inalDate.f ormat(date ));
        52                    data Item.add(d oc.getStat us());
        53                    if ( doc.getSta tus() != n ull && doc .getStatus ().equals( "COMPLETED ")) {
        54                         dataItem.a dd("<a hre f='Schedul edExports. do_sec?get Export=tru e&docId="  + doc.getD ocumentId( ).toString ()
        55                             + "'>< button tit le='Downlo ad' class= 'btn btn-p rimary btn -xs'><span  class='fa  fa-downlo ad pad-rig ht-5' aria -hidden='t rue'></spa n>Download </button>< /a>");
        56                    } el se {
        57                         dataItem.a dd("&nbsp; "); //add  in a non-b reaking sp ace if it' s not comp leted yet  so the vie w doesn't  show "null "
        58                    }
        59                    data .add(dataI tem);
        60                }
        61                //Add in  required  Datables v alues
        62                obj.put( "draw", dr aw);
        63                obj.put( "recordsFi ltered", c ount);
        64                obj.put( "recordsTo tal", coun t);
        65                obj.put( "data", da ta);
        66  
        67                obj.writ e(json);
        68  
        69                return j son.toStri ng();
        70           }  catch (JSO NException  ex) {
        71                Logger.g etLogger(S cheduledEx ports.clas s.getName( )).log(Lev el.SEVERE,  null, ex) ;
        72           }
        73           re turn "";
        74       }
        75  
        76       privat e UserDocu mentDAO ge tUserDocum entDAO() {
        77           re turn this. getBean("U serDocumen tDAO", Use rDocumentD AO.class);
        78       }
        79  
        80       //Meth od to retr eive sched uled expor t from the  database  for downlo ad.
        81       public  void getE xport(Http ServletReq uest reque st, HttpSe rvletRespo nse respon se) throws  ServletEx ception {
        82           Lo ng docId =  Long.pars eLong(requ est.getPar ameter("do cId"));
        83           if  (!NullChe cker.isNul lOrEmpty(d ocId)) {
        84                //Get th e document  from usin g the DAO.
        85                UserDocu ment docum ent = this .getUserDo cumentDAO( ).findUser Document(d ocId);
        86                String d ate = df.f ormat(new  Date());
        87  
        88                if (!Nul lChecker.i sNullOrEmp ty(documen t)) {
        89                    //Co nvert to b ytes for o utput stre am.
        90                    byte [] wbBytes  = (byte[] ) document .getConten t();
        91  
        92                    //Se t response  attribute s.
        93                    swit ch (docume nt.getForm at()) {
        94                         case "Exce l":
        95                             respon se.setCont entType("a pplication /vnd.ms-ex cel");
        96                             respon se.setHead er("Conten t-Disposit ion",
        97                                      "attachm ent; filen ame=\"" +  document.g etTitle(). replaceAll (" ", "_")  + "_" + d ate + ".xl s" + "\"") ;
        98                             respon se.setHead er("Cache- Control",  "must-reva lidate");
        99                             break;
        100                         case "CSV" :
        101                             respon se.setCont entType("t ext/csv");
        102                             respon se.setHead er("Conten t-Disposit ion",
        103                                      "attachm ent; filen ame=\"" +  document.g etTitle(). replaceAll (" ", "_")  + "_" + d ate + ".cs v" + "\"") ;
        104                             respon se.setHead er("Cache- Control",  "must-reva lidate");
        105                             break;
        106                    }
        107  
        108                    try  {
        109                         //Write to  output st ream.
        110                         final Serv letOutputS tream os =  response. getOutputS tream();
        111                         Assert.ass ertNotEmpt y(os, "Out put Stream  cannot be  null!");
        112                         os.write(w bBytes);
        113                         try {
        114                             os.clo se();
        115                         }
        116                         catch (fin al IOExcep tion ex) {
        117                         }
        118                    } ca tch (final  IOExcepti on ex) {
        119                         throw new  ServletExc eption(ex) ;
        120                    }
        121                }
        122           }
        123       }
        124  
        125       public  void getU serExports (HttpServl etRequest  request, H ttpServlet Response r esponse) t hrows IOEx ception, S ervletExce ption, Par seExceptio n {
        126           // Get parama ters from  Datables r equest
        127           fi nal HttpSe ssion sess ion = requ est.getSes sion(false );
        128           fi nal String  maxRows =  request.g etParamete r("length" );
        129           fi nal String  startRow  = request. getParamet er("start" );
        130           fi nal String  draw = (S tring)requ est.getPar ameter("dr aw");
        131           fi nal String  sortBy =  request.ge tParameter ("order[0] [column]") ;
        132           fi nal String  sortOrder  = request .getParame ter("order [0][dir]") ;
        133  
        134           // Get the ex ports with  the param eters from  Datables
        135           Ha shMap hm =  this.getU serDocumen tDAO().fin dByUserId( UserHelper .getUserNa me(request ), sortBy,  sortOrder , Integer. parseInt(m axRows), I nteger.par seInt(star tRow));
        136  
        137           se ssion.setA ttribute(" results",  encodeToJS ON(hm, dra w));
        138  
        139           th is.forward (request,  response,  "resultsJS ON");
        140       }
        141  
        142       @Overr ide
        143       protec ted void u nspecified (HttpServl etRequest  request, H ttpServlet Response r esponse) t hrows IOEx ception, S ervletExce ption {
        144           th is.forward (request,  response,  "show");
        145       }
        146  
        147   }
        148