Search in sources :

Example 41 with Page

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

the class ComponentsTest method page.

@Test
public void page() {
    PropertyTree pageConfig = new PropertyTree();
    pageConfig.addLong("pause", 200L);
    Page page = Page.create().template(PageTemplateKey.from("pageTemplateName")).config(pageConfig).regions(PageRegions.create().build()).build();
    assertEquals("pageTemplateName", page.getTemplate().toString());
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Page(com.enonic.xp.page.Page) Test(org.junit.jupiter.api.Test)

Example 42 with Page

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

the class PageDataSerializer method fromPageData.

private Page fromPageData(final PropertySet pageData, final List<PropertySet> componentsAsData) {
    final Page.Builder page = Page.create();
    final PropertySet specialBlockSet = pageData.getSet(PAGE);
    if (specialBlockSet != null) {
        if (specialBlockSet.isNotNull(DESCRIPTOR)) {
            final DescriptorKey descriptorKey = DescriptorKey.from(specialBlockSet.getString(DESCRIPTOR));
            page.descriptor(descriptorKey);
            page.config(getConfigFromData(specialBlockSet, descriptorKey));
            page.regions(getPageRegions(descriptorKey, componentsAsData));
        }
        if (specialBlockSet.isNotNull(TEMPLATE)) {
            page.template(PageTemplateKey.from(specialBlockSet.getReference(TEMPLATE).toString()));
        }
        if (specialBlockSet.isNotNull(CUSTOMIZED)) {
            page.customized(specialBlockSet.getBoolean(CUSTOMIZED));
        }
    }
    return page.build();
}
Also used : PropertySet(com.enonic.xp.data.PropertySet) DescriptorKey(com.enonic.xp.page.DescriptorKey) Page(com.enonic.xp.page.Page)

Example 43 with Page

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

the class PageResolver method mergePageFromPageTemplate.

private static Page mergePageFromPageTemplate(final PageTemplate pageTemplate, final Page page) {
    final Page templatePage = pageTemplate.getPage();
    final PageTemplateKey templateKey = pageTemplate.getKey();
    if (templatePage != null) {
        final Page.Builder pageBuilder = Page.create(templatePage).descriptor(null).template(templateKey);
        if (page != null) {
            if (page.getConfig() != null) {
                pageBuilder.config(page.getConfig());
            }
            if (page.getRegions() != null) {
                pageBuilder.regions(page.getRegions());
            }
        }
        return pageBuilder.build();
    } else {
        return page != null ? page : Page.create().template(templateKey).build();
    }
}
Also used : Page(com.enonic.xp.page.Page) PageTemplateKey(com.enonic.xp.page.PageTemplateKey)

Example 44 with Page

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

the class ComponentHandlerWorker method getFragmentComponent.

private Component getFragmentComponent(final FragmentComponent component) {
    final ContentId contentId = component.getFragment();
    if (contentId == null) {
        return null;
    }
    try {
        final Content fragmentContent = contentService.getById(contentId);
        if (!fragmentContent.hasPage() || !fragmentContent.getType().isFragment()) {
            return null;
        }
        final Page page = fragmentContent.getPage();
        return page.getFragment();
    } catch (ContentNotFoundException e) {
        return null;
    }
}
Also used : ContentNotFoundException(com.enonic.xp.content.ContentNotFoundException) Content(com.enonic.xp.content.Content) ContentId(com.enonic.xp.content.ContentId) Page(com.enonic.xp.page.Page)

Example 45 with Page

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

the class RenderBaseHandlerTest method createSite.

private Site createSite(final String id, final String path) {
    PropertyTree rootDataSet = new PropertyTree();
    rootDataSet.addString("property1", "value1");
    Page page = Page.create().template(PageTemplateKey.from("my-page")).config(rootDataSet).build();
    return Site.create().id(ContentId.from(id)).path(ContentPath.from(path)).owner(PrincipalKey.from("user:myStore:me")).displayName("My Content").modifier(PrincipalKey.from("user:system:admin")).type(ContentTypeName.from("portal:site")).page(page).build();
}
Also used : PropertyTree(com.enonic.xp.data.PropertyTree) Page(com.enonic.xp.page.Page)

Aggregations

Page (com.enonic.xp.page.Page)58 PropertyTree (com.enonic.xp.data.PropertyTree)30 Test (org.junit.jupiter.api.Test)28 Content (com.enonic.xp.content.Content)25 Site (com.enonic.xp.site.Site)12 DescriptorKey (com.enonic.xp.page.DescriptorKey)9 PageRegions (com.enonic.xp.page.PageRegions)9 AbstractDataSerializerTest (com.enonic.xp.core.impl.content.page.AbstractDataSerializerTest)7 PageDescriptor (com.enonic.xp.page.PageDescriptor)7 PageTemplate (com.enonic.xp.page.PageTemplate)7 PropertySet (com.enonic.xp.data.PropertySet)6 Form (com.enonic.xp.form.Form)5 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)5 LayoutComponent (com.enonic.xp.region.LayoutComponent)5 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)4 EditableContent (com.enonic.xp.content.EditableContent)4 Component (com.enonic.xp.region.Component)4 PartComponent (com.enonic.xp.region.PartComponent)4 ContentId (com.enonic.xp.content.ContentId)3 UpdateContentParams (com.enonic.xp.content.UpdateContentParams)3