Search in sources :

Example 26 with PageMetadata

use of com.agiletec.aps.system.services.page.PageMetadata in project entando-core by entando.

the class PageService method valueMetadataFromRequest.

private void valueMetadataFromRequest(PageMetadata metadata, PageRequest request) {
    metadata.setGroup(request.getOwnerGroup());
    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);
    if (metadata.getExtraGroups() != null) {
        List<String> oldGroups = new ArrayList<>(metadata.getExtraGroups());
        oldGroups.forEach(metadata::removeExtraGroup);
    }
    if (request.getJoinGroups() != null) {
        request.getJoinGroups().forEach(metadata::addExtraGroup);
    }
    String charset = request.getCharset();
    metadata.setCharset(StringUtils.isNotBlank(charset) ? charset : null);
    String mimetype = request.getContentType();
    metadata.setMimeType(StringUtils.isNotBlank(mimetype) ? mimetype : null);
}
Also used : ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) Arrays(java.util.Arrays) BeanComparator(org.apache.commons.beanutils.BeanComparator) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) Group(com.agiletec.aps.system.services.group.Group) IPage(com.agiletec.aps.system.services.page.IPage) PageConfigurationDto(org.entando.entando.aps.system.services.page.model.PageConfigurationDto) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) PageSearchDto(org.entando.entando.aps.system.services.page.model.PageSearchDto) IGroupManager(com.agiletec.aps.system.services.group.IGroupManager) WidgetValidatorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetValidatorFactory) Widget(com.agiletec.aps.system.services.page.Widget) Map(java.util.Map) PagePositionRequest(org.entando.entando.web.page.model.PagePositionRequest) PageDtoBuilder(org.entando.entando.aps.system.services.page.model.PageDtoBuilder) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) JsonNode(com.fasterxml.jackson.databind.JsonNode) PageModelUtilizer(com.agiletec.aps.system.services.pagemodel.PageModelUtilizer) PageSearchRequest(org.entando.entando.web.page.model.PageSearchRequest) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) DataBinder(org.springframework.validation.DataBinder) ComponentUsageEntity(org.entando.entando.web.component.ComponentUsageEntity) Collectors(java.util.stream.Collectors) PagesStatus(com.agiletec.aps.system.services.page.PagesStatus) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) List(java.util.List) RestListRequest(org.entando.entando.web.common.model.RestListRequest) GroupUtilizer(com.agiletec.aps.system.services.group.GroupUtilizer) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) 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) PageUtils(org.entando.entando.aps.util.PageUtils) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) ApplicationContextAware(org.springframework.context.ApplicationContextAware) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) BeanUtils(org.springframework.beans.BeanUtils) JsonPatchService(org.entando.entando.aps.system.services.jsonpatch.JsonPatchService) Page(com.agiletec.aps.system.services.page.Page) HashMap(java.util.HashMap) BindingResult(org.springframework.validation.BindingResult) ApsProperties(com.agiletec.aps.util.ApsProperties) IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) PageUtilizer(com.agiletec.aps.system.services.page.PageUtilizer) ArrayList(java.util.ArrayList) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IPageManager(com.agiletec.aps.system.services.page.IPageManager) IManager(com.agiletec.aps.system.common.IManager) PagedMetadataMapper(org.entando.entando.web.common.assembler.PagedMetadataMapper) WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) GroupServiceUtilizer(org.entando.entando.aps.system.services.group.GroupServiceUtilizer) PageSearchMapper(org.entando.entando.web.common.assembler.PageSearchMapper) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) PageRequest(org.entando.entando.web.page.model.PageRequest) PagesStatusDto(org.entando.entando.aps.system.services.page.model.PagesStatusDto) BeansException(org.springframework.beans.BeansException) PageValidator(org.entando.entando.web.page.validator.PageValidator) ApplicationContext(org.springframework.context.ApplicationContext) PageModelServiceUtilizer(org.entando.entando.aps.system.services.pagemodel.PageModelServiceUtilizer) WidgetProcessorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetProcessorFactory) Collections(java.util.Collections) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 27 with PageMetadata

