use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.
the class GetBranchEntriesMethod method execute.
@Override
public void execute(final Collection<NodeId> nodeIds, final NodeBranchEntries.Builder builder) {
final GetByIdsRequest getByIdsRequest = new GetByIdsRequest();
for (final NodeId nodeId : nodeIds) {
getByIdsRequest.add(GetByIdRequest.create().id(new BranchDocumentId(nodeId, context.getBranch()).toString()).storageSettings(StorageSource.create().storageName(StoreStorageName.from(context.getRepositoryId())).storageType(StaticStorageType.BRANCH).build()).returnFields(returnFields).routing(nodeId.toString()).build());
}
final GetResults getResults = this.storageDao.getByIds(getByIdsRequest);
for (final GetResult getResult : getResults) {
if (!getResult.isEmpty()) {
final NodeBranchEntry nodeBranchEntry = NodeBranchVersionFactory.create(getResult.getReturnValues());
builder.add(nodeBranchEntry);
}
}
}
use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.
the class NodeStorageServiceImpl method doReturnNodes.
private Nodes doReturnNodes(final NodeBranchEntries nodeBranchEntries, final InternalContext context) {
final NodeVersionKeys.Builder builder = NodeVersionKeys.create();
nodeBranchEntries.stream().map(NodeBranchEntry::getNodeVersionKey).forEach(builder::add);
final NodeVersions nodeVersions = nodeVersionService.get(builder.build(), context);
final Nodes.Builder filteredNodes = Nodes.create();
nodeVersions.stream().filter((nodeVersion) -> canRead(nodeVersion.getPermissions())).forEach((nodeVersion) -> filteredNodes.add(NodeFactory.create(nodeVersion, nodeBranchEntries.get(nodeVersion.getId()))));
return filteredNodes.build();
}
use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.
the class NodeStorageServiceImpl method move.
@Override
public Node move(final StoreMovedNodeParams params, final InternalContext context) {
final NodeBranchEntry nodeBranchEntry = this.branchService.get(params.getNode().id(), context);
final NodeVersionKey nodeVersionKey = nodeVersionService.store(NodeVersion.from(params.getNode()), context);
NodeVersionId nodeVersionId = params.getNodeVersionId();
if (nodeVersionId == null) {
nodeVersionId = new NodeVersionId();
storeVersionMetadata(params.getNode(), nodeVersionId, nodeVersionKey, context);
}
return moveInBranchAndReIndex(params.getNode(), nodeVersionId, nodeVersionKey, nodeBranchEntry.getNodePath(), context);
}
use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.
the class NodeStorageServiceImpl method push.
@Override
public void push(final PushNodeEntries entries, final PushNodesListener pushListener, final InternalContext context) {
for (final PushNodeEntry entry : entries) {
final NodeBranchEntry nodeBranchEntry = entry.getNodeBranchEntry();
this.branchService.store(nodeBranchEntry, entry.getCurrentTargetPath(), InternalContext.create(context).branch(entries.getTargetBranch()).build());
if (pushListener != null) {
pushListener.nodesPushed(1);
}
}
this.indexDataService.push(IndexPushNodeParams.create().nodeIds(entries.getNodeIds()).targetBranch(entries.getTargetBranch()).targetRepo(entries.getTargetRepo()).pushListener(pushListener).build(), context);
}
use of com.enonic.xp.node.NodeBranchEntry in project xp by enonic.
the class NodeStorageServiceImplTest method testGetNode_ByPath.
@Test
public void testGetNode_ByPath() {
final NodeBranchEntry nodeBranchEntry = NodeBranchEntry.create().nodeId(nodeId).nodePath(nodePath).nodeState(NodeState.DEFAULT).build();
final NodeVersionMetadata nodeVersionMetadata = NodeVersionMetadata.create().nodeVersionId(nodeVersionId).nodeVersionKey(versionKey).nodePath(nodePath).build();
final NodeVersion nodeVersion = NodeVersion.create().permissions(AccessControlList.create().add(AccessControlEntry.create().principal(RoleKeys.EVERYONE).allow(Permission.READ).build()).build()).build();
when(branchService.get(any(NodePath.class), any(InternalContext.class))).thenReturn(nodeBranchEntry);
when(versionService.getVersion(any(NodeId.class), any(NodeVersionId.class), any(InternalContext.class))).thenReturn(nodeVersionMetadata);
when(nodeVersionService.get(any(NodeVersionKey.class), any(InternalContext.class))).thenReturn(nodeVersion);
final Node result = instance.getNode(nodePath, nodeVersionId, context);
assertNotNull(result);
verify(branchService, times(1)).get(any(NodePath.class), any(InternalContext.class));
verify(versionService, times(1)).getVersion(any(NodeId.class), any(NodeVersionId.class), any(InternalContext.class));
verify(nodeVersionService, times(1)).get(any(NodeVersionKey.class), any(InternalContext.class));
verifyNoMoreInteractions(branchService, versionService, nodeVersionService);
}
Aggregations