use of org.hypertrace.entity.service.exception.InvalidRequestException in project entity-service by hypertrace.
the class EntityDataServiceImpl method getEnrichedEntityById.
@Override
public void getEnrichedEntityById(ByIdRequest request, StreamObserver<EnrichedEntity> responseObserver) {
try {
validate(request);
} catch (InvalidRequestException e) {
responseObserver.onError(e);
return;
}
Optional<String> tenantId = RequestContext.CURRENT.get().getTenantId();
if (tenantId.isEmpty()) {
responseObserver.onError(new ServiceException("Tenant id is missing in the request."));
return;
}
searchByIdAndStreamSingleResponse(tenantId.get(), request.getEntityId(), request.getEntityType(), enrichedEntitiesCollection, EnrichedEntity.newBuilder(), responseObserver);
}
use of org.hypertrace.entity.service.exception.InvalidRequestException in project entity-service by hypertrace.
the class EntityDataServiceImpl method getById.
/**
* Get an Entity by the EntityId and EntityType
*
* @param request ID of the entity which constitutes the EntityType and EntityID(UUID)
* @param responseObserver Observer to be notified on about the Entity get request
*/
@Override
public void getById(ByIdRequest request, StreamObserver<Entity> responseObserver) {
try {
validate(request);
} catch (InvalidRequestException e) {
responseObserver.onError(e);
return;
}
Optional<String> tenantId = RequestContext.CURRENT.get().getTenantId();
if (tenantId.isEmpty()) {
responseObserver.onError(new ServiceException("Tenant id is missing in the request."));
return;
}
searchByIdAndStreamSingleResponse(tenantId.get(), request.getEntityId(), request.getEntityType(), entitiesCollection, Entity.newBuilder(), responseObserver);
}
use of org.hypertrace.entity.service.exception.InvalidRequestException in project entity-service by hypertrace.
the class EntityDataServiceImpl method getByTypeAndIdentifyingProperties.
/**
* Get an Entity by the EntityType and its identifying attributes
*
* @param request ID of the entity which constitutes the EntityType and EntityID(UUID)
* @param responseObserver Observer to be notified on about the Entity get request
*/
@Override
public void getByTypeAndIdentifyingProperties(ByTypeAndIdentifyingAttributes request, StreamObserver<Entity> responseObserver) {
try {
validate(request);
} catch (InvalidRequestException e) {
responseObserver.onError(e);
return;
}
String tenantId = RequestContext.CURRENT.get().getTenantId().orElse(null);
if (tenantId == null) {
responseObserver.onError(new ServiceException("Tenant id is missing in the request."));
return;
}
String entityId = this.entityIdGenerator.generateEntityId(tenantId, request.getEntityType(), request.getIdentifyingAttributesMap());
searchByIdAndStreamSingleResponse(tenantId, entityId, request.getEntityType(), entitiesCollection, Entity.newBuilder(), responseObserver);
}
use of org.hypertrace.entity.service.exception.InvalidRequestException in project entity-service by hypertrace.
the class EntityDataServiceImpl method getEnrichedEntityByTypeAndIdentifyingProps.
@Override
public void getEnrichedEntityByTypeAndIdentifyingProps(ByTypeAndIdentifyingAttributes request, StreamObserver<EnrichedEntity> responseObserver) {
try {
validate(request);
} catch (InvalidRequestException e) {
responseObserver.onError(e);
return;
}
String tenantId = RequestContext.CURRENT.get().getTenantId().orElse(null);
if (tenantId == null) {
responseObserver.onError(new ServiceException("Tenant id is missing in the request."));
return;
}
String entityId = this.entityIdGenerator.generateEntityId(tenantId, request.getEntityType(), request.getIdentifyingAttributesMap());
searchByIdAndStreamSingleResponse(tenantId, entityId, request.getEntityType(), enrichedEntitiesCollection, EnrichedEntity.newBuilder(), responseObserver);
}
Aggregations