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());
}
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();
}
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();
}
}
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;
}
}
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();
}
Aggregations