use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class CurrentWidgetTag method extractTitle.
private String extractTitle(Widget widget) {
ServletRequest request = this.pageContext.getRequest();
RequestContext reqCtx = (RequestContext) request.getAttribute(RequestContext.REQCTX);
Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
WidgetType type = widget.getType();
String value = type.getTitles().getProperty(currentLang.getCode());
if (null == value || value.trim().length() == 0) {
ILangManager langManager = (ILangManager) ApsWebApplicationUtils.getBean(SystemConstants.LANGUAGE_MANAGER, this.pageContext);
Lang defaultLang = langManager.getDefaultLang();
value = type.getTitles().getProperty(defaultLang.getCode());
}
return value;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class ApiServiceAction method newService.
/**
* Create of new api service.
*
* @return The result code.
*/
public String newService() {
try {
if (null != this.getResourceCode()) {
String[] sections = this.getResourceCode().split(":");
if (sections.length == 2) {
this.setNamespace(sections[0]);
this.setResourceName(sections[1]);
} else {
this.setResourceName(sections[0]);
}
}
String check = this.checkMasterMethod(this.getNamespace(), this.getResourceName());
if (null != check) {
return check;
}
ApiMethod masterMethod = this.getMethod(this.getNamespace(), this.getResourceName());
if (null != this.getWidgetTypeCode() && null != masterMethod.getRelatedWidget()) {
WidgetType type = this.getWidgetTypeManager().getWidgetType(this.getWidgetTypeCode());
if (null != type && type.isLogic()) {
ApsProperties parameters = this.extractParametersFromWidgetProperties(masterMethod.getRelatedWidget(), type.getConfig());
this.setApiParameterValues(parameters);
}
}
this.setApiParameters(masterMethod.getParameters());
this.setStrutsAction(ApsAdminSystemConstants.ADD);
this.setServiceKey(this.buildTempKey(masterMethod.getResourceName()));
} catch (Throwable t) {
_logger.error("error in newService", t);
return FAILURE;
}
return SUCCESS;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class ContentListViewerWidgetAction method validateFilters.
protected void validateFilters() {
WidgetType type = this.getWidget().getType();
ApsProperties config = this.getWidget().getConfig();
if (null != config && null != type && type.hasParameter("categories") && type.hasParameter("maxElemForItem") && type.hasParameter("maxElements") && StringUtils.isNotEmpty(config.getProperty("contentType")) && StringUtils.isEmpty(config.getProperty("categories")) && StringUtils.isEmpty(config.getProperty("maxElemForItem")) && StringUtils.isEmpty(config.getProperty("maxElements"))) {
this.addFieldError("categories", this.getText("error.widget.listViewer.parameters.invalid"));
}
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class AbstractPortalAction method getWidgetFlavoursMapping.
protected Map<String, List<SelectItem>> getWidgetFlavoursMapping(List<String> pluginCodes) {
Map<String, List<SelectItem>> mapping = new HashMap<String, List<SelectItem>>();
List<WidgetType> types = this.getWidgetTypeManager().getWidgetTypes();
for (int i = 0; i < types.size(); i++) {
WidgetType type = types.get(i);
String pluginCode = type.getPluginCode();
if (null != pluginCode && pluginCode.trim().length() > 0) {
// is a plugin's widgets
if (!pluginCodes.contains(pluginCode)) {
pluginCodes.add(pluginCode);
}
this.addFlavourWidgetType(pluginCode, type, mapping);
} else if (type.isUserType()) {
// is a user widgets
this.addFlavourWidgetType(USER_WIDGETS_CODE, type, mapping);
} else // is a core widgets
{
if (this.getStockWidgetCodes().contains(type.getCode())) {
this.addFlavourWidgetType(STOCK_WIDGETS_CODE, type, mapping);
} else {
this.addFlavourWidgetType(CUSTOM_WIDGETS_CODE, type, mapping);
}
}
}
Collections.sort(pluginCodes);
return mapping;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class PageConfigAction method editFrame.
public String editFrame() {
try {
String result = this.checkBaseParams();
if (null != result) {
return result;
}
// can be null
Widget widget = this.getCurrentPage().getWidgets()[this.getFrame()];
this.setWidget(widget);
if (widget != null) {
WidgetType widgetType = widget.getType();
_logger.debug("pageCode: {}, frame: {}, widgetType: {}", this.getPageCode(), this.getFrame(), widgetType.getCode());
this.setWidgetAction(widgetType.getAction());
if (null == widgetType.getConfig() && null != this.getWidgetAction()) {
return "configureSpecialWidget";
}
} else {
_logger.debug("pageCode: {} frame: {}, empty widhet to config", this.getPageCode(), this.getFrame());
}
} catch (Exception e) {
_logger.error("error in edit frame", e);
return FAILURE;
}
return SUCCESS;
}
Aggregations