Search in sources :

Example 1 with ApplyContentPermissionsResult

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

the class ContentServiceImpl method applyPermissions.

@Override
public ApplyContentPermissionsResult applyPermissions(final ApplyContentPermissionsParams params) {
    final ApplyContentPermissionsResult result = ApplyContentPermissionsCommand.create(params).nodeService(this.nodeService).contentTypeService(this.contentTypeService).translator(this.translator).eventPublisher(this.eventPublisher).build().execute();
    contentAuditLogSupport.applyPermissions(params, result);
    return result;
}
Also used : ApplyContentPermissionsResult(com.enonic.xp.content.ApplyContentPermissionsResult)

Example 2 with ApplyContentPermissionsResult

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

the class ContentServiceImplTest_applyPermissions method audit_data.

@Test
public void audit_data() throws Exception {
    final ArgumentCaptor<LogAuditLogParams> captor = ArgumentCaptor.forClass(LogAuditLogParams.class);
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content content = this.contentService.create(createContentParams);
    final ApplyContentPermissionsParams applyParams = ApplyContentPermissionsParams.create().contentId(content.getId()).applyContentPermissionsListener(Mockito.mock(ApplyPermissionsListener.class)).build();
    final ApplyContentPermissionsResult result = this.contentService.applyPermissions(applyParams);
    Mockito.verify(auditLogService, Mockito.timeout(5000).times(2)).log(captor.capture());
    final PropertySet logResultSet = captor.getValue().getData().getSet("result");
    assertEquals(content.getPath().toString(), logResultSet.getStrings("succeedContents").iterator().next());
}
Also used : LogAuditLogParams(com.enonic.xp.audit.LogAuditLogParams) CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ApplyContentPermissionsParams(com.enonic.xp.content.ApplyContentPermissionsParams) PropertySet(com.enonic.xp.data.PropertySet) ApplyContentPermissionsResult(com.enonic.xp.content.ApplyContentPermissionsResult) Test(org.junit.jupiter.api.Test)

Example 3 with ApplyContentPermissionsResult

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

the class ContentServiceImplTest_applyPermissions method content_not_found.

@Test
public void content_not_found() throws Exception {
    final ApplyContentPermissionsParams applyParams = ApplyContentPermissionsParams.create().contentId(ContentId.from("id1")).applyContentPermissionsListener(Mockito.mock(ApplyPermissionsListener.class)).build();
    final ApplyContentPermissionsResult result = this.contentService.applyPermissions(applyParams);
    assertEquals(result.getSkippedContents().getSize(), 0);
    assertEquals(result.getSucceedContents().getSize(), 0);
}
Also used : ApplyContentPermissionsParams(com.enonic.xp.content.ApplyContentPermissionsParams) ApplyContentPermissionsResult(com.enonic.xp.content.ApplyContentPermissionsResult) Test(org.junit.jupiter.api.Test)

Example 4 with ApplyContentPermissionsResult

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

the class ContentServiceImplTest_applyPermissions method success.

@Test
public void success() throws Exception {
    final CreateContentParams createContentParams = CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my content").parent(ContentPath.ROOT).type(ContentTypeName.folder()).build();
    final Content content = this.contentService.create(createContentParams);
    final Content child = this.contentService.create(CreateContentParams.create(createContentParams).parent(content.getPath()).build());
    final ApplyContentPermissionsParams applyParams = ApplyContentPermissionsParams.create().contentId(content.getId()).applyContentPermissionsListener(Mockito.mock(ApplyPermissionsListener.class)).build();
    final ApplyContentPermissionsResult result = this.contentService.applyPermissions(applyParams);
    assertEquals(result.getSkippedContents().getSize(), 0);
    assertEquals(result.getSucceedContents().getSize(), 2);
    assertTrue(result.getSucceedContents().contains(child.getPath()));
    assertTrue(result.getSucceedContents().contains(content.getPath()));
}
Also used : CreateContentParams(com.enonic.xp.content.CreateContentParams) Content(com.enonic.xp.content.Content) PropertyTree(com.enonic.xp.data.PropertyTree) ApplyContentPermissionsParams(com.enonic.xp.content.ApplyContentPermissionsParams) ApplyContentPermissionsResult(com.enonic.xp.content.ApplyContentPermissionsResult) Test(org.junit.jupiter.api.Test)

Aggregations

ApplyContentPermissionsResult (com.enonic.xp.content.ApplyContentPermissionsResult)4 ApplyContentPermissionsParams (com.enonic.xp.content.ApplyContentPermissionsParams)3 Test (org.junit.jupiter.api.Test)3 Content (com.enonic.xp.content.Content)2 CreateContentParams (com.enonic.xp.content.CreateContentParams)2 PropertyTree (com.enonic.xp.data.PropertyTree)2 LogAuditLogParams (com.enonic.xp.audit.LogAuditLogParams)1 PropertySet (com.enonic.xp.data.PropertySet)1