It's all about the answers!

Ask a question

How can i get the "my repository workspace" programmatically with plain java API


vikas v (15314) | asked May 14 '15, 8:43 a.m.
I am able to find the project area,stream and component with the help of  IWorkspaceManager but not able to find the my repository workspace.

I have to do few operation with the following parameters
ITeamRepository repo,
IWorkspaceHandle workspace,
IComponentHandle component,
String sandboxLocation_CanBeNullIfRunningFromWithinEclipseRTC


In all these parameter i am not able to find IWorkspaceHandle workspace programmatically.

Please provide solution ASAP.

Thanks!!

One answer



permanent link
Surya Tripathi (65017) | answered May 14 '15, 1:37 p.m.
 You will need to search for your workspace. 
IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(repository)
IWorkspaceSearchCriteria criteria = IWorkspaceSearchCriteria.FACTORY.newInstance();
criteria.setExactName(rtcWorkspace); // or use another criteria
criteria.setKind(IWorkspaceSearchCriteria.WORKSPACES); 
List<IWorkspaceHandle> workspaces = wm.findWorkspaces(criteria, maxSize, minitor);
IWorkspaceConnection connection = wm.getWorkspaceConnection(workspaces.get(0), monitor);


Comments
vikas v commented May 15 '15, 12:35 a.m.

i done in the same way but after getting workspace connection when i am calling new function with the following parameter
(IteamRepository arg0,IWorkSpaceHandle arg1, IComponentHandle arg2,String arg4)

i am getting exception
java.lang.RuntimeException: Uanble to find sandbox for given Workspace/Component
    at com.ibm.team.aspice.traceability.TraceabilityRTCPlainJavaAPI.registerSandboxAndCheckWorkspaceComponent(Unknown Source)
    at com.ibm.team.aspice.traceability.TraceabilityRTCPlainJavaAPI.getAssociations(Unknown Source)
    at com.ibm.team.aspice.traceability.TraceabilityRTCPlainJavaAPI.getAllAssociations(Unknown Source)





Surya Tripathi commented May 15 '15, 2:05 p.m. | edited May 15 '15, 2:05 p.m.

 What function are you calling after getting WorkspaceConnection ?


vikas v commented May 18 '15, 5:49 a.m.

It is not a generic method, it was provided by ibm for my organization.

Now i found a problem behind this, before calling that function i have to load workspace.
I am new with RTC, can you help me to load workspace with the help of plain java api.

Thanks!! 


Surya Tripathi commented May 18 '15, 1:50 p.m.

ISharingManager sharingManager = FileSystemCore.getSharingManager();

File workspaceRoot = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile();
PathLocation pathlocation = new PathLocation(workspaceRoot.getAbsolutePath());
ILocation sandBoxLocation = pathlocation.getCanonicalForm();
ISandbox sandbox = sharingManager.getSandbox(sandBoxLocation, false);
LoadDilemmaHandler p = LoadDilemmaHandler.getDefault(); 
IRelativeLocation  relativeLocation = new RelativeLocation(new String[0]);
ILoadOperation loadOp = IOperationFactory.instance.getLoadOperation(p);
loadOp.requestLoad(sandbox, relativeLoadPath, workspaceConnection, componentHandle, Collection<? extends IVersionableHandle> itemsToLoad);
You can also use loadrule to load your workspace -
loadOp.requestLoad(ISandbox sandbox, IRelativeLocation relativeLoadPath, Collection<ILoadRule> loadRules, monitor)

Your answer


Register or to post your answer.