use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageServiceWidgetIntegrationTest method testRemovePageWidget.
public void testRemovePageWidget() throws JsonProcessingException, ApsSystemException {
String pageCode = "temp001";
IPage parentPage = pageManager.getDraftRoot();
PageModel pageModel = parentPage.getMetadata().getModel();
PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, pageCode, null, null, false, null, null);
Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage, "free", metadata, null);
try {
pageManager.addPage(pageToAdd);
WidgetConfigurationDto widgetConfigurationDto = this.pageService.getWidgetConfiguration(pageToAdd.getCode(), 0, IPageService.STATUS_DRAFT);
assertThat(widgetConfigurationDto, is(nullValue()));
WidgetConfigurationRequest widgetConfigurationRequest = new WidgetConfigurationRequest();
widgetConfigurationRequest.setCode("login_form");
widgetConfigurationRequest.setConfig(null);
this.pageService.updateWidgetConfiguration(pageCode, 0, widgetConfigurationRequest);
assertThat(this.pageService.getWidgetConfiguration(pageToAdd.getCode(), 0, IPageService.STATUS_DRAFT).getCode(), is("login_form"));
this.pageService.deleteWidgetConfiguration(pageToAdd.getCode(), 0);
assertThat(widgetConfigurationDto, is(nullValue()));
} finally {
pageManager.deletePage(pageCode);
}
}
use of com.agiletec.aps.system.services.pagemodel.PageModel 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);
}
use of com.agiletec.aps.system.services.pagemodel.PageModel 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;
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageModelService method addPageModel.
@Override
public PageModelDto addPageModel(PageModelRequest pageModelRequest) {
try {
BeanPropertyBindingResult validationResult = this.validateAdd(pageModelRequest);
if (validationResult.hasErrors()) {
throw new ValidationConflictException(validationResult);
}
PageModel pageModel = this.createPageModel(pageModelRequest);
this.getPageModelManager().addPageModel(pageModel);
return this.getDtoBuilder().convert(pageModel);
} catch (ApsSystemException e) {
logger.error("Error in add pageModel", e);
throw new RestServerError("error in add pageModel", e);
}
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageModelService method updatePageModel.
@Override
public PageModelDto updatePageModel(PageModelRequest pageModelRequest) {
try {
PageModel pageModel = this.getPageModelManager().getPageModel(pageModelRequest.getCode());
if (null == pageModel) {
throw new RestRourceNotFoundException(PageModelValidator.ERRCODE_PAGEMODEL_NOT_FOUND, "pageModel", pageModelRequest.getCode());
}
this.copyProperties(pageModelRequest, pageModel);
this.getPageModelManager().updatePageModel(pageModel);
return this.getDtoBuilder().convert(pageModel);
} catch (ApsSystemException e) {
logger.error("Error in update pageModel {}", pageModelRequest.getCode(), e);
throw new RestServerError("error in update pageMdel", e);
}
}
Aggregations