From 5e7be7194b0f364989fced30d53c53cd50b4ad12 Mon Sep 17 00:00:00 2001 From: PRATHAM2002-DS Date: Mon, 9 Sep 2024 18:17:09 +0530 Subject: [PATCH] added validation on asset type --- .../store/graph/v2/preprocessor/AssetPreProcessor.java | 5 +++++ 1 file changed, 5 insertions(+) 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 9655a59c00..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 @@ -82,12 +82,17 @@ private void processDomainLinkAttribute(AtlasEntity entity) throws AtlasBaseExce private void validateDomainAssetLinks(AtlasEntity entity) throws AtlasBaseException { List domainGuids = ( List) entity.getAttribute(DOMAIN_GUIDS); + 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)); if(CollectionUtils.isNotEmpty(domainGuids)){ if(domainGuids.size() > 1) { throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "Asset can be linked to only one domain"); } + if (excludedTypes.contains(entity.getTypeName())) { + throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "Asset Type {} is not allowed to link with Domain", entity.getTypeName()); + } + for(String domainGuid : domainGuids) { AtlasVertex domainVertex = entityRetriever.getEntityVertex(domainGuid); if(domainVertex == null) {