if (existingPackageMap.get(key) != null) {
existingPackageMap.remove(key);
continue;
}
ContentProviderPackageDetails packageDetails = new ContentProviderPackageDetails(key);
packageDetails.setClassification(softwareType);
packageDetails.setDisplayName(packageName);
packageDetails.setFileCreatedDate(dublinCore.getDate().getTime());
packageDetails.setFileName(patch.getFileName());
packageDetails.setFileSize(Long.parseLong(patch.getFileSize()));
packageDetails.setLicenseName(patch.getLicenseName());
packageDetails.setLicenseVersion(patch.getLicenseVersion());
packageDetails.setLocation(patch.getAutomatedDownloadUrl());
packageDetails.setMD5(patch.getMd5());
packageDetails.setSHA256(patch.getSha256());
packageDetails.setDisplayVersion(displayVersion);
packageDetails.setShortDescription(patch.getShortDescription());
packageDetails.setLongDescription(patch.getLongDescription());
if (patch.getAutomatedInstallation() != null) {
String instructions = patch.getAutomatedInstallation();
// JOPR-51, remove some of the xml elements which wrap the automated installation
// instructions but which aren't needed by JBPM
try {
Document document = builder.parse(new ByteArrayInputStream(instructions.getBytes()));
String choppedInstructions = xpath.evaluate(instructionExpression, document);
// The JBPM XML processor doesn't like whitespace at the beginning, so trim it.
// Bytes will be retrieved using platform encoding on the agent side, so use the same
// on the server side and assume they are identical.
packageDetails.setMetadata(choppedInstructions.trim().getBytes());
} catch (Exception e) {
log.error("Could not parse or set automated installation instructions for package: "
+ packageName);
continue;
}
}
packageDetails.setExtraProperties(extraProperties);
// For each product listed for the patch, add an entry for its resource version.
for (Object productObj : products) {
RssJbnDependency product = (RssJbnDependency) productObj;
// The CSP feed will include an optional JON version that maps up to how the resource
// version will be identified by RHQ. If this is specified, we'll want to use the mapped
// version instead.
String productVersion = product.getJonResourceVersion();
if (product.getProductVersion().equals("4.0.4")) {
productVersion = "4.0.4.GA";
}
if ((null == productVersion) || ("".equals(productVersion.trim()))) {
productVersion = product.getProductVersion();
}
packageDetails.addResourceVersion(productVersion);
}
report.addNewPackage(packageDetails);
}
}