Search in sources :

Example 1 with ReturnValues

use of com.enonic.xp.repo.impl.ReturnValues in project xp by enonic.

the class GetResultCanReadResolverTest method anonymous_access.

@Test
public void anonymous_access() throws Exception {
    final ReturnValues returnValues = ReturnValues.create().add(IndexFieldNameNormalizer.normalize(NodeIndexPath.PERMISSIONS_READ.toString()), PrincipalKey.ofAnonymous().toString()).build();
    assertTrue(GetResultCanReadResolver.canRead(PrincipalKeys.empty(), returnValues.get(NodeIndexPath.PERMISSIONS_READ.toString())));
}
Also used : ReturnValues(com.enonic.xp.repo.impl.ReturnValues) Test(org.junit.jupiter.api.Test)

Example 2 with ReturnValues

use of com.enonic.xp.repo.impl.ReturnValues in project xp by enonic.

the class GetResultCanReadResolverTest method anonymous_no_access.

@Test
public void anonymous_no_access() throws Exception {
    final ReturnValues returnValues = ReturnValues.create().add(IndexFieldNameNormalizer.normalize(NodeIndexPath.PERMISSIONS_READ.toString()), "user:system:rmy").build();
    assertFalse(GetResultCanReadResolver.canRead(PrincipalKeys.empty(), returnValues.get(NodeIndexPath.PERMISSIONS_READ.getPath())));
}
Also used : ReturnValues(com.enonic.xp.repo.impl.ReturnValues) Test(org.junit.jupiter.api.Test)

Example 3 with ReturnValues

use of com.enonic.xp.repo.impl.ReturnValues in project xp by enonic.

the class IndexDataServiceImpl method get.

@Override
public ReturnValues get(final NodeIds nodeIds, final ReturnFields returnFields, final InternalContext context) {
    final GetByIdsRequest getByIdsRequest = new GetByIdsRequest();
    for (final NodeId nodeId : nodeIds) {
        getByIdsRequest.add(createGetByIdRequest(nodeId, returnFields, context));
    }
    final GetResults result = storageDao.getByIds(getByIdsRequest);
    final ReturnValues.Builder allResultValues = ReturnValues.create();
    for (GetResult getResult : result) {
        final ReturnValues returnValues = getResult.getReturnValues();
        for (final String key : returnValues.getReturnValues().keySet()) {
            allResultValues.add(key, returnValues.get(key).getValues());
        }
    }
    return allResultValues.build();
}
Also used : NodeId(com.enonic.xp.node.NodeId) ReturnValues(com.enonic.xp.repo.impl.ReturnValues)

Example 4 with ReturnValues

use of com.enonic.xp.repo.impl.ReturnValues 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)

Example 5 with ReturnValues

use of com.enonic.xp.repo.impl.ReturnValues in project xp by enonic.

the class GetResultCanReadResolverTest method user_access.

@Test
public void user_access() throws Exception {
    final ReturnValues returnValues = ReturnValues.create().add(IndexFieldNameNormalizer.normalize(NodeIndexPath.PERMISSIONS_READ.toString()), PrincipalKey.from("user:system:rmy").toString()).build();
    assertTrue(GetResultCanReadResolver.canRead(PrincipalKeys.from(PrincipalKey.from("user:system:rmy")), returnValues.get(NodeIndexPath.PERMISSIONS_READ.toString())));
}
Also used : ReturnValues(com.enonic.xp.repo.impl.ReturnValues) Test(org.junit.jupiter.api.Test)

Aggregations

ReturnValues (com.enonic.xp.repo.impl.ReturnValues)6 Test (org.junit.jupiter.api.Test)4 BlobKeys (com.enonic.xp.blob.BlobKeys)1 NodeVersionKey (com.enonic.xp.blob.NodeVersionKey)1 NodeId (com.enonic.xp.node.NodeId)1 ReturnValue (com.enonic.xp.repo.impl.ReturnValue)1 Instant (java.time.Instant)1