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