// Return only the contents that are arch appropriate
Set<ProductContent> archApproriateProductContent = filterContentByContentArch(
productContent, consumer, product);
for (ProductContent pc : archApproriateProductContent) {
Content content = new Content();
if (enableEnvironmentFiltering) {
if (consumer.getEnvironment() != null && !promotedContent.containsKey(
pc.getContent().getId())) {
log.debug("Skipping content not promoted to environment: " +
pc.getContent().getId());
continue;
}
}
// Augment the content path with the prefix if it is passed in
String contentPath = this.createFullContentPath(contentPrefix, pc);
content.setId(pc.getContent().getId());
content.setType(pc.getContent().getType());
content.setName(pc.getContent().getName());
content.setLabel(pc.getContent().getLabel());
content.setVendor(pc.getContent().getVendor());
content.setPath(contentPath);
content.setGpgUrl(pc.getContent().getGpgUrl());
// Set content model's arches here, inheriting from the product if
// they are not set on the content.
List<String> archesList = new ArrayList<String>();
Set<String> contentArches = Arch.parseArches(pc.getContent()
.getArches());
if (contentArches.isEmpty()) {
archesList.addAll(Arch.parseArches(product
.getAttributeValue(PRODUCT_ARCH_ATTR)));
}
else {
archesList
.addAll(Arch.parseArches(pc.getContent().getArches()));
}
content.setArches(archesList);
// Check if we should override the enabled flag due to setting on promoted
// content
Boolean enabled = pc.getEnabled();
if ((consumer.getEnvironment() != null) && enableEnvironmentFiltering) {
// we know content has been promoted at this point
Boolean enabledOverride = promotedContent.get(
pc.getContent().getId()).getEnabled();
if (enabledOverride != null) {
log.debug("overriding enabled flag: " + enabledOverride);
enabled = enabledOverride;
}
}
// only included if not the default value of true
if (!enabled) {
content.setEnabled(enabled);
}
// Include metadata expiry if specified on the content
if (pc.getContent().getMetadataExpire() != null) {
content.setMetadataExpire(pc.getContent().getMetadataExpire());
}
// Include required tags if specified on the content set
String requiredTags = pc.getContent().getRequiredTags();
if ((requiredTags != null) && !requiredTags.equals("")) {
StringTokenizer st = new StringTokenizer(requiredTags, ",");
List<String> tagList = new ArrayList<String>();
while (st.hasMoreElements()) {
tagList.add((String) st.nextElement());
}
content.setRequiredTags(tagList);
}
toReturn.add(content);
}
return toReturn;
}