Search in sources :

Example 1 with NodeVersion

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

the class RepoDumper method doStoreVersion.

private void doStoreVersion(final VersionsDumpEntry.Builder builder, final NodeVersionMetadata metaData, final RepoDumpResult.Builder dumpResult) {
    try {
        final NodeVersion nodeVersion = this.nodeService.getByNodeVersionKey(metaData.getNodeVersionKey());
        builder.addVersion(VersionMetaFactory.create(metaData));
        storeVersionBlob(metaData.getNodeVersionId(), metaData.getNodeVersionKey());
        storeVersionBinaries(metaData.getNodeVersionId(), nodeVersion);
    } catch (Exception e) {
        dumpResult.error(DumpError.error(e.getMessage()));
    }
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion)

Example 2 with NodeVersion

use of com.enonic.xp.node.NodeVersion 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 3 with NodeVersion

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

the class FlattenedPageDumpUpgrader method upgradeBlobRecord.

private void upgradeBlobRecord(final DumpBlobRecord dumpBlobRecord, final FlattenedPageDataUpgrader dataUpgrader) {
    final NodeVersion nodeVersion = getNodeVersion(dumpBlobRecord);
    final boolean upgraded = dataUpgrader.upgrade(nodeVersion.getData());
    if (upgraded) {
        writeNodeVersion(nodeVersion, dumpBlobRecord);
    }
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion)

Example 4 with NodeVersion

use of com.enonic.xp.node.NodeVersion 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 5 with NodeVersion

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

the class NodeStorageServiceImpl method getNode.

@Override
public Node getNode(final NodeId nodeId, final NodeVersionId nodeVersionId, final InternalContext context) {
    final NodeVersionMetadata nodeVersionMetadata = versionService.getVersion(nodeId, nodeVersionId, context);
    if (nodeVersionMetadata == null) {
        return null;
    }
    final NodeVersion nodeVersion = nodeVersionService.get(nodeVersionMetadata.getNodeVersionKey(), context);
    if (nodeVersion == null) {
        return null;
    }
    return constructNode(nodeVersion, nodeVersionMetadata);
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) NodeVersionMetadata(com.enonic.xp.node.NodeVersionMetadata)

Aggregations

NodeVersion (com.enonic.xp.node.NodeVersion)23 Node (com.enonic.xp.node.Node)9 Test (org.junit.jupiter.api.Test)8 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)6 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)6 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)4 NodeId (com.enonic.xp.node.NodeId)4 NodeVersionId (com.enonic.xp.node.NodeVersionId)4 InternalContext (com.enonic.xp.repo.impl.InternalContext)4 PropertyTree (com.enonic.xp.data.PropertyTree)3 NodePath (com.enonic.xp.node.NodePath)3 DumpBlobRecord (com.enonic.xp.repo.impl.dump.blobstore.DumpBlobRecord)3 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)3 BlobKey (com.enonic.xp.blob.BlobKey)2 BlobRecord (com.enonic.xp.blob.BlobRecord)2 DumpUpgradeStepResult (com.enonic.xp.dump.DumpUpgradeStepResult)2 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)2 MemoryBlobRecord (com.enonic.xp.internal.blobstore.MemoryBlobRecord)2 AttachedBinary (com.enonic.xp.node.AttachedBinary)2 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)2