Search in sources :

Example 6 with PageDTO

use of org.broadleafcommerce.common.page.dto.PageDTO in project BroadleafCommerce by BroadleafCommerce.

the class PageHandlerMapping method getHandlerInternal.

@Override
protected Object getHandlerInternal(HttpServletRequest request) throws Exception {
    BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
    if (context != null && context.getRequestURIWithoutContext() != null) {
        String requestUri = URLDecoder.decode(context.getRequestURIWithoutContext(), charEncoding);
        Boolean internalValidateFindPreviouslySet = false;
        PageDTO page;
        try {
            if (!BroadleafRequestContext.getBroadleafRequestContext().getInternalValidateFind()) {
                BroadleafRequestContext.getBroadleafRequestContext().setInternalValidateFind(true);
                internalValidateFindPreviouslySet = true;
            }
            page = pageService.findPageByURI(context.getLocale(), requestUri, buildMvelParameters(request), context.isSecure());
        } finally {
            if (internalValidateFindPreviouslySet) {
                BroadleafRequestContext.getBroadleafRequestContext().setInternalValidateFind(false);
            }
        }
        if (page != null && !(page instanceof NullPageDTO)) {
            context.getRequest().setAttribute(PAGE_ATTRIBUTE_NAME, page);
            return controllerName;
        }
    }
    return null;
}
Also used : NullPageDTO(org.broadleafcommerce.common.page.dto.NullPageDTO) PageDTO(org.broadleafcommerce.common.page.dto.PageDTO) BroadleafRequestContext(org.broadleafcommerce.common.web.BroadleafRequestContext) NullPageDTO(org.broadleafcommerce.common.page.dto.NullPageDTO)

Example 7 with PageDTO

use of org.broadleafcommerce.common.page.dto.PageDTO in project BroadleafCommerce by BroadleafCommerce.

the class BroadleafPageController method handleRequest.

@Override
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    ModelAndView model = new ModelAndView();
    PageDTO page = (PageDTO) request.getAttribute(PageHandlerMapping.PAGE_ATTRIBUTE_NAME);
    assert page != null;
    model.addObject(MODEL_ATTRIBUTE_NAME, page);
    // For convenience
    model.addObject("pageFields", page.getPageFields());
    model.addObject("BLC_PAGE_TYPE", "page");
    String plainTextStr = (String) page.getPageFields().get("plainText");
    if (!StringUtils.isEmpty(plainTextStr)) {
        if (Boolean.valueOf(plainTextStr)) {
            response.setCharacterEncoding("UTF-8");
            response.setContentType("text/plain");
        }
    }
    String templatePath = page.getTemplatePath();
    // Allow extension managers to override the path.
    ExtensionResultHolder<String> erh = new ExtensionResultHolder<String>();
    Boolean internalValidateFindPreviouslySet = false;
    ExtensionResultStatusType extResult;
    try {
        if (!BroadleafRequestContext.getBroadleafRequestContext().getInternalValidateFind()) {
            BroadleafRequestContext.getBroadleafRequestContext().setInternalValidateFind(true);
            internalValidateFindPreviouslySet = true;
        }
        extResult = templateOverrideManager.getProxy().getOverrideTemplate(erh, page);
    } finally {
        if (internalValidateFindPreviouslySet) {
            BroadleafRequestContext.getBroadleafRequestContext().setInternalValidateFind(false);
        }
    }
    if (extResult != ExtensionResultStatusType.NOT_HANDLED) {
        templatePath = erh.getResult();
    }
    model.setViewName(templatePath);
    addDeepLink(model, deepLinkService, page);
    return model;
}
Also used : PageDTO(org.broadleafcommerce.common.page.dto.PageDTO) ModelAndView(org.springframework.web.servlet.ModelAndView) ExtensionResultStatusType(org.broadleafcommerce.common.extension.ExtensionResultStatusType) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Example 8 with PageDTO

use of org.broadleafcommerce.common.page.dto.PageDTO in project BroadleafCommerce by BroadleafCommerce.

the class PageServiceImpl method findPageByURI.

/*
     * Retrieve the page if one is available for the passed in uri.
     */
@Override
public PageDTO findPageByURI(Locale locale, String uri, Map<String, Object> ruleDTOs, boolean secure) {
    final List<PageDTO> returnList = getPageDTOListForURI(locale, uri, secure);
    PageDTO dto = evaluatePageRules(returnList, locale, ruleDTOs);
    if (dto.getId() != null) {
        final Page page = findPageById(dto.getId());
        final ExtensionResultHolder<PageDTO> newDTO = new ExtensionResultHolder<>();
        // Allow an extension point to override the page to render.
        extensionManager.getProxy().overridePageDto(newDTO, dto, page);
        if (newDTO.getResult() != null) {
            dto = newDTO.getResult();
        }
    }
    if (dto != null) {
        dto = pageServiceUtility.hydrateForeignLookups(dto);
    }
    return dto;
}
Also used : NullPageDTO(org.broadleafcommerce.common.page.dto.NullPageDTO) PageDTO(org.broadleafcommerce.common.page.dto.PageDTO) Page(org.broadleafcommerce.cms.page.domain.Page) ExtensionResultHolder(org.broadleafcommerce.common.extension.ExtensionResultHolder)

Example 9 with PageDTO

use of org.broadleafcommerce.common.page.dto.PageDTO in project BroadleafCommerce by BroadleafCommerce.

the class PageServiceImpl method copyDTOList.

/*
     * Because everything is passed by reference in java, and we don't want the cached list to be modified when the
     * returned list is.
     */
protected List<PageDTO> copyDTOList(List<PageDTO> dtoList) {
    List<PageDTO> dtoListCopy = new ArrayList<>();
    for (PageDTO dto : dtoList) {
        PageDTO dtoCopy = new PageDTO();
        dtoCopy.copy(dto);
        dtoListCopy.add(dtoCopy);
    }
    return dtoListCopy;
}
Also used : NullPageDTO(org.broadleafcommerce.common.page.dto.NullPageDTO) PageDTO(org.broadleafcommerce.common.page.dto.PageDTO) ArrayList(java.util.ArrayList)

Aggregations

PageDTO (org.broadleafcommerce.common.page.dto.PageDTO)9 NullPageDTO (org.broadleafcommerce.common.page.dto.NullPageDTO)5 ArrayList (java.util.ArrayList)2 ExtensionResultHolder (org.broadleafcommerce.common.extension.ExtensionResultHolder)2 BroadleafRequestContext (org.broadleafcommerce.common.web.BroadleafRequestContext)2 BeanComparator (org.apache.commons.beanutils.BeanComparator)1 Page (org.broadleafcommerce.cms.page.domain.Page)1 PageAttribute (org.broadleafcommerce.cms.page.domain.PageAttribute)1 ExtensionResultStatusType (org.broadleafcommerce.common.extension.ExtensionResultStatusType)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1