String cacheKey, Map<String, Serializable> moduleParams, String areaIdentifier) {
// if missing data call RenderService after creating the right resource
final CacheKeyGenerator cacheKeyGenerator = cacheProvider.getKeyGenerator();
try {
Map<String, String> keyAttrbs = cacheKeyGenerator.parse(cacheKey);
JCRSessionWrapper currentUserSession = JCRSessionFactory.getInstance().getCurrentUserSession(keyAttrbs.get(
"workspace"), LanguageCodeConverters.languageCodeToLocale(keyAttrbs.get("language")),
renderContext.getFallbackLocale());
final JCRNodeWrapper node = currentUserSession.getNode(keyAttrbs.get("path"));
if(logger.isDebugEnabled()) {
logger.debug("Calling render service for generating content for key " + cacheKey + " with attributes : " +
new ToStringBuilder(keyAttrbs,ToStringStyle.MULTI_LINE_STYLE)+ "\nmodule params : " +
ToStringBuilder.reflectionToString(moduleParams,ToStringStyle.MULTI_LINE_STYLE)+
" areaIdentifier "+ areaIdentifier);
}
renderContext.getRequest().removeAttribute(
"areaNodeTypesRestriction" + renderContext.getRequest().getAttribute("org.jahia.modules.level"));
Template oldOne = (Template) renderContext.getRequest().getAttribute("previousTemplate");
boolean restoreOldOneIfNeeded = false;
String context = keyAttrbs.get("context");
if(!context.equals("page")) {
renderContext.getRequest().setAttribute("templateSet", Boolean.TRUE);
}
if (!StringUtils.isEmpty(keyAttrbs.get("templateNodes"))) {
Template templateNodes = new Template(keyAttrbs.get("templateNodes"));
renderContext.getRequest().setAttribute("previousTemplate", templateNodes);
} else {
renderContext.getRequest().removeAttribute("previousTemplate");
restoreOldOneIfNeeded = true;
}
renderContext.getRequest().setAttribute("skipWrapper", Boolean.TRUE);
String inArea = keyAttrbs.get("inArea");
if (inArea == null || "".equals(inArea)) {
renderContext.getRequest().removeAttribute("inArea");
} else {
renderContext.getRequest().setAttribute("inArea", inArea);
}
if(areaIdentifier!=null) {
renderContext.getRequest().setAttribute("areaListResource",currentUserSession.getNodeByIdentifier(areaIdentifier));
}
Resource resource = new Resource(node, keyAttrbs.get("templateType"), keyAttrbs.get("template"), context);
if (moduleParams != null) {
for (Map.Entry<String, Serializable> entry : moduleParams.entrySet()) {
resource.getModuleParams().put(entry.getKey(), entry.getValue());