Fórum

Getting portal url from within hook [RESOLVED]

M J, modificado 13 Anos atrás.

Getting portal url from within hook [RESOLVED]

New Member Postagens: 8 Data de Entrada: 07/07/10 Postagens Recentes
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, modificado 13 Anos atrás.

RE: Getting portal url from within hook

thumbnail
Sandeep Nair, modificado 13 Anos atrás.

RE: Getting portal url from within hook (Resposta)

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
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, modificado 13 Anos atrás.

RE: Getting portal url from within hook

New Member Postagens: 8 Data de Entrada: 07/07/10 Postagens Recentes
Works like a charm!

Thank you very much for your help.
thumbnail
Jitendra Rajput, modificado 12 Anos atrás.

RE: Getting portal url from within hook [RESOLVED]

Liferay Master Postagens: 875 Data de Entrada: 07/01/11 Postagens Recentes
Whats the third argument mean in this method
 PortalUtil.getPortalURL(
company.getVirtualHost(), PortalUtil.getPortalPort(), false);
thumbnail
Sandeep Nair, modificado 12 Anos atrás.

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
Secure or non secure. If secure(flag is true) it will give url with https
thumbnail
Jitendra Rajput, modificado 12 Anos atrás.

RE: Getting portal url from within hook [RESOLVED]

Liferay Master Postagens: 875 Data de Entrada: 07/01/11 Postagens Recentes
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, modificado 12 Anos atrás.

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
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, modificado 12 Anos atrás.

RE: Getting portal url from within hook [RESOLVED]

Liferay Master Postagens: 875 Data de Entrada: 07/01/11 Postagens Recentes
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, modificado 12 Anos atrás.

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
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, modificado 9 Anos atrás.

RE: Getting portal url from within hook

Expert Postagens: 375 Data de Entrada: 10/03/09 Postagens Recentes
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()