If the group name field in the permissions object is null, this permission must be for a user For each permissions object that the source space contains Grab the permissions from the source Space, so that we can apply them to the destination Space Define the three strings that hold the permissions attributesĭef sourceSpace = ComponentLocator.getComponent(SpaceManager).getSpace("")ĭef destinationSpace = ComponentLocator.getComponent(SpaceManager).getSpace("")ĭef sourcePermissions = sourceSpace.getPermissions() Define the soap service, with which we will add the permissions to the target Space Import .ĭef addSpacePermission = ComponentLocator.getComponent(SpacesSoapService) The loop iterates through each permission retrieved from the Source Space. The addPermissionsToSpace method of the SpacesSoapService is invoked, and the three elements are provided to it. We declare the three elements required to add permissions to a Confluence Space: permission type, user or group name, and target Space Key. Whether we detect a group or user permission, the rest of the process is straightforward. This matters because we need to know whether to retrieve the username or the group name when setting the permission on the destination page. It’s easy enough to test for a group or user permission if the username or group is null, the object is clearly for a group or user respectively. Īs you can see, if the permissions object is for a user, the username appears as the fourth element. ![]() The third element is the group with which this permission is associated, and this is where the format of the permissions object differs in comparison to the user-oriented permissions object. The first attribute is the permission type. Permissions objects associated with a group look like so: Every type of permission gets it’s own object. We need to determine if the permissions object relates to a single user, or a group. Each object is a collection of attributes. We iterate through each of the permission objects. This is not a single object, but rather a collection of objects. The permissions of the source Space are then extracted. We do the same for the destination source. After using the ComponentLocator to declare the SpaceSoapService, we retrieve the source Space as an object. We’re using the Soap Service to affect change in the permissions of a Space. This allows us to easily pass them on to a source page as a new set of permissions. ![]() The permissions of a Confluence Space can be retrieved and treated as collection of objects. There may come a day where you need to script the migration of permissions from one Confluence Space to another.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |