comments.add(new Comment(Rating.fromInt(new Integer(
commentElement.getAttribute("rating"))), commentElement
.getAttribute("comment"), dateFormat
.parse(commentElement.getAttribute("date"))));
}
final Bundle bundle = new Bundle(bundleElement.getAttribute("bsn"),
new Float(bundleElement.getAttribute("uaa-ranking")),
comments);
for (final Element versionElement : XmlUtils.findElements(
"versions/version", bundleElement)) {
if (bsn != null && bsn.length() > 0 && versionElement != null) {
String signedBy = "";
final String pgpKey = versionElement
.getAttribute("pgp-key-id");
if (pgpKey != null && pgpKey.length() > 0) {
final Element pgpSigned = XmlUtils.findFirstElement(
"/roobot/pgp-keys/pgp-key[@id='" + pgpKey
+ "']/pgp-key-description",
roobotXml.getDocumentElement());
if (pgpSigned != null) {
signedBy = pgpSigned.getAttribute("text");
}
}
final Map<String, String> commands = new HashMap<String, String>();
for (final Element shell : XmlUtils.findElements(
"shell-commands/shell-command", versionElement)) {
commands.put(shell.getAttribute("command"),
shell.getAttribute("help"));
}
final StringBuilder versionBuilder = new StringBuilder();
versionBuilder.append(versionElement.getAttribute("major"))
.append(".")
.append(versionElement.getAttribute("minor"));
final String versionMicro = versionElement
.getAttribute("micro");
if (versionMicro != null && versionMicro.length() > 0) {
versionBuilder.append(".").append(versionMicro);
}
final String versionQualifier = versionElement
.getAttribute("qualifier");
if (versionQualifier != null
&& versionQualifier.length() > 0) {
versionBuilder.append(".").append(versionQualifier);
}
String rooVersion = versionElement
.getAttribute("roo-version");
if (rooVersion.equals("*") || rooVersion.length() == 0) {
rooVersion = getVersionForCompatibility();
}
else {
final String[] split = rooVersion.split("\\.");
if (split.length > 2) {
// Only interested in major.minor
rooVersion = split[0] + "." + split[1];
}
}
final BundleVersion version = new BundleVersion(
versionElement.getAttribute("url"),
versionElement.getAttribute("obr-url"),
versionBuilder.toString(),
versionElement.getAttribute("name"),
new Long(versionElement.getAttribute("size"))
.longValue(),
versionElement.getAttribute("description"), pgpKey,
signedBy, rooVersion, commands);
// For security reasons we ONLY accept httppgp://
// add-on versions
if (!version.getUri().startsWith("httppgp://")) {
continue;
}
bundle.addVersion(version);
}
bundleCache.put(bsn, bundle);
}
}
}