Search in sources :

Example 1 with BlobKeys

use of com.enonic.xp.blob.BlobKeys 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)

Example 2 with BlobKeys

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

the class NodeVersionFactory method create.

public static NodeVersionMetadata create(final GetResult getResult) {
    final ReturnValues values = getResult.getReturnValues();
    final String versionId = values.getSingleValue(VersionIndexPath.VERSION_ID.getPath()).toString();
    final String nodeBlobKey = values.getSingleValue(VersionIndexPath.NODE_BLOB_KEY.getPath()).toString();
    final String indexConfigBlobKey = values.getSingleValue(VersionIndexPath.INDEX_CONFIG_BLOB_KEY.getPath()).toString();
    final String accessControlBlobKey = values.getSingleValue(VersionIndexPath.ACCESS_CONTROL_BLOB_KEY.getPath()).toString();
    final ReturnValue binaryBlobKeysReturnValue = values.get(VersionIndexPath.BINARY_BLOB_KEYS.getPath());
    final Instant timestamp = Instant.parse(values.getSingleValue(VersionIndexPath.TIMESTAMP.getPath()).toString());
    final String id = values.getSingleValue(VersionIndexPath.NODE_ID.getPath()).toString();
    final String path = values.getSingleValue(VersionIndexPath.NODE_PATH.getPath()).toString();
    final Object commitId = values.getSingleValue(VersionIndexPath.COMMIT_ID.getPath());
    final NodeVersionKey nodeVersionKey = NodeVersionKey.from(nodeBlobKey, indexConfigBlobKey, accessControlBlobKey);
    final BlobKeys binaryBlobKeys = toBlobKeys(binaryBlobKeysReturnValue);
    return NodeVersionMetadata.create().nodeId(NodeId.from(id)).nodePath(NodePath.create(path).build()).timestamp(timestamp).nodeVersionId(NodeVersionId.from(versionId)).nodeVersionKey(nodeVersionKey).binaryBlobKeys(binaryBlobKeys).nodeCommitId(commitId == null ? null : NodeCommitId.from(commitId.toString())).build();
}
Also used : BlobKeys(com.enonic.xp.blob.BlobKeys) NodeVersionKey(com.enonic.xp.blob.NodeVersionKey) Instant(java.time.Instant) ReturnValue(com.enonic.xp.repo.impl.ReturnValue) ReturnValues(com.enonic.xp.repo.impl.ReturnValues)

Aggregations

BlobKeys (com.enonic.xp.blob.BlobKeys)2 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)2 ReturnValue (com.enonic.xp.repo.impl.ReturnValue)2 ReturnValues (com.enonic.xp.repo.impl.ReturnValues)1 Instant (java.time.Instant)1