mirror of
https://github.com/datahub-project/datahub.git
synced 2025-09-07 16:16:51 +00:00
32 lines
856 B
Java
32 lines
856 B
Java
![]() |
package com.linkedin.metadata.entity;
|
||
|
|
||
|
import com.linkedin.common.Status;
|
||
|
import com.linkedin.common.urn.Urn;
|
||
|
import com.linkedin.entity.EnvelopedAspect;
|
||
|
import lombok.extern.slf4j.Slf4j;
|
||
|
|
||
|
|
||
|
@Slf4j
|
||
|
public class EntityUtils {
|
||
|
private EntityUtils() {
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Check if entity is removed (removed=true in Status aspect)
|
||
|
*/
|
||
|
public static boolean checkIfRemoved(EntityService entityService, Urn entityUrn) {
|
||
|
try {
|
||
|
EnvelopedAspect statusAspect =
|
||
|
entityService.getLatestEnvelopedAspect(entityUrn.getEntityType(), entityUrn, "status");
|
||
|
if (statusAspect == null) {
|
||
|
return false;
|
||
|
}
|
||
|
Status status = new Status(statusAspect.getValue().data());
|
||
|
return status.isRemoved();
|
||
|
} catch (Exception e) {
|
||
|
log.error("Error while checking if {} is removed", entityUrn, e);
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|