Search in sources :

Example 1 with NodeVersionKey

use of com.enonic.xp.blob.NodeVersionKey in project xp by enonic.

the class NodeStorageServiceImpl method store.

@Override
public Node store(final Node node, final InternalContext context) {
    final NodeVersionId nodeVersionId = new NodeVersionId();
    final NodeVersionKey nodeVersionKey = nodeVersionService.store(NodeVersion.from(node), context);
    storeVersionMetadata(node, nodeVersionId, nodeVersionKey, context);
    final StoreBranchMetadataParams storeBranchMetadataParams = StoreBranchMetadataParams.create().node(node).nodeVersionId(nodeVersionId).nodeVersionKey(nodeVersionKey).context(context).build();
    storeBranchMetadata(storeBranchMetadataParams);
    indexNode(node, nodeVersionId, context);
    return Node.create(node).nodeVersionId(nodeVersionId).build();
}
Also used : NodeVersionId(com.enonic.xp.node.NodeVersionId) RoutableNodeVersionId(com.enonic.xp.node.RoutableNodeVersionId) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey)

Example 2 with NodeVersionKey

use of com.enonic.xp.blob.NodeVersionKey in project xp by enonic.

the class NodeStorageServiceImpl method updateMetadata.

@Override
public Node updateMetadata(final Node node, final InternalContext context) {
    final NodeBranchEntry nodeBranchEntry = this.branchService.get(node.id(), context);
    if (nodeBranchEntry == null) {
        throw new NodeNotFoundException("Cannot find node with id: " + node.id() + " in branch " + context.getBranch());
    }
    final NodeVersionId nodeVersionId = nodeBranchEntry.getVersionId();
    final NodeVersionKey nodeVersionKey = nodeBranchEntry.getNodeVersionKey();
    final StoreBranchMetadataParams storeBranchMetadataParams = StoreBranchMetadataParams.create().node(node).nodeVersionId(nodeVersionId).nodeVersionKey(nodeVersionKey).context(context).build();
    storeBranchMetadata(storeBranchMetadataParams);
    indexNode(node, nodeVersionId, context);
    return Node.create(node).nodeVersionId(nodeVersionId).build();
}
Also used : NodeNotFoundException(com.enonic.xp.node.NodeNotFoundException) NodeVersionId(com.enonic.xp.node.NodeVersionId) RoutableNodeVersionId(com.enonic.xp.node.RoutableNodeVersionId) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) NodeBranchEntry(com.enonic.xp.node.NodeBranchEntry)

Example 3 with NodeVersionKey

use of com.enonic.xp.blob.NodeVersionKey in project xp by enonic.

the class NodeStorageServiceImpl method storeVersion.

@Override
public void storeVersion(final StoreNodeVersionParams params, final InternalContext context) {
    final NodeVersionKey nodeVersionKey = this.nodeVersionService.store(params.getNodeVersion(), context);
    this.versionService.store(NodeVersionMetadata.create().nodeVersionId(params.getNodeVersionId()).nodeVersionKey(nodeVersionKey).binaryBlobKeys(getBinaryBlobKeys(params.getNodeVersion().getAttachedBinaries())).nodeId(params.getNodeId()).nodePath(params.getNodePath()).nodeCommitId(params.getNodeCommitId()).timestamp(params.getTimestamp()).build(), context);
}
Also used : NodeVersionKey(com.enonic.xp.blob.NodeVersionKey)

Example 4 with NodeVersionKey

use of com.enonic.xp.blob.NodeVersionKey in project xp by enonic.

the class NodeStorageServiceImpl method load.

@Override
public Node load(final LoadNodeParams params, final InternalContext context) {
    final Node node = params.getNode();
    final NodeVersion nodeVersion = NodeVersion.create().id(node.id()).nodeType(node.getNodeType()).data(node.data()).indexConfigDocument(node.getIndexConfigDocument()).childOrder(node.getChildOrder()).manualOrderValue(node.getManualOrderValue()).permissions(node.getPermissions()).inheritPermissions(node.inheritsPermissions()).attachedBinaries(node.getAttachedBinaries()).build();
    final NodeVersionId nodeVersionId = node.getNodeVersionId();
    final NodeVersionKey nodeVersionKey = nodeVersionService.store(nodeVersion, context);
    final LoadVersionMetadataParams loadVersionMetadataParams = LoadVersionMetadataParams.create().node(node).nodeVersionId(nodeVersionId).nodeVersionKey(nodeVersionKey).nodeCommitId(params.getNodeCommitId()).context(context).build();
    loadVersionMetadata(loadVersionMetadataParams);
    final StoreBranchMetadataParams storeBranchMetadataParams = StoreBranchMetadataParams.create().node(node).nodeVersionId(nodeVersionId).nodeVersionKey(nodeVersionKey).context(context).build();
    storeBranchMetadata(storeBranchMetadataParams);
    indexNode(node, nodeVersionId, context);
    return Node.create(node).nodeVersionId(nodeVersionId).build();
}
Also used : NodeVersion(com.enonic.xp.node.NodeVersion) NodeVersionId(com.enonic.xp.node.NodeVersionId) RoutableNodeVersionId(com.enonic.xp.node.RoutableNodeVersionId) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) Node(com.enonic.xp.node.Node)

