Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
e48a4864
Commit
e48a4864
authored
May 15, 2018
by
apoorvnaik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2685: Impose displayName restrictions for Glossary, term and category.
Change-Id: I4cddcfe76eabcf7ee705b60848521158bb33a8a5
parent
2ff71e30
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
1 deletion
+29
-1
AtlasErrorCode.java
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+1
-0
GlossaryService.java
.../main/java/org/apache/atlas/glossary/GlossaryService.java
+27
-0
GlossaryServiceTest.java
...t/java/org/apache/atlas/glossary/GlossaryServiceTest.java
+1
-1
No files found.
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
View file @
e48a4864
...
...
@@ -146,6 +146,7 @@ public enum AtlasErrorCode {
INVALID_TERM_DISSOCIATION
(
400
,
"ATLAS-400-00-080"
,
"Given term (guid={0}) is not associated to entity(guid={1})"
),
ATTRIBUTE_TYPE_INVALID
(
400
,
"ATLAS-400-00-081"
,
"{0}.{1}: invalid attribute type. Attribute cannot be of type classification"
),
MISSING_CATEGORY_DISPLAY_NAME
(
400
,
"ATLAS-400-00-082"
,
"Category displayName is empty/null"
),
INVALID_DISPLAY_NAME
(
400
,
"ATLAS-400-00-083"
,
"displayName cannot contain following special chars ('@', '.')"
),
TERM_HAS_ENTITY_ASSOCIATION
(
400
,
"ATLAS-400-00-086"
,
"Term (guid={}) can't be deleted as it has been assigned to {} entities."
),
UNAUTHORIZED_ACCESS
(
403
,
"ATLAS-403-00-001"
,
"{0} is not authorized to perform {1}"
),
...
...
repository/src/main/java/org/apache/atlas/glossary/GlossaryService.java
View file @
e48a4864
...
...
@@ -66,6 +66,8 @@ public class GlossaryService {
private
final
GlossaryCategoryUtils
glossaryCategoryUtils
;
private
final
AtlasTypeRegistry
atlasTypeRegistry
;
private
final
char
[]
invalidNameChars
=
{
'@'
,
'.'
};
@Inject
public
GlossaryService
(
DataAccess
dataAccess
,
final
AtlasRelationshipStore
relationshipStore
,
final
AtlasTypeRegistry
typeRegistry
)
{
this
.
dataAccess
=
dataAccess
;
...
...
@@ -134,6 +136,8 @@ public class GlossaryService {
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
())){
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INVALID_DISPLAY_NAME
);
}
else
{
atlasGlossary
.
setQualifiedName
(
atlasGlossary
.
getDisplayName
());
}
...
...
@@ -242,6 +246,10 @@ public class GlossaryService {
throw
new
AtlasBaseException
(
AtlasErrorCode
.
BAD_REQUEST
,
"DisplayName can't be null/empty"
);
}
if
(
isNameInvalid
(
atlasGlossary
.
getDisplayName
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INVALID_DISPLAY_NAME
);
}
AtlasGlossary
storeObject
=
dataAccess
.
load
(
atlasGlossary
);
if
(!
storeObject
.
equals
(
atlasGlossary
))
{
...
...
@@ -321,6 +329,9 @@ public class GlossaryService {
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
);
}
// This might fail for the case when the term's qualifiedName has been updated and the duplicate request comes in with old name
if
(
termExists
(
glossaryTerm
))
{
...
...
@@ -377,6 +388,10 @@ public class GlossaryService {
throw
new
AtlasBaseException
(
AtlasErrorCode
.
BAD_REQUEST
,
"DisplayName can't be null/empty"
);
}
if
(
isNameInvalid
(
atlasGlossaryTerm
.
getDisplayName
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INVALID_DISPLAY_NAME
);
}
AtlasGlossaryTerm
storeObject
=
dataAccess
.
load
(
atlasGlossaryTerm
);
if
(!
storeObject
.
equals
(
atlasGlossaryTerm
))
{
try
{
...
...
@@ -495,6 +510,10 @@ public class GlossaryService {
if
(
Objects
.
isNull
(
glossaryCategory
.
getDisplayName
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
MISSING_CATEGORY_DISPLAY_NAME
);
}
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
...
...
@@ -561,6 +580,10 @@ public class GlossaryService {
throw
new
AtlasBaseException
(
AtlasErrorCode
.
BAD_REQUEST
,
"DisplayName can't be null/empty"
);
}
if
(
isNameInvalid
(
glossaryCategory
.
getDisplayName
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INVALID_DISPLAY_NAME
);
}
AtlasGlossaryCategory
storeObject
=
dataAccess
.
load
(
glossaryCategory
);
if
(!
storeObject
.
equals
(
glossaryCategory
))
{
...
...
@@ -952,6 +975,10 @@ public class GlossaryService {
termHeaders
.
forEach
(
t
->
t
.
setDisplayText
(
termMap
.
get
(
t
.
getTermGuid
()).
getDisplayName
()));
}
private
boolean
isNameInvalid
(
String
name
)
{
return
StringUtils
.
containsAny
(
name
,
invalidNameChars
);
}
static
class
PaginationHelper
<
T
>
{
private
int
pageStart
;
private
int
pageEnd
;
...
...
repository/src/test/java/org/apache/atlas/glossary/GlossaryServiceTest.java
View file @
e48a4864
...
...
@@ -164,7 +164,7 @@ public class GlossaryServiceTest {
fixedRateMortgage
=
new
AtlasGlossaryTerm
();
fixedRateMortgage
.
setQualifiedName
(
"fixed_mtg@testBankingGlossary"
);
fixedRateMortgage
.
setDisplayName
(
"
15/30 yr
mortgage"
);
fixedRateMortgage
.
setDisplayName
(
"
Conventional
mortgage"
);
fixedRateMortgage
.
setShortDescription
(
"Short description"
);
fixedRateMortgage
.
setLongDescription
(
"Long description"
);
fixedRateMortgage
.
setAbbreviation
(
"FMTG"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment