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

How do you retreve file content using Java API

How do you retrieve file content.

this is what I have so far, I don't know if it is right

// Stream component branch_build_info.txt
IConfiguration fred = (IConfiguration) stream.configuration(component);

// Map folders = fred.childEntriesForRoot(MONITOR);

IFolderHandle root = fred.rootFolderHandle(MONITOR);
IVersionableHandle pathHandle = fred.resolvePath(root,nameSegments, MONITOR);
if (pathHandle != null) {

System.out.println("hi ken " + pathHandle.toString());
//IVersionable a = root.fetchCompleteItem(pathHandle, MONITOR);

UUID file = pathHandle.getItemId();


System.out.println("hi ken " + file.toString());
}

0 votes



One answer

Permanent link
public void updateVersions(IWorkspaceConnection stream,IComponentHandle component,IBaselineHandle baseline) throws TeamRepositoryException {
IFileItem fileItem = null;
IFileContentManager contentManager = FileSystemCore.getContentManager(repo);
String nameSegments[] = {"build_info.txt"};

// Create tmp output file
FileOutputStream outputStream = null;
try {
outputStream = new FileOutputStream("branch.tmp");
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}

// Find file handle
IConfiguration iconfig = (IConfiguration) stream.configuration(component);
IFolderHandle root = iconfig.rootFolderHandle(MONITOR);
IVersionableHandle filePathHandle = iconfig.resolvePath(root,nameSegments, MONITOR);

// Check if file found
if (filePathHandle == null) {
throw new TeamRepositoryException("Could not find file " + nameSegments);
}

// Fetch file complete item
IVersionable filePath = (IVersionable) iconfig.fetchCompleteItem(filePathHandle, MONITOR);
if (filePath.hasFullState()) {
fileItem = (IFileItem) filePath.getFullState();
} else {
throw new TeamRepositoryException("Could not find file " + nameSegments + " item");
}

// Get file content
IFileContent content = fileItem.getContent();
contentManager.retrieveContent(fileItem, content, outputStream, MONITOR);

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,938

Question asked: Apr 28 '10, 10:01 a.m.

Question was seen: 8,593 times

Last updated: Apr 28 '10, 10:01 a.m.

Confirmation Cancel Confirm