Search in sources :

Example 91 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class PageService method valueMetadataFromRequest.

private void valueMetadataFromRequest(PageMetadata metadata, PageRequest request) {
    if (metadata.getModel() == null || !metadata.getModel().getCode().equals(request.getPageModel())) {
        // Ho cambiato modello e allora cancello tutte le showlets
        // Precedenti
        PageModel model = this.getPageModelManager().getPageModel(request.getPageModel());
        metadata.setModel(model);
    }
    metadata.setShowable(request.isDisplayedInMenu());
    metadata.setUseExtraTitles(request.isSeo());
    Optional<Map<String, String>> titles = Optional.ofNullable(request.getTitles());
    ApsProperties apsTitles = new ApsProperties();
    titles.ifPresent(values -> values.keySet().forEach((lang) -> {
        apsTitles.put(lang, values.get(lang));
    }));
    metadata.setTitles(apsTitles);
    Optional<List<String>> groups = Optional.ofNullable(request.getJoinGroups());
    groups.ifPresent(values -> values.forEach((group) -> {
        metadata.addExtraGroup(group);
    }));
    String charset = request.getCharset();
    metadata.setCharset(StringUtils.isNotBlank(charset) ? charset : null);
    String mimetype = request.getContentType();
    metadata.setMimeType(StringUtils.isNotBlank(mimetype) ? mimetype : null);
}
Also used : Arrays(java.util.Arrays) Page(com.agiletec.aps.system.services.page.Page) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) ApsProperties(com.agiletec.aps.util.ApsProperties) IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) IPage(com.agiletec.aps.system.services.page.IPage) PageConfigurationDto(org.entando.entando.aps.system.services.page.model.PageConfigurationDto) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IGroupManager(com.agiletec.aps.system.services.group.IGroupManager) IPageManager(com.agiletec.aps.system.services.page.IPageManager) WidgetValidatorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetValidatorFactory) Widget(com.agiletec.aps.system.services.page.Widget) Map(java.util.Map) IManager(com.agiletec.aps.system.common.IManager) PagePositionRequest(org.entando.entando.web.page.model.PagePositionRequest) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) GroupServiceUtilizer(org.entando.entando.aps.system.services.group.GroupServiceUtilizer) Logger(org.slf4j.Logger) PageRequest(org.entando.entando.web.page.model.PageRequest) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) List(java.util.List) GroupUtilizer(com.agiletec.aps.system.services.group.GroupUtilizer) WidgetProcessorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetProcessorFactory) Optional(java.util.Optional) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) IPageModelManager(com.agiletec.aps.system.services.pagemodel.IPageModelManager) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) ArrayList(java.util.ArrayList) List(java.util.List) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) Map(java.util.Map) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 92 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class PageService method createPage.

private IPage createPage(PageRequest pageRequest) {
    Page page = new Page();
    page.setCode(pageRequest.getCode());
    page.setShowable(pageRequest.isDisplayedInMenu());
    PageModel model = this.getPageModelManager().getPageModel(pageRequest.getPageModel());
    page.setModel(model);
    page.setCharset(pageRequest.getCharset());
    page.setMimeType(pageRequest.getContentType());
    page.setParentCode(pageRequest.getParentCode());
    page.setUseExtraTitles(pageRequest.isSeo());
    Optional<Map<String, String>> titles = Optional.ofNullable(pageRequest.getTitles());
    ApsProperties apsTitles = new ApsProperties();
    titles.ifPresent(values -> values.keySet().forEach((lang) -> {
        apsTitles.put(lang, values.get(lang));
    }));
    page.setTitles(apsTitles);
    page.setGroup(pageRequest.getOwnerGroup());
    Optional<List<String>> groups = Optional.ofNullable(pageRequest.getJoinGroups());
    groups.ifPresent(values -> values.forEach((group) -> {
        page.addExtraGroup(group);
    }));
    page.setParentCode(pageRequest.getParentCode());
    if (pageRequest.getParentCode() != null) {
        IPage parent = this.getPageManager().getDraftPage(pageRequest.getParentCode());
        page.setParent(parent);
    }
    PageMetadata metadata = new PageMetadata();
    this.valueMetadataFromRequest(metadata, pageRequest);
    page.setMetadata(metadata);
    return page;
}
Also used : Arrays(java.util.Arrays) Page(com.agiletec.aps.system.services.page.Page) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) ApsProperties(com.agiletec.aps.util.ApsProperties) IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) IPage(com.agiletec.aps.system.services.page.IPage) PageConfigurationDto(org.entando.entando.aps.system.services.page.model.PageConfigurationDto) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IGroupManager(com.agiletec.aps.system.services.group.IGroupManager) IPageManager(com.agiletec.aps.system.services.page.IPageManager) WidgetValidatorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetValidatorFactory) Widget(com.agiletec.aps.system.services.page.Widget) Map(java.util.Map) IManager(com.agiletec.aps.system.common.IManager) PagePositionRequest(org.entando.entando.web.page.model.PagePositionRequest) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) GroupServiceUtilizer(org.entando.entando.aps.system.services.group.GroupServiceUtilizer) Logger(org.slf4j.Logger) PageRequest(org.entando.entando.web.page.model.PageRequest) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) List(java.util.List) GroupUtilizer(com.agiletec.aps.system.services.group.GroupUtilizer) WidgetProcessorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetProcessorFactory) Optional(java.util.Optional) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) IPageModelManager(com.agiletec.aps.system.services.pagemodel.IPageModelManager) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) Page(com.agiletec.aps.system.services.page.Page) IPage(com.agiletec.aps.system.services.page.IPage) ArrayList(java.util.ArrayList) List(java.util.List) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) Map(java.util.Map) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 93 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class WidgetService method processWidgetType.

