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