mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-06 07:32:46 +00:00
Check if user is bot before updateOrCreate bot user (#10178)
This commit is contained in:
parent
2a99114c94
commit
fc78d03cc4
@ -1138,7 +1138,9 @@ public class UserResource extends EntityResource<User, UserRepository> {
|
|||||||
String botName = create.getBotName();
|
String botName = create.getBotName();
|
||||||
EntityInterface bot = retrieveBot(botName);
|
EntityInterface bot = retrieveBot(botName);
|
||||||
// check if the bot user exists
|
// check if the bot user exists
|
||||||
if (!botHasRelationshipWithUser(bot, original)
|
if (original != null && (original.getIsBot() == null || Boolean.FALSE.equals(original.getIsBot()))) {
|
||||||
|
throw new IllegalArgumentException(String.format("User [%s] already exists.", original.getName()));
|
||||||
|
} else if (!botHasRelationshipWithUser(bot, original)
|
||||||
&& original != null
|
&& original != null
|
||||||
&& userHasRelationshipWithAnyBot(original, bot)) {
|
&& userHasRelationshipWithAnyBot(original, bot)) {
|
||||||
// throw an exception if user already has a relationship with a bot
|
// throw an exception if user already has a relationship with a bot
|
||||||
|
Loading…
x
Reference in New Issue
Block a user