use of org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter in project entando-core by entando.
the class JAXBWidgetType method getModifiedWidgetType.
public WidgetType getModifiedWidgetType(IWidgetTypeManager widgetTypeManager) throws ApiException {
WidgetType type = widgetTypeManager.getWidgetType(this.getCode());
type.setTitles(this.getTitles());
if (type.isLogic()) {
ApsProperties configuration = this.getConfig();
type.setConfig(configuration);
} else {
List<WidgetTypeParameter> parameters = this.getTypeParameters();
if (null != parameters && !parameters.isEmpty()) {
// type.setAction("configSimpleParameter");
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Parameters of existing widget mustn't been changed", Response.Status.CONFLICT);
}
}
type.setMainGroup(this.getMainGroup());
// type.setPluginCode(this.getPluginCode());
return type;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter 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 org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter in project entando-core by entando.
the class TestWidgetTypeDOM method testCreateConfig.
public void testCreateConfig() throws ApsSystemException {
WidgetTypeParameter params1 = new WidgetTypeParameter();
params1.setName("param1");
params1.setDescr("Param1 Descr");
WidgetTypeParameter params2 = new WidgetTypeParameter();
params2.setName("param2");
params2.setDescr("Param2 Descr");
List<WidgetTypeParameter> params = new ArrayList<WidgetTypeParameter>();
params.add(params1);
params.add(params2);
WidgetTypeDOM showletTypeDOM = new WidgetTypeDOM(params, "customActionName");
String xml = showletTypeDOM.getXMLDocument();
WidgetTypeDOM showletTypeDOM2 = new WidgetTypeDOM(xml);
assertEquals("customActionName", showletTypeDOM2.getAction());
List<WidgetTypeParameter> extractedParams = showletTypeDOM2.getParameters();
assertEquals(2, extractedParams.size());
assertEquals("param1", extractedParams.get(0).getName());
assertEquals("Param2 Descr", extractedParams.get(1).getDescr());
}
use of org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter in project entando-core by entando.
the class TestWidgetTypeManager method testGetWidgetType_1.
public void testGetWidgetType_1() throws ApsSystemException {
WidgetType widgetType = _widgetTypeManager.getWidgetType("content_viewer");
assertEquals("content_viewer", widgetType.getCode());
assertEquals("Contenuti - Pubblica un Contenuto", widgetType.getTitles().get("it"));
assertTrue(widgetType.isLocked());
assertFalse(widgetType.isLogic());
assertFalse(widgetType.isUserType());
assertNull(widgetType.getParentType());
assertNull(widgetType.getConfig());
String action = widgetType.getAction();
assertEquals(action, "viewerConfig");
List<WidgetTypeParameter> list = widgetType.getTypeParameters();
Iterator<WidgetTypeParameter> iter = list.iterator();
Map<String, String> parameters = new HashMap<String, String>();
while (iter.hasNext()) {
WidgetTypeParameter parameter = (WidgetTypeParameter) iter.next();
parameters.put(parameter.getName(), parameter.getDescr());
}
boolean containsKey = parameters.containsKey("contentId");
boolean containsValue = parameters.containsValue("Identificativo del Contenuto");
assertEquals(containsKey, true);
assertEquals(containsValue, true);
containsKey = parameters.containsKey("modelId");
containsValue = parameters.containsValue("Identificativo del Modello di Contenuto");
assertEquals(containsKey, true);
assertEquals(containsValue, true);
}
use of org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter in project entando-core by entando.
the class ContentMapperCacheWrapperTest method createMockWidget.
private Widget createMockWidget() {
Widget widget = new Widget();
WidgetType type = new WidgetType();
type.setCode("type");
WidgetTypeParameter param1 = new WidgetTypeParameter();
param1.setName("contentId");
WidgetTypeParameter param2 = new WidgetTypeParameter();
param2.setName("testParam");
List<WidgetTypeParameter> params = Arrays.asList(new WidgetTypeParameter[] { param1, param2 });
type.setTypeParameters(params);
widget.setType(type);
ApsProperties props = new ApsProperties();
props.put("contentId", "ART1");
props.put("testParam", "test");
widget.setConfig(props);
return widget;
}
Aggregations