Skip to content

Commit

Permalink
added validation on asset type
Browse files Browse the repository at this point in the history
  • Loading branch information
PRATHAM2002-DS committed Sep 9, 2024
1 parent c5551d9 commit 5e7be71
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ private void processDomainLinkAttribute(AtlasEntity entity) throws AtlasBaseExce

private void validateDomainAssetLinks(AtlasEntity entity) throws AtlasBaseException {
List<String> domainGuids = ( List<String>) entity.getAttribute(DOMAIN_GUIDS);
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));

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) {
Expand Down

0 comments on commit 5e7be71

Please sign in to comment.