IBM RTC API - 将文件添加到更改集
IBM RTC API - Adding files to change sets
基本上,我正在尝试使用 IBM Rational Team Concert Plain Java 客户端 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. ;)
基本上,我正在尝试使用 IBM Rational Team Concert Plain Java 客户端 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 runIWorkspaceConnection#commit()
on those ops.
Callingsave()
without committing the change drops the op onto the stack for the garbage collector to gobble up. ;)