Search in sources :

Example 51 with Site

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

the class GetNearestSiteCommandTest method get_nearest_site_parent_is_site.

@Test
public void get_nearest_site_parent_is_site() throws Exception {
    final ContentId contentId = ContentId.from("aaa");
    final Node node = Node.create().id(NodeId.from("test")).name("myContent").parentPath(ContentConstants.CONTENT_ROOT_PATH).build();
    final Content content = Content.create().id(contentId).name("name").parentPath(ContentPath.from("/aaa")).build();
    final Site parent = Site.create().path("/mycontent").id(ContentId.from("bbb")).build();
    Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenReturn(node);
    Mockito.when(this.nodeService.getByPath(Mockito.isA(NodePath.class))).thenReturn(node);
    Mockito.when(this.translator.fromNode(node, true)).thenReturn(content, parent);
    assertEquals(parent, createCommand(contentId).execute());
}
Also used : Site(com.enonic.xp.site.Site) Content(com.enonic.xp.content.Content) Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) ContentId(com.enonic.xp.content.ContentId) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 52 with Site

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

the class GetNearestSiteCommandTest method get_nearest_site_parent_of_parent_is_site.

@Test
public void get_nearest_site_parent_of_parent_is_site() throws Exception {
    final Node node = Node.create().id(NodeId.from("test")).name("myContent").parentPath(ContentConstants.CONTENT_ROOT_PATH).build();
    final ContentId contentId = ContentId.from("aaa");
    final Content content = Content.create().id(contentId).name("name").parentPath(ContentPath.from("/aaa")).build();
    final Content parent = Content.create().id(ContentId.from("bbb")).name("renome").parentPath(ContentPath.from("/bbb")).build();
    final Site parentOfParent = Site.create().path("/mycontent").id(ContentId.from("ccc")).build();
    Mockito.when(this.nodeService.getById(Mockito.any(NodeId.class))).thenReturn(node);
    Mockito.when(this.nodeService.getByPath(Mockito.isA(NodePath.class))).thenReturn(node);
    Mockito.when(this.translator.fromNode(node, true)).thenReturn(content, parent, parentOfParent);
    assertEquals(parentOfParent, createCommand(contentId).execute());
}
Also used : Site(com.enonic.xp.site.Site) Content(com.enonic.xp.content.Content) Node(com.enonic.xp.node.Node) NodeId(com.enonic.xp.node.NodeId) ContentId(com.enonic.xp.content.ContentId) NodePath(com.enonic.xp.node.NodePath) Test(org.junit.jupiter.api.Test)

Example 53 with Site

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

the class TestDataFixtures method newSite.

public static Site 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.build();
}
Also used : Site(com.enonic.xp.site.Site) PropertyTree(com.enonic.xp.data.PropertyTree) SiteConfig(com.enonic.xp.site.SiteConfig)

Example 54 with Site

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

the class LocaleScriptBean method resolveLocaleFromSite.

private Locale resolveLocaleFromSite() {
    final PortalRequest request = portalRequest.get();
    if (request == null) {
        return null;
    }
    final Site site = request.getSite();
    if (site != null) {
        return site.getLanguage();
    }
    return null;
}
Also used : Site(com.enonic.xp.site.Site) PortalRequest(com.enonic.xp.portal.PortalRequest)

Example 55 with Site

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

the class ContentResolver method resolveInNonEditMode.

private ContentResolverResult resolveInNonEditMode(final ContentPath contentPath) {
    Content content = getContentByPath(contentPath);
    final boolean contentExists = content != null || contentExistsByPath(contentPath);
    final Site site = callAsContentAdmin(() -> this.contentService.findNearestSiteByPath(contentPath));
    return new ContentResolverResult(content, contentExists, site, siteRelativePath(site, contentPath), contentPath.toString());
}
Also used : Site(com.enonic.xp.site.Site) Content(com.enonic.xp.content.Content)

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