09-19-2013 10:54 AM
Hi All i need to create a group on every domain creation, and assign some access rights to this group.
I am thinking of adding an operation and then using an event listener to call the operation on document creation.
I can not seem to find the right method to call for the creation of the group.
I am using version 5.6.
EDIT, rephrasing my question:
in this method call
DocumentModel createGroup(DocumentModel groupModel)
throws ClientException,
GroupAlreadyExistsException)
What should be the DocumentModel i should pass for a new group ?
09-19-2013 11:52 AM
Here's the complete code for the operation
package org.nuxeo.sample;
import org.nuxeo.ecm.automation.core.Constants;
import org.nuxeo.ecm.automation.core.annotations.Context;
import org.nuxeo.ecm.automation.core.annotations.Operation;
import org.nuxeo.ecm.automation.core.annotations.OperationMethod;
import org.nuxeo.ecm.automation.core.annotations.Param;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.platform.usermanager.UserManager;
/**
* @author ldoguin
*/
@Operation(id = CreateGroup.ID, category = Constants.CAT_USERS_GROUPS, label = "Create Group", description = "This operation creates a new group using the given group label and group id.", since = "5.7.3")
public class CreateGroup {
public static final String ID = "CreateGroup";
@Context
UserManager userManager;
@Param(name = "Group Id", required = true)
String groupId;
@Param(name = "Group Label", required = true)
String goupLabel;
@Param(name = "Group Description", required = false, widget = Constants.W_MULTILINE_TEXT )
String description;
@OperationMethod
public DocumentModel run() throws ClientException {
DocumentModel groupModel = userManager.getBareGroupModel();
groupModel.setProperty("group", "groupname", groupId);
groupModel.setProperty("group", "grouplabel", goupLabel);
groupModel.setProperty("group", "description", description);
groupModel = userManager.createGroup(groupModel);
return groupModel;
}
}
Attention: Blogs & Forums are in READ-ONLY mode from Oct 9-19 as we transition to our new platform. Learn more.
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.