Examples of BroadleafRequestContext


Examples of org.broadleafcommerce.common.web.BroadleafRequestContext

        return extractValueRequest.getMetadata().getFieldType() == SupportedFieldType.MONEY;
    }
   
    @Override
    protected Locale getLocale(ExtractValueRequest extractValueRequest, Property property) {
        BroadleafRequestContext brc = BroadleafRequestContext.getBroadleafRequestContext();
        return brc.getJavaLocale();
    }
View Full Code Here

Examples of org.broadleafcommerce.common.web.BroadleafRequestContext

                return Currency.getInstance(((CurrencyCodeIdentifiable) extractValueRequest.getEntity()).getCurrencyCode());
            } catch (Exception e) {
                //do nothing
            }
        }
        BroadleafRequestContext brc = BroadleafRequestContext.getBroadleafRequestContext();
        return brc.getJavaCurrency();
    }
View Full Code Here

Examples of org.broadleafcommerce.common.web.BroadleafRequestContext

        tabOrder = tabOrder == null ? DEFAULT_TAB_ORDER : tabOrder;
       
        // Tabs and groups should be looked up by their display, translated name since 2 unique strings can display the same
        // thing when they are looked up in message bundles after display
        // When displayed on the form the duplicate groups and tabs look funny
        BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
        if (context != null && context.getMessageSource() != null) {
            groupName = context.getMessageSource().getMessage(groupName, null, groupName, context.getJavaLocale());
            tabName = context.getMessageSource().getMessage(tabName, null, tabName, context.getJavaLocale());
        }
       
        Tab tab = findTab(tabName);
        if (tab == null) {
            tab = new Tab();
View Full Code Here

Examples of org.broadleafcommerce.common.web.BroadleafRequestContext

        fieldGroup.addField(field);
    }

    public void addListGrid(ListGrid listGrid, String tabName, Integer tabOrder) {
        // Tabs should be looked up and referenced by their display name
        BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
        if (context != null && context.getMessageSource() != null) {
            tabName = context.getMessageSource().getMessage(tabName, null, tabName, context.getJavaLocale());
        }
        Tab tab = findTab(tabName);
        if (tab == null) {
            tab = new Tab();
            tab.setTitle(tabName);
View Full Code Here

Examples of org.broadleafcommerce.common.web.BroadleafRequestContext

    @Resource(name = "blPageService")
    private PageService pageService;

    public String getRobotsFile(HttpServletRequest request, HttpServletResponse response) {
        BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();

        response.setContentType("text/plain");
        response.setCharacterEncoding("UTF-8");

        PageDTO page = pageService.findPageByURI(null,
View Full Code Here

Examples of org.broadleafcommerce.common.web.BroadleafRequestContext

    @Resource(name="blEntityExtensionManagers")
    protected Map<String, ExtensionManager<?>> entityExtensionManagers;

    @Override
    public void process(WebRequest request) throws SiteNotFoundException {
        BroadleafRequestContext brc = BroadleafRequestContext.getBroadleafRequestContext();
        if (brc == null) {
            brc = new BroadleafRequestContext();
            BroadleafRequestContext.setBroadleafRequestContext(brc);
        }
       
        brc.getAdditionalProperties().putAll(entityExtensionManagers);
       
        if (brc.getSite() == null) {
            Site site = siteResolver.resolveSite(request);
            brc.setSite(site);
        }
        brc.setWebRequest(request);
        brc.setIgnoreSite(brc.getSite() == null);
        brc.setAdmin(true);

        brc.getAdditionalProperties().put(ADMIN_ENFORCE_PRODUCTION_WORKFLOW_KEY, enforceProductionWorkflowUpdate);
       
        Locale locale = localeResolver.resolveLocale(request);
        brc.setLocale(locale);
       
        brc.setMessageSource(messageSource);
       
        TimeZone timeZone = broadleafTimeZoneResolver.resolveTimeZone(request);
        brc.setTimeZone(timeZone);

        BroadleafCurrency currency = currencyResolver.resolveCurrency(request);
        brc.setBroadleafCurrency(currency);

        prepareSandBox(request, brc);
    }
View Full Code Here

Examples of org.broadleafcommerce.common.web.BroadleafRequestContext

            }
        }

        if (!valid) {
            BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
            MessageSource messages = context.getMessageSource();

            FieldMetadata fmd = entityFieldMetadata.get(compareFieldName);
            String fieldName = messages.getMessage(fmd.getFriendlyName(), null, context.getJavaLocale());
            errorMessage = messages.getMessage("requiredIfValidationFailure",
                    new Object[] { fieldName, compareFieldProperty.getValue() },
                    context.getJavaLocale());
        }

        return new PropertyValidationResult(valid, errorMessage);
    }
View Full Code Here

Examples of org.broadleafcommerce.common.web.BroadleafRequestContext

        if (propertyMetadata.getLength() != null) {
            valid = StringUtils.length(value) <= propertyMetadata.getLength();
        }
       
        if (!valid) {
            BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
            MessageSource messages = context.getMessageSource();
            errorMessage = messages.getMessage("fieldLengthValidationFailure",
                    new Object[] {propertyMetadata.getLength(), StringUtils.length(value) },
                    context.getJavaLocale());
        }
       
        return new PropertyValidationResult(valid, errorMessage);
    }
View Full Code Here

Examples of org.broadleafcommerce.common.web.BroadleafRequestContext

    @Override
    public List<StructuredContentDTO> lookupStructuredContentItemsByType(StructuredContentType contentType, Locale locale,
                                                             Integer count, Map<String, Object> ruleDTOs, boolean secure) {
        List<StructuredContentDTO> contentDTOList = null;
        Locale languageOnlyLocale = findLanguageOnlyLocale(locale);
        BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
        String cacheKey = buildTypeKey(context.getSandBox(), languageOnlyLocale, contentType.getName());
        cacheKey = cacheKey+"-"+secure;
        if (context.isProductionSandBox()) {
            contentDTOList = getStructuredContentListFromCache(cacheKey);
        }
        if (contentDTOList == null) {
            List<StructuredContent> contentList = structuredContentDao.findActiveStructuredContentByType(contentType,
                    locale, languageOnlyLocale);
            contentDTOList = buildStructuredContentDTOList(contentList, secure);
            if (context.isProductionSandBox()) {
                addStructuredContentListToCache(cacheKey, contentDTOList);
            }
        }

        return evaluateAndPriortizeContent(contentDTOList, count, ruleDTOs);
View Full Code Here

Examples of org.broadleafcommerce.common.web.BroadleafRequestContext

    @Override
    public PageDTO findPageByURI(Locale locale, String uri, Map<String,Object> ruleDTOs, boolean secure) {
        List<PageDTO> returnList = null;
        if (uri != null) {
            Locale languageOnlyLocale = findLanguageOnlyLocale(locale);
            BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
            //store the language only locale for cache since we have to use the lowest common denominator (i.e. the cache
            //locale and the pageTemplate locale used for cache invalidation can be different countries)
            String key = buildKey(context.getSandBox(), languageOnlyLocale, uri);
            key = key + "-" + secure;
            if (context.isProductionSandBox()) {
                returnList = getPageListFromCache(key);
            }
            if (returnList == null) {
                //TODO does this pull the right sandbox in multitenant?
                List<Page> pageList = pageDao.findPageByURI(locale, languageOnlyLocale, uri);
                returnList = buildPageDTOList(pageList, secure);
                if (context.isProductionSandBox()) {
                    Collections.sort(returnList, new BeanComparator("priority"));
                    addPageListToCache(returnList, key);
                }
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.