Trying to get a collection of IFileItems from a known workspace and a known sandbox
Trying to use the following sort of code on all the files in a workspace, struggling to get hold of all the files in a workspace as a collection of IFileItems such that I can add tons of custom properties. Probably missing something obvious, help appreciated!! I have tried using scm for my task, but it takes about a second to add each property, which means my migrations take for ever, adding a tiny amount of data should not take a second a throw, hence using the java-api route.
IFileItem fileWorkingCopy = (IFileItem) aFile.getWorkingCopy(); fileWorkingCopy.setContent(storedzipContent); fileWorkingCopy.setUserProperty("MyProperty", "MyValue"); fWorkspace.commit(fChangeSet, Collections .singletonList(fWorkspace.configurationOpFactory() .save(fileWorkingCopy)), fMonitor); |
Accepted answer
Ralph Schoon (63.3k●3●36●46)
| answered May 05 '15, 3:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
For the reverse direction look at
http://thescmlounge.blogspot.co.uk/2013/10/committing-content-to-rtc-scm-with-sdk.html and https://rsjazz.wordpress.com/2013/10/15/extracting-an-archive-into-jazz-scm-using-the-plain-java-client-libraries/ and https://rsjazz.wordpress.com/2013/09/30/delivering-change-sets-and-baselines-to-a-stream-using-the-plain-java-client-libraries/ and the related links if needed. Richard Good selected this answer as the correct answer
Comments
Richard Good
commented May 11 '15, 11:49 a.m.
Thanks Ralph. I think this is the way forward. I have written some code that I think should do the trick, will test and report back if I have any unexpected issues. Note that I did a search on all this and found your rsjazz links, but this scmlounge is blocked by the company firewall, because it thinks its a non work related blog I guess. Shame as it has the best example for my problem ;-) Cheers Richard |
3 other answers
Ralph Schoon (63.3k●3●36●46)
| answered May 05 '15, 3:02 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please see http://thescmlounge.blogspot.co.uk/2013/08/getting-your-stuff-using-rtc-sdk-to-zip.html for an example.
|
I have had a chance to write the code, but am some how fundamentally misunderstanding something or have made a daft error I cannot see. The following code runs through, but no changes to the metadata are checked in to the workspace, stepped through the code and the right things are being extracted and passed to the set user properties code and nothing gives me an error, probably need to connect to something or disconnect to something to concrete the change. Anyway here is the relevant code, can someone tell me what is wrong with it. Note I am using global variables and a recursive procedure, then applying all the changes to the workspace at the same time using the save operations "ops" global variable filled out in the recursive procedure. Any pointers appreciated probably some daft mistake. Note I expect my error is in this bit of code: - v.setUserProperty(metaDataFieldsToExtract[i], metaDataStr); Here comes the code listing : - List<IWorkspaceHandle> workspaces = findConnectionByName(teamRepository,tempWorkSpace, IWorkspaceSearchCriteria.WORKSPACES, monitor); List<IComponentHandle> comps = wm.findComponents(fred, 20, monitor); mycomp = comps.get(0); if(myTeamArea != null) { IConfiguration compConfig = connection.configuration(mycomp); // Fetch the items at the root of each component. We do this to initialize our // create a change set for our metadata changes for (IVersionable v : toLoad) { getMetaDataRecurse(contentManager, compConfig, dirPath, completeChildren, opFactory);
String metaDataStr = findMetaDataHex.group(1).toString(); v.setUserProperty(metaDataFieldsToExtract[i], metaDataStr); } |
Might have got my versionables and fileworkingcopies mixed up! works a lot better when you change v.setUserProperty to file.setUserProperty
|
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.
Comments
Are you looking for code that you can use to get a list of file items?