Esempio n. 1
0
  private Content createPage(final String id, final String name, final String contentTypeName) {
    PropertyTree rootDataSet = new PropertyTree();
    rootDataSet.addString("property1", "value1");

    Region region =
        Region.create()
            .name("myRegion")
            .add(
                PartComponent.create()
                    .name("myPartComponent")
                    .descriptor(DescriptorKey.from("myapplication:myparttemplate"))
                    .build())
            .build();

    PageRegions pageRegions = PageRegions.create().add(region).build();
    Page page =
        Page.create().template(PageTemplateKey.from("my-page")).regions(pageRegions).build();

    return Content.create()
        .id(ContentId.from(id))
        .path(ContentPath.from(name))
        .owner(PrincipalKey.from("user:myStore:me"))
        .displayName("My Content")
        .modifier(PrincipalKey.from("user:system:admin"))
        .type(ContentTypeName.from(contentTypeName))
        .page(page)
        .build();
  }
Esempio n. 2
0
  private PageTemplate createPageTemplate() {
    final PropertyTree pageTemplateConfig = new PropertyTree();
    pageTemplateConfig.addLong("pause", 10000L);

    PageRegions pageRegions =
        PageRegions.create()
            .add(
                Region.create()
                    .name("main-region")
                    .add(PartComponent.create().name(ComponentName.from("mypart")).build())
                    .build())
            .build();

    final PageTemplate.Builder builder =
        PageTemplate.newPageTemplate()
            .key(PageTemplateKey.from("abc"))
            .canRender(ContentTypeNames.from("myapplication:article", "myapplication:banner"))
            .regions(pageRegions)
            .config(pageTemplateConfig);

    builder.controller(DescriptorKey.from("mainapplication:landing-page"));

    builder.displayName("Main page template");
    builder.displayName("Main page template");
    builder.name("main-page-template");
    builder.parentPath(ContentPath.ROOT);

    return builder.build();
  }
Esempio n. 3
0
  private Content createPage(
      final String id, final String path, final String contentTypeName, final boolean withPage) {
    PropertyTree rootDataSet = new PropertyTree();
    rootDataSet.addString("property1", "value1");

    final Content.Builder content =
        Content.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(contentTypeName));

    if (withPage) {
      PageRegions pageRegions =
          PageRegions.create()
              .add(
                  Region.create()
                      .name("main-region")
                      .add(PartComponent.create().name(ComponentName.from("mypart")).build())
                      .build())
              .build();

      Page page =
          Page.create()
              .template(PageTemplateKey.from("my-page"))
              .regions(pageRegions)
              .config(rootDataSet)
              .build();
      content.page(page);
    }
    return content.build();
  }
Esempio n. 4
0
  protected final void setupTemplates() throws Exception {
    Mockito.when(this.pageTemplateService.getByKey(Mockito.eq(PageTemplateKey.from("my-page"))))
        .thenReturn(createPageTemplate());

    Mockito.when(this.pageDescriptorService.getByKey(Mockito.isA(DescriptorKey.class)))
        .thenReturn(createDescriptor());
  }
Esempio n. 5
0
 private PageTemplate createPageTemplate() {
   return PageTemplate.newPageTemplate()
       .key(PageTemplateKey.from("my-page"))
       .controller(DescriptorKey.from("myapplication:mypagetemplate"))
       .name("my-page-template")
       .parentPath(ContentPath.ROOT)
       .build();
 }
Esempio n. 6
0
  private Site createSite(final String id, final String name, final String contentTypeName) {
    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(name))
        .owner(PrincipalKey.from("user:myStore:me"))
        .displayName("My Content")
        .modifier(PrincipalKey.from("user:system:admin"))
        .type(ContentTypeName.from(contentTypeName))
        .page(page)
        .build();
  }