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

getting IWorkspaceManager as null

I am trying to get the IWorkspaceManager object using IteamRepository as follow:

ITeamRepository teamRepository = TeamPlatform.getTeamRepositoryService().getTeamRepository(iac.getRepositoryURI());
teamRepository.registerLoginHandler(new LoginHandler(CosiConstant.COSI_GENERIC_USER_ID, CosiConstant.COSI_GENERIC_PASSWD));
teamRepository.login(monitor);
System.out.println("Team repository :"+teamRepository);
IWorkspaceManager workSpaceManager= SCMPlatform.getWorkspaceManager(teamRepository);

but getting workSpaceManager object as null.

I using following client jars :
 com.ibm.team.repository.client_1.3.0.v20140406_2347.jar,
 com.ibm.team.repository.common.json_1.2.200.v20141019_2353.jar,
 com.ibm.team.scm.client_3.2.200.v20140414_0046.jar,
 com.ibm.team.scm.common_3.2.200.v20140414_0046.jar

Please help with this.

0 votes



3 answers

Permanent link
The code explained here https://rsjazz.wordpress.com/2013/09/24/managing-workspaces-streams-and-components-using-the-plain-java-client-libraries/ works and gets the required classes. I Have never seen issues, provided the code is correct, regardless of the version.

Consider to provide the code with the whole plain java client libraries.

You should be able to debug your code and see if code before that has issues as the code above does not contain any error handling. There is no way to provide more help with this few bits of information.

0 votes


Permanent link

Please find the complete implementation :

import org.eclipse.core.runtime.IProgressMonitor;

import com.ibm.team.process.common.IProcessConfigurationElement;

import com.ibm.team.process.common.advice.AdvisableOperation;

import com.ibm.team.process.common.advice.runtime.IOperationParticipant;

import com.ibm.team.process.common.advice.runtime.IParticipantInfoCollector;

import com.ibm.team.repository.client.ITeamRepository;

import com.ibm.team.repository.client.TeamPlatform;

import com.ibm.team.repository.common.TeamRepositoryException;

import com.ibm.team.repository.common.query.IItemQueryPage;

import com.ibm.team.repository.service.AbstractService;

import com.ibm.team.scm.client.IWorkspaceConnection;

import com.ibm.team.scm.client.IWorkspaceManager;

import com.ibm.team.scm.client.SCMPlatform;

import com.ibm.team.scm.common.IComponentHandle;

import com.ibm.team.scm.common.IWorkspaceHandle;

import com.ibm.team.scm.common.dto.IWorkspaceSearchCriteria;

import com.ibm.team.workitem.common.IAuditableCommon;

import com.ibm.team.workitem.common.ISaveParameter;

public class ConnectStreamToGetChangeSetDetails extends AbstractService implements

IOperationParticipant {

private static final String INTEGRATION_WORKSPACE = "Integration Stream Workspace";

@Override

public void run(AdvisableOperation operation,

IProcessConfigurationElement arg1,

IParticipantInfoCollector collector, IProgressMonitor monitor)

throws TeamRepositoryException {

System.out.println("In ConnectStreamToGetChangeSetDetails");

Object data = operation.getOperationData();

try {

if(data instanceof ISaveParameter)

{

System.out.println("ConnectStreamToGetChangeSetDetails :: In check if instance of Isave parameter");

ISaveParameter param = (ISaveParameter) data;

IAuditableCommon iac = (param).getSaveOperationParameter().getAuditableCommon();

ITeamRepository teamRepository = TeamPlatform.getTeamRepositoryService().getTeamRepository(iac.getRepositoryURI());

teamRepository.registerLoginHandler(new LoginHandler(CosiConstant.COSI_GENERIC_USER_ID, CosiConstant.COSI_GENERIC_PASSWD));

teamRepository.login(monitor);

System.out.println("Team repository :"+teamRepository+" "+teamRepository.loggedIn());

IWorkspaceManager workSpaceManager= (IWorkspaceManager)SCMPlatform.getWorkspaceManager(teamRepository);

//IWorkspaceManager workSpaceManager = (IWorkspaceManager)teamRepository.getClientLibrary(IWorkspaceManager.class);

System.out.println("Workspace manager :"+workSpaceManager);

IWorkspaceSearchCriteria criteria = IWorkspaceSearchCriteria.FACTORY.newInstance();

criteria.setKind( IWorkspaceSearchCriteria.WORKSPACES );

criteria.setExactName( INTEGRATION_WORKSPACE );

if(workSpaceManager != null)

{

List<IWorkspaceHandle> workspaceHandles = ((IItemQueryPage) workSpaceManager.findWorkspaces(criteria, Integer.MAX_VALUE, monitor)).getItemHandles();

IWorkspaceHandle wh = workspaceHandles.get( 0 );

System.out.println("Workspace handle :"+wh);

IWorkspaceConnection workspaceConnection = workSpaceManager.getWorkspaceConnection(wh, monitor);

List<IComponentHandle> components = workspaceConnection.getComponents();

for(IComponentHandle componentHandle : components)

{

System.out.println("component name :"+componentHandle.toString());

}

}

}

}

catch (Exception e) {

System.out.println(" In ConnectStreamToGetChangeSetDetails Exception :");

e.printStackTrace();

}

}

}

