It's all about the answers!

Ask a question

existing stream to deliver and multiple files


Eray İzgin (11611724) | asked Jan 27 '12, 3:57 a.m.
I try to deliver new file or to update existing file from my repository workspace to existing Stream. I work snippets in plain java client.

I created a changeset and set comments and relate to workitem by creating new stream succesfully. But I try to deliver changeset to existing stream. I think I set to wrong streamConnection. I try like

IChangeSetHandle cs1 = workspace.createChangeSet(currentComponent, monitor);
SCMPlatform.getWorkspaceManager(workspace.teamRepository()).setComment(cs1, "comments", monitor);

IFolderHandle rootFolder = (IFolderHandle) workspace.configuration(currentComponent).rootFolderHandle(monitor);
String[] nameSegments = new String;
nameSegments = "project";
IVersionableHandle filePathHandle = workspace.configuration(currentComponent).resolvePath(rootFolder,nameSegments, monitor);

IFolderHandle projectFolder = (IFolderHandle) filePathHandle;

IFileItem file = (IFileItem) IFileItem.ITEM_TYPE.createItem();
file.setName("file2.txt");
file.setParent(projectFolder);//file.setParent(projectFolder);
IFileContentManager contentManager = FileSystemCore.getContentManager(repo);
IFileContent storedContent = contentManager.storeContent(IFileContent.ENCODING_US_ASCII,FileLineDelimiter.LINE_DELIMITER_PLATFORM,
new VersionedContentManagerByteArrayInputStreamPovider("The contents of mhhy 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);

IWorkItemClient workItemClient = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
IWorkItemWorkingCopyManager copyManager = workItemClient.getWorkItemWorkingCopyManager();
IWorkItem workItem = workItemClient.findWorkItemById(972, IWorkItem.FULL_PROFILE, monitor);
IWorkItemHandle workItemhandle= workItemClient.findWorkItemById(972,IWorkItem.FULL_PROFILE, null);
.......
IChangeHistorySyncReport sync = workspace.compareTo(workspace, WorkspaceComparisonFlags.CHANGE_SET_COMPARISON_ONLY,
Collections.EMPTY_LIST, monitor);
workspace.deliver(workspace, sync, Collections.EMPTY_LIST,
sync.outgoingChangeSets(currentComponent), monitor);

I set to same values for StreamConnection and workspaceConnection because I want to deliver them to existing stream. Is it wrong or how can I set stream Connection? In addition it creates files in repository workspace.

And also I wonder about to deliver. Is it possible to deliver multiple files? I can do it like workspace.configurationOpFactory().save(rootFolder) ?

One answer



permanent link
Eray İzgin (11611724) | answered Jan 27 '12, 8:48 a.m.
I can get stream connection and deliver to existing stream successfully. Maybe I can get stream Connection with different way. I had stream connection value like this...

List<IFlowEntry> flowEntryList = workspace.getFlowTable().deliverTargets();
IFlowEntry FlowList = flowEntryList.get(0);

IFlowNodeHandle flowhandle = FlowList.getFlowNode();
IWorkspaceHandle remoteworkspaceHandle = (IWorkspaceHandle) flowhandle;

IWorkspaceConnection remoteworkspace = wm.getWorkspaceConnection(remoteworkspaceHandle, null);

Your answer


Register or 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.