Search in sources :

Example 61 with Site

use of com.enonic.xp.site.Site in project xp by enonic.

the class TestDataFixtures method newSite.

public static Site.Builder newSite() {
    final PropertyTree siteConfigConfig = new PropertyTree();
    siteConfigConfig.setLong("Field", 42L);
    final SiteConfig siteConfig = SiteConfig.create().application(ApplicationKey.from("myapplication")).config(siteConfigConfig).build();
    final Site.Builder site = Site.create();
    site.id(ContentId.from("100123"));
    site.siteConfigs(SiteConfigs.from(siteConfig));
    site.name("my-content");
    site.parentPath(ContentPath.ROOT);
    site.permissions(AccessControlList.of(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allow(Permission.READ).build()));
    return site;
}
Also used : Site(com.enonic.xp.site.Site) PropertyTree(com.enonic.xp.data.PropertyTree) SiteConfig(com.enonic.xp.site.SiteConfig)

Example 62 with Site

use of com.enonic.xp.site.Site in project xp by enonic.

the class GetCurrentSiteConfigScriptTest method testExample.

@Test
public void testExample() {
    final Site site = TestDataFixtures.newSite().build();
    this.portalRequest.setSite(site);
    runScript("/lib/xp/examples/portal/getSiteConfig.js");
}
Also used : Site(com.enonic.xp.site.Site) Test(org.junit.jupiter.api.Test)

Example 63 with Site

use of com.enonic.xp.site.Site in project xp by enonic.

the class ComponentInstructionTest method testInstructionRenderFragment.

@Test
public void testInstructionRenderFragment() throws Exception {
    RendererDelegate rendererDelegate = newRendererFactory("<b>part content</b>");
    ComponentService componentService = Mockito.mock(ComponentService.class);
    Component component = createPartComponent();
    doReturn(component).when(componentService).getByKey(isA(DescriptorKey.class));
    ComponentInstruction instruction = new ComponentInstruction();
    instruction.setRendererDelegate(rendererDelegate);
    instruction.setComponentService(componentService);
    PortalRequest portalRequest = new PortalRequest();
    Content content = createFragmentPage("content-id", "content-name");
    portalRequest.setContent(content);
    Site site = createSite("site-id", "site-name", "myapplication:content-type");
    portalRequest.setSite(site);
    PageTemplate pageTemplate = createPageTemplate();
    portalRequest.setPageTemplate(pageTemplate);
    String outputHtml = instruction.evaluate(portalRequest, "COMPONENT fragment").getAsString();
    assertEquals("<b>part content</b>", outputHtml);
}
Also used : Site(com.enonic.xp.site.Site) PageTemplate(com.enonic.xp.page.PageTemplate) Content(com.enonic.xp.content.Content) DescriptorKey(com.enonic.xp.page.DescriptorKey) ComponentService(com.enonic.xp.region.ComponentService) Component(com.enonic.xp.region.Component) PartComponent(com.enonic.xp.region.PartComponent) RendererDelegate(com.enonic.xp.portal.impl.rendering.RendererDelegate) PortalRequest(com.enonic.xp.portal.PortalRequest) Test(org.junit.jupiter.api.Test)

Example 64 with Site

use of com.enonic.xp.site.Site in project xp by enonic.

the class MacroInstructionTest method setUp.

@BeforeEach
public void setUp() {
    macroDescriptorService = Mockito.mock(MacroDescriptorService.class);
    macroProcessorFactory = Mockito.mock(MacroProcessorFactory.class);
    macroInstruction = new MacroInstruction();
    macroInstruction.setMacroDescriptorService(macroDescriptorService);
    macroInstruction.setMacroProcessorFactory(macroProcessorFactory);
    portalRequest = new PortalRequest();
    Site site = createSite("site-id", "site-name", "myapplication:content-type");
    portalRequest.setSite(site);
    portalRequest.setContent(site);
}
Also used : Site(com.enonic.xp.site.Site) MacroDescriptorService(com.enonic.xp.macro.MacroDescriptorService) MacroProcessorFactory(com.enonic.xp.portal.macro.MacroProcessorFactory) PortalRequest(com.enonic.xp.portal.PortalRequest) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 65 with Site

use of com.enonic.xp.site.Site in project xp by enonic.

the class ContentServiceImpl method create.

@Override
public Site create(final CreateSiteParams params) {
    final PropertyTree data = new PropertyTree();
    data.setString("description", params.getDescription());
    SITE_CONFIGS_DATA_SERIALIZER.toProperties(params.getSiteConfigs(), data.getRoot());
    final CreateContentParams createContentParams = CreateContentParams.create().type(ContentTypeName.site()).parent(params.getParentContentPath()).name(params.getName()).displayName(params.getDisplayName()).contentData(data).requireValid(params.isRequireValid()).build();
    final Site site = (Site) CreateContentCommand.create().nodeService(this.nodeService).contentTypeService(this.contentTypeService).translator(this.translator).eventPublisher(this.eventPublisher).siteService(this.siteService).xDataService(this.xDataService).contentProcessors(this.contentProcessors).contentValidators(this.contentValidators).formDefaultValuesProcessor(this.formDefaultValuesProcessor).pageDescriptorService(this.pageDescriptorService).partDescriptorService(this.partDescriptorService).layoutDescriptorService(this.layoutDescriptorService).contentDataSerializer(this.contentDataSerializer).allowUnsafeAttachmentNames(config.attachments_allowUnsafeNames()).params(createContentParams).build().execute();
    this.create(CreateContentParams.create().owner(site.getOwner()).displayName(TEMPLATES_FOLDER_DISPLAY_NAME).name(TEMPLATES_FOLDER_NAME).inheritPermissions(true).parent(site.getPath()).type(ContentTypeName.templateFolder()).requireValid(true).contentData(new PropertyTree()).build());
    contentAuditLogSupport.createSite(params, site);
    return site;
}
Also used : Site(com.enonic.xp.site.Site) CreateContentParams(com.enonic.xp.content.CreateContentParams) PropertyTree(com.enonic.xp.data.PropertyTree)

Aggregations

Site (com.enonic.xp.site.Site)78 Test (org.junit.jupiter.api.Test)51 Content (com.enonic.xp.content.Content)41 PortalRequest (com.enonic.xp.portal.PortalRequest)17 PropertyTree (com.enonic.xp.data.PropertyTree)14 Page (com.enonic.xp.page.Page)12 ContentId (com.enonic.xp.content.ContentId)10 ContentPath (com.enonic.xp.content.ContentPath)10 SiteConfig (com.enonic.xp.site.SiteConfig)10 WebException (com.enonic.xp.web.WebException)10 ApplicationKey (com.enonic.xp.app.ApplicationKey)9 PageTemplate (com.enonic.xp.page.PageTemplate)8 PortalResponse (com.enonic.xp.portal.PortalResponse)7 ControllerMappingDescriptor (com.enonic.xp.site.mapping.ControllerMappingDescriptor)7 SiteDescriptor (com.enonic.xp.site.SiteDescriptor)6 BeforeEach (org.junit.jupiter.api.BeforeEach)6 DescriptorKey (com.enonic.xp.page.DescriptorKey)5 SiteConfigs (com.enonic.xp.site.SiteConfigs)5 Branch (com.enonic.xp.branch.Branch)4 ContentService (com.enonic.xp.content.ContentService)4