Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Changing the group name and Authorizations path #15

zaara1 ·

I want to update the group name of a group from old to new.
Also the configuration path in Authorizations need to be updated to the new path.
Please let me know how that needs to be done through script.

  • replies 5
  • views 899
  • stars 0
robinshen ADMIN ·

To update a group name:

groovy:
def someGroup = system.groupManager.get("group name");
someGroup.setName("new name");
system.groupManager.save(someGroup);

You do not need to update authorized configurations when changing group name, as authorizations are associated with group id which will not affected by group renaming.

zaara1 ·

I have such a system that if I rename group name then I have to also update the configuration path in group authorization

Like if in authorizations the path was
A/B/C/OLD_NAME

then if I rename the group name to NEW_NAME the corresponding authorization path should also be renamed like below
A/B/C/NEW_NAME

robinshen ADMIN ·

Then it can be done via below script:

groovy:
import com.pmease.quickbuild.persistence.*;

SessionManager.openSession();
try {
  def group = system.groupManager.get("some group");
  for (authorization in group.authorizations) {
    authorization.configuration.setName("new name");
    system.configurationManager.save(authorization.configuration);
  }
} finally {
  SessionManager.closeSession();
}
zaara1 ·

system.configurationManager.save(authorization.configuration);
what is this doing????

robinshen ADMIN ·

Since you also want to change name of related authorized configurations of the group, this statement saves the configuration after changing its name.