ATLAS-2679 #2
Change-Id: I00ce22fe7dc58ef193f9fe884a36316171abbcb2
diff --git a/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java b/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java
index 9a8676b..bae2ea1 100644
--- a/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java
+++ b/repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java
@@ -136,7 +136,8 @@
if (StringUtils.isEmpty(atlasGlossary.getQualifiedName())) {
if (StringUtils.isEmpty(atlasGlossary.getDisplayName())) {
throw new AtlasBaseException(AtlasErrorCode.GLOSSARY_QUALIFIED_NAME_CANT_BE_DERIVED);
- } else if (isNameInvalid(atlasGlossary.getDisplayName())){
+ }
+ if (isNameInvalid(atlasGlossary.getDisplayName())){
throw new AtlasBaseException(AtlasErrorCode.INVALID_DISPLAY_NAME);
} else {
atlasGlossary.setQualifiedName(atlasGlossary.getDisplayName());
@@ -326,11 +327,16 @@
if (Objects.isNull(glossaryTerm.getAnchor())) {
throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ANCHOR);
}
- if (StringUtils.isEmpty(glossaryTerm.getDisplayName())) {
- throw new AtlasBaseException(AtlasErrorCode.GLOSSARY_TERM_QUALIFIED_NAME_CANT_BE_DERIVED);
- }
- if (isNameInvalid(glossaryTerm.getDisplayName())) {
- throw new AtlasBaseException(AtlasErrorCode.INVALID_DISPLAY_NAME);
+ if (StringUtils.isEmpty(glossaryTerm.getQualifiedName())) {
+ if (StringUtils.isEmpty(glossaryTerm.getDisplayName())) {
+ throw new AtlasBaseException(AtlasErrorCode.GLOSSARY_TERM_QUALIFIED_NAME_CANT_BE_DERIVED);
+ }
+
+ if (isNameInvalid(glossaryTerm.getDisplayName())){
+ throw new AtlasBaseException(AtlasErrorCode.INVALID_DISPLAY_NAME);
+ } else {
+ glossaryTerm.setQualifiedName(glossaryTerm.getDisplayName());
+ }
}
// This might fail for the case when the term's qualifiedName has been updated and the duplicate request comes in with old name
@@ -507,13 +513,16 @@
if (Objects.isNull(glossaryCategory.getAnchor())) {
throw new AtlasBaseException(AtlasErrorCode.MISSING_MANDATORY_ANCHOR);
}
- if (Objects.isNull(glossaryCategory.getDisplayName())) {
- throw new AtlasBaseException(AtlasErrorCode.MISSING_CATEGORY_DISPLAY_NAME);
+ if (StringUtils.isEmpty(glossaryCategory.getQualifiedName())) {
+ if (StringUtils.isEmpty(glossaryCategory.getDisplayName())) {
+ throw new AtlasBaseException(AtlasErrorCode.GLOSSARY_CATEGORY_QUALIFIED_NAME_CANT_BE_DERIVED);
+ }
+ if (isNameInvalid(glossaryCategory.getDisplayName())){
+ throw new AtlasBaseException(AtlasErrorCode.INVALID_DISPLAY_NAME);
+ } else {
+ glossaryCategory.setQualifiedName(glossaryCategory.getDisplayName());
+ }
}
- if (isNameInvalid(glossaryCategory.getDisplayName())) {
- throw new AtlasBaseException(AtlasErrorCode.INVALID_DISPLAY_NAME);
- }
-
// This might fail for the case when the category's qualifiedName has been updated during a hierarchy change
// and the duplicate request comes in with old name
diff --git a/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java b/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java
index 6a6b971..c72e642 100644
--- a/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java
+++ b/repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java
@@ -126,7 +126,6 @@
// Category
accountCategory = new AtlasGlossaryCategory();
- accountCategory.setQualifiedName("acc@testBankingGlossary");
accountCategory.setDisplayName("Account categorization");
accountCategory.setShortDescription("Short description");
accountCategory.setLongDescription("Long description");
@@ -138,14 +137,12 @@
customerCategory.setLongDescription("Long description");
mortgageCategory = new AtlasGlossaryCategory();
- mortgageCategory.setQualifiedName("mtg@testBankingGlossary");
mortgageCategory.setDisplayName("Mortgage categorization");
mortgageCategory.setShortDescription("Short description");
mortgageCategory.setLongDescription("Long description");
// Terms
checkingAccount = new AtlasGlossaryTerm();
- checkingAccount.setQualifiedName("chk_acc@testBankingGlossary");
checkingAccount.setDisplayName("A checking account");
checkingAccount.setShortDescription("Short description");
checkingAccount.setLongDescription("Long description");
@@ -163,7 +160,6 @@
savingsAccount.setUsage("N/A");
fixedRateMortgage = new AtlasGlossaryTerm();
- fixedRateMortgage.setQualifiedName("fixed_mtg@testBankingGlossary");
fixedRateMortgage.setDisplayName("Conventional mortgage");
fixedRateMortgage.setShortDescription("Short description");
fixedRateMortgage.setLongDescription("Long description");