Search in sources :

Example 1 with EditablePage

use of com.enonic.xp.page.EditablePage in project xp by enonic.

the class UpdatePageCommand method execute.

public Content execute() {
    final Content content = this.contentService.getById(this.params.getContent());
    if (content == null) {
        throw new ContentNotFoundException(this.params.getContent(), ContextAccessor.current().getBranch());
    }
    if (content.getPage() == null) {
        throw new PageNotFoundException(this.params.getContent());
    }
    final EditablePage editablePage = new EditablePage(content.getPage());
    this.params.getEditor().edit(editablePage);
    final Page editedPage = editablePage.build();
    if (editedPage.equals(content.getPage())) {
        return content;
    }
    defaultValuesProcessor.applyDefaultValues(editedPage, content.getPage());
    final UpdateContentParams params = new UpdateContentParams().contentId(this.params.getContent()).editor(edit -> edit.page = editedPage);
    this.contentService.update(params);
    return this.contentService.getById(this.params.getContent());
}
Also used : PageNotFoundException(com.enonic.xp.page.PageNotFoundException) ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) UpdateContentParams(com.enonic.xp.content.UpdateContentParams) Content(com.enonic.xp.content.Content) EditablePage(com.enonic.xp.page.EditablePage) Page(com.enonic.xp.page.Page) EditablePage(com.enonic.xp.page.EditablePage)

Aggregations

Content (com.enonic.xp.content.Content)1 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)1 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)1 EditablePage (com.enonic.xp.page.EditablePage)1 Page (com.enonic.xp.page.Page)1 PageNotFoundException (com.enonic.xp.page.PageNotFoundException)1