掲示板

Getting portal url from within hook [RESOLVED]

13年前 に M J によって更新されました。

Getting portal url from within hook [RESOLVED]

New Member 投稿: 8 参加年月日: 10/07/07 最新の投稿
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!
13年前 に v c vijayan によって更新されました。

RE: Getting portal url from within hook

thumbnail
13年前 に Sandeep Nair によって更新されました。

RE: Getting portal url from within hook (回答)

Liferay Legend 投稿: 1744 参加年月日: 08/11/06 最新の投稿
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
13年前 に M J によって更新されました。

RE: Getting portal url from within hook

New Member 投稿: 8 参加年月日: 10/07/07 最新の投稿
Works like a charm!

Thank you very much for your help.
thumbnail
12年前 に Jitendra Rajput によって更新されました。

RE: Getting portal url from within hook [RESOLVED]

Liferay Master 投稿: 875 参加年月日: 11/01/07 最新の投稿
Whats the third argument mean in this method
 PortalUtil.getPortalURL(
company.getVirtualHost(), PortalUtil.getPortalPort(), false);
thumbnail
12年前 に Sandeep Nair によって更新されました。

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend 投稿: 1744 参加年月日: 08/11/06 最新の投稿
Secure or non secure. If secure(flag is true) it will give url with https
thumbnail
12年前 に Jitendra Rajput によって更新されました。

RE: Getting portal url from within hook [RESOLVED]

Liferay Master 投稿: 875 参加年月日: 11/01/07 最新の投稿
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
12年前 に Sandeep Nair によって更新されました。

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend 投稿: 1744 参加年月日: 08/11/06 最新の投稿
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
12年前 に Jitendra Rajput によって更新されました。

RE: Getting portal url from within hook [RESOLVED]

Liferay Master 投稿: 875 参加年月日: 11/01/07 最新の投稿
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
12年前 に Sandeep Nair によって更新されました。

RE: Getting portal url from within hook [RESOLVED]

Liferay Legend 投稿: 1744 参加年月日: 08/11/06 最新の投稿
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
9年前 に Bijan Vakili によって更新されました。

RE: Getting portal url from within hook

Expert 投稿: 375 参加年月日: 09/03/10 最新の投稿
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()