1

Basically I'm experimenting with the IBM Rational Team Concert Plain Java Client API, and I'm stuck at adding operations to change sets.

I create a new change set, retrieve the Operation factory and then I'd like to add a new file from the local machine file system (might be a new file of a project).

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

I do not understand how to to obtain an IVersionable handle to submit to the save() method.

LppEdd
  • 20,274
  • 11
  • 84
  • 139

1 Answers1

1

You can refer to this thread which shows an example of 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);

However, this is not enough:

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. ;)

LppEdd
  • 20,274
  • 11
  • 84
  • 139
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • See also https://jazz.net/forum/questions/180073/trying-to-get-a-collection-of-ifileitems-from-a-known-workspace-and-a-known-sandbox for existing files. – VonC Jan 06 '18 at 21:23
  • Thanks, really! I find the RTC API have a steep learning curve, seems learning will take months. Also, the documentation is a bit spare (maybe I still do not understand how it is organized) – LppEdd Jan 06 '18 at 21:33
  • @LppEdd Yes, the maintainers of the product might answer there rather than here. – VonC Jan 06 '18 at 21:37