Foros de discusión

Setting java property from portal_normal.vm?

brian bohnet, modificado hace 11 años.

Setting java property from portal_normal.vm?

Junior Member Mensajes: 46 Fecha de incorporación: 27/01/10 Mensajes recientes
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, modificado hace 11 años.

RE: Setting java property from portal_normal.vm?

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
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, modificado hace 11 años.

RE: Setting java property from portal_normal.vm?

Junior Member Mensajes: 46 Fecha de incorporación: 27/01/10 Mensajes recientes
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, modificado hace 11 años.

RE: Setting java property from portal_normal.vm?

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
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, modificado hace 11 años.

RE: Setting java property from portal_normal.vm?

Junior Member Mensajes: 46 Fecha de incorporación: 27/01/10 Mensajes recientes
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, modificado hace 11 años.

RE: Setting java property from portal_normal.vm?

Regular Member Mensajes: 118 Fecha de incorporación: 24/02/10 Mensajes recientes
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, modificado hace 11 años.

RE: Setting java property from portal_normal.vm?

Expert Mensajes: 435 Fecha de incorporación: 9/02/09 Mensajes recientes
Hi Brian,

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

Regards,
Dhrutika