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;
}
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);
}
}
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);
}
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);
}
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));
}
Aggregations