public Set<Entitlement> listModifying(Entitlement entitlement) { Set<Entitlement> modifying = new HashSet<Entitlement>(); Consumer consumer = entitlement.getConsumer(); Date startDate = entitlement.getStartDate(); Date endDate = entitlement.getEndDate(); modifying.addAll(listModifying(consumer, entitlement.getProductId(), startDate, endDate)); for (ProvidedProduct product : entitlement.getPool().getProvidedProducts()) { modifying.addAll(listModifying(consumer, product.getProductId(), startDate, endDate)); } return modifying; }
/** * Checks if the given pool provides any product with a content set which modifies the given * product ID. * * @param ent Entitlement to check. * @param modifiedProductId Product ID we're looking for a modifier to. * @return true if entitlement modifies the given product */ public boolean modifies(Entitlement ent, String modifiedProductId) { Set<String> prodIdsToCheck = new HashSet<String>(); prodIdsToCheck.add(ent.getPool().getProductId()); for (ProvidedProduct pp : ent.getPool().getProvidedProducts()) { prodIdsToCheck.add(pp.getProductId()); } for (String prodId : prodIdsToCheck) { Product p = productAdapter.getProductById(prodId); if (null == p) { String msg = i18n.tr("No product found for product ID {0}", prodId); log.error("No product found for product id " + prodId); throw new CuratorException(msg); } else { if (p.modifies(modifiedProductId)) { return true; } } } return false; }