Skip to content

Commit

Permalink
Merge pull request #402 from wttech/bugfix/add-group
Browse files Browse the repository at this point in the history
fixed ADD-CHILDREN, ADD-PARENT command
  • Loading branch information
dprzybyl authored Aug 2, 2023
2 parents 0f1539b + cc9ee45 commit c71e06b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,18 @@ private ActionResult process(Context context, boolean execute) {
ActionUtils.checkCyclicRelations(group, (Group) authorizable);
}

boolean flag = true;
if (execute) {
group.addMember(authorizable);
flag = group.addMember(authorizable);
if (!flag) {
flag = group.isMember(authorizable);
}
}
if (flag) {
actionResult.logMessage(MessagingUtils.addedToGroup(authorizableId, group.getID()));
} else {
actionResult.logError(MessagingUtils.failedToAddToGroup(authorizableId, group.getID()));
}

actionResult.logMessage(MessagingUtils.addedToGroup(authorizableId, group.getID()));
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
} catch (AuthorizableNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,18 @@ private ActionResult process(Context context, boolean execute) {
LOGGER.info(String.format("Adding Authorizable with id = %s to group with id = %s",
authorizable.getID(), group.getID()));

boolean flag = true;
if (execute) {
group.addMember(authorizable);
flag = group.addMember(authorizable);
if (!flag) {
flag = group.isMember(authorizable);
}
}
if (flag) {
actionResult.logMessage(MessagingUtils.addedToGroup(authorizable.getID(), id));
} else {
actionResult.logError(MessagingUtils.failedToAddToGroup(authorizable.getID(), id));
}
actionResult.logMessage(MessagingUtils.addedToGroup(authorizable.getID(), id));
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
} catch (AuthorizableNotFoundException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public static String addedToGroup(String authorizableId, String groupId) {
return "Authorizable " + authorizableId + " added to group " + groupId;
}

public static String failedToAddToGroup(String authorizableId, String groupId) {
return String.format("Failed to add authorizable %s to group %s (some specific constraint)", authorizableId, groupId);
}

public static String newPasswordSet(String userId) {
return "New password for user " + userId + " was set";
}
Expand Down

0 comments on commit c71e06b

Please sign in to comment.