use of org.hypertrace.entity.data.service.v1.EnrichedEntities in project entity-service by hypertrace.
the class EntityDataServiceImpl method upsertEnrichedEntities.
@Override
public void upsertEnrichedEntities(EnrichedEntities request, StreamObserver<Empty> responseObserver) {
String tenantId = RequestContext.CURRENT.get().getTenantId().orElse(null);
if (isNull(tenantId)) {
responseObserver.onError(new ServiceException("Tenant id is missing in the request."));
return;
}
for (EnrichedEntity entity : request.getEntitiesList()) {
if (StringUtils.isEmpty(entity.getEntityType())) {
LOG.info("{}. Invalid upsertEnrichedEntities request:{}", entity, ErrorMessages.ENTITY_TYPE_EMPTY);
responseObserver.onError(new RuntimeException(ErrorMessages.ENTITY_TYPE_EMPTY));
return;
}
if (StringUtils.isEmpty(entity.getEntityId())) {
LOG.info("{}. Invalid upsertEnrichedEntities request:{}", entity, ErrorMessages.ENTITY_ID_EMPTY);
responseObserver.onError(new RuntimeException(ErrorMessages.ENTITY_ID_EMPTY));
return;
}
}
Map<Key, EnrichedEntity> entities = request.getEntitiesList().stream().collect(Collectors.toUnmodifiableMap(entity -> this.entityNormalizer.getEntityDocKey(tenantId, entity.getEntityType(), entity.getEntityId()), Function.identity()));
upsertEntities(entities, enrichedEntitiesCollection, responseObserver);
}
Aggregations