Hi, I'm trying to disable a user in my plugin but for some reason I am getting the following error message "This user does not exist please select a user from the user browser." I am getting this issue on JIRA 6.4. Can any one suggest?
jiraUser = userUtil.getUserByName(user.getSamAccountName()).getDirectoryUser();
ImmutableUser.Builder builder = ImmutableUser.newUser(jiraUser);
builder.active(false);
ApplicationUser updatedUser = new DelegatingApplicationUser(jiraUser.getName(), builder.toUser());
UserService.UpdateUserValidationResult updateUserValidationResult = userService.validateUpdateUser(updatedUser);
Iterator iterator = updateUserValidationResult.getErrorCollection().getErrorMessages().iterator();
while (iterator.hasNext()) {
log.debug("Error Message :: "+ iterator.next().toString());
}
I think the issue is that jiraUser is a User object and not an ApplicationUser. You'll need the userKey from the ApplicationUser object to be passed into the DelegatingApplicationUser constructor instead the username.
So something like:
jirarAppUser = userUtil.getUserByName(user.getSamAccountName());
ImmutableUser.Builder builder = ImmutableUser.newUser(jiraAppUser.getUser());
builder.active(false);
ApplicationUser updatedUser = new DelegatingApplicationUser(jiraAppUser.getKey(), builder.toUser());
UserService.UpdateUserValidationResult updateUserValidationResult = userService.validateUpdateUser(updatedUser);
Iterator iterator = updateUserValidationResult.getErrorCollection().getErrorMessages().iterator();
while (iterator.hasNext()) {
log.debug("Error Message :: "+ iterator.next().toString());
}
That should do it. If it doesn't, you may want to ask this question over at community.developer.atlassian.com .
Hi Daniel,
Tested with getKey() method of ApplicationUser instead of getUser() and it worked. Thank you for help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I don't think there's anything wrong with your code, I suspect the object "user" does not contain what you think it does.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I checked jiraUser object loaded successfully using the string it got from "user" object. The same code is working from groovy console but it is not working when we deploy as a plugin.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.