use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class ContentListViewerWidgetAction method init.
@Override
public String init() {
try {
super.init();
ApsProperties config = this.getWidget().getConfig();
if (null == config) {
return SUCCESS;
}
this.extractFiltersProperties(config);
this.extractUserFiltersProperties(config);
this.extractCategories(config);
} catch (Throwable t) {
_logger.error("error in init", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class WidgetTypeAction method extractWidgetTypeConfig.
private ApsProperties extractWidgetTypeConfig(List<WidgetTypeParameter> parameters) throws Exception {
ApsProperties config = new ApsProperties();
for (int i = 0; i < parameters.size(); i++) {
WidgetTypeParameter param = parameters.get(i);
String paramName = param.getName();
String value = this.getRequest().getParameter(paramName);
if (value != null && value.trim().length() > 0) {
config.setProperty(paramName, value);
}
}
return config;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class WidgetTypeAction method saveUserWidget.
protected String saveUserWidget() {
try {
boolean isCopy = (null != this.getPageCode() && this.getPageCode().trim().length() > 0);
String check = (isCopy) ? this.checkWidgetToCopy() : this.checkNewUserWidget();
if (null != check) {
return check;
}
WidgetType newType = null;
Widget widgetToCopy = this.extractWidgetToCopy();
if (null == widgetToCopy) {
this.setReplaceOnPage(false);
newType = this.createNewWidgetType();
WidgetType parentType = this.getWidgetTypeManager().getWidgetType(this.getParentWidgetTypeCode());
newType.setParentType(parentType);
ApsProperties config = this.extractWidgetTypeConfig(parentType.getTypeParameters());
newType.setConfig(config);
} else {
newType = this.createCopiedWidget(widgetToCopy);
}
// TODO CHECK MainGroup
newType.setMainGroup(this.getMainGroup());
this.getWidgetTypeManager().addWidgetType(newType);
if (this.isReplaceOnPage()) {
WidgetType type = this.getWidgetType(this.getWidgetTypeCode());
Widget widget = new Widget();
widget.setType(type);
IPage page = this.getPageManager().getDraftPage(this.getPageCode());
page.getWidgets()[this.getFramePos()] = widget;
this.getPageManager().updatePage(page);
return "replaceOnPage";
}
} catch (Throwable t) {
_logger.error("error in saveUserWidget", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class LabelControllerIntegrationTest method testUpdateLabelWithUnexistingLang.
@Test
public void testUpdateLabelWithUnexistingLang() throws Exception {
String code = "THIS_LABEL_HAS_NO_NAME";
ObjectMapper mapper = new ObjectMapper();
try {
assertThat(this.ii18nManager.getLabelGroup(code), is(nullValue()));
ApsProperties labels = new ApsProperties();
labels.put(this.langManager.getDefaultLang().getCode(), "hello");
this.ii18nManager.addLabelGroup(code, labels);
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
LabelRequest request = new LabelRequest();
request.setKey(code);
Map<String, String> languages = new HashMap<>();
languages.put(langManager.getDefaultLang().getCode(), "hello");
languages.put("kk", "hello");
request.setTitles(languages);
String payLoad = mapper.writeValueAsString(request);
ResultActions result = mockMvc.perform(put("/labels/{code}", code).content(payLoad).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isBadRequest());
} finally {
this.ii18nManager.deleteLabelGroup(code);
}
}
use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.
the class PageConfigurationControllerWidgetsIntegrationTest method createPage.
protected Page createPage(String pageCode) {
IPage parentPage = pageManager.getDraftPage("service");
PageModel pageModel = parentPage.getMetadata().getModel();
PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, pageCode + "_title", null, null, false, null, null);
ApsProperties config = PageTestUtil.createProperties("temp", "tempValue", "contentId", "ART11");
Widget widgetToAdd = PageTestUtil.createWidget("content_viewer", config, this.widgetTypeManager);
Widget[] widgets = { widgetToAdd };
Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage, "free", metadata, widgets);
return pageToAdd;
}
Aggregations