use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesResultMapperTest method single_failed.
@Test
public void single_failed() throws Exception {
final PushNodesResult result = PushNodesResult.create().addFailed(createEntry("a"), PushNodesResult.Reason.ACCESS_DENIED).build();
final JsonMapGenerator jsonGenerator = new JsonMapGenerator();
new PushNodesResultMapper(result, NodeIds.empty()).serialize(jsonGenerator);
assertJson("nodeResult/single_failed.json", jsonGenerator);
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PublishContentCommand method doPushNodes.
private void doPushNodes(final NodeIds nodesToPush) {
if (nodesToPush.isEmpty()) {
return;
}
SetPublishInfoCommand.create(this).nodeIds(nodesToPush).contentPublishInfo(contentPublishInfo).pushListener(publishContentListener).build().execute();
final PushNodesResult pushNodesResult = nodeService.push(nodesToPush, this.target, this);
commitPushedNodes(pushNodesResult.getSuccessful());
this.resultBuilder.setFailed(ContentNodeHelper.toContentIds(NodeIds.from(pushNodesResult.getFailed().stream().map(failed -> failed.getNodeBranchEntry().getNodeId()).collect(Collectors.toList()))));
this.resultBuilder.setPushed(ContentNodeHelper.toContentIds(NodeIds.from(pushNodesResult.getSuccessful().getKeys())));
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesCommandTest method push_rename_push.
@Test
public void push_rename_push() throws Exception {
final Node parent = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("parent").setNodeId(NodeId.from("parent")).build());
final Node child1 = createNode(CreateNodeParams.create().parent(parent.path()).name("child1").setNodeId(NodeId.from("child1")).build());
final Node child1_1 = createNode(CreateNodeParams.create().parent(child1.path()).name("child1_1").setNodeId(NodeId.from("child1_1")).build());
pushNodes(NodeIds.from(parent.id(), child1.id()), WS_OTHER);
renameNode(parent, "parent-renamed");
renameNode(child1, "child1-renamed");
renameNode(child1_1, "child1_1-renamed");
final PushNodesResult result = pushNodes(NodeIds.from(parent.id(), child1.id()), WS_OTHER);
assertEquals(2, result.getSuccessful().getSize());
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesCommandTest method rename_to_name_already_there_but_renamed_in_same_push.
@Test
public void rename_to_name_already_there_but_renamed_in_same_push() throws Exception {
final Node a = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("a").setNodeId(NodeId.from("a")).build());
final Node b = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("b").setNodeId(NodeId.from("b")).build());
pushNodes(NodeIds.from(a.id()), WS_OTHER);
renameNode(a.id(), "a_old");
renameNode(b.id(), "a");
final PushNodesResult result = pushNodes(NodeIds.from(b.id(), a.id()), WS_OTHER);
assertEquals(0, result.getFailed().size());
assertEquals(2, result.getSuccessful().getSize());
}
use of com.enonic.xp.node.PushNodesResult in project xp by enonic.
the class PushNodesCommandTest method ensure_order_for_publish_with_children.
@Test
public void ensure_order_for_publish_with_children() throws Exception {
final Node node = createNode(CreateNodeParams.create().parent(NodePath.ROOT).name("my-node").build());
final Node child1 = createNode(CreateNodeParams.create().parent(node.path()).name("my-child").build());
final Node child2 = createNode(CreateNodeParams.create().parent(node.path()).name("my-child2").build());
final Node child1_1 = createNode(CreateNodeParams.create().parent(node.path()).name("my-child1_1").build());
final Node child2_1 = createNode(CreateNodeParams.create().parent(node.path()).name("my-child2_1").build());
final PushNodesResult result = pushNodes(NodeIds.from(child2_1.id(), child1_1.id(), child1.id(), child2.id(), node.id()), WS_OTHER);
assertTrue(result.getFailed().isEmpty());
ctxOther().runWith(() -> {
assertNotNull(getNodeById(node.id()));
assertNotNull(getNodeById(child1.id()));
assertNotNull(getNodeById(child1_1.id()));
assertNotNull(getNodeById(child2.id()));
assertNotNull(getNodeById(child2_1.id()));
});
}
Aggregations