private static Map < String , IFixInfo > processIFixXmls ( File wlpInstallationDirectory , Map < String , BundleFile > bundleFiles , CommandConsole console ) { // A map of update file names and the IfixInfo objects that contain the latest versions of these files. Map < String , IFixInfo > filteredIfixInfos = new HashMap < String , IFixInfo > ( ) ; // A map of updated file names and the UpdateFile Object that represents the latest version of the file. // We use this map so that we don't have to find the file in the ifix info object each time. Map < String , UpdatedFile > latestIfixFiles = new HashMap < String , UpdatedFile > ( ) ; // Get the full list of XML files Set < IFixInfo > ifixInfos = getInstalledIFixes ( wlpInstallationDirectory , console ) ; // Iterate over each one and process each file. for ( IFixInfo chkinfo : ifixInfos ) { // For each ifix, list all of the updated files for ( UpdatedFile updateFile : chkinfo . getUpdates ( ) . getFiles ( ) ) { // See if we have an existing entry in the map of existing files. If not, add this one to the map, otherwise // check to see if this file has a more recent date than the one stored. If it does, then // replace the existing one with this new entry. String existingUpdateFileID ; String updateId = updateFile . getId ( ) ; // If we have a jar file, then we need to find the existing id which won't be the same as our current one, because the ifix qualifiers are // different for each ifix jar. if ( bundleFiles . containsKey ( updateId ) ) { existingUpdateFileID = getExistingMatchingIfixID ( bundleFiles . get ( updateId ) , latestIfixFiles . keySet ( ) , bundleFiles ) ; } else { // If we're not a jar but a static file, then use the updateID to find the existing values. existingUpdateFileID = updateId ; } // If we've got an existing entry and the date of the currently processed updateFile has a greater date, // then remove the old version and replace it with the new one. UpdatedFile existingUpdateFile = latestIfixFiles . get ( existingUpdateFileID ) ; if ( existingUpdateFile != null ) { int dateComparison = updateFile . getDate ( ) . compareTo ( existingUpdateFile . getDate ( ) ) ; boolean replaceInMap = false ; if ( dateComparison > 0 ) replaceInMap = true ; else if ( dateComparison == 0 ) { //the same file had the same date in two fixes //check the number of problems being resolved IFixInfo existingFixInfo = filteredIfixInfos . get ( existingUpdateFileID ) ; List < Problem > existingProblems = existingFixInfo . getResolves ( ) . getProblems ( ) ; List < Problem > problems = chkinfo . getResolves ( ) . getProblems ( ) ; //since fixes are cumulative, whichever resolves more problems is newer if ( existingProblems . size ( ) < problems . size ( ) ) replaceInMap = true ; } if ( replaceInMap ) { filteredIfixInfos . remove ( existingUpdateFileID ) ; latestIfixFiles . remove ( existingUpdateFileID ) ; filteredIfixInfos . put ( updateId , chkinfo ) ; latestIfixFiles . put ( updateId , updateFile ) ; } } else { // If we don't have an existing entry, add this new entry. filteredIfixInfos . put ( updateId , chkinfo ) ; latestIfixFiles . put ( updateId , updateFile ) ; } } } return filteredIfixInfos ; }
This method processes all of the ifix xml s and stores the latest version of each file found in a map . The comparisons on each file are based on the date associated with the file . The latest date means the latest update .