Search in sources :

Example 1 with ImportContentParams

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

the class ContentServiceImplTest_importContent method skipSourcePermissionsOnCreate.

@Test
public void skipSourcePermissionsOnCreate() throws Exception {
    final AccessControlList aclList = AccessControlList.create().add(AccessControlEntry.create().principal(TEST_DEFAULT_USER.getKey()).allowAll().deny(Permission.DELETE).build()).build();
    final Content sourceContent = ctxDefault().callWith(() -> createContent(ContentPath.ROOT, "content1", aclList));
    final ImportContentParams importContentParams = ImportContentParams.create().importContent(sourceContent).targetPath(ContentPath.from(ContentPath.ROOT, sourceContent.getName().toString())).importPermissionsOnCreate(false).build();
    final Content importedContent = ctxOther().callWith(() -> this.contentService.importContent(importContentParams).getContent());
    assertNotEquals(sourceContent.getPermissions(), importedContent.getPermissions());
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) ImportContentParams(com.enonic.xp.content.ImportContentParams) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Example 2 with ImportContentParams

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

the class ContentServiceImplTest_importContent method keepSourcePermissionsOnCreate.

@Test
public void keepSourcePermissionsOnCreate() throws Exception {
    final AccessControlList aclList = AccessControlList.create().add(AccessControlEntry.create().principal(TEST_DEFAULT_USER.getKey()).allowAll().deny(Permission.DELETE).build()).build();
    final Content sourceContent = ctxDefault().callWith(() -> createContent(ContentPath.ROOT, "content1", aclList));
    final ImportContentParams importContentParams = ImportContentParams.create().importContent(sourceContent).targetPath(ContentPath.from(ContentPath.ROOT, sourceContent.getName().toString())).importPermissionsOnCreate(true).build();
    final Content importedContent = ctxOther().callWith(() -> this.contentService.importContent(importContentParams).getContent());
    assertEquals(sourceContent.getPermissions(), importedContent.getPermissions());
}
Also used : AccessControlList(com.enonic.xp.security.acl.AccessControlList) ImportContentParams(com.enonic.xp.content.ImportContentParams) Content(com.enonic.xp.content.Content) Test(org.junit.jupiter.api.Test)

Aggregations

Content (com.enonic.xp.content.Content)2 ImportContentParams (com.enonic.xp.content.ImportContentParams)2 AccessControlList (com.enonic.xp.security.acl.AccessControlList)2 Test (org.junit.jupiter.api.Test)2