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

How to read repository files from stream ?

Hi,
I am writing a client side plug-in for RTC and I have IPRoject in my hand.
My scenario is:
I have many streams in my project area. I want to get one of the streams, that contains "integration_stream" in name. Then in that stream I want to read pom.xml file in folder "x".

I have project area name in my hand and to read pom.xml, I think I need

1. get uuid of the stream in project area that has "integration_stream" in name
2. read X\pom.xml in repository files of the stream

Thanks,

0 votes


Accepted answer

Permanent link
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

1 vote

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,940
× 169

Question asked: Jul 13 '11, 4:20 a.m.

Question was seen: 5,958 times

Last updated: Oct 12 '17, 1:21 p.m.

Confirmation Cancel Confirm