title: Adding roles to users in team area in RTC
body: <p>I need to add users ( users are already present in repository. I only need to add them.) and roles from a CSV file to team areas. Project area and Team Area already exists.I could successfully add users but not the roles from csv file. </p>
  
  <p>The CSV file format is :</p>
  
  <pre><code>Project name,Team Area name,Members,roles
  Project1,User_Role_TA,Alex,Team Member
  Project2,TA2,David,Scrum Master
  </code></pre>
  
  <p>Below is the code for it. It successfully add the users and currently add roles to them from project area but I need to add roles to the users from CSV file. In the below code, If I can get roles from csv file in the line  "IRole[] availableRoles = clientProcess.getRoles(area, null);" , I think it should resolve the issue. I am not getting any error but it doesn't add the roles.</p>
  
  <pre><code>     while((row = CSVFileReader.readLine()) != null ) 
              {
              rowNumber++;
              st = new StringTokenizer(row,",");
              while (st.hasMoreTokens()) {
               projectAreaList.add(st.nextToken());
               teamAreaList.add(st.nextToken());
               membersList.add(st.nextToken());
               roleList.add(st.nextToken());
              }
              }
              for (int i=1; i&lt;rowNumber; i++)
              {
              projectAreaName = projectAreaList.get(i);
              teamAreaName = teamAreaList.get(i);
              members = membersList.get(i);
              member_roles =roleList.get(i);
  
  
                 URI uri = URI.create(projectAreaName.replaceAll(" ", "%20"));
                 IProjectArea projectArea = (IProjectArea) processClient.findProcessArea(uri, null, null);
                  if (projectArea == null)
                  {
                      System.out.println("Project Area not found");
                  }
                  if (!teamAreaName.equals("NULL")){
                      List &lt;TeamAreaHandle&gt; teamlist = projectArea.getTeamAreas();
                      ITeamAreaHandle newTAHandle = findTeamAreaByName(teamlist,teamAreaName,monitor);
                      if(newTAHandle == null) {
                      System.out.println("Team Area not found");
                      }
                      else {
                          ITeamArea TA = (ITeamArea)teamRepository.itemManager().fetchCompleteItem(newTAHandle,ItemManager.DEFAULT,monitor);
                          IRole role = getRole(projectArea);
                      IContributor user = teamRepository.contributorManager().fetchContributorByUserId(members,monitor);
  
                      /*role1 = getRole(area).getId();
                      if(role1.equalsIgnoreCase(member_roles))
                      {
                          user_role = getRole(area);
                          }*/
  
  
                       IProcessAreaWorkingCopy areaWc = (IProcessAreaWorkingCopy)service.getWorkingCopyManager().createPrivateWorkingCopy(TA);
                       areaWc.getTeam().addContributorsSettingRoleCast(
                               new IContributor[] {user}, 
                               new IRole[] {role}); 
                      areaWc.save(monitor);
  
                      }
  
  public static IRole getRole(IProcessArea area) throws TeamRepositoryException {
              ITeamRepository repo = (ITeamRepository) area.getOrigin();
              IProcessItemService service =(IProcessItemService) repo
                  .getClientLibrary(IProcessItemService.class);
              IClientProcess clientProcess = service.getClientProcess(area, null);
              IRole[] availableRoles = clientProcess.getRoles(area, null);
              for (int i = 0; i &lt; availableRoles.length; i++) {
                  return availableRoles[i];
              }
              throw new IllegalArgumentException("Couldn't find role");
          }
  </code></pre>