I want to add roles the users (not from UI)thru java code.can any one help me out which files should i look in alfresco to achive this.Thanks in advance for the help.
Take a look at the code in: org.alfresco.web.bean.users.UserMembersBean especially look in the finishOK() method. This class is full of examples of code to get/set/clear permissions/roles for users.