Foros de discusión

Getting portal url from within hook [RESOLVED]

M J, modificado hace 13 años.

Getting portal url from within hook [RESOLVED]

New Member Mensajes: 8 Fecha de incorporación: 7/07/10 Mensajes recientes
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 hace 13 años.

RE: Getting portal url from within hook

thumbnail
Sandeep Nair, modificado hace 13 años.

RE: Getting portal url from within hook (Respuesta)

Liferay Legend Mensajes: 1744 Fecha de incorporación: 6/11/08 Mensajes recientes
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 hace 13 años.

RE: Getting portal url from within hook

New Member Mensajes: 8 Fecha de incorporación: 7/07/10 Mensajes recientes
Works like a charm!

Thank you very much for your help.
thumbnail
Jitendra Rajput, modificado hace 12 años.

RE: Getting portal url from within hook [RESOLVED]

Liferay Master Mensajes: 875 Fecha de incorporación: 7/01/11 Mensajes recientes
Whats the third argument mean in this method
 PortalUtil.getPortalURL(
company.getVirtualHost(), PortalUtil.getPortalPort(), false);
thumbnail
Sandeep Nair, modificado hace 12 años.

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend Mensajes: 1744 Fecha de incorporación: 6/11/08 Mensajes recientes
Secure or non secure. If secure(flag is true) it will give url with https
thumbnail
Jitendra Rajput, modificado hace 12 años.

RE: Getting portal url from within hook [RESOLVED]

Liferay Master Mensajes: 875 Fecha de incorporación: 7/01/11 Mensajes recientes
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 hace 12 años.

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend Mensajes: 1744 Fecha de incorporación: 6/11/08 Mensajes recientes
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 hace 12 años.

RE: Getting portal url from within hook [RESOLVED]

Liferay Master Mensajes: 875 Fecha de incorporación: 7/01/11 Mensajes recientes
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 hace 12 años.

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend Mensajes: 1744 Fecha de incorporación: 6/11/08 Mensajes recientes
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 hace 9 años.

RE: Getting portal url from within hook

Expert Mensajes: 375 Fecha de incorporación: 10/03/09 Mensajes recientes
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()