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
f15995cc
Commit
f15995cc
authored
May 10, 2018
by
apoorvnaik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-2670: Validate entity guid when processing term dissociation
Change-Id: I5e2db1b9968a37482b9ff97ba8602aa262a2db80
parent
f85ff28e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
AtlasErrorCode.java
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
+2
-1
GlossaryTermUtils.java
...ain/java/org/apache/atlas/glossary/GlossaryTermUtils.java
+17
-0
No files found.
intg/src/main/java/org/apache/atlas/AtlasErrorCode.java
View file @
f15995cc
...
@@ -142,7 +142,8 @@ public enum AtlasErrorCode {
...
@@ -142,7 +142,8 @@ public enum AtlasErrorCode {
RELATIONSHIP_END_IS_NULL
(
400
,
"ATLAS-400-00-07D"
,
"Relationship end is invalid. Expected {0} but is NULL"
),
RELATIONSHIP_END_IS_NULL
(
400
,
"ATLAS-400-00-07D"
,
"Relationship end is invalid. Expected {0} but is NULL"
),
INVALID_TERM_RELATION_TO_SELF
(
400
,
"ATLAS-400-00-07E"
,
"Invalid Term relationship: Term can't have a relationship with self"
),
INVALID_TERM_RELATION_TO_SELF
(
400
,
"ATLAS-400-00-07E"
,
"Invalid Term relationship: Term can't have a relationship with self"
),
INVALID_CHILD_CATEGORY_DIFFERENT_GLOSSARY
(
400
,
"ATLAS-400-00-07F"
,
"Invalid child category relationship: Child category (guid = {0}) belongs to different glossary"
),
INVALID_CHILD_CATEGORY_DIFFERENT_GLOSSARY
(
400
,
"ATLAS-400-00-07F"
,
"Invalid child category relationship: Child category (guid = {0}) belongs to different glossary"
),
ATTRIBUTE_TYPE_INVALID
(
400
,
"ATLAS-400-00-080"
,
"{0}.{1}: invalid attribute type. Attribute cannot be of type classification"
),
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"
),
UNAUTHORIZED_ACCESS
(
403
,
"ATLAS-403-00-001"
,
"{0} is not authorized to perform {1}"
),
UNAUTHORIZED_ACCESS
(
403
,
"ATLAS-403-00-001"
,
"{0} is not authorized to perform {1}"
),
...
...
repository/src/main/java/org/apache/atlas/glossary/GlossaryTermUtils.java
View file @
f15995cc
...
@@ -100,6 +100,14 @@ public class GlossaryTermUtils extends GlossaryUtils {
...
@@ -100,6 +100,14 @@ public class GlossaryTermUtils extends GlossaryUtils {
}
}
Objects
.
requireNonNull
(
glossaryTerm
);
Objects
.
requireNonNull
(
glossaryTerm
);
Set
<
AtlasRelatedObjectId
>
assignedEntities
=
glossaryTerm
.
getAssignedEntities
();
Map
<
String
,
AtlasRelatedObjectId
>
assignedEntityMap
=
new
HashMap
<>();
if
(
CollectionUtils
.
isNotEmpty
(
assignedEntities
))
{
for
(
AtlasRelatedObjectId
relatedObjectId
:
assignedEntities
)
{
assignedEntityMap
.
put
(
relatedObjectId
.
getGuid
(),
relatedObjectId
);
}
}
if
(
CollectionUtils
.
isNotEmpty
(
relatedObjectIds
))
{
if
(
CollectionUtils
.
isNotEmpty
(
relatedObjectIds
))
{
for
(
AtlasRelatedObjectId
relatedObjectId
:
relatedObjectIds
)
{
for
(
AtlasRelatedObjectId
relatedObjectId
:
relatedObjectIds
)
{
if
(
DEBUG_ENABLED
)
{
if
(
DEBUG_ENABLED
)
{
...
@@ -108,7 +116,12 @@ public class GlossaryTermUtils extends GlossaryUtils {
...
@@ -108,7 +116,12 @@ public class GlossaryTermUtils extends GlossaryUtils {
if
(
Objects
.
isNull
(
relatedObjectId
.
getRelationshipGuid
()))
{
if
(
Objects
.
isNull
(
relatedObjectId
.
getRelationshipGuid
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TERM_DISSOCIATION_MISSING_RELATION_GUID
);
throw
new
AtlasBaseException
(
AtlasErrorCode
.
TERM_DISSOCIATION_MISSING_RELATION_GUID
);
}
}
AtlasRelatedObjectId
existingTermRelation
=
assignedEntityMap
.
get
(
relatedObjectId
.
getGuid
());
if
(
CollectionUtils
.
isNotEmpty
(
assignedEntities
)
&&
isRelationshipGuidSame
(
existingTermRelation
,
relatedObjectId
))
{
relationshipStore
.
deleteById
(
relatedObjectId
.
getRelationshipGuid
());
relationshipStore
.
deleteById
(
relatedObjectId
.
getRelationshipGuid
());
}
else
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INVALID_TERM_DISSOCIATION
,
glossaryTerm
.
getGuid
(),
relatedObjectId
.
getGuid
());
}
}
}
}
}
...
@@ -117,6 +130,10 @@ public class GlossaryTermUtils extends GlossaryUtils {
...
@@ -117,6 +130,10 @@ public class GlossaryTermUtils extends GlossaryUtils {
}
}
}
}
private
boolean
isRelationshipGuidSame
(
final
AtlasRelatedObjectId
existing
,
final
AtlasRelatedObjectId
relatedObjectId
)
{
return
StringUtils
.
equals
(
relatedObjectId
.
getRelationshipGuid
(),
existing
.
getRelationshipGuid
());
}
private
void
processTermAnchor
(
AtlasGlossaryTerm
updatedTerm
,
AtlasGlossaryTerm
existing
,
RelationshipOperation
op
)
throws
AtlasBaseException
{
private
void
processTermAnchor
(
AtlasGlossaryTerm
updatedTerm
,
AtlasGlossaryTerm
existing
,
RelationshipOperation
op
)
throws
AtlasBaseException
{
AtlasGlossaryHeader
existingAnchor
=
existing
.
getAnchor
();
AtlasGlossaryHeader
existingAnchor
=
existing
.
getAnchor
();
AtlasGlossaryHeader
updatedTermAnchor
=
updatedTerm
.
getAnchor
();
AtlasGlossaryHeader
updatedTermAnchor
=
updatedTerm
.
getAnchor
();
...
...
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