Search in sources :

Example 56 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class RepoDumper method createDumpEntry.

private BranchDumpEntry createDumpEntry(final NodeId nodeId) {
    final BranchDumpEntry.Builder builder = BranchDumpEntry.create().nodeId(nodeId);
    final Node currentNode = this.nodeService.getById(nodeId);
    final NodeVersionMetadata currentVersionMetaData = getActiveVersion(nodeId);
    builder.meta(VersionMetaFactory.create(currentNode, currentVersionMetaData));
    if (this.includeBinaries) {
        builder.addBinaryReferences(currentNode.getAttachedBinaries().stream().map(AttachedBinary::getBlobKey).collect(Collectors.toSet()));
    }
    return builder.build();
}
Also used : NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata) Node(com.enonic.xp.node.Node) BranchDumpEntry(com.enonic.xp.repo.impl.dump.model.BranchDumpEntry) AttachedBinary(com.enonic.xp.node.AttachedBinary)

Example 57 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class BranchEntryProcessor method addNode.

private void addNode(final EntryLoadResult.Builder result, final BranchDumpEntry branchDumpEntry, final VersionMeta meta) {
    final NodeVersion nodeVersion = getVersion(meta);
    if (nodeVersion == null) {
        reportVersionError(result, meta);
        return;
    }
    final Node node = NodeFactory.create(nodeVersion, NodeBranchEntry.create().nodeId(branchDumpEntry.getNodeId()).nodePath(meta.getNodePath()).timestamp(meta.getTimestamp()).nodeState(meta.getNodeState()).nodeVersionId(meta.getVersion()).build());
    try {
        this.nodeService.loadNode(LoadNodeParams.create().node(node).nodeCommitId(meta.getNodeCommitId()).build());
        validateOrAddBinary(nodeVersion, result);
        result.successful();
    } catch (Exception e) {
        final String message = String.format("Cannot load node with id %s, path %s: %s", node.id(), node.path(), e.getMessage());
        result.error(EntryLoadError.error(message));
        LOG.error(message, e);
    }
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) Node(com.enonic.xp.node.Node) IOException(java.io.IOException) RepoLoadException(com.enonic.xp.repo.impl.dump.RepoLoadException)

Example 58 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class ReindexExecutor method doReindexBranchNew.

private void doReindexBranchNew(final RepositoryId repositoryId, final ReindexResult.Builder builder, final Branch branch) {
    final NodeBranchEntries nodeBranchEntries = GetBranchDataCommand.create().branch(branch).repositoryId(repositoryId).nodeSearchService(this.nodeSearchService).build().execute();
    if (listener != null) {
        listener.branch(repositoryId, branch, nodeBranchEntries.getSize());
    }
    for (final NodeBranchEntry nodeBranchEntry : nodeBranchEntries) {
        final InternalContext context = InternalContext.create(ContextAccessor.current()).repositoryId(repositoryId).branch(branch).build();
        final NodeVersion nodeVersion = this.nodeVersionService.get(nodeBranchEntry.getNodeVersionKey(), context);
        final Node node = NodeFactory.create(nodeVersion, nodeBranchEntry);
        this.indexDataService.store(node, context);
        builder.add(node.id());
        if (listener != null) {
            listener.branchEntry(nodeBranchEntry);
        }
    }
}
Also used : NodeBranchEntries(com.enonic.xp.node.NodeBranchEntries) NodeVersion(com.enonic.xp.node.NodeVersion) InternalContext(com.enonic.xp.repo.impl.InternalContext) Node(com.enonic.xp.node.Node) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 59 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class ApplyNodePermissionsCommand method applyPermissions.

private Node applyPermissions(final AccessControlList permissions, final Node node) {
    if (contextUserHasPermissionOrAdmin(Permission.WRITE_PERMISSIONS, node)) {
        final Node childApplied = storePermissions(permissions, node);
        if (params.getListener() != null) {
            params.getListener().permissionsApplied(1);
        }
        applyPermissionsToChildren(childApplied);
        resultBuilder.succeedNode(childApplied);
        return childApplied;
    } else {
        params.getListener().notEnoughRights(1);
        resultBuilder.skippedNode(node);
        LOG.info("Not enough rights for applying permissions to node [" + node.id() + "] " + node.path());
        return node;
    }
}
Also used : Node(com.enonic.xp.node.Node)

Example 60 with Node

use of com.enonic.xp.node.Node in project xp by enonic.

the class ApplyNodePermissionsCommand method execute.

public ApplyNodePermissionsResult execute() {
    final Node node = doGetById(params.getNodeId());
    if (node == null) {
        return resultBuilder.build();
    }
    applyPermissions(params.getPermissions() != null ? params.getPermissions() : node.getPermissions(), node);
    return resultBuilder.build();
}
Also used : Node(com.enonic.xp.node.Node)

Aggregations

Node (com.enonic.xp.node.Node)521 Test (org.junit.jupiter.api.Test)371 PropertyTree (com.enonic.xp.data.PropertyTree)114 NodeId (com.enonic.xp.node.NodeId)52 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)51 NodePath (com.enonic.xp.node.NodePath)45 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)42 UpdateNodeParams (com.enonic.xp.node.UpdateNodeParams)34 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)32 FindNodesByParentResult (com.enonic.xp.node.FindNodesByParentResult)29 NodeQuery (com.enonic.xp.node.NodeQuery)27 AccessControlList (com.enonic.xp.security.acl.AccessControlList)27 BinaryReference (com.enonic.xp.util.BinaryReference)26 ByteSource (com.google.common.io.ByteSource)24 Content (com.enonic.xp.content.Content)23 PropertySet (com.enonic.xp.data.PropertySet)20 NodeIds (com.enonic.xp.node.NodeIds)18 Context (com.enonic.xp.context.Context)17 InternalContext (com.enonic.xp.repo.impl.InternalContext)17 Application (com.enonic.xp.app.Application)16