-
Notifications
You must be signed in to change notification settings - Fork 1
/
site.groovy
30 lines (23 loc) · 837 Bytes
/
site.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
int numberToAdd = 10;
String namePrefix = "Site ";
String namePostfix = "";
String friendlyUrlPrefix = "/site-";
String friendlyUrlPostfix = "";
//
// End Configuration
//
import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.model.GroupConstants;
import com.liferay.portal.kernel.service.GroupLocalServiceUtil;
import com.liferay.portal.kernel.util.PortalUtil;
userId = PortalUtil.getUserId(actionRequest);
for (int i = 1; i <= numberToAdd; i++) {
String name = namePrefix + i + namePostfix;
String friendlyUrl = friendlyUrlPrefix + i + friendlyUrlPostfix;
GroupLocalServiceUtil.addGroup(
userId, 0, Group.class.getName(), 0,
GroupConstants.DEFAULT_LIVE_GROUP_ID, name, "",
GroupConstants.TYPE_SITE_OPEN, true,
GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, friendlyUrl, true, true,
null);
}