Example 5 with NodeVersionKey

use of com.enonic.xp.blob.NodeVersionKey in project xp by enonic.

the class NodeVersionQueryResultFactory method createVersionEntry.

private static NodeVersionMetadata createVersionEntry(final SearchHit hit) {
    final String timestamp = getStringValue(hit, VersionIndexPath.TIMESTAMP, true);
    final String versionId = getStringValue(hit, VersionIndexPath.VERSION_ID, true);
    final String nodeBlobKey = getStringValue(hit, VersionIndexPath.NODE_BLOB_KEY, true);
    final String indexConfigBlobKey = getStringValue(hit, VersionIndexPath.INDEX_CONFIG_BLOB_KEY, true);
    final String accessControlBlobKey = getStringValue(hit, VersionIndexPath.ACCESS_CONTROL_BLOB_KEY, true);
    final ReturnValue binaryBlobKeyReturnValue = hit.getField(VersionIndexPath.BINARY_BLOB_KEYS.getPath(), false);
    final String nodePath = getStringValue(hit, VersionIndexPath.NODE_PATH, true);
    final String nodeId = getStringValue(hit, VersionIndexPath.NODE_ID, true);
    final String commitId = getStringValue(hit, VersionIndexPath.COMMIT_ID, false);
    final NodeVersionKey nodeVersionKey = NodeVersionKey.from(nodeBlobKey, indexConfigBlobKey, accessControlBlobKey);
    final BlobKeys binaryBlobKeys = toBlobKeys(binaryBlobKeyReturnValue);
    return NodeVersionMetadata.create().nodeVersionId(NodeVersionId.from(versionId)).nodeVersionKey(nodeVersionKey).binaryBlobKeys(binaryBlobKeys).timestamp(isNullOrEmpty(timestamp) ? null : Instant.parse(timestamp)).nodePath(NodePath.create(nodePath).build()).nodeId(NodeId.from(nodeId)).nodeCommitId(isNullOrEmpty(commitId) ? null : NodeCommitId.from(commitId)).build();
}
Also used : BlobKeys(com.enonic.xp.blob.BlobKeys) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) ReturnValue(com.enonic.xp.repo.impl.ReturnValue)

Aggregations

NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)14 NodeVersionId (com.enonic.xp.node.NodeVersionId)7 Node (com.enonic.xp.node.Node)6 Test (org.junit.jupiter.api.Test)6 NodeVersion (com.enonic.xp.node.NodeVersion)5 NodeId (com.enonic.xp.node.NodeId)4 RoutableNodeVersionId (com.enonic.xp.node.RoutableNodeVersionId)4 BlobRecord (com.enonic.xp.blob.BlobRecord)3 MemoryBlobRecord (com.enonic.xp.internal.blobstore.MemoryBlobRecord)3 NodeBranchEntry (com.enonic.xp.node.NodeBranchEntry)3 InternalContext (com.enonic.xp.repo.impl.InternalContext)3 AbstractNodeTest (com.enonic.xp.repo.impl.node.AbstractNodeTest)3 BlobKeys (com.enonic.xp.blob.BlobKeys)2 Segment (com.enonic.xp.blob.Segment)2 CreateNodeParams (com.enonic.xp.node.CreateNodeParams)2 NodePath (com.enonic.xp.node.NodePath)2 NodeVersionMetadata (com.enonic.xp.node.NodeVersionMetadata)2 ReturnValue (com.enonic.xp.repo.impl.ReturnValue)2 PropertyTree (com.enonic.xp.data.PropertyTree)1 CachedBlobStore (com.enonic.xp.internal.blobstore.cache.CachedBlobStore)1