How to read repository files from stream ?
Kivanc Ahat (11●2●2)
| asked Jul 13 '11, 4:20 a.m.
edited Oct 12 '17, 1:21 p.m. by David Lafreniere (4.8k●7) Hi,
|
Accepted answer
When you say you have an IProject, do you mean that you have a project that is shared with an RTC server. Is there a relationship between this IProject and folder X that contains the file, pom.xml, that you are interested in?
I ask because you do not have everything that is needed to find the file in the repository. You have a project area and a stream (assuming the stream name is unique) but what is missing is the component (i.e. a stream is a collection of components that then contain files and folders). What's also not a given is whether folder X is a top level folder in the target component. Here is a code snippet that illustrates how you could get at the file assuming that you already had the component. I haven;t tried this out myself so there may be typos etc. but it should give you the general idea. ITeamRepository repo = ???; String namePattern = "integration_stream"; IAuditableHandle projectArea = ???; IComponentHandle component = ???; IWorkspaceManager wm = SCMPlatform.getWorkspaceManager(repo); IWorkspaceSearchCriteria wcrit = IWorkspaceSearchCriteria.FACTORY.newInstance(); wcrit.setKind(IWorkspaceSearchCriteria.STREAMS); wcrit.getFilterByOwnerOptional().add(projectArea) wcrit.setPartialName(namePattern) List<IWorkspaceHandle> workspaces = wm.findWorkspaces(wcrit, 10, monitor); if (!workspaces.size() ==1) { // Unexpected condition. throw exception? } IWorkspaceHandle handle= workspaces.get(0); IWorkspaceConnection ws = wm.getWorkspaceConnection(handle, monitor); IConfiguration config = ws.configuration(component); IVersionable Handle file = config.resolvePath(config.rootFolderHandle(monitor), new String[] { "X", "pom.xml" }, monitor); David Lafreniere selected this answer as the correct answer
|
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.