Using Portal Properties for Separate Liferay Instances

Much like the portal-ext.properties file, portal-${instance}.properties files override properties set in portal.properties and other files for a specific Liferay instance. This article outlines the steps necessary to enable these portal properties files for a single instance.

Resolution

Note: This solution is not applicable for DXP 7.3 and above.
  1. Go to Control Panel > Server Administration > Portal Instance and note the Web ID's of the two (or more) portal instances that you have. If you have not created a second instance, create one in this step.
  2. Shut down the Liferay server, and navigate to ${tomcat_Home}/webapps/ROOT/WEB-INF/classes and create a property file for each portal instance. Title each file in the following manner:
    portal-{$instance_WebID}.properties
    

    So for instance, the Web ID of the default Liferay instance is Liferay.com. Therefore, the portal-{$instance}.properties file for this instance would be called:

    portal-Liferay.com.properties
    
  3. In the same path, create a system-ext.properties file, and add the following line to the file:
    company-id-properties=true
    
  4. Open sentev.bat (or sentev.sh in Linux) in {$tomcat_Home}/bin and add the following line to the Java Settings:
    -Dcompany-id-properties=true
    
  5. Open the portal-{$instance}.properties files and add the following line to each of them
    terms.of.use.required=
    

    Give a value of false to at least one of these files, and a value of true to the others.

  6. Start the portal and see that this property is properly applied according to the setting given this property. Also, look at the stacktrace and look to see that the portal-{$instance}.properties files had loaded. The logs should show an output simliar to below if the files are loaded properly:
    Loading file:/D:/Customer_Environment/liferay-portal-6.1.20-ee-ga2/portal-setup-wizard.properties for {companyId=10154, webId=liferay.com}
    Loading file:/D:/Customer_Environment/liferay-portal-6.1.20-ee-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes/portal-liferay.com.properties for {companyId=10154, webId=liferay.com} ...
    Loading file:/D:/Customer_Environment/liferay-portal-6.1.20-ee-ga2/portal-setup-wizard.properties for {companyId=10435, webId=instance2.com}
    Loading file:/D:/Customer_Environment/liferay-portal-6.1.20-ee-ga2/tomcat-7.0.27/webapps/ROOT/WEB-INF/classes/portal-instance2.com.properties for {companyId=10435, webId=instance2.com}
    

    If the property terms.of.use.required= properly applied to each instance, and the two portal-${instance}.properties files both loaded in the stacktrace, then the portal-${instance}.properties have been utilized successfully.

 

Limited Properties

Not every property is configurable on an instance-by-instance basis. Most properties, in fact, are not configurable by instance. In many cases, two separate bundles work better to meet customers' needs. If using portal instances with distinct property sets is a requirement, however, this list comprises the types of properties that are configurable by instance:

  • Google Apps
  • Facebook Connect SSO
  • CAS
  • OpenSSO
  • Admin Portlet
  • SiteMinder
  • LDAP Content Delivery Network
  • Email section under Flags portlet
  • Email section under Configure email notification settings for discussions.
  • Trash
  • OpenSSO
  • Email notification session under Discussion Tag Library
  • NTLM
  • Openid
  • Users

Note: If you would like to find out if a specific property is configurable per-instance, review the source code to see if the properties are using the CompanyId in the method. For example, the property discussion.email.commments.added.enabled has CompanyId connected to it:

PrefsPropsUtil.getBoolean(message.getCompanyId(),PropsKeys.DISCUSSION_EMAIL_COMMENTS_ADDED_ENABLED))

Therefore, the above example passes the Company ID in the method. This is one way to see if a property should be configurable by a per instance basis. If the Company ID is not passed in its method, it is likely that it cannot be configured by instance.

 

Best Practice

Liferay recommends configuring properties on a per-instance basis via the Control Panel and not through distinct Portal-{$instance}.properties files. See this description in the portal.properties file:

# Each portal instance can have its own overriden property file following
# the convention portal-companyWebId.properties. To enable this feature, set
# the "company-id-properties" system property to true.
#
# To enable:
#
# java ... -Dcompany-id-properties=true
#
# The read order will now be: portal.properties, then portal-ext.properties,
# and then portal-liferay.com.properties.
#
# Note that not all properties can have different values per company. This
# functionality is only available for legacy reasons. The preferred way to
# configure a portal instance is through the Control Panel.
这篇文章有帮助吗?
0 人中有 0 人觉得有帮助