public
anonymous / blogs.groovy
Created

  • Download Gist
blogs.groovy
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 31 32
import com.liferay.portal.kernel.workflow.WorkflowConstants
import com.liferay.portal.model.GroupConstants
import com.liferay.portal.service.GroupLocalServiceUtil
import com.liferay.portal.service.ServiceContext
import com.liferay.portlet.blogs.model.BlogsEntry
import com.liferay.portlet.blogs.service.BlogsEntryLocalServiceUtil;
 
long companyId = userInfo.get("liferay.company.id").toLong();
long userId = userInfo.get("liferay.user.id").toLong();
 
guestGroup = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.GUEST);
 
context = new ServiceContext();
context.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);
context.setAddGroupPermissions(true);
context.setAddGuestPermissions(true);
context.setCompanyId(companyId);
context.setScopeGroupId(guestGroup.getGroupId());
 
for (int i = 0; i < 100; i++) {
rCal = Calendar.getInstance();
BlogsEntry newEntry = BlogsEntryLocalServiceUtil.addEntry(
userId,
"Blog " + i + " Title", "",
"The awesome content of blog #" + i,
rCal.get(Calendar.MONTH), rCal.get(Calendar.DAY_OF_MONTH),
rCal.get(Calendar.YEAR),
rCal.get(Calendar.HOUR_OF_DAY), rCal.get(Calendar.MINUTE), false,
false, null, false, null,
null, null, context);
println("Created blog " + newEntry.getTitle());
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.