Search in sources :

Example 76 with ApsProperties

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

Example 77 with ApsProperties

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

Example 78 with ApsProperties

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

Example 79 with ApsProperties

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);
    }
}
Also used : ApiResource(org.entando.entando.aps.system.services.api.model.ApiResource) JAXBI18nLabel(org.entando.entando.aps.system.services.i18n.model.JAXBI18nLabel) ApiMethod(org.entando.entando.aps.system.services.api.model.ApiMethod) Properties(java.util.Properties) ApsProperties(com.agiletec.aps.util.ApsProperties) StringApiResponse(org.entando.entando.aps.system.services.api.model.StringApiResponse) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 80 with ApsProperties

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());
    }
}
Also used : GuiFragment(org.entando.entando.aps.system.services.guifragment.GuiFragment) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) ApsProperties(com.agiletec.aps.util.ApsProperties) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

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