1

基本上,我正在尝试使用 IBM Rational Team Concert 普通 Java 客户端 API,并且一直在向更改集添加操作。

我创建了一个新的更改集,检索了操作工厂,然后我想从本地机器文件系统中添加一个新文件(可能是项目的新文件)。

val changeSetHandle = workspaceConnection.createChangeSet(component, null)
val operationFactory = workspaceConnection.configurationOpFactory()
val saveOperation = operationFactory.save(...)

我不明白如何获取IVersionable提交给该save()方法的句柄。

4

1 回答 1

1

您可以参考此线程,其中显示了以下示例IVersionable

// Create a new file and give it some content
IFileItem file = (IFileItem) IFileItem.ITEM_TYPE.createItem();
file.setName("file.txt");
file.setParent(projectFolder);

// Create file content.
IFileContentManager contentManager = FileSystemCore.getContentManager(repository);
IFileContent fileContent = contentManager.storeContent(
              "UTF-8",
              FileLineDelimiter.LINE_DELIMITER_LF,
              new VersionedContentManagerByteArrayInputStreamPovider(BYTE_ARRAY),
              null,
              null);

file.setContent(fileContent);
file.setContentType(IFileItem.CONTENT_TYPE_TEXT);
file.setFileTimestamp(new Date());

workspaceConnection.configurationOpFactory().save(file);

然而,这还不够:

IConfigurationOpFactory用于通过将更改添加到更改集来更新存储库工作区。
使用模式是获取工作空间连接,创建一堆保存操作,然后IWorkspaceConnection#commit()在这些操作上运行。
在不提交更改的情况下调用save()会将操作放到堆栈上,以便垃圾收集器吞噬。;)

于 2018-01-06T21:22:53.677 回答