Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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?

0 votes

Comments

I replaced line 2 with:


ITeamRepositoryService repositoryService = TeamPlatform.getTeamRepositoryService();
ITeamRepository repository = repositoryService.getTeamRepository(getPublicRepositoryURL());

The repository was now not null but I got an error indicating I was not logged into the repository. 

Then I added the line:

repository.login(monitor); 

I got java.lang.IllegalStateException. Why am I not logged into the Repository when the client shows that I am? and how do I solve this? 



One answer

Permanent link
 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


0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,948

Question asked: Dec 26 '12, 10:23 p.m.

Question was seen: 4,991 times

Last updated: Dec 31 '12, 5:22 p.m.

Confirmation Cancel Confirm