Why is IProjectAreaHandle.getOrigin() returning null ?
I am trying to programatically create a Team Area when the state of a work item changes. The code I am using is listed below:
1 IProjectAreaHandle projectAreaHandle = workitem.getProjectArea();
2 ITeamRepository repository = (ITeamRepository)projectAreaHandle.getOrigin();
3 IProjectArea projectArea = (IProjectArea)repository.itemManager().fetchCompleteItem(projectAreaHandle, IItemManager.DEFAULT, monitor);
4 List<ITeamArea> teamList = (projectArea).getTeamAreas();
5 //create a new team name
6 TeamNameGenerator generator = new TeamNameGenerator(teamList);
7 String teamName = generator.generate();
8 //Get the service to create a new Team Area
9 IProcessItemService service = (IProcessItemService)repository.getClientLibrary(IProcessItemService.class);
10 //Create a new Team Area
11 ITeamArea teamArea = createNewTeamArea(monitor, projectArea, teamName, service);
When I run this code, the Repository in Line 2 comes up null which prevents me from getting the Project Area in Line 3 and Process Item Service in Line 9 which are needed for creating the Team Area in Line 11. Is there another way of getting the Repository. The work item is being created manually as part of an existing Project Area. Both of these are being save to the the repository. Can someone explain why projectAreaHandle.getOrigin() returns null? Is there another way to get the Team Repository?
|
One answer
I got past the IllegalStateException by replacing Line 2 with:
//Log into the Team Repository
String aUserID = "TestJazzAdmin1";
String aPassword = "TestJazzAdmin1";
repository.registerLoginHandler(new LoginHandler(aUserID, aPassword));
repository.login(monitor);
I also needed to create 2 Static inner classes:
private static class LoginHandler implements ITeamRepository.ILoginHandler {
private String eUserID;
private String ePassword;
private LoginHandler(String userID, String password){
eUserID = userID;
ePassword = password;
}
public ITeamRepository.ILoginHandler.ILoginInfo challenge(ITeamRepository repository) {
return new LoginInfo(eUserID, ePassword);
}
}//End LoginHandler inner class
private static class LoginInfo implements ITeamRepository.ILoginHandler.ILoginInfo {
private String fUserId;
private String fPassword;
private LoginInfo(String userId, String password) {
fUserId= userId;
fPassword= password;
}
@Override
public String getPassword() {
return fPassword;
}
@Override
public String getUserId() {
return fUserId;
}
}//End LoginInfo inner class
|
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.
Comments
I replaced line 2 with: