留言板

Setting java property from portal_normal.vm?

brian bohnet,修改在11 年前。

Setting java property from portal_normal.vm?

Junior Member 帖子: 46 加入日期: 10-1-27 最近的帖子
We are running Liferay 6.0 EE SP1 on Redhat Linux 5

Being on a 4 node cluster, sometimes logging in as an Administrator, we would like to know to what server we are being routed. Of course, we could go to each server and tail the log files, which means opening up 4 terminal windows and such, which is a nuisance. Or you can check the java properties in the Control Panel ->Server Administration -> Properties; again that's a nuisance.

What I would like to do in the portal_normal.vm, is dynamically set the Liferay java property "web.server.display.node=true" when users login with the Administrator role.

Does anyone know if its possible to dynamically set the property in this manner to have the server node display?

Thanks
thumbnail
David H Nebinger,修改在11 年前。

RE: Setting java property from portal_normal.vm?

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
You can add a login post event handler to get the current user, see if they're an administrator, and set the property accordingly.
brian bohnet,修改在11 年前。

RE: Setting java property from portal_normal.vm?

Junior Member 帖子: 46 加入日期: 10-1-27 最近的帖子
David H Nebinger:
You can add a login post event handler to get the current user, see if they're an administrator, and set the property accordingly.


Thinking about this a little more, my original idea and the login post event handler would set the property for the portal as whole, so as soon as I login as an Administrator, each subsequent login would see the node display also, which I didn't really want. There could be a risk of users seeing it and complaining or a possibility of affecting the rendered pages.

Is there an easier way to identify the server node than adding a hook, seems like with a few simple lines of velocity markup we could capture what node we are on and keep it isolated to the one user logged in via javascript? ( hence my trying to place this in the portal_normal.vm )
thumbnail
David H Nebinger,修改在11 年前。

RE: Setting java property from portal_normal.vm?

Liferay Legend 帖子: 14919 加入日期: 06-9-2 最近的帖子
I wouldn't make it a global property, just a session variable. You can reference the session variable in the velocity template and selectively show it or not.
brian bohnet,修改在11 年前。

RE: Setting java property from portal_normal.vm?

Junior Member 帖子: 46 加入日期: 10-1-27 最近的帖子
I'm thinking of just grabbing the System.env HOSTNAME variable and using it your way and displaying to only Administrators, then I'm not dealing with any global settings.

Thanks for your quick and knowledgeable input!
thumbnail
Jay Patel,修改在11 年前。

RE: Setting java property from portal_normal.vm?

Regular Member 帖子: 118 加入日期: 10-2-24 最近的帖子
I think you can continue to have property "web.server.display.node=true" set in portal-ext.properties for every user & rather write custom logic in theme's .vm file such that when only admin user has logged in then only node information is shown.

I think this can be done by checking logged-in user's role.

-Jay.
thumbnail
Dhrutika Parekh,修改在11 年前。

RE: Setting java property from portal_normal.vm?

Expert 帖子: 435 加入日期: 09-2-9 最近的帖子
Hi Brian,

You can check try this way:
#if ($permissionChecker.isOmniadmin())
$propsUtil("web.server.display.node")
#end

Regards,
Dhrutika