Search in sources :

Example 6 with InternalContext

use of com.enonic.xp.repo.impl.InternalContext in project xp by enonic.

the class SetActiveVersionCommand method execute.

public NodeVersionId execute() {
    final InternalContext context = InternalContext.from(ContextAccessor.current());
    final Node node = this.nodeStorageService.get(nodeId, nodeVersionId, context);
    if (node == null) {
        throw new NodeNotFoundException("Cannot find nodeVersion [" + this.nodeVersionId + "] in branch " + context.getBranch().getValue());
    }
    if (!node.id().equals(nodeId)) {
        throw new NodeNotFoundException("NodeVersionId [" + nodeVersionId + "] not a version of Node with id [" + nodeId + "]");
    }
    NodePermissionsResolver.requireContextUserPermissionOrAdmin(REQUIRED_PERMISSION, node);
    this.nodeStorageService.updateVersion(node, nodeVersionId, context);
    return nodeVersionId;
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) InternalContext(com.enonic.xp.repo.impl.InternalContext) Node(com.enonic.xp.node.Node)

Example 7 with InternalContext

use of com.enonic.xp.repo.impl.InternalContext in project xp by enonic.

the class NodeCreatedHandler method handleEvent.

@Override
public void handleEvent(NodeStorageService nodeStorageService, 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);
        nodeStorageService.handleNodeCreated(getId(map), getPath(map), nodeContext);
    }
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Map(java.util.Map)

Example 8 with InternalContext

use of com.enonic.xp.repo.impl.InternalContext in project xp by enonic.

the class RepositoryServiceImpl method pushRootNode.

private void pushRootNode(final Repository currentRepo, final Branch branch) {
    final Context context = ContextAccessor.current();
    final InternalContext internalContext = InternalContext.create(context).branch(RepositoryConstants.MASTER_BRANCH).build();
    final Node rootNode = this.nodeStorageService.get(Node.ROOT_UUID, internalContext);
    if (rootNode == null) {
        throw new NodeNotFoundException("Cannot find root-node in repository [" + currentRepo + "]");
    }
    this.nodeStorageService.push(rootNode, branch, internalContext);
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Context(com.enonic.xp.context.Context) NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) InternalContext(com.enonic.xp.repo.impl.InternalContext) Node(com.enonic.xp.node.Node)

Example 9 with InternalContext

use of com.enonic.xp.repo.impl.InternalContext in project xp by enonic.

the class RepositoryServiceImpl method getRootNode.

private Node getRootNode(final RepositoryId repositoryId, final Branch branch) {
    final Context rootNodeContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(repositoryId).branch(branch).build();
    final InternalContext rootNodeInternalContext = InternalContext.create(rootNodeContext).build();
    return this.nodeStorageService.get(Node.ROOT_UUID, rootNodeInternalContext);
}
Also used : InternalContext(com.enonic.xp.repo.impl.InternalContext) Context(com.enonic.xp.context.Context) InternalContext(com.enonic.xp.repo.impl.InternalContext)

Example 10 with InternalContext

use of com.enonic.xp.repo.impl.InternalContext in project xp by enonic.

the class DumpServiceImplTest method createRootNode.

private void createRootNode(final RepositoryId repositoryId, final AccessControlList permissions, final ChildOrder childOrder) {
    final Context rootNodeContext = ContextBuilder.from(ContextAccessor.current()).repositoryId(repositoryId).branch(RepositoryConstants.MASTER_BRANCH).build();
    final InternalContext rootNodeInternalContext = InternalContext.create(rootNodeContext).build();
    this.storageService.store(Node.createRoot().permissions(permissions != null ? permissions : RepositoryConstants.DEFAULT_REPO_PERMISSIONS).inheritPermissions(false).childOrder(childOrder != null ? childOrder : RepositoryConstants.DEFAULT_CHILD_ORDER).build(), rootNodeInternalContext);
    rootNodeContext.runWith(() -> nodeService.refresh(RefreshMode.ALL));
}
Also used : BundleContext(org.osgi.framework.BundleContext) Context(com.enonic.xp.context.Context) InternalContext(com.enonic.xp.repo.impl.InternalContext) InternalContext(com.enonic.xp.repo.impl.InternalContext)

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