Skip to content

Commit

Permalink
Revert "added validation for domain delete flow"
Browse files Browse the repository at this point in the history
This reverts commit 7cf5e4f, reversing
changes made to 5e7be71.
  • Loading branch information
PRATHAM2002-DS committed Sep 9, 2024
1 parent 7cf5e4f commit 2d7d175
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1644,6 +1644,8 @@ private void executePreProcessor(EntityMutationContext context) throws AtlasBase
LOG.debug("Executing preprocessor {} for entity {}", processor.getClass().getName(), entity.getGuid());
processor.processAttributes(entity, context, CREATE);
}


}

List<AtlasEntity> copyOfUpdated = new ArrayList<>(context.getUpdatedEntities());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public class AssetPreProcessor implements PreProcessor {
private AtlasTypeRegistry typeRegistry;
private EntityGraphRetriever entityRetriever;

private static final Set<String> excludedTypes = new HashSet<>(Arrays.asList(ATLAS_GLOSSARY_ENTITY_TYPE, ATLAS_GLOSSARY_TERM_ENTITY_TYPE, ATLAS_GLOSSARY_CATEGORY_ENTITY_TYPE, DATA_PRODUCT_ENTITY_TYPE, DATA_DOMAIN_ENTITY_TYPE));

public AssetPreProcessor(AtlasTypeRegistry typeRegistry, EntityGraphRetriever entityRetriever) {
this.typeRegistry = typeRegistry;
this.entityRetriever = entityRetriever;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static String updateQueryResourceAttributes(AtlasTypeRegistry typeRegistr
return newCollectionQualifiedName;
}

public static List<AtlasEntityHeader> indexSearchPaginated(Map<String, Object> dsl, Set<String> attributes, EntityDiscoveryService discovery, int size) throws AtlasBaseException {
public static List<AtlasEntityHeader> indexSearchPaginated(Map<String, Object> dsl, Set<String> attributes, EntityDiscoveryService discovery) throws AtlasBaseException {
IndexSearchParams searchParams = new IndexSearchParams();
List<AtlasEntityHeader> ret = new ArrayList<>();

Expand All @@ -180,6 +180,7 @@ public static List<AtlasEntityHeader> indexSearchPaginated(Map<String, Object> d
dsl.put("sort", sortList);

int from = 0;
int size = 100;
boolean hasMore = true;
do {
dsl.put("from", from);
Expand Down Expand Up @@ -212,7 +213,7 @@ public static void verifyDuplicateAssetByName(String typeName, String assetName,

Map<String, Object> dsl = mapOf("query", mapOf("bool", bool));

List<AtlasEntityHeader> assets = indexSearchPaginated(dsl, null, discovery, 100);
List<AtlasEntityHeader> assets = indexSearchPaginated(dsl, null, discovery);

if (CollectionUtils.isNotEmpty(assets)) {
throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, errorMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ protected void verifyDuplicateStakeholderByDomainAndTitle(String domainQualified
Map<String, Object> bool = mapOf("must", mustClauseList);
Map<String, Object> dsl = mapOf("query", mapOf("bool", bool));

List<AtlasEntityHeader> assets = indexSearchPaginated(dsl, null, this.discovery, 100);
List<AtlasEntityHeader> assets = indexSearchPaginated(dsl, null, this.discovery);

if (CollectionUtils.isNotEmpty(assets)) {
throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST,
Expand All @@ -282,7 +282,7 @@ protected void ensureTitleAvailableForDomain(String domainQualifiedName, String
Map<String, Object> bool = mapOf("must", mustClauseList);
Map<String, Object> dsl = mapOf("query", mapOf("bool", bool));

List<AtlasEntityHeader> assets = indexSearchPaginated(dsl, Collections.singleton(ATTR_DOMAIN_QUALIFIED_NAMES), this.discovery, 100);
List<AtlasEntityHeader> assets = indexSearchPaginated(dsl, Collections.singleton(ATTR_DOMAIN_QUALIFIED_NAMES), this.discovery);

if (CollectionUtils.isNotEmpty(assets)) {
AtlasEntityHeader stakeholderTitleHeader = assets.get(0);
Expand Down Expand Up @@ -311,7 +311,7 @@ public static void verifyDuplicateStakeholderByName(String assetName, String dom
Map<String, Object> bool = mapOf("must", mustClauseList);
Map<String, Object> dsl = mapOf("query", mapOf("bool", bool));

List<AtlasEntityHeader> assets = indexSearchPaginated(dsl, null, discovery, 100);
List<AtlasEntityHeader> assets = indexSearchPaginated(dsl, null, discovery);

if (CollectionUtils.isNotEmpty(assets)) {
throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ protected void exists(String assetType, String assetName, String parentDomainQua
}
Map<String, Object> dsl = mapOf("query", mapOf("bool", bool));

List<AtlasEntityHeader> assets = indexSearchPaginated(dsl, null, this.discovery, 100);
List<AtlasEntityHeader> assets = indexSearchPaginated(dsl, null, this.discovery);

if (CollectionUtils.isNotEmpty(assets)) {
for (AtlasEntityHeader asset : assets) {
Expand Down Expand Up @@ -280,32 +280,7 @@ protected List<AtlasEntityHeader> getPolicies(Set<String> resources) throws Atla

Map<String, Object> dsl = mapOf("query", mapOf("bool", bool));

return indexSearchPaginated(dsl, POLICY_ATTRIBUTES_FOR_SEARCH, discovery, 100);
} finally {
RequestContext.get().endMetricRecord(metricRecorder);
}
}

protected Boolean isAssetLinked(String domainGuid) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("isAssetLinked");
boolean exists = false;
try {
List<Map<String, Object>> mustClauseList = new ArrayList<>();
mustClauseList.add(mapOf("term", mapOf("__state", "ACTIVE")));
mustClauseList.add(mapOf("terms", mapOf(DOMAIN_GUIDS, domainGuid)));

Map<String, Object> bool = new HashMap<>();
bool.put("must", mustClauseList);

Map<String, Object> dsl = mapOf("query", mapOf("bool", bool));

List<AtlasEntityHeader> assets = indexSearchPaginated(dsl, null, this.discovery, 1);
if (CollectionUtils.isNotEmpty(assets)) {
exists = true;
}

return exists;

return indexSearchPaginated(dsl, POLICY_ATTRIBUTES_FOR_SEARCH, discovery);
} finally {
RequestContext.get().endMetricRecord(metricRecorder);
}
Expand All @@ -328,7 +303,7 @@ protected List<AtlasEntityHeader> getStakeholderTitlesAndStakeholders(Set<String

Map<String, Object> dsl = mapOf("query", mapOf("bool", bool));

return indexSearchPaginated(dsl, STAKEHOLDER_ATTRIBUTES_FOR_SEARCH, discovery, 100);
return indexSearchPaginated(dsl, STAKEHOLDER_ATTRIBUTES_FOR_SEARCH, discovery);
} finally {
RequestContext.get().endMetricRecord(metricRecorder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,8 @@ public void processDelete(AtlasVertex vertex) throws AtlasBaseException {
AtlasPerfMetrics.MetricRecorder metricRecorder = RequestContext.get().startMetricRecord("processDomainDelete");

try{
String domainGuid = GraphHelper.getGuid(vertex);
List<String> stakeHolderGuids = new ArrayList<>();

if (isAssetLinked(domainGuid)) {
throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Cannot delete domain as it has linked assets");
}

// active childrens exists?
Iterator<AtlasVertex> childrens = getActiveChildrenVertices(vertex,
DOMAIN_PARENT_EDGE_LABEL, DATA_PRODUCT_EDGE_LABEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void termExists(String termName, String glossaryQName) throws AtlasBaseEx

Map<String, Object> dsl = mapOf("query", mapOf("bool", mapOf("must", mustClauseList)));

List<AtlasEntityHeader> terms = indexSearchPaginated(dsl, null, this.discovery, 100);
List<AtlasEntityHeader> terms = indexSearchPaginated(dsl, null, this.discovery);

if (CollectionUtils.isNotEmpty(terms)) {
ret = terms.stream().map(term -> (String) term.getAttribute(NAME)).anyMatch(name -> termName.equals(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ private void categoryExists(String categoryName, String glossaryQualifiedName) t

Map<String, Object> dsl = mapOf("query", mapOf("bool", bool));

List<AtlasEntityHeader> categories = indexSearchPaginated(dsl, null, this.discovery, 100);
List<AtlasEntityHeader> categories = indexSearchPaginated(dsl, null, this.discovery);

if (CollectionUtils.isNotEmpty(categories)) {
for (AtlasEntityHeader category : categories) {
Expand Down

0 comments on commit 2d7d175

Please sign in to comment.