I using following client jars :

 com.ibm.team.repository.client_1.3.0.v20140406_2347.jar,
 com.ibm.team.repository.common.json_1.2.200.v20141019_2353.jar,
 com.ibm.team.scm.client_3.2.200.v20140414_0046.jar,
 com.ibm.team.scm.common_3.2.200.v20140414_0046.jar

0 votes


Permanent link

Please find the complete implementation :

import org.eclipse.core.runtime.IProgressMonitor;

 

import com.ibm.team.process.common.IProcessConfigurationElement;

import com.ibm.team.process.common.advice.AdvisableOperation;

import com.ibm.team.process.common.advice.runtime.IOperationParticipant;

import com.ibm.team.process.common.advice.runtime.IParticipantInfoCollector;

import com.ibm.team.repository.client.ITeamRepository;

import com.ibm.team.repository.client.TeamPlatform;

import com.ibm.team.repository.common.TeamRepositoryException;

import com.ibm.team.repository.common.query.IItemQueryPage;

import com.ibm.team.repository.service.AbstractService;

import com.ibm.team.scm.client.IWorkspaceConnection;

import com.ibm.team.scm.client.IWorkspaceManager;

import com.ibm.team.scm.client.SCMPlatform;

import com.ibm.team.scm.common.IComponentHandle;

import com.ibm.team.scm.common.IWorkspaceHandle;

import com.ibm.team.scm.common.dto.IWorkspaceSearchCriteria;

import com.ibm.team.workitem.common.IAuditableCommon;

import com.ibm.team.workitem.common.ISaveParameter;

 

public class ConnectStreamToGetChangeSetDetails extends AbstractService implements

 

IOperationParticipant {

private static final String INTEGRATION_WORKSPACE = "Integration Stream Workspace";

 

@Override

public void run(AdvisableOperation operation,

 

IProcessConfigurationElement arg1,

IParticipantInfoCollector collector, IProgressMonitor monitor)

throws TeamRepositoryException {

 

System.out.println("In ConnectStreamToGetChangeSetDetails");

 

Object data = operation.getOperationData();

try {

if(data instanceof ISaveParameter)

 

{

System.out.println("ConnectStreamToGetChangeSetDetails :: In check if instance of Isave parameter");

 

ISaveParameter param = (ISaveParameter) data;

IAuditableCommon iac = (param).getSaveOperationParameter().getAuditableCommon();

ITeamRepository teamRepository = TeamPlatform.getTeamRepositoryService().getTeamRepository(iac.getRepositoryURI());

teamRepository.registerLoginHandler(new LoginHandler(CosiConstant.COSI_GENERIC_USER_ID, CosiConstant.COSI_GENERIC_PASSWD));

 

teamRepository.login(monitor);

System.out.println("Team repository :"+teamRepository+" "+teamRepository.loggedIn());

 

IWorkspaceManager workSpaceManager= (IWorkspaceManager)SCMPlatform.getWorkspaceManager(teamRepository);

//IWorkspaceManager workSpaceManager = (IWorkspaceManager)teamRepository.getClientLibrary(IWorkspaceManager.class);

 

System.out.println("Workspace manager :"+workSpaceManager);

IWorkspaceSearchCriteria criteria = IWorkspaceSearchCriteria.FACTORY.newInstance();

 

criteria.setKind( IWorkspaceSearchCriteria.WORKSPACES );

 

criteria.setExactName( INTEGRATION_WORKSPACE );

if(workSpaceManager != null)

 

{

List<IWorkspaceHandle> workspaceHandles = ((IItemQueryPage) workSpaceManager.findWorkspaces(criteria, Integer.MAX_VALUE, monitor)).getItemHandles();

 

IWorkspaceHandle wh = workspaceHandles.get( 0 );

System.out.println("Workspace handle :"+wh);

 

IWorkspaceConnection workspaceConnection = workSpaceManager.getWorkspaceConnection(wh, monitor);

List<IComponentHandle> components = workspaceConnection.getComponents();

for(IComponentHandle componentHandle : components)

 

{

System.out.println("component name :"+componentHandle.toString());

 

}

}

}

}

catch (Exception e) {

System.out.println(" In ConnectStreamToGetChangeSetDetails Exception :");

 

e.printStackTrace();

}

}

}

I using following client jars :

 com.ibm.team.repository.client_1.3.0.v20140406_2347.jar,
 com.ibm.team.repository.common.json_1.2.200.v20141019_2353.jar,
 com.ibm.team.scm.client_3.2.200.v20140414_0046.jar,
 com.ibm.team.scm.common_3.2.200.v20140414_0046.jar

0 votes

Comments

Sorry, my code works, so you might want to start wit working code. I will not debug your code.

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,943

Question asked: Apr 20 '16, 8:16 a.m.

Question was seen: 2,298 times

Last updated: Apr 22 '16, 7:10 a.m.

Confirmation Cancel Confirm