} else {
condition = EntityCondition.makeCondition(EntityCondition.makeCondition("autoCreateKeywords", EntityOperator.EQUALS, null), EntityOperator.OR, EntityCondition.makeCondition("autoCreateKeywords", EntityOperator.NOT_EQUAL, "N"));
}
EntityListIterator entityListIterator = null;
int numProds = 0;
int errProds = 0;
boolean beganTx = false;
try {
// begin the transaction
beganTx = TransactionUtil.begin(7200);
try {
if (Debug.infoOn()) {
long count = delegator.findCountByCondition("Product", condition, null, null);
Debug.logInfo("========== Found " + count + " products to index ==========", module);
}
entityListIterator = delegator.find("Product", condition, null, null, null, null);
} catch (GenericEntityException gee) {
Debug.logWarning(gee, gee.getMessage(), module);
Map<String, String> messageMap = UtilMisc.toMap("gee", gee.toString());
errMsg = UtilProperties.getMessage(resource,"productevents.error_getting_product_list", messageMap, UtilHttp.getLocale(request));
request.setAttribute("_ERROR_MESSAGE_", errMsg);
throw gee;
}
GenericValue product;
while ((product = entityListIterator.next()) != null) {
try {
KeywordIndex.indexKeywords(product, "Y".equals(doAll));
} catch (GenericEntityException e) {
//errMsg = UtilProperties.getMessage(resource,"productevents.could_not_create_keywords_write", UtilHttp.getLocale(request));
//request.setAttribute("_ERROR_MESSAGE_", errMsg);
Debug.logWarning("[ProductEvents.updateAllKeywords] Could not create product-keyword (write error); message: " + e.getMessage(), module);
errProds++;
}
numProds++;
if (numProds % 500 == 0) {
Debug.logInfo("Keywords indexed for " + numProds + " so far", module);
}
}
} catch (GenericEntityException e) {
try {
TransactionUtil.rollback(beganTx, e.getMessage(), e);
} catch (Exception e1) {
Debug.logError(e1, module);
}
return "error";
} catch (Throwable t) {
Debug.logError(t, module);
request.setAttribute("_ERROR_MESSAGE_", t.getMessage());
try {
TransactionUtil.rollback(beganTx, t.getMessage(), t);
} catch (Exception e2) {
Debug.logError(e2, module);
}
return "error";
} finally {
if (entityListIterator != null) {
try {
entityListIterator.close();
} catch (GenericEntityException gee) {
Debug.logError(gee, "Error closing EntityListIterator when indexing product keywords.", module);
}
}