use of com.agiletec.aps.system.services.page.PageMetadata 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.setWidgets(new Widget[model.getFrames().length]);
    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.setParentCode(parent.getCode());
    }
    PageMetadata metadata = page.getMetadata();
    this.valueMetadataFromRequest(metadata, pageRequest);
    page.setMetadata(metadata);
    return page;
}
Also used : ResourceNotFoundException(org.entando.entando.aps.system.exception.ResourceNotFoundException) Arrays(java.util.Arrays) BeanComparator(org.apache.commons.beanutils.BeanComparator) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) StringUtils(org.apache.commons.lang3.StringUtils) Group(com.agiletec.aps.system.services.group.Group) IPage(com.agiletec.aps.system.services.page.IPage) PageConfigurationDto(org.entando.entando.aps.system.services.page.model.PageConfigurationDto) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) PageDto(org.entando.entando.aps.system.services.page.model.PageDto) PageSearchDto(org.entando.entando.aps.system.services.page.model.PageSearchDto) IGroupManager(com.agiletec.aps.system.services.group.IGroupManager) WidgetValidatorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetValidatorFactory) Widget(com.agiletec.aps.system.services.page.Widget) Map(java.util.Map) PagePositionRequest(org.entando.entando.web.page.model.PagePositionRequest) PageDtoBuilder(org.entando.entando.aps.system.services.page.model.PageDtoBuilder) ValidationGenericException(org.entando.entando.web.common.exceptions.ValidationGenericException) JsonNode(com.fasterxml.jackson.databind.JsonNode) PageModelUtilizer(com.agiletec.aps.system.services.pagemodel.PageModelUtilizer) PageSearchRequest(org.entando.entando.web.page.model.PageSearchRequest) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) DataBinder(org.springframework.validation.DataBinder) ComponentUsageEntity(org.entando.entando.web.component.ComponentUsageEntity) Collectors(java.util.stream.Collectors) PagesStatus(com.agiletec.aps.system.services.page.PagesStatus) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) List(java.util.List) RestListRequest(org.entando.entando.web.common.model.RestListRequest) GroupUtilizer(com.agiletec.aps.system.services.group.GroupUtilizer) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) 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) PageUtils(org.entando.entando.aps.util.PageUtils) WidgetConfigurationDto(org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto) ApplicationContextAware(org.springframework.context.ApplicationContextAware) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) BeanUtils(org.springframework.beans.BeanUtils) JsonPatchService(org.entando.entando.aps.system.services.jsonpatch.JsonPatchService) Page(com.agiletec.aps.system.services.page.Page) HashMap(java.util.HashMap) BindingResult(org.springframework.validation.BindingResult) ApsProperties(com.agiletec.aps.util.ApsProperties) IWidgetTypeManager(org.entando.entando.aps.system.services.widgettype.IWidgetTypeManager) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) PageUtilizer(com.agiletec.aps.system.services.page.PageUtilizer) ArrayList(java.util.ArrayList) RestServerError(org.entando.entando.aps.system.exception.RestServerError) IPageManager(com.agiletec.aps.system.services.page.IPageManager) IManager(com.agiletec.aps.system.common.IManager) PagedMetadataMapper(org.entando.entando.web.common.assembler.PagedMetadataMapper) WidgetConfigurationRequest(org.entando.entando.web.page.model.WidgetConfigurationRequest) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) GroupServiceUtilizer(org.entando.entando.aps.system.services.group.GroupServiceUtilizer) PageSearchMapper(org.entando.entando.web.common.assembler.PageSearchMapper) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) PageRequest(org.entando.entando.web.page.model.PageRequest) PagesStatusDto(org.entando.entando.aps.system.services.page.model.PagesStatusDto) BeansException(org.springframework.beans.BeansException) PageValidator(org.entando.entando.web.page.validator.PageValidator) ApplicationContext(org.springframework.context.ApplicationContext) PageModelServiceUtilizer(org.entando.entando.aps.system.services.pagemodel.PageModelServiceUtilizer) WidgetProcessorFactory(org.entando.entando.aps.system.services.widgettype.validators.WidgetProcessorFactory) Collections(java.util.Collections) PageMetadata(com.agiletec.aps.system.services.page.PageMetadata) IPage(com.agiletec.aps.system.services.page.IPage) IPage(com.agiletec.aps.system.services.page.IPage) Page(com.agiletec.aps.system.services.page.Page) List(java.util.List) ArrayList(java.util.ArrayList) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) Map(java.util.Map) HashMap(java.util.HashMap) ApsProperties(com.agiletec.aps.util.ApsProperties)

Example 28 with PageMetadata

use of com.agiletec.aps.system.services.page.PageMetadata in project entando-core by entando.

the class StreamInterceptorIntegrationTest method createPage.

protected Page createPage(String pageCode, PageModel pageModel, String parent) {
    if (null == parent) {
        parent = "service";
    }
    IPage parentPage = pageManager.getDraftPage(parent);
    if (null == pageModel) {
        pageModel = parentPage.getMetadata().getModel();
    }
    PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel, true, pageCode + "_title", null, null, false, null, null);
    Widget[] widgets = {};
    Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage.getCode(), "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)

Example 29 with PageMetadata

use of com.agiletec.aps.system.services.page.PageMetadata in project entando-core by entando.

the class ActivityStreamControllerIntegrationTest method createPage.

protected Page createPage(String pageCode, PageModel pageModel) {
    IPage parentPage = pageManager.getDraftPage("service");
    if (null == pageModel) {
        pageModel = parentPage.getMetadata().getModel();
    }
    PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel, true, pageCode + "_title", null, null, false, null, null);
    ApsProperties config = PageTestUtil.createProperties("modelId", "default", "contentId", "EVN24");
    Widget widgetToAdd = PageTestUtil.createWidget("content_viewer", config, this.widgetTypeManager);
    Widget[] widgets = { widgetToAdd };
    Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage.getCode(), "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) ApsProperties(com.agiletec.aps.util.ApsProperties)

Aggregations

PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)29 IPage (com.agiletec.aps.system.services.page.IPage)22 Page (com.agiletec.aps.system.services.page.Page)17 Widget (com.agiletec.aps.system.services.page.Widget)15 PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)9 ApsProperties (com.agiletec.aps.util.ApsProperties)8 ArrayList (java.util.ArrayList)7 WidgetConfigurationDto (org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)5 WidgetConfigurationRequest (org.entando.entando.web.page.model.WidgetConfigurationRequest)5 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)4 PagesStatus (com.agiletec.aps.system.services.page.PagesStatus)4 HashMap (java.util.HashMap)4 List (java.util.List)4 FieldSearchFilter (com.agiletec.aps.system.common.FieldSearchFilter)3 IManager (com.agiletec.aps.system.common.IManager)3 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)3 Group (com.agiletec.aps.system.services.group.Group)3 GroupUtilizer (com.agiletec.aps.system.services.group.GroupUtilizer)3 IGroupManager (com.agiletec.aps.system.services.group.IGroupManager)3 IPageManager (com.agiletec.aps.system.services.page.IPageManager)3