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