use of com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo in project entando-core by entando.
the class TestCacheInfoManager method testGetRenderedContent_3.
public void testGetRenderedContent_3() throws Throwable {
RequestContext reqCtx = this.getRequestContext();
String contentId = null;
String langCode = "en";
long modelId = -1;
try {
modelId = this.createMockContentModel();
contentId = this.createMockContent();
String renderInfoCacheKey = BaseContentDispenser.getRenderizationInfoCacheKey(contentId, modelId, langCode, reqCtx);
ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
assertNotNull(outputInfo);
assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
// -----------
ContentModel contentModel = this._contentModelManager.getContentModel(modelId);
contentModel.setDescription("Modified model description");
this._contentModelManager.updateContentModel(contentModel);
super.waitNotifyingThread();
assertNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
// -----------
outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
assertNotNull(outputInfo);
assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
} catch (Throwable t) {
throw t;
} finally {
this.deleteMockContentObject(contentId, modelId);
}
}
use of com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo in project entando-core by entando.
the class TestCacheInfoManager method testGetRenderedContent_2.
public void testGetRenderedContent_2() throws Throwable {
RequestContext reqCtx = this.getRequestContext();
String contentId = null;
String langCode = "en";
long modelId = -1;
try {
modelId = this.createMockContentModel();
contentId = this.createMockContent();
String renderInfoCacheKey = BaseContentDispenser.getRenderizationInfoCacheKey(contentId, modelId, langCode, reqCtx);
ContentRenderizationInfo outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
assertNotNull(outputInfo);
assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
// -----------
Content content = this._contentManager.loadContent(contentId, true);
content.setDescription("Modified content description");
this._contentManager.insertOnLineContent(content);
super.waitNotifyingThread();
assertNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
// -----------
outputInfo = this._contentDispenser.getRenderizationInfo(contentId, modelId, langCode, reqCtx);
assertNotNull(outputInfo);
assertNotNull(this._cacheInfoManager.getFromCache(ICacheInfoManager.DEFAULT_CACHE_NAME, renderInfoCacheKey));
} catch (Throwable t) {
throw t;
} finally {
this.deleteMockContentObject(contentId, modelId);
}
}
use of com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo in project entando-core by entando.
the class ContentPreviewDispenser method getBaseRenderizationInfo.
@Override
public ContentRenderizationInfo getBaseRenderizationInfo(PublicContentAuthorizationInfo authInfo, String contentId, long modelId, String langCode, UserDetails currentUser, RequestContext reqCtx) {
ContentRenderizationInfo renderInfo = null;
try {
List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
if (authInfo.isUserAllowed(userGroups)) {
Content contentOnSession = this.extractContentOnSession(reqCtx);
String renderedContent = this.buildRenderedContent(contentOnSession, modelId, langCode, reqCtx);
if (null != renderedContent && renderedContent.trim().length() > 0) {
List<AttributeRole> roles = this.getContentManager().getAttributeRoles();
renderInfo = new ContentRenderizationInfo(contentOnSession, renderedContent, modelId, langCode, roles);
}
}
} catch (Throwable t) {
_logger.error("Error while rendering content {}", contentId, t);
return null;
}
return renderInfo;
}
use of com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo in project entando-core by entando.
the class ContentPreviewViewerHelper method getRenderedContent.
@Override
public String getRenderedContent(String contentId, String modelId, RequestContext reqCtx) throws ApsSystemException {
String renderedContent = "";
HttpServletRequest request = reqCtx.getRequest();
try {
String contentOnSessionMarker = (String) request.getAttribute("contentOnSessionMarker");
if (null == contentOnSessionMarker || contentOnSessionMarker.trim().length() == 0) {
contentOnSessionMarker = request.getParameter("contentOnSessionMarker");
}
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
String langCode = currentLang.getCode();
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
Content contentOnSession = (Content) request.getSession().getAttribute(ContentActionConstants.SESSION_PARAM_NAME_CURRENT_CONTENT_PREXIX + contentOnSessionMarker);
contentId = (contentOnSession.getId() == null ? contentOnSession.getTypeCode() + "123" : contentOnSession.getId());
ApsProperties widgetConfig = widget.getConfig();
modelId = this.extractModelId(contentId, modelId, widgetConfig);
if (null != contentId && null != modelId) {
long longModelId = new Long(modelId).longValue();
this.setStylesheet(longModelId, reqCtx);
ContentRenderizationInfo renderizationInfo = this.getContentDispenser().getRenderizationInfo(contentId, longModelId, langCode, reqCtx);
if (null == renderizationInfo) {
_logger.warn("Null Renderization informations: content={}", contentId);
} else {
this.getContentDispenser().resolveLinks(renderizationInfo, reqCtx);
renderedContent = renderizationInfo.getRenderedContent();
}
} else {
_logger.warn("Parametri visualizzazione contenuto incompleti: contenuto={} modello={}", contentId, modelId);
}
} catch (Throwable t) {
_logger.error("error loading rendered content for preview", t);
// ApsSystemUtils.logThrowable(t, this, "getRenderedContent");
throw new ApsSystemException("error loading rendered content for preview", t);
}
return renderedContent;
}
use of com.agiletec.plugins.jacms.aps.system.services.dispenser.ContentRenderizationInfo in project entando-core by entando.
the class ContentViewerHelper method getRenderizationInfo.
@Override
public ContentRenderizationInfo getRenderizationInfo(String contentId, String modelId, boolean publishExtraTitle, RequestContext reqCtx) throws ApsSystemException {
ContentRenderizationInfo renderizationInfo = null;
try {
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
String langCode = currentLang.getCode();
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
ApsProperties widgetConfig = widget.getConfig();
contentId = this.extractContentId(contentId, widgetConfig, reqCtx);
modelId = this.extractModelId(contentId, modelId, widgetConfig, reqCtx);
if (contentId != null && modelId != null) {
long longModelId = new Long(modelId).longValue();
this.setStylesheet(longModelId, reqCtx);
renderizationInfo = this.getContentDispenser().getRenderizationInfo(contentId, longModelId, langCode, reqCtx, true);
if (null == renderizationInfo) {
_logger.info("Null Renderization informations: content={}", contentId);
return null;
}
this.getContentDispenser().resolveLinks(renderizationInfo, reqCtx);
this.manageAttributeValues(renderizationInfo, publishExtraTitle, reqCtx);
} else {
_logger.warn("Parametri visualizzazione contenuto incompleti: " + "contenuto={} modello={}", contentId, modelId);
}
} catch (Throwable t) {
_logger.error("Error extracting renderization info", t);
throw new ApsSystemException("Error extracting renderization info", t);
}
return renderizationInfo;
}
Aggregations