Adicionando "owners" para todas as comunidades

Here's another administration script to cover a common request to add a particular user (e.g. an administrator) to the ACL for every community. We can do this using two wsadmin commands:
  • CommunitiesService.fetchAllComms()
  • CommunitiesService.addMembersToCommunityByEmail()
In environments with many communities, you'd want to use CommunitiesService.fetchBatchComm() instead of retrieving them all in one shot, and that would require some additional code to handle the batches that I won't illustrate here. In the simple approach, you can just combine these two commands with a bit of glue to yield the following:

from java.util import ArrayList

# Initialize Communities Administration

# Define the new owner to add
newOwnerList = ArrayList()
newOwnerList = [""]

# Get all communities
comms = CommunitiesService.fetchAllComm()

# Loop through the communities and add the new owner to each
for comm in comms:

In the real world, I'd pass in the email address of the user to add as an argument to the command, but you get the idea. The addMembersToCommunityByEmail() command can use the community name instead of UUID, but we already have the UUID from fetchAllComms(), so it's better to use that and avoid name collisions that would result in an error.

Also note that because fetchAllComms() returns communities and subcommunities in indeterminate order, you'll need to run the command twice to cover the scenario where we try to update the ACL for a subcommunity before the user has been added to the parent community. The first pass will update all parent communities and any subcommunities processed after their parents, and the second pass will catch any of the subcommunities that were processed before their parents.

by Chad Scott

Postagens mais visitadas deste blog

Como adicionar uma rota no MAC OSX

Demo: IBM Watson Workspace for Marketing

Instalando o IBM Connections 6 - Instalando o ksh93 (korn shell) para o DB2