use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class CmsPageUtil method isFreeViewerPage.
/**
* Check whether the page can publish free content, related to the model and
* the widgets of the page.
*
* @param model
* The model of the page to check.
* @param widgets
* The widgets of the page to check.
* @param viewerWidgetCode
* The code of the viewer widget (optional)
* @return True if the page can publish free content, false else.
*/
public static boolean isFreeViewerPage(PageModel model, Widget[] widgets, String viewerWidgetCode) {
try {
if (model != null && widgets != null) {
int mainFrame = model.getMainFrame();
if (mainFrame < 0)
return false;
Widget viewer = widgets[mainFrame];
if (null == viewer)
return false;
boolean isRightCode = null == viewerWidgetCode || viewer.getType().getCode().equals(viewerWidgetCode);
String actionName = viewer.getType().getAction();
boolean isRightAction = null != actionName && actionName.toLowerCase().indexOf("viewer") >= 0;
List<WidgetTypeParameter> typeParameters = viewer.getType().getTypeParameters();
if ((isRightCode || isRightAction) && (null != typeParameters && !typeParameters.isEmpty()) && (null == viewer.getConfig() || viewer.getConfig().isEmpty())) {
return true;
}
}
} catch (Throwable t) {
_logger.error("Error while checking page for widget '{}'", viewerWidgetCode, t);
// ApsSystemUtils.logThrowable(t, CmsPageActionUtil.class,
// "isViewerPage", "Error while checking page '" + page.getCode() +
// "'");
}
return false;
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class DataObjectMapperCacheWrapper method searchPublishedDataObjects.
private void searchPublishedDataObjects(DataObjectPageMapper dataObjectPageMapper, IPage page, IPageManager pageManager) {
PageModel pageModel = page.getModel();
if (pageModel != null) {
int mainFrame = pageModel.getMainFrame();
Widget[] widgets = page.getWidgets();
Widget widget = null;
if (null != widgets && mainFrame != -1) {
widget = widgets[mainFrame];
}
ApsProperties config = (null != widget) ? widget.getConfig() : null;
String dataId = (null != config) ? config.getProperty("dataId") : null;
if (null != dataId) {
dataObjectPageMapper.add(dataId, page.getCode());
}
String[] childCodes = page.getChildrenCodes();
for (String childCode : childCodes) {
IPage child = pageManager.getOnlinePage(childCode);
if (null != child) {
this.searchPublishedDataObjects(dataObjectPageMapper, child, pageManager);
}
}
}
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class DataObjectModelManager method addReferencingPage.
private void addReferencingPage(long modelId, IPage page, Map<String, List<IPage>> utilizers) {
if (null != page && null != page.getWidgets()) {
Widget[] widgets = page.getWidgets();
for (Widget widget : widgets) {
if (null == widget) {
continue;
}
if (null != widget.getConfig()) {
String id = widget.getConfig().getProperty("modelId");
String dataId = widget.getConfig().getProperty("dataId");
if (null != id && null != dataId) {
long longId = Long.parseLong(id);
if (modelId == longId) {
List<IPage> pages = (List<IPage>) utilizers.get(dataId);
if (null == pages) {
pages = new ArrayList<>();
}
pages.add(page);
utilizers.put(dataId, pages);
}
}
}
}
}
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class TestDataObjectListHelper method valueRequestContext.
private RequestContext valueRequestContext(String pageCode, int frame) throws Throwable {
RequestContext reqCtx = this.getRequestContext();
try {
Widget widgetToAdd = this.getShowletForTest("content_viewer_list", null);
this.setPageWidgets(pageCode, frame, widgetToAdd);
IPage page = this._pageManager.getOnlinePage(pageCode);
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE, page);
Widget widget = page.getWidgets()[frame];
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
reqCtx.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME, new Integer(frame));
} catch (Throwable t) {
this.setPageWidgets(pageCode, frame, null);
throw t;
}
return reqCtx;
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class TestDataObjectViewerHelper method init.
private void init() throws Exception {
try {
_requestContext = this.getRequestContext();
Lang lang = new Lang();
lang.setCode("it");
lang.setDescr("italiano");
_requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, lang);
Widget widget = new Widget();
IWidgetTypeManager showletTypeMan = (IWidgetTypeManager) this.getService(SystemConstants.WIDGET_TYPE_MANAGER);
WidgetType showletType = showletTypeMan.getWidgetType("content_viewer");
widget.setType(showletType);
widget.setConfig(new ApsProperties());
_requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
this._helper = (IDataObjectViewerHelper) this.getApplicationContext().getBean("DataObjectViewerHelper");
} catch (Throwable t) {
throw new Exception(t);
}
}
Aggregations