Search in sources :

Example 1 with CompareContentResult

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

the class PublishContentCommand method pushAndDelete.

private void pushAndDelete(final CompareContentResults results) {
    NodeIds.Builder pushNodesIds = NodeIds.create();
    NodeIds.Builder deletedNodesIds = NodeIds.create();
    for (CompareContentResult compareResult : results) {
        if (compareResult.getCompareStatus() == CompareStatus.PENDING_DELETE) {
            deletedNodesIds.add(NodeId.from(compareResult.getContentId()));
        } else {
            pushNodesIds.add(NodeId.from(compareResult.getContentId()));
        }
    }
    final ContentIds pushContentsIds = ContentIds.from(pushNodesIds.build().stream().map((n) -> ContentId.from(n.toString())).toArray(ContentId[]::new));
    final boolean validContents = checkIfAllContentsValid(pushContentsIds);
    if (validContents) {
        doPushNodes(pushNodesIds.build());
    } else {
        this.resultBuilder.setFailed(pushContentsIds);
    }
    doDeleteNodes(deletedNodesIds.build());
}
Also used : NodeIds(com.enonic.xp.node.NodeIds) CompareContentResult(com.enonic.xp.content.CompareContentResult) ContentIds(com.enonic.xp.content.ContentIds) ContentId(com.enonic.xp.content.ContentId)

Example 2 with CompareContentResult

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

the class ContentServiceImplTest_publish method assertStatus.

private void assertStatus(final ContentId id, CompareStatus status) {
    final CompareContentResult compare = this.contentService.compare(new CompareContentParams(id, WS_OTHER));
    assertEquals(status, compare.getCompareStatus());
}
Also used : CompareContentResult(com.enonic.xp.content.CompareContentResult) CompareContentParams(com.enonic.xp.content.CompareContentParams)

Aggregations

CompareContentResult (com.enonic.xp.content.CompareContentResult)2 CompareContentParams (com.enonic.xp.content.CompareContentParams)1 ContentId (com.enonic.xp.content.ContentId)1 ContentIds (com.enonic.xp.content.ContentIds)1 NodeIds (com.enonic.xp.node.NodeIds)1