Skip to content

Instantly share code, notes, and snippets.

import javax.mail.internet.InternetAddress;
import com.liferay.mail.kernel.model.MailMessage;
import com.liferay.mail.kernel.service.MailServiceUtil;
// from
InternetAddress from = new InternetAddress();
from.setAddress("[email protected]");
// to
InternetAddress to = new InternetAddress();
<#-- dump.ftl
--
-- Generates tree representations of data model items.
--
-- Usage:
-- <#import "dump.ftl" as dumper>
--
-- <#assign foo = something.in["your"].data[0].model />
--
-- <@dumper.dump foo />
@beeTechMantra
beeTechMantra / AddUserRole.groovy
Created September 13, 2020 05:49
Liferay assign role to user by Groovy script / Programmatically
import com.liferay.portal.kernel.model.User
import com.liferay.portal.kernel.service.UserLocalServiceUtil
import com.liferay.portal.kernel.service.RoleLocalServiceUtil
import com.liferay.portal.kernel.model.Role
try{
//123456 - here you have to pass userId
//11111 - CompanyId
User user = UserLocalServiceUtil.getUser(123456);
<#-- dump.ftl
--
-- Generates tree representations of data model items.
--
-- Usage:
-- <#import "dump.ftl" as dumper>
--
-- <#assign foo = something.in["your"].data[0].model />
--
-- <@dumper.dump foo />

How to add an image to a gist

  1. Create a gist if you haven't already.
  2. Clone your gist:
    # make sure to replace `<hash>` with your gist's hash
    git clone https://gist.github.com/<hash>.git # with https
    git clone [email protected]:<hash>.git     # or with ssh