@Override
public Page createPage(String pageTemplateId, Page page) {
if (page.getName() == null) {
throw new BadRequestException("Page name property must be defined.");
}
org.apache.rave.model.Page fromDb;
if(StringUtils.isNotBlank(pageTemplateId)) {
fromDb = pageService.addNewPage(page.getName(), null, pageTemplateId);
//TODO: RAVE-977 - when Page type enum is deprecated escape from this logic
} else if (page.getPageType().equals("user")) {
if (page.getPageLayoutCode() == null) {
throw new BadRequestException("Page pageLayoutCode property must be defined.");
}
fromDb = pageService.addNewUserPage(page.getName(), page.getPageLayoutCode());
} else {
//TODO: RAVE-977 this will change
throw new BadRequestException("Page pageType property must equal 'user'.");
}
return new Page(fromDb);
}