Search in sources :

Example 16 with InternalContext

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);
    }
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Map(java.util.Map) NodePath(com.enonic.xp.node.NodePath)

Example 17 with InternalContext

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());
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Context(com.enonic.xp.context.Context) InternalContext(com.enonic.xp.repo.impl.InternalContext) Node(com.enonic.xp.node.Node)

Example 18 with InternalContext

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();
}
Also used : NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry) BlobKeys(com.enonic.xp.blob.BlobKeys) NodePaths(com.enonic.xp.node.NodePaths) Nodes(com.enonic.xp.node.Nodes) RoutableNodeVersionIds(com.enonic.xp.node.RoutableNodeVersionIds) Node(com.enonic.xp.node.Node) VersionService(com.enonic.xp.repo.impl.version.VersionService) NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) BlobKey(com.enonic.xp.blob.BlobKey) Branch(com.enonic.xp.branch.Branch) Permission(com.enonic.xp.security.acl.Permission) NodeCommitId(com.enonic.xp.node.NodeCommitId) Component(org.osgi.service.component.annotations.Component) BranchService(com.enonic.xp.repo.impl.branch.BranchService) ContextAccessor(com.enonic.xp.context.ContextAccessor) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) NodeVersionId(com.enonic.xp.node.NodeVersionId) NodeVersionKeys(com.enonic.xp.blob.NodeVersionKeys) PushNodeEntries(com.enonic.xp.node.PushNodeEntries) AttachedBinaries(com.enonic.xp.node.AttachedBinaries) InternalContext(com.enonic.xp.repo.impl.InternalContext) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) NodePath(com.enonic.xp.node.NodePath) NodeVersions(com.enonic.xp.node.NodeVersions) AuthenticationInfo(com.enonic.xp.security.auth.AuthenticationInfo) AccessControlList(com.enonic.xp.security.acl.AccessControlList) AttachedBinary(com.enonic.xp.node.AttachedBinary) NodeId(com.enonic.xp.node.NodeId) PushNodeEntry(com.enonic.xp.node.PushNodeEntry) NodeCommitEntry(com.enonic.xp.node.NodeCommitEntry) NodeVersionService(com.enonic.xp.repo.impl.node.dao.NodeVersionService) NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) RoutableNodeVersionId(com.enonic.xp.node.RoutableNodeVersionId) NodeVersion(com.enonic.xp.node.NodeVersion) RoleKeys(com.enonic.xp.security.RoleKeys) CommitService(com.enonic.xp.repo.impl.commit.CommitService) Reference(org.osgi.service.component.annotations.Reference) NodeIds(com.enonic.xp.node.NodeIds) NodeFactory(com.enonic.xp.repo.impl.branch.storage.NodeFactory) PushNodesListener(com.enonic.xp.node.PushNodesListener) NodeVersionKeys(com.enonic.xp.blob.NodeVersionKeys) Nodes(com.enonic.xp.node.Nodes) NodeVersions(com.enonic.xp.node.NodeVersions)

Aggregations

InternalContext (com.enonic.xp.repo.impl.InternalContext)18 Node (com.enonic.xp.node.Node)6 Context (com.enonic.xp.context.Context)5 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)5 NodeNotFoundException (com.enonic.xp.node.NodeNotFoundException)5 NodePath (com.enonic.xp.node.NodePath)5 NodeBranchEntries (com.enonic.xp.node.NodeBranchEntries)4 NodeId (com.enonic.xp.node.NodeId)4 Map (java.util.Map)4 Branch (com.enonic.xp.branch.Branch)3 NodeIds (com.enonic.xp.node.NodeIds)3 NodePaths (com.enonic.xp.node.NodePaths)3 NodeVersion (com.enonic.xp.node.NodeVersion)3 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)2 ContextAccessor (com.enonic.xp.context.ContextAccessor)2 NodeAlreadyExistAtPathException (com.enonic.xp.node.NodeAlreadyExistAtPathException)2 NodeCommitEntry (com.enonic.xp.node.NodeCommitEntry)2 NodeCommitId (com.enonic.xp.node.NodeCommitId)2 NodeComparison (com.enonic.xp.node.NodeComparison)2 NodeVersionId (com.enonic.xp.node.NodeVersionId)2