diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java index 404b1ab264..c9c928c48a 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasEntityStoreV2.java @@ -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 copyOfUpdated = new ArrayList<>(context.getUpdatedEntities()); diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/AssetPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/AssetPreProcessor.java index bfa6f508b4..35c612813b 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/AssetPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/AssetPreProcessor.java @@ -27,8 +27,6 @@ public class AssetPreProcessor implements PreProcessor { private AtlasTypeRegistry typeRegistry; private EntityGraphRetriever entityRetriever; - private static final Set 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; diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/PreProcessorUtils.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/PreProcessorUtils.java index ce00afb3de..b36c8babe6 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/PreProcessorUtils.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/PreProcessorUtils.java @@ -166,7 +166,7 @@ public static String updateQueryResourceAttributes(AtlasTypeRegistry typeRegistr return newCollectionQualifiedName; } - public static List indexSearchPaginated(Map dsl, Set attributes, EntityDiscoveryService discovery, int size) throws AtlasBaseException { + public static List indexSearchPaginated(Map dsl, Set attributes, EntityDiscoveryService discovery) throws AtlasBaseException { IndexSearchParams searchParams = new IndexSearchParams(); List ret = new ArrayList<>(); @@ -180,6 +180,7 @@ public static List indexSearchPaginated(Map d dsl.put("sort", sortList); int from = 0; + int size = 100; boolean hasMore = true; do { dsl.put("from", from); @@ -212,7 +213,7 @@ public static void verifyDuplicateAssetByName(String typeName, String assetName, Map dsl = mapOf("query", mapOf("bool", bool)); - List assets = indexSearchPaginated(dsl, null, discovery, 100); + List assets = indexSearchPaginated(dsl, null, discovery); if (CollectionUtils.isNotEmpty(assets)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, errorMessage); diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/accesscontrol/StakeholderPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/accesscontrol/StakeholderPreProcessor.java index 504b90416d..1cba29f935 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/accesscontrol/StakeholderPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/accesscontrol/StakeholderPreProcessor.java @@ -264,7 +264,7 @@ protected void verifyDuplicateStakeholderByDomainAndTitle(String domainQualified Map bool = mapOf("must", mustClauseList); Map dsl = mapOf("query", mapOf("bool", bool)); - List assets = indexSearchPaginated(dsl, null, this.discovery, 100); + List assets = indexSearchPaginated(dsl, null, this.discovery); if (CollectionUtils.isNotEmpty(assets)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, @@ -282,7 +282,7 @@ protected void ensureTitleAvailableForDomain(String domainQualifiedName, String Map bool = mapOf("must", mustClauseList); Map dsl = mapOf("query", mapOf("bool", bool)); - List assets = indexSearchPaginated(dsl, Collections.singleton(ATTR_DOMAIN_QUALIFIED_NAMES), this.discovery, 100); + List assets = indexSearchPaginated(dsl, Collections.singleton(ATTR_DOMAIN_QUALIFIED_NAMES), this.discovery); if (CollectionUtils.isNotEmpty(assets)) { AtlasEntityHeader stakeholderTitleHeader = assets.get(0); @@ -311,7 +311,7 @@ public static void verifyDuplicateStakeholderByName(String assetName, String dom Map bool = mapOf("must", mustClauseList); Map dsl = mapOf("query", mapOf("bool", bool)); - List assets = indexSearchPaginated(dsl, null, discovery, 100); + List assets = indexSearchPaginated(dsl, null, discovery); if (CollectionUtils.isNotEmpty(assets)) { throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/AbstractDomainPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/AbstractDomainPreProcessor.java index e92a179d77..ff6ad04b5e 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/AbstractDomainPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/AbstractDomainPreProcessor.java @@ -249,7 +249,7 @@ protected void exists(String assetType, String assetName, String parentDomainQua } Map dsl = mapOf("query", mapOf("bool", bool)); - List assets = indexSearchPaginated(dsl, null, this.discovery, 100); + List assets = indexSearchPaginated(dsl, null, this.discovery); if (CollectionUtils.isNotEmpty(assets)) { for (AtlasEntityHeader asset : assets) { @@ -280,32 +280,7 @@ protected List getPolicies(Set resources) throws Atla Map 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> mustClauseList = new ArrayList<>(); - mustClauseList.add(mapOf("term", mapOf("__state", "ACTIVE"))); - mustClauseList.add(mapOf("terms", mapOf(DOMAIN_GUIDS, domainGuid))); - - Map bool = new HashMap<>(); - bool.put("must", mustClauseList); - - Map dsl = mapOf("query", mapOf("bool", bool)); - - List 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); } @@ -328,7 +303,7 @@ protected List getStakeholderTitlesAndStakeholders(Set 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); } diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataDomainPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataDomainPreProcessor.java index e785fcc0ec..403d4b0128 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataDomainPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/DataDomainPreProcessor.java @@ -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 stakeHolderGuids = new ArrayList<>(); - if (isAssetLinked(domainGuid)) { - throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Cannot delete domain as it has linked assets"); - } - // active childrens exists? Iterator childrens = getActiveChildrenVertices(vertex, DOMAIN_PARENT_EDGE_LABEL, DATA_PRODUCT_EDGE_LABEL); diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/glossary/AbstractGlossaryPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/glossary/AbstractGlossaryPreProcessor.java index 6cbddfd3c4..383273d73a 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/glossary/AbstractGlossaryPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/glossary/AbstractGlossaryPreProcessor.java @@ -99,7 +99,7 @@ public void termExists(String termName, String glossaryQName) throws AtlasBaseEx Map dsl = mapOf("query", mapOf("bool", mapOf("must", mustClauseList))); - List terms = indexSearchPaginated(dsl, null, this.discovery, 100); + List terms = indexSearchPaginated(dsl, null, this.discovery); if (CollectionUtils.isNotEmpty(terms)) { ret = terms.stream().map(term -> (String) term.getAttribute(NAME)).anyMatch(name -> termName.equals(name)); diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/glossary/CategoryPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/glossary/CategoryPreProcessor.java index db35a613db..0d3e26b83d 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/glossary/CategoryPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/glossary/CategoryPreProcessor.java @@ -388,7 +388,7 @@ private void categoryExists(String categoryName, String glossaryQualifiedName) t Map dsl = mapOf("query", mapOf("bool", bool)); - List categories = indexSearchPaginated(dsl, null, this.discovery, 100); + List categories = indexSearchPaginated(dsl, null, this.discovery); if (CollectionUtils.isNotEmpty(categories)) { for (AtlasEntityHeader category : categories) {