The Guestbook application accepts submissions from any logged in user, so there’s no telling what people could post. Illegal data, objectionable content, the entire contents of Don Quixote: all of these and more are possibilities. You can make sure user posts don’t run afoul of the law or policy by enabling workflow in your application.
Workflow is a review process that ensures a submitted entity isn’t published before it’s reviewed. To prevent posting objectionable content, an initially submitted Guestbook entry should be marked as a draft and sent through the workflow framework. It comes back to the application code ready to have any relevant fields updated in the database based on its status. The view layer must filter entities by status to display only reviewed entities.
This section instructs the reader in workflow-enabling the Guestbook App’s
Guestbook
and Entry
entities to ensure that only approved content is
published after review.
Figure 1: Enable workflow in your assets, just like Liferay DXP's own assets.
There are five steps to enabling workflow:
-
Update the service layer to set each entity’s status fields.
-
Send the entity to Liferay DXP’s workflow framework.
-
Add getter methods that account for an entity’s workflow status.
-
Handle the entity as it returns from the workflow framework.
-
Update the user interface to account for workflow status.
The first three steps happen in the service layer, so that’s a good place to start.