use of com.agiletec.aps.util.ApsProperties 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 com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class DataObjectMapperCacheWrapper method searchPublishedDataObjects.
private void searchPublishedDataObjects(DataObjectPageMapper dataObjectPageMapper, IPage page, IPageManager pageManager) {
PageModel pageModel = page.getModel();
if (pageModel != null) {
int mainFrame = pageModel.getMainFrame();
Widget[] widgets = page.getWidgets();
Widget widget = null;
if (null != widgets && mainFrame != -1) {
widget = widgets[mainFrame];
}
ApsProperties config = (null != widget) ? widget.getConfig() : null;
String dataId = (null != config) ? config.getProperty("dataId") : null;
if (null != dataId) {
dataObjectPageMapper.add(dataId, page.getCode());
}
String[] childCodes = page.getChildrenCodes();
for (String childCode : childCodes) {
IPage child = pageManager.getOnlinePage(childCode);
if (null != child) {
this.searchPublishedDataObjects(dataObjectPageMapper, child, pageManager);
}
}
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class TestDataObjectViewerHelper method init.
private void init() throws Exception {
try {
_requestContext = this.getRequestContext();
Lang lang = new Lang();
lang.setCode("it");
lang.setDescr("italiano");
_requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG, lang);
Widget widget = new Widget();
IWidgetTypeManager showletTypeMan = (IWidgetTypeManager) this.getService(SystemConstants.WIDGET_TYPE_MANAGER);
WidgetType showletType = showletTypeMan.getWidgetType("content_viewer");
widget.setType(showletType);
widget.setConfig(new ApsProperties());
_requestContext.addExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET, widget);
this._helper = (IDataObjectViewerHelper) this.getApplicationContext().getBean("DataObjectViewerHelper");
} catch (Throwable t) {
throw new Exception(t);
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class TestApiI18nLabelInterface method testCreateNewLabel.
protected void testCreateNewLabel(MediaType mediaType) throws Throwable {
String key = "TEST_LABEL_KEY";
String label = this._i18nManager.getLabel(key, "it");
assertNull(label);
ApsProperties labels = new ApsProperties();
labels.put("en", "Test label");
labels.put("it", "Label di Test");
JAXBI18nLabel jaxbLabel = new JAXBI18nLabel(key, labels);
ApiResource labelResource = this.getApiCatalogManager().getResource("core", "i18nlabel");
ApiMethod postMethod = labelResource.getPostMethod();
Properties properties = super.createApiProperties("admin", "it", mediaType);
try {
Object response = this.getResponseBuilder().createResponse(postMethod, jaxbLabel, properties);
assertNotNull(response);
assertTrue(response instanceof StringApiResponse);
assertEquals(IResponseBuilder.SUCCESS, ((StringApiResponse) response).getResult());
label = this._i18nManager.getLabel(key, "it");
assertEquals("Label di Test", label);
} catch (Exception e) {
throw e;
} finally {
this._i18nManager.deleteLabelGroup(key);
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class TestApiWidgetTypeInterface method testInvokeUpdateJaxbNoLogicWidgetType.
private void testInvokeUpdateJaxbNoLogicWidgetType(String widgetTypeCode, ApsProperties titles, boolean removeParametersFromCall, String customSingleGui, boolean expectedSuccess) throws Throwable {
WidgetType widgetType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(widgetType);
WidgetType widgetTypeToEdit = widgetType.clone();
GuiFragment previousFragment = this._guiFragmentManager.getUniqueGuiFragmentByWidgetType(widgetTypeCode);
ApsProperties originalTitles = widgetType.getTitles();
try {
JAXBWidgetType jaxbWidgetType = this.getJaxbWidgetType(widgetTypeToEdit);
if (StringUtils.isNotBlank(customSingleGui)) {
jaxbWidgetType.setGui(customSingleGui);
}
if (null != titles) {
jaxbWidgetType.setTitles(titles);
}
if (removeParametersFromCall) {
jaxbWidgetType.setTypeParameters(null);
}
this._apiWidgetTypeInterface.updateWidgetType(jaxbWidgetType);
if (!expectedSuccess) {
fail();
}
WidgetType extractedWidgetType = this._widgetTypeManager.getWidgetType(widgetTypeCode);
assertNotNull(extractedWidgetType);
assertEquals(widgetType.getMainGroup(), extractedWidgetType.getMainGroup());
assertEquals(titles, extractedWidgetType.getTitles());
assertEquals(widgetType.getTypeParameters(), extractedWidgetType.getTypeParameters());
assertEquals(widgetType.isLocked(), extractedWidgetType.isLocked());
if (StringUtils.isNotBlank(customSingleGui) && null == previousFragment) {
assertNotNull(this._guiFragmentManager.getUniqueGuiFragmentByWidgetType(widgetTypeCode));
}
} catch (ApiException ae) {
if (expectedSuccess) {
fail();
}
} catch (Throwable t) {
throw t;
} finally {
if (null == previousFragment) {
List<String> codes = this._guiFragmentManager.getGuiFragmentCodesByWidgetType(widgetTypeCode);
if (null != codes) {
for (int i = 0; i < codes.size(); i++) {
String code = codes.get(i);
this._guiFragmentManager.deleteGuiFragment(code);
}
}
} else {
if (null == this._guiFragmentManager.getUniqueGuiFragmentByWidgetType(widgetTypeCode)) {
this._guiFragmentManager.addGuiFragment(previousFragment);
} else {
this._guiFragmentManager.updateGuiFragment(previousFragment);
}
}
this._widgetTypeManager.updateWidgetType(widgetType.getCode(), originalTitles, widgetType.getConfig(), widgetType.getMainGroup());
}
}
Aggregations