Ahmed
Ahmed

Reputation: 13

Liferay PortalURL in scheduler

I am creating a Scheduler in liferay Portlet and once the scheduler job is complete i have to send an email.

In this email i need to send the Portal URL as a link.

<a href="http://localhost:8080"

Can any body help me on how i can get the portal URL in scheduler.

Upvotes: 1

Views: 1102

Answers (1)

Tony Rad
Tony Rad

Reputation: 2509

You can use the following:

Company company = CompanyLocalServiceUtil.getCompany(companyId); 
String portalURL = PortalUtil.getPortalURL(company.getVirtualHost(),
PortalUtil.getPortalPort(), false);

In the last call, the last parameter must be true if you are using https.

If you don't have access to the companyId in your class but you know that you have only one company in the DB (which is the normal case unless you are in a hosting/multitenant scenario) then you can use the following:

Company company = CompanyLocalServiceUtil.getCompanies().get(0);

Upvotes: 2

Related Questions