RTC v4.0.1+ Java API: how to load a workspace using Java API
Hi
I find my self struggling with a simple task: given an RTC repository and a ready made workspace I want to download its content. getting the repository instance was easy (there are online samples to do login): ITeamRepository repository = TeamPlatform.getTeamRepositoryService().getTeamRepository(rtcServerURL); ... then code here perform a login... then get an IWorkspaceConnection using IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(repository) IWorkspaceSearchCriteria criteria = IWorkspaceSearchCriteria.FACTORY.newInstance(); criteria.setExactName(rtcWorkspace); criteria.setKind(IWorkspaceSearchCriteria.WORKSPACES); ... and then run a findWorkspace... or maybe simply run : 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); IRelativeLocation relativeLocation = new RelativeLocation(new String[0]); Collection<ILoadRule> paramCollection = null; ILoadOperation loadOp = IOperationFactory.instance.getLoadOperation(p); loadOp.requestLoad(ISandbox paramISandbox, IRelativeLocation paramIRelativeLocation, Collection<ILoadRule> paramCollection, IProgressMonitor paramIProgressMonitor) however, I'm not sure what to put in the params for the simplest load command. can anyone help here ? |
4 answers
actually my post is duplicate of https://jazz.net/forum/questions/114708/load-workspace-using-api
|
You seem to have figured out the sandbox for the operation.
The relative location is where you want the content loaded in your sandbox. You can give it null if you want to load in the sandbox root. ILoadRuleFactory will provide you with a way to create your load rule object from the file to pass to the operation. Comments Indeed ILoadRuleFactory class has a static factory to read files.
getting the repository instance was easy (there are online samples to do login): ITeamRepository repository = TeamPlatform.getTeamRepositoryService().getTeamRepository(rtcServerURL); ... then code here perform a login... then get an IWorkspaceConnection using IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(repository) IWorkspaceSearchCriteria criteria = IWorkspaceSearchCriteria.FACTORY.newInstance(); criteria.setExactName(rtcWorkspace); criteria.setKind(IWorkspaceSearchCriteria.WORKSPACES); You already wrote the code to get those. Is there something else that you're missing?
mordechi taitelman
commented Jul 04 '13, 11:07 a.m.
the search result is :
IWorkspaceManager#getWorkspaceConnection(IWorkspaceHandle, IProgressMonitor) would get you your connection.
|
here is what I did to load an existing workspace (need to attach the XML load rule file too)
Comments
mordechi taitelman
commented Jul 07 '13, 7:28 a.m.
and the loadrule XML file content is:
mordechi taitelman
commented Jul 17 '13, 4:07 a.m.
As an IBMer i find it sad there are not enough samples available online.
|
Here you may find a trace:
|
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
The filesystem operations aren't supported API yet. We are formalizing them, but we don't have an expected date for their release. In the meantime you are encouraged to use the commandline client.