use of com.enonic.xp.repo.impl.InternalContext in project xp by enonic.
the class NodePushedHandler method handleEvent.
@Override
public void handleEvent(NodeStorageService storageService, final Event event, final InternalContext context) {
final List<Map<Object, Object>> valueMapList = getValueMapList(event);
for (final Map<Object, Object> map : valueMapList) {
final InternalContext nodeContext = createNodeContext(map, context);
final NodePath currentTargetPath = map.containsKey(CURRENT_TARGET_PATH) ? NodePath.create(map.get(CURRENT_TARGET_PATH).toString()).build() : null;
storageService.handleNodePushed(getId(map), getPath(map), currentTargetPath, nodeContext);
}
}
use of com.enonic.xp.repo.impl.InternalContext in project xp by enonic.
the class RepositoryServiceImpl method createRootNode.
private void createRootNode(final CreateRepositoryParams params) {
final Context rootNodeContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(params.getRepositoryId()).branch(RepositoryConstants.MASTER_BRANCH).build();
final InternalContext rootNodeInternalContext = InternalContext.create(rootNodeContext).build();
final Node rootNode = this.nodeStorageService.store(Node.createRoot().permissions(params.getRootPermissions()).inheritPermissions(false).childOrder(params.getRootChildOrder()).build(), rootNodeInternalContext);
rootNodeContext.runWith(() -> RefreshCommand.create().indexServiceInternal(this.indexServiceInternal).refreshMode(RefreshMode.ALL).build().execute());
LOG.info("Created root node with id [{}] in repository [{}]", rootNode.id(), params.getRepositoryId());
}
use of com.enonic.xp.repo.impl.InternalContext 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();
}
Aggregations