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