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

Can not create changeset on stream using RTC java api

 Hello,

I am trying to add folder and file to new stream using rtc Java api.
 Please find below my code:
 public void addFileToStream(IWorkspaceConnection workspace, ITeamRepository iTeamRepository) {
IProgressMonitor monitor = new NullProgressMonitor();
List<IComponentHandle> components;
try {
components = (List<IComponentHandle>) workspace.getComponents();
for (IComponentHandle iComponentHandle : components) {
try {
// add a folder called 'project' to the workspace
IFlowTable flowtable = workspace.getFlowTable().getWorkingCopy();
IFlowEntry[] targets = (IFlowEntry[]) flowtable.deliverTargets().toArray(new IFlowEntry[flowtable.deliverTargets().size()]);
for(IFlowEntry target:targets)
{
flowtable.addDeliverFlow(workspace.getResolvedWorkspace(), iTeamRepository.getId(), iTeamRepository.getRepositoryURI(), null,
workspace.getDescription());
// get the node just added
IFlowEntry newnode = flowtable.getDeliverFlow(workspace.getResolvedWorkspace());
// record if this target flow node should be current or default
if(target.equals(flowtable.getCurrentDeliverFlow()))
{
flowtable.setCurrent(newnode);
}
if(target.equals(flowtable.getDefaultDeliverFlow()))
{
flowtable.setDefault(newnode);
}
}
workspace.setFlowTable(flowtable, null);
IChangeSetHandle cs1 = workspace.createChangeSet(iComponentHandle, monitor);
IFolder rootFolder = (IFolder) workspace.configuration(iComponentHandle).rootFolderHandle(monitor);
// create source folder ("/project")
IFolder projectFolder = (IFolder) IFolder.ITEM_TYPE.createItem();
projectFolder.setParent(rootFolder);
projectFolder.setName("00_PJM_Overall");
workspace.commit(cs1, Collections
.singletonList(workspace.configurationOpFactory().save(projectFolder)), monitor);
// add a file called 'file.txt' under the 'project' folder.
IFileItem file = (IFileItem) IFileItem.ITEM_TYPE.createItem();
file.setName("file.txt");
file.setParent(projectFolder);
IFileContentManager contentManager = FileSystemCore.getContentManager(iTeamRepository);
IFileContent storedContent = null;
storedContent = contentManager.storeContent(
IFileContent.ENCODING_US_ASCII,
FileLineDelimiter.LINE_DELIMITER_PLATFORM,
new VersionedContentManagerByteArrayInputStreamPovider("The contents of my file.txt".getBytes()),
null, monitor);
file.setContentType(IFileItem.CONTENT_TYPE_TEXT);
file.setContent(storedContent);
file.setFileTimestamp(new Date());
workspace.commit(cs1, Collections
.singletonList(workspace.configurationOpFactory().save(file)), monitor);
// deliver the changes to the stream
IChangeHistorySyncReport sync =
workspace.compareTo(workspace, WorkspaceComparisonFlags.CHANGE_SET_COMPARISON_ONLY,
Collections.EMPTY_LIST, monitor);
workspace.deliver(workspace, sync, Collections.EMPTY_LIST,
sync.outgoingChangeSets(iComponentHandle), monitor);
monitor.subTask("Created changes and delivered to " + workspace.getName());
} catch (TeamRepositoryException e) {
e.printStackTrace();
}
break;
}
} catch (TeamRepositoryException e) {
e.printStackTrace();
}
}


But I am getting error as follows:
    
com.ibm.team.scm.common.InvalidStreamOperationException: Change sets cannot be created on a stream
    
I have followed code from snippets of IBM.
    
Please let me know what is missing with my code.
    
Thanks in advance.
    
Arati
    




0 votes


Be the first one to answer this question!

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

Question asked: Dec 08 '21, 12:53 a.m.

Question was seen: 620 times

Last updated: Dec 08 '21, 12:53 a.m.

Confirmation Cancel Confirm