use of org.broadleafcommerce.common.page.dto.PageDTO in project BroadleafCommerce by BroadleafCommerce.
the class PageServiceImpl method buildPageDTOListUsingCache.
@SuppressWarnings("unchecked")
protected List<PageDTO> buildPageDTOListUsingCache(List<Page> pageList, String identifier, Locale locale, boolean secure) {
List<PageDTO> dtoList = getCachedPageDTOList(pageList, identifier, locale, secure);
if (dtoList == null || dtoList.isEmpty()) {
addPageListToPageDTOList(pageList, secure, dtoList);
if (dtoList != null && !dtoList.isEmpty()) {
Collections.sort(dtoList, new BeanComparator("priority"));
addPageListToCache(dtoList, identifier, locale, secure);
}
}
return dtoList;
}
use of org.broadleafcommerce.common.page.dto.PageDTO in project BroadleafCommerce by BroadleafCommerce.
the class PageServiceImpl method buildPageDTOList.
/*
* Converts a list of pages to a list of pageDTOs, and caches the list.
*/
@Override
public List<PageDTO> buildPageDTOList(List<Page> pageList, boolean secure, String identifier, Locale locale) {
List<PageDTO> dtoList = new ArrayList<>();
BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
if (context.isProductionSandBox()) {
dtoList = buildPageDTOListUsingCache(pageList, identifier, locale, secure);
} else {
// no caching actions needed if not production sandbox
addPageListToPageDTOList(pageList, secure, dtoList);
}
return copyDTOList(dtoList);
}
use of org.broadleafcommerce.common.page.dto.PageDTO in project BroadleafCommerce by BroadleafCommerce.
the class PageServiceUtility method hydrateForeignLookups.
public PageDTO hydrateForeignLookups(PageDTO page) {
for (Entry<String, Object> entry : page.getPageFields().entrySet()) {
if (entry.getValue() instanceof String && ((String) entry.getValue()).startsWith(FOREIGN_LOOKUP)) {
page.getForeignPageFields().put(entry.getKey(), entry.getValue());
}
}
if (page.getForeignPageFields().size() > 0) {
PageDTO clone = new PageDTO();
clone.copy(page);
for (Entry<String, Object> entry : page.getForeignPageFields().entrySet()) {
String clazz = ((String) entry.getValue()).split("\\|")[1];
String id = ((String) entry.getValue()).split("\\|")[2];
Object newValue = null;
if (StringUtils.isNotBlank(clazz) && StringUtils.isNotBlank(id) && !"null".equals(id)) {
newValue = genericDao.readGenericEntity(genericDao.getImplClass(clazz), id);
}
if (newValue != null) {
clone.getPageFields().put(entry.getKey(), newValue);
} else {
clone.getPageFields().remove(entry.getKey());
}
}
return clone;
} else {
return page;
}
}
use of org.broadleafcommerce.common.page.dto.PageDTO in project BroadleafCommerce by BroadleafCommerce.
the class PageServiceUtility method buildPageDTO.
public PageDTO buildPageDTO(Page page, boolean secure) {
PageDTO pageDTO = new PageDTO();
pageDTO.setId(page.getId());
pageDTO.setDescription(page.getDescription());
pageDTO.setUrl(page.getFullUrl());
pageDTO.setPriority(page.getPriority());
if (page.getPageTemplate() != null) {
pageDTO.setTemplatePath(page.getPageTemplate().getTemplatePath());
if (page.getPageTemplate().getLocale() != null) {
pageDTO.setLocaleCode(page.getPageTemplate().getLocale().getLocaleCode());
}
}
for (String fieldKey : page.getPageFields().keySet()) {
addPageFieldToDTO(page, secure, pageDTO, fieldKey);
}
pageDTO.setRuleExpression(buildRuleExpression(page));
if (page.getQualifyingItemCriteria() != null && page.getQualifyingItemCriteria().size() > 0) {
pageDTO.setItemCriteriaDTOList(buildItemCriteriaDTOList(page));
}
for (Entry<String, PageAttribute> entry : page.getAdditionalAttributes().entrySet()) {
pageDTO.getPageAttributes().put(entry.getKey(), entry.getValue().getValue());
}
pageDTO.getPageAttributes().put("title", page.getMetaTitle());
pageDTO.getPageAttributes().put("metaDescription", page.getMetaDescription());
return pageDTO;
}
use of org.broadleafcommerce.common.page.dto.PageDTO in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafRobotsController method getRobotsFile.
public String getRobotsFile(HttpServletRequest request, HttpServletResponse response) {
blcContextUtil.establishThinRequestContext();
response.setContentType("text/plain");
response.setCharacterEncoding("UTF-8");
PageDTO page = pageService.findPageByURI(null, "/robots.txt", buildMvelParameters(request), isSecure(request));
if (page != null && page.getPageFields().containsKey("body")) {
String body = (String) page.getPageFields().get("body");
body = body.replace("${siteBaseUrl}", baseUrlResolver.getSiteBaseUrl());
return body;
} else {
return getDefaultRobotsTxt();
}
}
Aggregations