Foros de discusión

Portal or Portlet Configuration

thumbnail
Trever Shick, modificado hace 12 años.

Portal or Portlet Configuration

New Member Mensajes: 6 Fecha de incorporación: 1/07/09 Mensajes recientes
We have a Liferay server in production that's been running fine for quite some time now, with portlets that communicate with backend servers for data (REST based services,etc).

Up to this point, we've been using JNDI to store the endpoint URLs and other configuration information that is 'server-wide'. This has served us well. However, portlet development is picking up and using JNDI causes us to have to modify Tomcat's server.xml and restart the server whenever a portlet has a new configuration parameter.

Obviously this is less than optimal.

I'm going thru and doing some up front work to determine the level of effort of migrating a 5.1.6 based code base to 6.0.12 (EE). It's fairly simple, but I have the opportunity to make our configuration 'better'.

It seems like using 'PortalPreferences' (portal not portlet) might work but I'm looking for a little guidance here. We do NOT use the ext environment. I don't want to add custom db tables. I want to be able to configure these values server wide via the control panel (I understand how to do that) but i'm not sure that PortalPreferences is the way to go there. The documentation is abysmal around PortalPreferences so i'm looking for a little help from the community.

Please help.

Thanks

Trever
thumbnail
Tomáš Polešovský, modificado hace 12 años.

RE: Portal or Portlet Configuration

Liferay Master Mensajes: 676 Fecha de incorporación: 13/02/09 Mensajes recientes
Trever,

there are more ways you can go and PortalPreferences is a good way to have portal-wide settings. But I'm not sure if you can edit it OOTB in the ControlPanel.

In your case it make sense to have your settings together with Liferay portal settings. I'm copying com.liferay.portal.util.PrefsPropsUtil.getPreferences method which returns portal preferences in 6.0.6. Hope it will work the same in 6.0.12 (don't have sources now).
 	public static PortletPreferences getPreferences(long companyId)
		throws SystemException {

		long ownerId = companyId;
		int ownerType = PortletKeys.PREFS_OWNER_TYPE_COMPANY;
		long plid = PortletKeys.PREFS_PLID_SHARED;
		String portletId = PortletKeys.LIFERAY_PORTAL;

		return PortletPreferencesLocalServiceUtil.getPreferences(
			companyId, ownerId, ownerType, plid, portletId);
	}


PortletPreferences is JSR-168/286 object, you can work with them as usual.
thumbnail
Trever Shick, modificado hace 12 años.

RE: Portal or Portlet Configuration

New Member Mensajes: 6 Fecha de incorporación: 1/07/09 Mensajes recientes
Thanks. I'll give that a try.

What would the companyId be? Since this is portal wide, it's the same for everyone.

I assume i'll have to build a portlet to manage the preferences within the control panel. I'm fine with that.
thumbnail
Trever Shick, modificado hace 12 años.

RE: Portal or Portlet Configuration

New Member Mensajes: 6 Fecha de incorporación: 1/07/09 Mensajes recientes
So, this does appear to work. However, I am unable to call .store() on the preferences object.

In 6.0.5 it checked to see if the portletId was LIFERAY_PORTAL, if it is, then it skipped locating validators. However, 6.0.12 apparently removed this check. Since LIFERAY_PORTAL doesn't return a portlet instance, an NPE is occurring within the code. Due to this I had to call PortletPreferencesLocalServiceUtil.updatePreferences. This seems to work now.

Thanks
thumbnail
Tomáš Polešovský, modificado hace 12 años.

RE: Portal or Portlet Configuration

Liferay Master Mensajes: 676 Fecha de incorporación: 13/02/09 Mensajes recientes
In 6.0 EE SP2 you have PortalPreferencesLocalServiceUtil.

It would be better to use this service and I think it won't cause NPE emoticon
thumbnail
Trever Shick, modificado hace 12 años.

RE: Portal or Portlet Configuration

New Member Mensajes: 6 Fecha de incorporación: 1/07/09 Mensajes recientes
Makes sense. I'll give that a try and report back. Thank you for your help.