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
1612b305
Commit
1612b305
authored
Mar 17, 2017
by
Sarath Subramanian
Committed by
apoorvnaik
Mar 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-1664: Able to add already added tag to an entity through REST API:
Signed-off-by:
apoorvnaik
<
anaik@hortonworks.com
>
parent
0c979028
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
AtlasEntityStoreV1.java
...e/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
+39
-0
EntityREST.java
...p/src/main/java/org/apache/atlas/web/rest/EntityREST.java
+1
-1
No files found.
repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java
View file @
1612b305
...
...
@@ -432,6 +432,9 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
validateAndNormalize
(
classification
);
}
// validate if entity, not already associated with classifications
validateEntityAssociations
(
guid
,
classifications
);
EntityGraphMapper
graphMapper
=
new
EntityGraphMapper
(
deleteHandler
,
typeRegistry
);
graphMapper
.
addClassifications
(
new
EntityMutationContext
(),
guid
,
classifications
);
...
...
@@ -460,6 +463,9 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
List
<
AtlasClassification
>
classifications
=
Collections
.
singletonList
(
classification
);
for
(
String
guid
:
guids
)
{
// validate if entity, not already associated with classifications
validateEntityAssociations
(
guid
,
classifications
);
graphMapper
.
addClassifications
(
new
EntityMutationContext
(),
guid
,
classifications
);
// notify listeners on classification addition
...
...
@@ -598,4 +604,37 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore {
type
.
getNormalizedValue
(
classification
);
}
/**
* Validate if classification is not already associated with the entities
* @param guid unique entity id
* @param classifications list of classifications to be associated
*/
private
void
validateEntityAssociations
(
String
guid
,
List
<
AtlasClassification
>
classifications
)
throws
AtlasBaseException
{
List
<
String
>
entityClassifications
=
getClassificationNames
(
guid
);
for
(
AtlasClassification
classification
:
classifications
)
{
String
newClassification
=
classification
.
getTypeName
();
if
(
CollectionUtils
.
isNotEmpty
(
entityClassifications
)
&&
entityClassifications
.
contains
(
newClassification
))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INVALID_PARAMETERS
,
"entity: "
+
guid
+
", already associated with classification: "
+
newClassification
);
}
}
}
private
List
<
String
>
getClassificationNames
(
String
guid
)
throws
AtlasBaseException
{
List
<
String
>
ret
=
null
;
List
<
AtlasClassification
>
classifications
=
getClassifications
(
guid
);
if
(
CollectionUtils
.
isNotEmpty
(
classifications
))
{
ret
=
new
ArrayList
<>();
for
(
AtlasClassification
classification
:
classifications
)
{
ret
.
add
(
classification
.
getTypeName
());
}
}
return
ret
;
}
}
webapp/src/main/java/org/apache/atlas/web/rest/EntityREST.java
View file @
1612b305
...
...
@@ -474,7 +474,7 @@ public class EntityREST {
AtlasClassification
classification
=
request
==
null
?
null
:
request
.
getClassification
();
List
<
String
>
entityGuids
=
request
==
null
?
null
:
request
.
getEntityGuids
();
if
(
classification
==
null
||
org
.
apache
.
commons
.
lang
.
StringUtils
.
isEmpty
(
classification
.
getTypeName
()))
{
if
(
classification
==
null
||
StringUtils
.
isEmpty
(
classification
.
getTypeName
()))
{
throw
new
AtlasBaseException
(
AtlasErrorCode
.
INVALID_PARAMETERS
,
"no classification"
);
}
...
...
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