@Override public Entity update(PersistencePackage persistencePackage, DynamicEntityDao dynamicEntityDao, RecordHelper helper) throws ServiceException { Entity entity = persistencePackage.getEntity(); Customer customer = customerService.readCustomerByUsername(entity.findProperty("username").getValue()); if (StringUtils.isEmpty(customer.getEmailAddress())) { throw new ServiceException("Unable to update password because an email address is not available for this customer. An email address is required to send the customer the new system generated password."); } PasswordReset passwordReset = new PasswordReset(); passwordReset.setUsername(entity.findProperty("username").getValue()); passwordReset.setPasswordChangeRequired(false); passwordReset.setEmail(customer.getEmailAddress()); passwordReset.setPasswordLength(22); passwordReset.setSendResetEmailReliableAsync(false); customer = customerService.resetPassword(passwordReset); return entity; }
@Override public String getSiteMapFileName() { if (StringUtils.isEmpty(siteMapFileName)) { return DEFAULT_SITE_MAP_FILE_NAME; } else { return siteMapFileName; } }
@Override public String getIndexedSiteMapFileName() { if (StringUtils.isEmpty(indexedSiteMapFileName)) { return getSiteMapFileName(); } return indexedSiteMapFileName; }
@Override public String getSiteMapIndexFilePattern() { if (!StringUtils.isEmpty(indexedSiteMapFilePattern) && indexedSiteMapFilePattern.contains("###")) { return indexedSiteMapFilePattern; } String siteMapFileName = getSiteMapFileName(); int pos = siteMapFileName.indexOf(".xml"); if (pos > 0) { return siteMapFileName.substring(0, pos) + "###" + siteMapFileName.substring(pos); } else { return "sitemap###.xml"; } }
@Override public void addSiteMapEntries(SiteMapGeneratorConfiguration smgc, SiteMapBuilder siteMapBuilder) { int pageNum = 0; List<Product> products; do { products = productDao.readAllActiveProducts(pageNum++, pageSize); for (Product product : products) { if (StringUtils.isEmpty(product.getUrl())) { continue; } SiteMapURLWrapper siteMapUrl = new SiteMapURLWrapper(); // location siteMapUrl.setLoc(generateUri(siteMapBuilder, product)); // change frequency siteMapUrl.setChangeFreqType(smgc.getSiteMapChangeFreq()); // priority siteMapUrl.setPriorityType(smgc.getSiteMapPriority()); // lastModDate siteMapUrl.setLastModDate(generateDate(product)); siteMapBuilder.addUrl(siteMapUrl); } } while (products.size() == pageSize); }
protected void addCategorySiteMapEntries(Category parentCategory, int currentDepth, CategorySiteMapGeneratorConfiguration categorySMGC, SiteMapBuilder siteMapBuilder) { int rowOffset = 0; List<Category> categories; do { categories = categoryDao.readActiveSubCategoriesByCategory(parentCategory, rowLimit, rowOffset); rowOffset += categories.size(); for (Category category : categories) { if (StringUtils.isEmpty(category.getUrl())) { continue; } if (currentDepth < categorySMGC.getEndingDepth()) { addCategorySiteMapEntries(category, currentDepth + 1, categorySMGC, siteMapBuilder); } if (currentDepth < categorySMGC.getStartingDepth()) { continue; } SiteMapURLWrapper siteMapUrl = new SiteMapURLWrapper(); // location siteMapUrl.setLoc(generateUri(siteMapBuilder, category)); // change frequency siteMapUrl.setChangeFreqType(categorySMGC.getSiteMapChangeFreq()); // priority siteMapUrl.setPriorityType(categorySMGC.getSiteMapPriority()); // lastModDate siteMapUrl.setLastModDate(generateDate(category)); siteMapBuilder.addUrl(siteMapUrl); } } while (categories.size() == rowLimit); }
/** * Private method which executes the appliesToCustomerRules in the Offer to determine if this Offer * can be applied to the Customer. * * @param offer * @param customer * @return true if offer can be applied, otherwise false */ protected boolean couldOfferApplyToCustomer(Offer offer, Customer customer) { boolean appliesToCustomer = false; String rule = null; if (!StringUtils.isEmpty(offer.getAppliesToCustomerRules())) { rule = offer.getAppliesToCustomerRules(); } else { OfferRule customerRule = offer.getOfferMatchRules().get(OfferRuleType.CUSTOMER.getType()); if (customerRule != null) { rule = customerRule.getMatchRule(); } } if (rule != null) { HashMap<String, Object> vars = new HashMap<String, Object>(); vars.put("customer", customer); Boolean expressionOutcome = executeExpression(rule, vars); if (expressionOutcome != null && expressionOutcome) { appliesToCustomer = true; } } else { appliesToCustomer = true; } return appliesToCustomer; }