private void processWidgetType(WidgetType type, WidgetRequest widgetRequest) {
    type.setCode(widgetRequest.getCode());
    ApsProperties titles = new ApsProperties();
    widgetRequest.getTitles().forEach((k, v) -> titles.put(k, v));
    type.setTitles(titles);
    type.setMainGroup(widgetRequest.getGroup());
}
Also used : ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 94 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class TestPageManager method checkUpdatePage.

private void checkUpdatePage() throws Exception {
    Page dbPage = (Page) _pageManager.getDraftPage("temp");
    Page pageToUpdate = PageTestUtil.createPage("temp", dbPage.getParent(), "free", dbPage.getMetadata().clone(), PageTestUtil.copyArray(dbPage.getWidgets()));
    pageToUpdate.setPosition(dbPage.getPosition());
    PageMetadata onlineMetadata = pageToUpdate.getMetadata();
    onlineMetadata.setTitle("en", "temptitle1");
    onlineMetadata.setShowable(true);
    ApsProperties config = PageTestUtil.createProperties("temp1", "temp1", "contentId", "ART11");
    Widget widgetToAdd = PageTestUtil.createWidget("content_viewer", config, this._widgetTypeManager);
    pageToUpdate.getWidgets()[2] = widgetToAdd;
    _pageManager.setPageOnline(pageToUpdate.getCode());
    IPage updatedPage = _pageManager.getOnlinePage(dbPage.getCode());
    pageToUpdate = (Page) _pageManager.getOnlinePage(pageToUpdate.getCode());
    assertNotNull(updatedPage);
    PageTestUtil.comparePages(pageToUpdate, updatedPage, false);
    PageTestUtil.comparePageMetadata(pageToUpdate.getMetadata(), updatedPage.getMetadata(), 0);
    assertEquals(1, pageToUpdate.getMetadata().getTitles().size());
    PageTestUtil.compareWidgets(pageToUpdate.getWidgets(), updatedPage.getWidgets());
// assertNotNull(updatedPage.getWidgets()[2]);
// assertEquals(widgetToAdd, updatedPage.getWidgets()[2]);
}
Also used : ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 95 with ApsProperties

use of com.agiletec.aps.util.ApsProperties in project entando-core by entando.

the class TestWidgetTypeManager method createNewWidgetType.

private WidgetType createNewWidgetType(String code) {
    WidgetType type = new WidgetType();
    type.setCode(code);
    ApsProperties titles = new ApsProperties();
    titles.put("it", "Titolo");
    titles.put("en", "Title");
    type.setTitles(titles);
    WidgetType parent = this._widgetTypeManager.getWidgetType("content_viewer");
    assertNotNull(parent);
    type.setParentType(parent);
    type.setPluginCode("jacms");
    ApsProperties config = new ApsProperties();
    config.put("contentId", "ART112");
    type.setConfig(config);
    return type;
}
Also used : WidgetType(org.entando.entando.aps.system.services.widgettype.WidgetType) 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