use of com.enonic.xp.node.Nodes in project xp by enonic.
the class DuplicateNodeCommand method storeChildNodes.
private void storeChildNodes(final Node originalParent, final Node newParent, final NodeReferenceUpdatesHolder.Builder builder) {
final FindNodesByParentResult findNodesByParentResult = doFindNodesByParent(FindNodesByParentParams.create().parentPath(originalParent.path()).from(0).size(NodeSearchService.GET_ALL_SIZE_FLAG).build());
final Nodes children = GetNodesByIdsCommand.create(this).ids(findNodesByParentResult.getNodeIds()).build().execute();
for (final Node node : children) {
final CreateNodeParams.Builder paramsBuilder = CreateNodeParams.from(node).parent(newParent.path());
decideInsertStrategy(originalParent, node, paramsBuilder);
attachBinaries(node, paramsBuilder);
final CreateNodeParams originalParams = paramsBuilder.build();
final CreateNodeParams processedParams = executeProcessors(originalParams);
final Node newChildNode = CreateNodeCommand.create(this).params(processedParams).binaryService(this.binaryService).build().execute();
builder.add(node.id(), newChildNode.id());
result.addChild(newChildNode);
nodeDuplicated(1);
storeChildNodes(node, newChildNode, builder);
}
}
use of com.enonic.xp.node.Nodes in project xp by enonic.
the class DuplicateNodeCommandTest method assertDuplicatedTree.
private void assertDuplicatedTree(final NodePath duplicatedTreeRootPath, final Node originalNode, final Node duplicatedNode) {
final ImmutableList<Property> originalReferences = originalNode.data().getProperties(ValueTypes.REFERENCE);
final ImmutableList<Property> duplicateReferences = duplicatedNode.data().getProperties(ValueTypes.REFERENCE);
assertReferenceIntegrity(duplicatedTreeRootPath, originalReferences, duplicateReferences);
final Nodes originalChildren = getNodes(findChildren(originalNode).getNodeIds());
final Nodes duplicatedChildren = getNodes(findChildren(duplicatedNode).getNodeIds());
assertEquals(originalChildren.getSize(), duplicatedChildren.getSize());
originalChildren.forEach((originalChild) -> {
final Node duplicatedChild = getNodeByName(duplicatedChildren, originalChild.name());
assertDuplicatedTree(duplicatedTreeRootPath, originalChild, duplicatedChild);
});
}
use of com.enonic.xp.node.Nodes in project xp by enonic.
the class GetNodesByIsCommandTest method get_by_id_no_access.
@Test
public void get_by_id_no_access() throws Exception {
createNode("1", true);
createNode("2", true);
createNode("3", false);
final Nodes nodes = GetNodesByIdsCommand.create().ids(NodeIds.from("1", "2", "3")).indexServiceInternal(this.indexServiceInternal).storageService(this.storageService).searchService(this.searchService).build().execute();
assertEquals(2, nodes.getSize());
}
use of com.enonic.xp.node.Nodes in project xp by enonic.
the class SecurityServiceImpl method getIdProviders.
@Override
public IdProviders getIdProviders() {
final FindNodesByParentParams findByParent = FindNodesByParentParams.create().parentPath(IdProviderNodeTranslator.getIdProvidersParentPath()).build();
final Nodes nodes = callWithContext(() -> {
final FindNodesByParentResult result = this.nodeService.findByParent(findByParent);
return this.nodeService.getByIds(result.getNodeIds());
});
return IdProviderNodeTranslator.fromNodes(nodes);
}
use of com.enonic.xp.node.Nodes in project xp by enonic.
the class SecurityServiceImpl method query.
@Override
public UserQueryResult query(final UserQuery query) {
try {
final NodeQuery nodeQueryBuilder = UserQueryNodeQueryTranslator.translate(query);
final FindNodesByQueryResult result = callWithContext(() -> this.nodeService.findByQuery(nodeQueryBuilder));
final Nodes nodes = callWithContext(() -> this.nodeService.getByIds(result.getNodeIds()));
final Principals principals = PrincipalNodeTranslator.fromNodes(nodes);
return UserQueryResult.create().addUsers(principals).totalSize(Ints.checkedCast(result.getTotalHits())).build();
} catch (NodeNotFoundException e) {
return UserQueryResult.create().build();
}
}
Aggregations