use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class PageWithWidgetTag method filterByConfigParamValue.
protected List<IPage> filterByConfigParamValue(List<IPage> pages) {
List<IPage> filteredPages = new ArrayList<IPage>();
Iterator<IPage> it = pages.iterator();
while (it.hasNext()) {
IPage currentPage = it.next();
Widget[] widgets = currentPage.getWidgets();
if (widgets != null) {
for (Widget currentWidget : widgets) {
if (null != currentWidget && currentWidget.getType().getCode().equals(this.getWidgetTypeCode())) {
ApsProperties config = currentWidget.getConfig();
if (null != config) {
String value = config.getProperty(this.getFilterParamName());
if (StringUtils.isNotBlank(value) && value.equals(this.getFilterParamValue())) {
filteredPages.add(currentPage);
}
}
}
}
}
}
return filteredPages;
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class PageAction method addPublishedContents.
protected void addPublishedContents(Widget[] widgets, Collection<Content> contents) {
try {
if (widgets != null) {
for (Widget widget : widgets) {
ApsProperties config = (null != widget) ? widget.getConfig() : null;
if (null == config || config.isEmpty()) {
continue;
}
String extracted = config.getProperty("contentId");
this.addContent(contents, extracted);
String contentsParam = config.getProperty("contents");
List<Properties> properties = (null != contentsParam) ? RowContentListHelper.fromParameterToContents(contentsParam) : 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");
this.addContent(contents, extracted2);
}
}
}
} catch (Throwable t) {
String msg = "Error extracting published contents on page";
_logger.error("Error extracting published contents on page", t);
throw new RuntimeException(msg, t);
}
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class ContentListViewerWidgetAction method changeContentType.
public String changeContentType() {
try {
Widget widget = super.createNewShowlet();
this.setWidget(widget);
} catch (Throwable t) {
_logger.error("error in changeContentType", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class ContentListViewerWidgetAction method configContentType.
public String configContentType() {
try {
Widget widget = super.createNewShowlet();
widget.getConfig().setProperty(IContentListWidgetHelper.WIDGET_PARAM_CONTENT_TYPE, this.getContentType());
this.setWidget(widget);
} catch (Throwable t) {
_logger.error("error in configContentType", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.page.Widget in project entando-core by entando.
the class PageAction method setDefaultWidgets.
public String setDefaultWidgets() {
Page page = null;
try {
page = (Page) this.getPage(this.getPageCode());
PageModel model = page.getMetadata().getModel();
Widget[] defaultWidgets = model.getDefaultWidget();
if (null == defaultWidgets) {
_logger.info("No default Widget found for pagemodel '{}' of page '{}'", model.getCode(), page.getCode());
return SUCCESS;
}
Widget[] widgets = new Widget[defaultWidgets.length];
for (int i = 0; i < defaultWidgets.length; i++) {
Widget defaultWidget = defaultWidgets[i];
if (null != defaultWidget) {
if (null == defaultWidget.getType()) {
_logger.info("Widget Type null when adding defaulWidget (of pagemodel '{}') on frame '{}' of page '{}'", model.getCode(), i, page.getCode());
continue;
}
widgets[i] = defaultWidget;
}
}
page.setWidgets(widgets);
this.getPageManager().updatePage(page);
} catch (Throwable t) {
_logger.error("Error setting default widget to page {}", page.getCode(), t);
return FAILURE;
}
return SUCCESS;
}
Aggregations