Search in sources :

Example 61 with ApsProperties

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;
}
Also used : ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 62 with ApsProperties

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;
}
Also used : WidgetTypeParameter(org.entando.entando.aps.system.services.widgettype.WidgetTypeParameter) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 63 with ApsProperties

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;
}
Also used : IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 64 with ApsProperties

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);
    }
}
Also used : UserDetails(com.agiletec.aps.system.services.user.UserDetails) HashMap(java.util.HashMap) ResultActions(org.springframework.test.web.servlet.ResultActions) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ApsProperties(com.agiletec.aps.util.ApsProperties) Test(org.junit.Test) AbstractControllerIntegrationTest(org.entando.entando.web.AbstractControllerIntegrationTest)

Example 65 with ApsProperties

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;
}
Also used : PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) Widget(com.agiletec.aps.system.services.page.Widget) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

ApsProperties (com.agiletec.aps.util.ApsProperties)146 Widget (com.agiletec.aps.system.services.page.Widget)62 WidgetType (org.entando.entando.aps.system.services.widgettype.WidgetType)34 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)29 HashMap (java.util.HashMap)17 IPage (com.agiletec.aps.system.services.page.IPage)16 Lang (com.agiletec.aps.system.services.lang.Lang)14 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)10 Properties (java.util.Properties)9 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)9 List (java.util.List)8 RestServerError (org.entando.entando.aps.system.exception.RestServerError)8 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)7 Page (com.agiletec.aps.system.services.page.Page)6 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)6 NavigatorExpression (com.agiletec.aps.system.services.page.widget.NavigatorExpression)6 ArrayList (java.util.ArrayList)6 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)6 IWidgetTypeManager (org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager)6 ValidationGenericException (org.entando.entando.web.common.exceptions.ValidationGenericException)6