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