Today I want to address a topic often ignored or underestimated: portlets deployment in a multi company environment.
Let's think about a server with multiple companies configured, one for each customer of your company; in this situation, when you deploy a portlet, this will become available in all companies.
But what if the portlet has been developed for a specific customer? Maybe under payment? This behaviour would not be the right choice.
The obvious solution is that the portlet will be available only in the instance (or instances) needed; fortunately Liferay help us with two different approaches.
The first type of approach is the simplest, namely disabling the portlet in all companies in which it is useless; to do this, simply login as an administrator to the Control Panel of each company and from the App Manager menu disable the entire plugin or just the single portlet.
This solution does not require development activities and is useful in all cases where the portlet should be available on most companies, otherwise you will lose too much time to turn it off in the various companies and you should also remember to turn it off after the creation of a new company.
In all these cases, when the portlet has to be available in few instances (maybe just one), you can proceed with the second approach: enabling portlet in all companies it's needed. This means that the portlet must be already disable at deploy time.
To do this, just edit the plugin's
liferay-portlet.xml file, and add the following tag inside every
<portlet> element you need to disable:
So the portlet, once deployed, will be disabled for all; then simply login as an administrator to the Control Panel of each company and from the App Manager menu just enable the portlet on the instances needed.
The only thing to remember is that the portlet must be disabled (in the
liferay-portlet.xml file) since its first deployment; otherwise the only way to turn it off will be the from the Control Panel.