use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class TestWidgetTypeManager method testUpdateTitles.
public void testUpdateTitles() throws Throwable {
String widgetTypeCode = "test_widgetType";
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
try {
WidgetType type = this.createNewWidgetType(widgetTypeCode);
this._widgetTypeManager.addWidgetType(type);
WidgetType extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extracted);
assertEquals("Titolo", extracted.getTitles().get("it"));
assertEquals("Title", extracted.getTitles().get("en"));
ApsProperties newTitles = new ApsProperties();
newTitles.put("it", "Titolo modificato");
newTitles.put("en", "Modified title");
this._widgetTypeManager.updateWidgetType(widgetTypeCode, newTitles, type.getConfig(), type.getMainGroup());
extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extracted);
assertEquals("Titolo modificato", extracted.getTitles().get("it"));
assertEquals("Modified title", extracted.getTitles().get("en"));
} catch (Throwable t) {
throw t;
} finally {
if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
}
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class TestWidgetTypeManager method testUpdate.
public void testUpdate() throws Throwable {
String widgetTypeCode = "test_showletType";
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
try {
WidgetType type = this.createNewWidgetType(widgetTypeCode);
this._widgetTypeManager.addWidgetType(type);
WidgetType extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extracted);
assertEquals("content_viewer", extracted.getParentType().getCode());
assertEquals("ART112", extracted.getConfig().get("contentId"));
ApsProperties newProperties = new ApsProperties();
this._widgetTypeManager.updateWidgetType(widgetTypeCode, extracted.getTitles(), newProperties, type.getMainGroup());
extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extracted);
assertNotNull(extracted.getConfig());
assertEquals(0, extracted.getConfig().size());
newProperties.put("contentId", "EVN103");
this._widgetTypeManager.updateWidgetType(widgetTypeCode, extracted.getTitles(), newProperties, type.getMainGroup());
extracted = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extracted);
assertEquals("EVN103", extracted.getConfig().get("contentId"));
} catch (Throwable t) {
throw t;
} finally {
if (null != this._widgetTypeManager.getWidgetType(widgetTypeCode)) {
this._widgetTypeManager.deleteWidgetType(widgetTypeCode);
}
assertNull(this._widgetTypeManager.getWidgetType(widgetTypeCode));
}
}
use of com.agiletec.aps.util.ApsProperties 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;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class ApiServiceAction method copyFromWidget.
/**
* Copy an exist widget (physic and with parameters, joined with a exist api
* method) and value the form of creation of new api service.
*
* @return The result code.
*/
public String copyFromWidget() {
try {
String check = this.checkMasterMethod(this.getNamespace(), this.getResourceName());
if (null != check) {
return check;
}
ApiMethod masterMethod = this.getMethod(this.getNamespace(), this.getResourceName());
// TODO Verify if DRAFT/ONLINE
IPage page = this.getPageManager().getOnlinePage(this.getPageCode());
if (null == page) {
this.addFieldError("pageCode", this.getText("error.service.paste.invalidPageCode", new String[] { this.getPageCode() }));
return INPUT;
}
Widget[] widgets = page.getWidgets();
if (null == this.getFramePos() || this.getFramePos() > widgets.length || null == widgets[this.getFramePos()]) {
String framePosString = (null != this.getFramePos()) ? this.getFramePos().toString() : "null";
this.addFieldError("framePos", this.getText("error.service.paste.invalidFramePos", new String[] { this.getPageCode(), framePosString }));
return INPUT;
}
Widget masterWidget = widgets[this.getFramePos()];
WidgetType type = (masterWidget.getType().isLogic()) ? masterWidget.getType().getParentType() : masterWidget.getType();
if (null == masterMethod.getRelatedWidget() || !masterMethod.getRelatedWidget().getWidgetCode().equals(type.getCode())) {
this.addFieldError("framePos", this.getText("error.service.paste.invalidWidget", new String[] { masterWidget.getType().getCode(), masterMethod.getResourceName() }));
return INPUT;
}
ApsProperties parameters = this.extractParametersFromWidget(masterMethod.getRelatedWidget(), masterWidget);
this.setApiParameterValues(parameters);
this.setApiParameters(masterMethod.getParameters());
this.setStrutsAction(ApsAdminSystemConstants.PASTE);
this.setServiceKey(this.buildTempKey(masterMethod.getResourceName()));
} catch (Throwable t) {
_logger.error("error in copyFromWidget", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class ApiServiceAction method extractParametersFromWidgetProperties.
private ApsProperties extractParametersFromWidgetProperties(ApiMethodRelatedWidget relatedWidget, ApsProperties widgetProperties) {
ApsProperties parameters = new ApsProperties();
ApsProperties mapping = relatedWidget.getMapping();
if (null != widgetProperties && null != mapping) {
Iterator<Object> keyIter = widgetProperties.keySet().iterator();
while (keyIter.hasNext()) {
Object key = keyIter.next();
if (null != mapping.get(key)) {
parameters.put(mapping.get(key), widgetProperties.get(key));
}
}
}
return parameters;
}
Aggregations