Foren

Getting portal url from within hook [RESOLVED]

M J, geändert vor 13 Jahren.

Getting portal url from within hook [RESOLVED]

New Member Beiträge: 8 Beitrittsdatum: 07.07.10 Neueste Beiträge
Hi

I'm writing a ModelListener on the JournalArticle and need to get the
Portal URL (http://host:port) from within this hook.

Is there a way to do this without an additional property file?

Every hint is welcome!
v c vijayan, geändert vor 13 Jahren.

RE: Getting portal url from within hook

thumbnail
Sandeep Nair, geändert vor 13 Jahren.

RE: Getting portal url from within hook (Antwort)

Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
Hi,

Try using this

String portalURL = PortalUtil.getPortalURL(
company.getVirtualHost(), PortalUtil.getPortalPort(), false);

Company u can get from companyid which may be there in your journal article

Regards,
Sandeep
M J, geändert vor 13 Jahren.

RE: Getting portal url from within hook

New Member Beiträge: 8 Beitrittsdatum: 07.07.10 Neueste Beiträge
Works like a charm!

Thank you very much for your help.
thumbnail
Jitendra Rajput, geändert vor 12 Jahren.

RE: Getting portal url from within hook [RESOLVED]

Liferay Master Beiträge: 875 Beitrittsdatum: 07.01.11 Neueste Beiträge
Whats the third argument mean in this method
 PortalUtil.getPortalURL(
company.getVirtualHost(), PortalUtil.getPortalPort(), false);
thumbnail
Sandeep Nair, geändert vor 12 Jahren.

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
Secure or non secure. If secure(flag is true) it will give url with https
thumbnail
Jitendra Rajput, geändert vor 12 Jahren.

RE: Getting portal url from within hook [RESOLVED]

Liferay Master Beiträge: 875 Beitrittsdatum: 07.01.11 Neueste Beiträge
can we determine this dynamically ?

I know there is one method in themeDisplay.isSecure() .
I mean can we check dynamically whether server is SSL enabled or not ? without using any request object . As i want to determine from my scheduler and i dnt have access to any of request object.
thumbnail
Sandeep Nair, geändert vor 12 Jahren.

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
Are you setting the follwoing in your portal-ext.properties

web.server.protocol=https

If yes then you can just check the property. Otherwise you dont have any other way

Regards,
Sandeep
thumbnail
Jitendra Rajput, geändert vor 12 Jahren.

RE: Getting portal url from within hook [RESOLVED]

Liferay Master Beiträge: 875 Beitrittsdatum: 07.01.11 Neueste Beiträge
You mean to say ,, this is manual job ..if my server is https enabled then i need to set this property as https otherwise http.
thumbnail
Sandeep Nair, geändert vor 12 Jahren.

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
Well, since you have no other option as you are using scheduler and protocol is associated with request. User A can hit http or https and scheduler cant magically dream about the request being made by each client. By setting the property you are saying that this is the preferred protocol and it becomes easy for you as you are generating the url and not the end user.

Regards,
Sandeep
thumbnail
Bijan Vakili, geändert vor 9 Jahren.

RE: Getting portal url from within hook

Expert Beiträge: 375 Beitrittsdatum: 10.03.09 Neueste Beiträge
Sandeep Nair:
Hi,

Try using this

String portalURL = PortalUtil.getPortalURL(
company.getVirtualHost(), PortalUtil.getPortalPort(), false);

Company u can get from companyid which may be there in your journal article

Regards,
Sandeep



Thank you; in 6.2, this has changed bit:

String portalURL = PortalUtil.getPortalURL(
company.getVirtualHostname(), PortalUtil.getPortalPort(), false);

Note: company.getVirtualHost() --> company.getVirtualHostname()