booleanliferayliferay-7liferay-service-builder

How to store a company-wide single variable in Liferay 7?


My company has a "status" which can have two values:

Only people with the DISASTER_MANAGER role are allowed to change that status. Depending on the status, a few portlets show/hide a UI component, and also a custom service checks the status to send an email or not.

Question: How to store this "status" in Liferay?

All of the usual Liferay storage options I can think of seem inappropriate:


Solution

  • I'd approach this problem from the side of using the information in question: What do you intend to do with this information - from "as simple as changing the background color for awareness" to "losen or tighten permissions all over the portal", the recommendation would be different.

    Options that come to my mind:

    As you're assuming that the last two are inappropriate: You can use them in combination, e.g. create a system setting, and a fake-entity service: In the definition of this service, you'd just create an empty entity (with a name, but no columns). You won't have any persistence, but a MyEntityLocalService and MyEntityService: In this, you can implement your own permission checks and flip the system setting, e.g. through your own UI. Given the implied urgency of the status, I'd refrain from sending anyone to the system settings UI, but just provide a straight button to push.

    Bonus: You'd have a natural API endpoint to flip the switch through external means if necessary.