use of com.enonic.xp.content.Content in project xp by enonic.
the class ContentOutboundDependenciesIdsResolver method resolveOutboundDependenciesIds.
private ContentIds resolveOutboundDependenciesIds(final ContentId contentId) {
final Content content = this.contentService.getById(contentId);
final ContentIds.Builder contentIds = ContentIds.create();
final PropertySet contentPageData = new PropertyTree().getRoot();
if (content.getPage() != null) {
contentDataSerializer.toPageData(content.getPage(), contentPageData);
}
final Stream<Property> extraDataDependencies = content.hasExtraData() ? content.getAllExtraData().stream().flatMap(extraData -> extraData.getData().getProperties(ValueTypes.REFERENCE).stream()) : Stream.empty();
Stream.of(content.getData().getProperties(ValueTypes.REFERENCE).stream(), contentPageData.getProperties(ValueTypes.REFERENCE).stream(), extraDataDependencies).flatMap(s -> s).forEach(property -> {
final String value = property.getValue().toString();
if (!contentId.toString().equals(value) && !nullToEmpty(value).isBlank()) {
contentIds.add(ContentId.from(value));
}
});
if (content.getProcessedReferences() != null && content.getProcessedReferences().getSize() > 0) {
contentIds.addAll(content.getProcessedReferences());
}
return contentIds.build();
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ContentServiceImplTest_versions method get_published_versions.
@Test
public void get_published_versions() throws Exception {
final Content content = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("content").parent(ContentPath.ROOT).name("myContent").type(ContentTypeName.folder()).build());
this.contentService.publish(PushContentParams.create().contentIds(ContentIds.from(content.getId())).target(WS_OTHER).build());
this.contentService.unpublishContent(UnpublishContentParams.create().contentIds(ContentIds.from(content.getId())).unpublishBranch(WS_OTHER).build());
final FindContentVersionsResult result = this.contentService.getVersions(FindContentVersionsParams.create().contentId(content.getId()).build());
assertEquals(3, result.getHits());
assertEquals(3, result.getTotalHits());
final Iterator<ContentVersion> versions = result.getContentVersions().iterator();
assertNotNull(versions.next().getPublishInfo());
assertNotNull(versions.next().getPublishInfo());
assertNull(versions.next().getPublishInfo());
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ContentServiceImplTest_versions method version_workflow_info.
@Test
public void version_workflow_info() throws Exception {
final Map<String, WorkflowCheckState> checks = Map.of("checkName1", WorkflowCheckState.APPROVED, "checkName2", WorkflowCheckState.PENDING);
final WorkflowInfo workflowInfo = WorkflowInfo.create().state(WorkflowState.IN_PROGRESS).checks(checks).build();
final Content content = this.contentService.create(CreateContentParams.create().contentData(new PropertyTree()).displayName("This is my test content").parent(ContentPath.ROOT).name("myContent").type(ContentTypeName.folder()).workflowInfo(workflowInfo).build());
final FindContentVersionsResult versions = this.contentService.getVersions(FindContentVersionsParams.create().contentId(content.getId()).build());
final ContentVersion contentVersion = versions.getContentVersions().iterator().next();
final WorkflowInfo retrievedWorkflowInfo = contentVersion.getWorkflowInfo();
assertEquals(WorkflowState.IN_PROGRESS, retrievedWorkflowInfo.getState());
assertEquals(WorkflowCheckState.APPROVED, retrievedWorkflowInfo.getChecks().get("checkName1"));
assertEquals(WorkflowCheckState.PENDING, retrievedWorkflowInfo.getChecks().get("checkName2"));
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ProjectEventListenerTest method testSingle.
@Test
public void testSingle() throws InterruptedException {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
handleEvents();
final Content targetContent = targetContext.callWith(() -> contentService.getById(sourceContent.getId()));
compareSynched(sourceContent, targetContent);
}
use of com.enonic.xp.content.Content in project xp by enonic.
the class ProjectEventListenerTest method testChildren.
@Test
public void testChildren() throws InterruptedException {
final Content sourceContent = sourceContext.callWith(() -> createContent(ContentPath.ROOT, "name"));
final Content sourceChild1 = sourceContext.callWith(() -> createContent(sourceContent.getPath(), "name"));
final Content sourceChild2 = sourceContext.callWith(() -> createContent(sourceChild1.getPath(), "name"));
handleEvents();
final Content targetChild1 = targetContext.callWith(() -> contentService.getById(sourceChild1.getId()));
final Content targetChild2 = targetContext.callWith(() -> contentService.getById(sourceChild2.getId()));
compareSynched(sourceChild1, targetChild1);
compareSynched(sourceChild2, targetChild2);
}
Aggregations