Now, when i publish a page which uses this AEM component, the anonymous user on the published site gets an error message:
Post-construct method has thrown an exception for model class
On further analysis: I have found that since "anonymous" user does not have permissions to write on /content nodes, the statement marked above with an (*) sets map object to null.
My Question is: Is there a better implementation pattern to achieve the scenario of configuring the state of content node such that the state of the content can be set through node property only for authors?
Usually, when you do content authoring in AEM, you do set all of the properties such as your "customProperty" via the dialog's. Which automatically send your data to SlingPostServlet that handles saving data to the database.
You normally, should not write data when you generate SlingModel.
In case if you do need to do it, due to your unique and awesome! requirements.
Kindly refer to the following guide on how to allow 'anonymous' to write into your database.
The "customProperty" is not part of the dialog and hence not added via authoring interface.
Question: "You normally, should not write data when you generate SlingModel."
What if I require to set/unset a property (such as "customProperty") whenever the page is loaded? In such circumstance, without apply business logic of updating properties via SlingModel, is there any other scheme or design I could follow?