Java API Extending - problem committing new change set, exception 'Parent ... has multiple children with name ...'.
Hi,
I have code based on Snippet2.java which delivers files to the stream successfully, but generates a TeamRepositoryException 'Parent folder-name has multiple children with name file-name' when trying to add a set of files in a new change set to a previously created folder.
I check for the existence of a previously created project folder, and if found, create a new change set comment. I assume I need to obtain the handle to the folder where I need to deliver the new change set to. In this scenario I do not execute a workspaceconnection.commit() after the setComment():
if (map.containsKey("RT_CO_CRNR_CHRG") == true) {
IVersionableHandle prjFldr = (IVersionableHandle) map.get("RT_CO_CRNR_CHRG");
IVersionable item = wkspccnctn.configuration(cmpnthndl).fetchCompleteItem(prjFldr, monitor);
IFolder tmp = (IFolder) item;
projectFolder = tmp;
SCMPlatform.getWorkspaceManager(repo).setComment(cs1, "RT_CO_CRNR_CHRG 20130922", null);
}
For each file in the projectFolder, I add to a byte[] object and call contentManager.storeContent(), exactly as I did when the files are first added. The TeamRepositoryException is thrown on the first file being processed (e.g. Parent '/RT_CO_CRNR_CHRG' has multiple children with the name '.project'.) from the following line of code:
wkspccnctn.commit(cs1, Collections.singletonList(wkspccnctn.configurationOpFactory().save(file)), monitor);
We are migrating to RTC from our old source repository, and need to copy a few revisions of each of our Eclipse projects over to RTC. What do I need to do in order to add each revision (as a new change set) to RTC using the API without generating this exception?
Peter
|
One answer
Ralph Schoon (63.5k●3●36●46)
| answered Sep 24 '13, 5:30 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Peter,
I have been looking into the SCM API recently. Please have a look at http://thescmlounge.blogspot.de/2013/08/getting-your-stuff-using-rtc-sdk-to-zip.html as well. The problem you are having is, I believe, you are creating folders and files again and again that already exist. This causes the message. The way I solved this (I am working on uncompressing directly into SCM) was, to try to find the IFolder and IFileItems in the SCM system. If I could find one, I reused it, if not, I created the object. This way I am able to also update files. Comments You also want to compare the old content of a file with the new content you created, and only setcontent(), if there are differences. There is API for that that is easy to find.
If you want to only share a few revisions of your eclipse projects, a manual way would be as follows:
Peter Moraza
commented Sep 25 '13, 3:31 p.m.
Hi Ralph,
Trying to update one file. Throwing IllegalArgumentException from commit:
wkspccnctn.commit(cs1, Collections.singletonList(wkspccnctn.configurationOpFactory().save(file)), monitor);
// get IFileItem from RTC
IVersionableHandle filePathHandle = iconfig.resolvePath(root, repoPath, monitor);
IVersionable filePath = (IVersionable) iconfig.fetchCompleteItem(filePathHandle, monitor);
IFileItem file = (IFileItem) filePath.getFullState();
// set the IFileItem to the updated
IFileContent storedContent = contentManager.storeContent(IFileContent.ENCODING_US_ASCII, FileLineDelimiter.LINE_DELIMITER_PLATFORM, new VersionedContentManagerByteArrayInputStreamPovider(getByte(f, b)), null, monitor);
file.setContentType(IFileItem.CONTENT_TYPE_TEXT);
file.setContent(storedContent);
Suggestions? Thanks! Peter
You should be able to debug Illegal argument exceptions easy enough. I have not the time to get your snippet running in my environment. See http://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/ for how to debug your code.
Peter Moraza
commented Sep 25 '13, 5:33 p.m.
Hi Ralph,
Sorry, I submitted before drilling into the methods. The IllegalArgumentException is thrown in ConfigurationOpFactory class method save() in this line:
if (item.isWorkingCopy()) == false)
throw new IllegalArgumentException();
isWorkingCopy() apparently expects a couple properties including WORKING_COPY_EFLAG set to true:
return (ALL_FLAGS & WORKING_COPY_EFLAG) != 0;
Researching how to use getWorkingCopy() now. Thanks!
Peter
Peter Moraza
commented Sep 25 '13, 6:17 p.m.
Hi Ralph,
The commit does come after the file content is changed. I added getWorkingCopy and now get the following exception (I am connected as user 'test'):
TeamRepositoryException: CRRTC5039E User test is not allowed to access content vPbUZqbY7OMeYf5ruYxLYEbJOi7ko3ewxIaWNquf0vM
Researching further.
Peter
I'd make sure to test if your user has permissions to access the data in Eclipse before trying to create automation. This makes sure you have the correct permissions and read access.
Peter Moraza
commented Sep 26 '13, 4:20 p.m.
Permissions allow everyone access. Wkspc, cmpnt, strm were accessed by 'test' for the initial deliver. 'vPbUZqbY7OMeYf5ruYxLYEbJOi7ko3ewxIaWNquf0vM' is the storedContent stringHash. Error below?
File f = new File(localPath + ".project");
byte[] b = new byte[(int) f.length()];
IFileContent storedContent = contentManager.storeContent(IFileContent.ENCODING_US_ASCII, FileLineDelimiter.LINE_DELIMITER_PLATFORM, new VersionedContentManagerByteArrayInputStreamPovider(getByte(f, b)), null, monitor);
file.setName(".project");
file.setParent(tmp);
file.setContent(storedContent);
file.setFileTimestamp(new Date());
file = (IFileItem) file.getWorkingCopy();
wkspccnctn.commit(cs1, Collections.singletonList(wkspccnctn.configurationOpFactory().save(file)), monitor);
showing 5 of 8
show 3 more comments
|
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.