it depends on what you mean by "createNode function" - the "Create Content" menu in the document library or the literal "createNode" operation on the NodeService (not Share but Repository) - or something completely different.
you you shouldn't override the createNode operation on the NodeService. Technically it is possibly by injecting an interceptor into the public bean or sub-classin the DbNodeServiceImpl and overriding the private bean, but this would be an unsupported change. What do you want to change in terms of behaviour? You should try to use any of the standard extension / customization methods for Alfresco, e.g. try using a Policy or Rule to achieve the desired behaviour…
I want to allow consumer to add comments but i don't want to include CreateChildren permission in my permission model. I've made Add comments button visible to every role. But when try to add comment by consumer, i got error pop up saying 'Unable to save comment'
Log - > Access Denied. You do not have the appropriate permissions to perform this operation
How can i allow consumer to add comments without including create children permission ?
you could try using a custom dynamic authority that uses request-scoped information to grant CreateChildren during permission evaluation without requiring that CreateChildren is granted statically (via ACL). E.g. the comments.post.json.js could be customized to set the request-scoped information that a comment is to be added to a specific NodeRef and the dynamic authority compares that request-scoped NodeRef with the NodeRef that is passed to it to check if the current user has that dynamic authority (and via <globalPermission> the CreateChildren permission).