Skip to content

anonymous /blogs.groovy
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.