Last active
May 23, 2017 08:02
-
-
Save martinlau/4491042 to your computer and use it in GitHub Desktop.
Sample code to create a site in liferay (don't do this)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SiteCreator { | |
public static void createGroup() throws Exception { | |
// Don't do this! | |
long groupId = CounterLocalServiceUtil.increment(Group.class.getName()); | |
Group group = GroupLocalServiceUtil.createGroup(groupId); | |
group.setName("Test Site"); | |
group.setDescription("This is a test site"); | |
group.setFriendlyURL("/test-site"); | |
// Set a bunch of other properties | |
GroupLocalServiceUtil.addGroup(group); | |
long layoutSetId = CounterLocalServiceUtil.increment(LayoutSet.class.getName()); | |
LayoutSet layoutSet = LayoutSetLocalServiceUtil.createLayoutSet(layoutSetId); | |
layoutSet.setGroupId(groupId); | |
layoutSet.setPrivateLayout(false); | |
layoutSet.setThemeId("classic"); | |
layoutSet.setColorSchemeId("01"); | |
// Set a bunch of other properties | |
LayoutSetLocalServiceUtil.addLayoutSet(layoutSet); | |
long resourcePermissionId = CounterLocalServiceUtil.increment(ResourcePermission.class.getName()); | |
ResourcePermission resourcePermission = ResourcePermissionLocalServiceUtil.createResourcePermission(resourcePermissionId); | |
resourcePermission.setName(Group.class.getName()); | |
resourcePermission.setPrimaryKey(groupId); | |
// Set a bunch of other properties | |
ResourcePermissionLocalServiceUtil.addResourcePermission(resourcePermission); | |
// Continue on with other objects, properties as needed until you get the job done... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why did you write "don't do this"?
Is there a better way to create a site/group programmatically?