use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class CmsPageManagerWrapper method findContentUtilizers.
public boolean findContentUtilizers(Widget[] widgets, String contentId) throws ApsSystemException {
boolean found = false;
if (null != widgets) {
for (Widget widget : widgets) {
ApsProperties config = (null != widget) ? widget.getConfig() : null;
if (null == config || config.isEmpty()) {
continue;
}
String extracted = config.getProperty("contentId");
if (null != extracted && contentId.equals(extracted)) {
found = true;
} else {
String contents = config.getProperty("contents");
List<Properties> properties = (null != contents) ? RowContentListHelper.fromParameterToContents(contents) : null;
if (null == properties || properties.isEmpty()) {
continue;
}
for (int j = 0; j < properties.size(); j++) {
Properties widgProp = properties.get(j);
String extracted2 = widgProp.getProperty("contentId");
if (null != extracted2 && contentId.equals(extracted2)) {
found = true;
break;
}
}
}
}
}
return found;
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class RowContentListTag method getContents.
protected List<Properties> getContents(RequestContext reqCtx) throws ApsSystemException {
List<Properties> contents = null;
try {
Widget currentWidget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
if (null == currentWidget || null == currentWidget.getConfig()) {
return new ArrayList<Properties>();
}
String widgetConfig = currentWidget.getConfig().getProperty("contents");
contents = RowContentListHelper.fromParameterToContents(widgetConfig);
if (StringUtils.isBlank(widgetConfig)) {
return contents;
}
} catch (Throwable t) {
_logger.error("Error extracting contents", t);
throw new ApsSystemException("Error extracting contents", t);
}
return contents;
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class CmsPageUtil method isDraftFreeViewerPage.
/**
* Check whether the page can publish free content, related to the draft
* configuration of the page.
*
* @param page
* 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 isDraftFreeViewerPage(IPage page, String viewerWidgetCode) {
if (page.isOnlineInstance()) {
_logger.warn("this check expects a draft instance of the page");
return false;
}
boolean found = false;
PageMetadata metadata = page.getMetadata();
Widget[] widgets = page.getWidgets();
if (metadata != null) {
found = isFreeViewerPage(metadata.getModel(), widgets, viewerWidgetCode);
}
return found;
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class ContentInfoTag method extractModelId.
private Object extractModelId(PublicContentAuthorizationInfo authInfo, RequestContext reqCtx) {
Widget widget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
ApsProperties showletConfig = widget.getConfig();
String modelId = (String) showletConfig.get("modelId");
if (null == modelId) {
modelId = reqCtx.getRequest().getParameter("modelId");
}
if (null == modelId) {
IContentManager contentManager = (IContentManager) ApsWebApplicationUtils.getBean(JacmsSystemConstants.CONTENT_MANAGER, this.pageContext);
modelId = contentManager.getDefaultModel(authInfo.getContentId());
}
return modelId;
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class PageService method getWidgetConfiguration.
@Override
public WidgetConfigurationDto getWidgetConfiguration(String pageCode, int frameId, String status) {
IPage page = this.loadPage(pageCode, status);
if (null == page) {
throw new RestRourceNotFoundException(ERRCODE_PAGE_NOT_FOUND, "page", pageCode);
}
if (frameId > page.getWidgets().length) {
throw new RestRourceNotFoundException(ERRCODE_FRAME_INVALID, "frame", String.valueOf(frameId));
}
Widget widget = page.getWidgets()[frameId];
if (null == widget) {
return null;
}
return new WidgetConfigurationDto(widget);
}
Aggregations