Search in sources :

Example 6 with RequestDTO

use of org.broadleafcommerce.common.RequestDTO in project BroadleafCommerce by BroadleafCommerce.

the class BroadleafRobotsController method buildMvelParameters.

/**
 * @param request
 * @return
 */
private Map<String, Object> buildMvelParameters(HttpServletRequest request) {
    TimeDTO timeDto = new TimeDTO(SystemTime.asCalendar());
    RequestDTO requestDto = (RequestDTO) request.getAttribute(REQUEST_DTO);
    Map<String, Object> mvelParameters = new HashMap<String, Object>();
    mvelParameters.put("time", timeDto);
    mvelParameters.put("request", requestDto);
    Map<String, Object> blcRuleMap = (Map<String, Object>) request.getAttribute(BLC_RULE_MAP_PARAM);
    if (blcRuleMap != null) {
        for (String mapKey : blcRuleMap.keySet()) {
            mvelParameters.put(mapKey, blcRuleMap.get(mapKey));
        }
    }
    return mvelParameters;
}
Also used : TimeDTO(org.broadleafcommerce.common.TimeDTO) HashMap(java.util.HashMap) RequestDTO(org.broadleafcommerce.common.RequestDTO) HashMap(java.util.HashMap) Map(java.util.Map)

Example 7 with RequestDTO

use of org.broadleafcommerce.common.RequestDTO in project BroadleafCommerce by BroadleafCommerce.

the class ContentProcessor method buildMvelParameters.

/**
 * MVEL is used to process the content targeting rules.
 *
 * @param request
 * @return
 */
protected Map<String, Object> buildMvelParameters(HttpServletRequest request, Map<String, String> tagAttributes, BroadleafTemplateContext context) {
    TimeZone timeZone = BroadleafRequestContext.getBroadleafRequestContext().getTimeZone();
    final TimeDTO timeDto;
    if (timeZone != null) {
        timeDto = new TimeDTO(SystemTime.asCalendar(timeZone));
    } else {
        timeDto = new TimeDTO();
    }
    RequestDTO requestDto = (RequestDTO) request.getAttribute(REQUEST_DTO);
    Map<String, Object> mvelParameters = new HashMap<>();
    mvelParameters.put("time", timeDto);
    mvelParameters.put("request", requestDto);
    String productString = tagAttributes.get("product");
    if (productString != null) {
        Object product = context.parseExpression(productString);
        if (product != null) {
            mvelParameters.put("product", product);
        }
    }
    String categoryString = tagAttributes.get("category");
    if (categoryString != null) {
        Object category = context.parseExpression(categoryString);
        if (category != null) {
            mvelParameters.put("category", category);
        }
    }
    @SuppressWarnings("unchecked") Map<String, Object> blcRuleMap = (Map<String, Object>) request.getAttribute(BLC_RULE_MAP_PARAM);
    if (blcRuleMap != null) {
        for (String mapKey : blcRuleMap.keySet()) {
            mvelParameters.put(mapKey, blcRuleMap.get(mapKey));
        }
    }
    return mvelParameters;
}
Also used : TimeZone(java.util.TimeZone) TimeDTO(org.broadleafcommerce.common.TimeDTO) HashMap(java.util.HashMap) RequestDTO(org.broadleafcommerce.common.RequestDTO) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

RequestDTO (org.broadleafcommerce.common.RequestDTO)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 TimeDTO (org.broadleafcommerce.common.TimeDTO)4 TimeZone (java.util.TimeZone)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 RequestDTOImpl (org.broadleafcommerce.common.RequestDTOImpl)2 BroadleafRequestContext (org.broadleafcommerce.common.web.BroadleafRequestContext)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 BroadleafRequestedCurrencyDto (org.broadleafcommerce.common.currency.domain.BroadleafRequestedCurrencyDto)1 Locale (org.broadleafcommerce.common.locale.domain.Locale)1 SandBox (org.broadleafcommerce.common.sandbox.domain.SandBox)1 Site (org.broadleafcommerce.common.site.domain.Site)1 Theme (org.broadleafcommerce.common.site.domain.Theme)1 EfficientLRUMap (org.broadleafcommerce.common.util.EfficientLRUMap)1 HaltFilterChainException (org.broadleafcommerce.common.web.exception.HaltFilterChainException)1 Offer (org.broadleafcommerce.core.offer.domain.Offer)1 ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)1