Search in sources :

Example 36 with ContentPath

use of com.enonic.xp.content.ContentPath in project xp by enonic.

the class ContentPathsTest method addAndRemoveContentPath.

@Test
void addAndRemoveContentPath() {
    Set<ContentPath> set = Set.of(CONTENT_PATH2, CONTENT_PATH3);
    ContentPath[] array = { CONTENT_PATH2, CONTENT_PATH3 };
    ContentPaths pathsFromSet = ContentPaths.from(CONTENT_PATH1).add(set);
    ContentPaths pathsFromArray = ContentPaths.from(CONTENT_PATH1).add(array);
    assertEquals(pathsFromSet, pathsFromArray);
    pathsFromArray = pathsFromArray.remove(set);
    pathsFromSet = pathsFromSet.remove(array);
    assertEquals(pathsFromSet, pathsFromArray);
    assertEquals(pathsFromSet.hashCode(), pathsFromArray.hashCode());
    assertEquals(pathsFromSet.toString(), pathsFromArray.toString());
}
Also used : ContentPaths(com.enonic.xp.content.ContentPaths) ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Example 37 with ContentPath

use of com.enonic.xp.content.ContentPath in project xp by enonic.

the class ContentServiceImplTest_findByParent method hasChildResolved.

@Test
public void hasChildResolved() throws Exception {
    final Content parentContent = createContent(ContentPath.ROOT);
    final Content content1 = createContent(parentContent.getPath());
    createContent(content1.getPath());
    final ContentPath parentContentPath = parentContent.getPath();
    this.nodeService.refresh(RefreshMode.SEARCH);
    final FindContentByParentParams params = FindContentByParentParams.create().from(0).size(30).parentPath(parentContentPath).build();
    final FindContentByParentResult result = contentService.findByParent(params);
    assertNotNull(result);
    assertEquals(1, result.getTotalHits());
    final Content content1Result = result.getContents().getContentById(content1.getId());
    assertTrue(content1Result.hasChildren());
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) Content(com.enonic.xp.content.Content) ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Example 38 with ContentPath

use of com.enonic.xp.content.ContentPath in project xp by enonic.

the class ContentServiceImplTest_findByParent method params_from.

@Test
public void params_from() throws Exception {
    final Content parentContent = createContent(ContentPath.ROOT);
    createContent(parentContent.getPath());
    createContent(parentContent.getPath());
    createContent(parentContent.getPath());
    createContent(parentContent.getPath());
    final ContentPath parentContentPath = parentContent.getPath();
    this.nodeService.refresh(RefreshMode.SEARCH);
    final FindContentByParentParams params = FindContentByParentParams.create().from(2).parentPath(parentContentPath).build();
    final FindContentByParentResult result = contentService.findByParent(params);
    assertNotNull(result);
    assertEquals(2, result.getHits());
    assertEquals(4, result.getTotalHits());
    assertEquals(2, result.getContents().getSize());
}
Also used : FindContentByParentParams(com.enonic.xp.content.FindContentByParentParams) FindContentByParentResult(com.enonic.xp.content.FindContentByParentResult) Content(com.enonic.xp.content.Content) ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Example 39 with ContentPath

use of com.enonic.xp.content.ContentPath in project xp by enonic.

the class ContentPathConverterTest method testSameType.

@Test
public void testSameType() {
    final ContentPath path = ContentPath.from("/some/path");
    assertSame(path, Converters.convert(path, ContentPath.class));
}
Also used : ContentPath(com.enonic.xp.content.ContentPath) Test(org.junit.jupiter.api.Test)

Example 40 with ContentPath

use of com.enonic.xp.content.ContentPath in project xp by enonic.

the class ContentServiceImpl method getRootPermissions.

@Override
public AccessControlList getRootPermissions() {
    final ContentPath rootContentPath = ContentPath.ROOT;
    final NodePath rootNodePath = ContentNodeHelper.translateContentPathToNodePath(rootContentPath);
    final Node rootNode = nodeService.getByPath(rootNodePath);
    return rootNode != null ? rootNode.getPermissions() : AccessControlList.empty();
}
Also used : Node(com.enonic.xp.node.Node) ContentPath(com.enonic.xp.content.ContentPath) NodePath(com.enonic.xp.node.NodePath)

Aggregations

ContentPath (com.enonic.xp.content.ContentPath)56 Content (com.enonic.xp.content.Content)30 Test (org.junit.jupiter.api.Test)30 ContentNotFoundException (com.enonic.xp.content.ContentNotFoundException)13 ContentId (com.enonic.xp.content.ContentId)11 FindContentByParentParams (com.enonic.xp.content.FindContentByParentParams)10 WebException (com.enonic.xp.web.WebException)8 FindContentByParentResult (com.enonic.xp.content.FindContentByParentResult)6 ArrayList (java.util.ArrayList)5 FindContentIdsByParentResult (com.enonic.xp.content.FindContentIdsByParentResult)4 Node (com.enonic.xp.node.Node)4 PortalRequest (com.enonic.xp.portal.PortalRequest)4 ContentInheritType (com.enonic.xp.content.ContentInheritType)3 Context (com.enonic.xp.context.Context)3 Site (com.enonic.xp.site.Site)3 ContentAlreadyExistsException (com.enonic.xp.content.ContentAlreadyExistsException)2 CONTENT_ROOT_PATH_ATTRIBUTE (com.enonic.xp.content.ContentConstants.CONTENT_ROOT_PATH_ATTRIBUTE)2 ContentVersionId (com.enonic.xp.content.ContentVersionId)2 List (java.util.List)2 Set (java.util.Set)2