Search in sources :

Example 1 with PageModel

use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.

the class PageService method updatePage.

private IPage updatePage(IPage oldPage, PageRequest pageRequest) {
    Page page = new Page();
    page.setCode(pageRequest.getCode());
    page.setShowable(pageRequest.isDisplayedInMenu());
    if (oldPage.getModel().getCode().equals(pageRequest.getPageModel())) {
        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());
    PageMetadata metadata = oldPage.getMetadata();
    if (metadata == null) {
        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) 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 2 with PageModel

use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.

the class PageModelService method removePageModel.

@Override
public void removePageModel(String code) {
    try {
        PageModel pageModel = this.getPageModelManager().getPageModel(code);
        if (null == pageModel) {
            return;
        }
        BeanPropertyBindingResult validationResult = this.validateDelete(pageModel);
        if (validationResult.hasErrors()) {
            throw new ValidationConflictException(validationResult);
        }
        this.getPageModelManager().deletePageModel(code);
    } catch (ApsSystemException e) {
        logger.error("Error in delete pagemodel {}", code, e);
        throw new RestServerError("error in delete pagemodel", e);
    }
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException)

Example 3 with PageModel

use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.

the class PageModelService method createPageModel.

protected PageModel createPageModel(PageModelRequest pageModelRequest) {
    PageModel pageModel = new PageModel();
    copyProperties(pageModelRequest, pageModel);
    return pageModel;
}
Also used : PageModel(com.agiletec.aps.system.services.pagemodel.PageModel)

Example 4 with PageModel

use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.

the class PageModelService method validateAdd.

protected BeanPropertyBindingResult validateAdd(PageModelRequest pageModelRequest) {
    BeanPropertyBindingResult bindingResult = new BeanPropertyBindingResult(pageModelRequest, "pageModel");
    PageModel pageModel = this.getPageModelManager().getPageModel(pageModelRequest.getCode());
    if (null == pageModel) {
        return bindingResult;
    }
    bindingResult.reject(PageModelValidator.ERRCODE_CODE_EXISTS, new String[] { pageModelRequest.getCode() }, "pageModel.code.exists");
    return bindingResult;
}
Also used : BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel)

Example 5 with PageModel

use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.

the class PageModelService method getPageModels.

@Override
public PagedMetadata<PageModelDto> getPageModels(RestListRequest restListReq) {
    try {
        // transforms the filters by overriding the key specified in the request with the correct one known by the dto
        List<FieldSearchFilter> filters = new ArrayList<FieldSearchFilter>(restListReq.buildFieldSearchFilters());
        filters.stream().filter(i -> i.getKey() != null).forEach(i -> i.setKey(PageModelDto.getEntityFieldName(i.getKey())));
        SearcherDaoPaginatedResult<PageModel> pageModels = this.getPageModelManager().searchPageModels(filters);
        List<PageModelDto> dtoList = null;
        if (null != pageModels) {
            dtoList = this.getDtoBuilder().convert(pageModels.getList());
        }
        PagedMetadata<PageModelDto> pagedMetadata = new PagedMetadata<>(restListReq, pageModels);
        pagedMetadata.setBody(dtoList);
        return pagedMetadata;
    } catch (Throwable t) {
        logger.error("error in search pageModels", t);
        throw new RestServerError("error in search pageModels", t);
    }
}
Also used : LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) RestRourceNotFoundException(org.entando.entando.aps.system.exception.RestRourceNotFoundException) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) ArrayList(java.util.ArrayList) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) PageModelValidator(org.entando.entando.web.pagemodel.validator.PageModelValidator) RestServerError(org.entando.entando.aps.system.exception.RestServerError) Frame(com.agiletec.aps.system.services.pagemodel.Frame) Service(org.springframework.stereotype.Service) Map(java.util.Map) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) PageModelUtilizer(com.agiletec.aps.system.services.pagemodel.PageModelUtilizer) Logger(org.slf4j.Logger) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) BeansException(org.springframework.beans.BeansException) Collectors(java.util.stream.Collectors) PageModelFrameReq(org.entando.entando.web.pagemodel.model.PageModelFrameReq) PageModelRequest(org.entando.entando.web.pagemodel.model.PageModelRequest) ApplicationContext(org.springframework.context.ApplicationContext) List(java.util.List) RestListRequest(org.entando.entando.web.common.model.RestListRequest) SearcherDaoPaginatedResult(com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException) IPageModelManager(com.agiletec.aps.system.services.pagemodel.IPageModelManager) PageModelDto(org.entando.entando.aps.system.services.pagemodel.model.PageModelDto) ApplicationContextAware(org.springframework.context.ApplicationContextAware) IDtoBuilder(org.entando.entando.aps.system.services.IDtoBuilder) PagedMetadata(org.entando.entando.web.common.model.PagedMetadata) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ArrayList(java.util.ArrayList) FieldSearchFilter(com.agiletec.aps.system.common.FieldSearchFilter) PageModel(com.agiletec.aps.system.services.pagemodel.PageModel) PageModelDto(org.entando.entando.aps.system.services.pagemodel.model.PageModelDto)

Aggregations

PageModel (com.agiletec.aps.system.services.pagemodel.PageModel)47 IPage (com.agiletec.aps.system.services.page.IPage)13 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)11 Page (com.agiletec.aps.system.services.page.Page)10 Widget (com.agiletec.aps.system.services.page.Widget)10 ApsProperties (com.agiletec.aps.util.ApsProperties)10 PageMetadata (com.agiletec.aps.system.services.page.PageMetadata)9 ArrayList (java.util.ArrayList)8 List (java.util.List)8 RestServerError (org.entando.entando.aps.system.exception.RestServerError)7 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)7 ValidationConflictException (org.entando.entando.web.common.exceptions.ValidationConflictException)6 Frame (com.agiletec.aps.system.services.pagemodel.Frame)5 Map (java.util.Map)5 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)5 WidgetConfigurationDto (org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto)5 WidgetConfigurationRequest (org.entando.entando.web.page.model.WidgetConfigurationRequest)5 IPageModelManager (com.agiletec.aps.system.services.pagemodel.IPageModelManager)4 PageModelDOM (com.agiletec.aps.system.services.pagemodel.PageModelDOM)4 IDtoBuilder (org.entando.entando.aps.system.services.IDtoBuilder)4