Source:
<code>public List<Entitlement> entitleByProducts(AutobindData data) throws EntitlementRefusedException { Consumer consumer = data.getConsumer(); String[] productIds = data.getProductIds(); Collection<String> fromPools = data.getPossiblePools(); Date entitleDate = data.getOnDate(); Owner owner = consumer.getOwner(); int retries = MAX_ENTITLE_RETRIES; while (true) { try { List<Entitlement> entitlements = new LinkedList<Entitlement>(); List<PoolQuantity> bestPools = new ArrayList<PoolQuantity>(); if (consumer != null && consumer.isDev() && !fromPools.isEmpty()) { String poolId = fromPools.iterator().next(); PoolQuantity pq = new PoolQuantity(poolCurator.find(poolId), 1); bestPools.add(pq); } else { bestPools = getBestPools(consumer, productIds, entitleDate, owner, null, fromPools); } if (bestPools == null) { List<String> fullList = new ArrayList<String>(); fullList.addAll(Arrays.asList(productIds)); for (ConsumerInstalledProduct cip : consumer.getInstalledProducts()) { fullList.add(cip.getId()); } log.info("No entitlements available for products: {}", fullList); return null; } return entitleByPools(consumer, convertToMap(bestPools)); } catch (EntitlementRefusedException e) { boolean retry = false; if (retries > 0) { for (String poolId : e.getResults().keySet()) { if (e.getResults().get(poolId).getErrors().size() == 1 && <START> e.getResults().get(poolId).getErrors().get(0).getResourceKey() <END> .equals("rulefailed.no.entitlements.available")) { retry = true; break; } } } if (retry) { log.info("Entitlements exhausted between select best pools and bind operations;" + " retrying"); retries--; continue; } throw e; } } }</code><technical_language>Please reformat this. hard read follow. create a temp variable hold errors. WhateverObject errors = e.getResults().get(poolId).getErrors(); if (errors.size() == 1 && errors.get(0).getResourceKey().equals(...)) { }</technical_language>

Target:
public List<Entitlement> entitleByProducts(AutobindData data) throws EntitlementRefusedException { Consumer consumer = data.getConsumer(); String[] productIds = data.getProductIds(); Collection<String> fromPools = data.getPossiblePools(); Date entitleDate = data.getOnDate(); Owner owner = consumer.getOwner(); int retries = MAX_ENTITLE_RETRIES; while (true) { try { List<PoolQuantity> bestPools = new ArrayList<PoolQuantity>(); if (consumer != null && consumer.isDev() && !fromPools.isEmpty()) { String poolId = fromPools.iterator().next(); PoolQuantity pq = new PoolQuantity(poolCurator.find(poolId), 1); bestPools.add(pq); } else { bestPools = getBestPools(consumer, productIds, entitleDate, owner, null, fromPools); } if (bestPools == null) { List<String> fullList = new ArrayList<String>(); fullList.addAll(Arrays.asList(productIds)); for (ConsumerInstalledProduct cip : consumer.getInstalledProducts()) { fullList.add(cip.getId()); } log.info("No entitlements available for products: {}", fullList); return null; } return entitleByPools(consumer, convertToMap(bestPools)); } catch (EntitlementRefusedException e) { boolean retry = false; if (retries > 0) { for (String poolId : e.getResults().keySet()) { List<ValidationError> errors = e.getResults().get(poolId).getErrors(); if (errors.size() == 1 && errors.get(0).getResourceKey() .equals("rulefailed.no.entitlements.available")) { retry = true; break; } } } if (retry) { log.info("Entitlements exhausted between select best pools and bind operations;" + " retrying"); retries--; continue; } throw e; } } }