gpt4 book ai didi

java - IBM RTC API - 将文件添加到更改集

转载 作者:行者123 更新时间:2023-11-30 06:21:08 25 4
gpt4 key购买 nike

基本上,我正在尝试使用 IBM Rational Team Concert Plain Java Client API,但我一直在向变更集添加操作。

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

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

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

最佳答案

您可以引用this thread其中显示了 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 is used to update a repository workspace by adding changes to a change set.
The usage pattern is to get a workspace connection, create a bunch of save operations, then run IWorkspaceConnection#commit() on those ops.
Calling save() without committing the change drops the op onto the stack for the garbage collector to gobble up. ;)

关于java - IBM RTC API - 将文件添加到更改集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48131839/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com