It's all about the answers!

Ask a question

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

vikas v (15319) | 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.


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
List<IWorkspaceHandle> workspaces = wm.findWorkspaces(criteria, maxSize, minitor);
IWorkspaceConnection connection = wm.getWorkspaceConnection(workspaces.get(0), monitor);

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 Source)
    at Source)
    at 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.


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.

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.