/** * Add erratum to repodata for given channel * * @param erratum erratum to be added * @param channel channel info * @throws SAXException */ private void addErratum(Errata erratum, Channel channel) throws SAXException { SimpleAttributesImpl attr = new SimpleAttributesImpl(); attr.addAttribute("from", "*****@*****.**"); attr.addAttribute("status", "final"); attr.addAttribute("type", mapAdvisoryType(erratum.getAdvisoryType())); attr.addAttribute("version", Long.toString(erratum.getAdvisoryRel())); handler.startElement("update", attr); handler.addElementWithCharacters("id", sanitize(0, erratum.getAdvisoryName())); handler.addElementWithCharacters("title", sanitize(0, erratum.getSynopsis())); DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); attr.clear(); attr.addAttribute("date", df.format(erratum.getIssueDate())); handler.startElement("issued", attr); handler.endElement("issued"); attr.clear(); attr.addAttribute("date", df.format(erratum.getUpdateDate())); handler.startElement("updated", attr); handler.endElement("updated"); handler.addElementWithCharacters("description", sanitize(0, erratum.getDescription())); addErratumReferences(erratum); addErratumPkgList(erratum, channel); handler.endElement("update"); }
/** * Adds packages associated to the errata * * @param erratum erratum to be added * @param channel channel info * @throws SAXException */ private void addErratumPkgList(Errata erratum, Channel channel) throws SAXException { handler.startElement("pkglist"); SimpleAttributesImpl attr = new SimpleAttributesImpl(); attr.addAttribute("short", channel.getLabel()); handler.startElement("collection", attr); handler.addElementWithCharacters("name", channel.getName()); Iterator iter = erratum.getPackages().iterator(); while (iter.hasNext()) { Package pkg = (Package) iter.next(); if (channel.getPackages().contains(pkg)) { long pkgId = pkg.getId(); String epoch = pkg.getPackageEvr().getEpoch(); if (epoch == null || epoch.length() == 0) { epoch = "0"; } attr.clear(); attr.addAttribute("name", sanitize(pkgId, pkg.getPackageName().getName())); attr.addAttribute("version", sanitize(pkgId, pkg.getPackageEvr().getVersion())); attr.addAttribute("release", sanitize(pkgId, pkg.getPackageEvr().getRelease())); attr.addAttribute("epoch", sanitize(pkgId, epoch)); attr.addAttribute("arch", sanitize(pkgId, pkg.getPackageArch().getLabel())); attr.addAttribute("src", sanitize(pkgId, pkg.getSourceRpm().getName())); handler.startElement("package", attr); handler.addElementWithCharacters("filename", sanitize(pkgId, pkg.getFilename())); attr.clear(); attr.addAttribute("type", sanitize(pkgId, pkg.getChecksum().getChecksumType().getLabel())); handler.startElement("sum", attr); handler.addCharacters(sanitize(pkgId, pkg.getChecksum().getChecksum())); handler.endElement("sum"); handler.endElement("package"); } } handler.endElement("collection"); handler.endElement("pkglist"); }
/** * @param handler content handler * @param pkgDto package info dto object * @throws SAXException */ protected static void addPackageBoilerplate(SimpleContentHandler handler, PackageDto pkgDto) throws SAXException { long pkgId = pkgDto.getId().longValue(); SimpleAttributesImpl attr = new SimpleAttributesImpl(); attr.addAttribute("pkgid", sanitize(pkgId, pkgDto.getChecksum())); attr.addAttribute("name", sanitize(pkgId, pkgDto.getName())); attr.addAttribute("arch", sanitize(pkgId, pkgDto.getArchLabel())); handler.startElement("package", attr); attr.clear(); attr.addAttribute("ver", sanitize(pkgId, pkgDto.getVersion())); attr.addAttribute("rel", sanitize(pkgId, pkgDto.getRelease())); attr.addAttribute("epoch", sanitize(pkgId, getPackageEpoch(pkgDto.getEpoch()))); handler.startElement("version", attr); handler.endElement("version"); }