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;
}
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;
}
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;
}
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;
}
Aggregations