Enumeration repoItems = repo.items();
while (repoItems.hasMoreElements()) {
RssChannelItem item = (RssChannelItem) repoItems.nextElement();
RssJbnPatch patch = item.getJbnPatch();
RssDublinCore dublinCore = item.getDublinCore();
// We need the data in these objects, so skip if either are null. I'm not sure this constitutes
// an error, but leaving the log message at warn for now.
if ((dublinCore == null) || (patch == null)) {
log.debug("Feed entry parsed data returned null. Skipping entry. Patch: " + patch
+ ", Dublin Core: " + dublinCore);
continue;
}
// If there are no products against which the software applies, punch out early
Collection products = patch.getProducts();
if ((products == null) || (products.size() == 0)) {
continue;
}
// First class properties
String packageName = dublinCore.getSubject();
String softwareType = patch.getType();
// Extra properties
String distributionStatus = patch.getDistributionStatus();
String jiraId = patch.getJira();
String downloadUrl = patch.getDownloadUrl();
String instructionCompatibilityVersion = patch.getInstructionCompatibilityVersion();
// If the distribution status indicates it's removed, don't do anything. Later in this method, if
// this package was known to the server, it will still be in the existing packages map and marked
// as deleted at the end. If the server didn't know about it, then nothing had to be done.
if (distributionStatus.equals(DIST_STATUS_REMOVED)) {
continue;
}
Configuration extraProperties = new Configuration();
extraProperties.put(new PropertySimple("jiraId", jiraId));
extraProperties.put(new PropertySimple("distributionStatus", distributionStatus));
extraProperties.put(new PropertySimple("downloadUrl", downloadUrl));
extraProperties.put(new PropertySimple("instructionCompatibilityVersion",
instructionCompatibilityVersion));
/* This will be refactored when we add support for the other types of data coming across in the feed,
such as product distributions and security/configuration advisories. For now, just leaving the
cumulative patch handling in here, but will clean up when the other types are supported.
jdobies, Jan 9, 2008
*/
// Technically, this is a check for installable patches. But for now, that's the same as a cumulative
// patch
if (softwareType.equals(RSS_SOFTWARE_TYPE_BUGFIX) && instructionCompatibilityVersion != null) {
String displayVersion = parseCumulativePatchVersion(packageName);
if (displayVersion == null) {
log.error("Could not parse version for package: " + packageName + ". Package skipped.");
continue;
}
if (patch.getSha256() == null) {
log.error("Could not parse SHA256 for package: " + packageName + ". Package skipped.");
continue;
}
String version = "[sha256=" + patch.getSha256() + "]";
ContentProviderPackageDetailsKey key = new ContentProviderPackageDetailsKey(packageName, version,
PACKAGE_TYPE_CUMULATIVE_PATCH, ARCHITECTURE, RESOURCE_TYPE_JBOSS_AS,
getPluginName(displayVersion));
// If this package is already known to the server, don't add it as a new package
// Remove from the map; entries still in the map will be returned as deleted packages
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()));