Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes



One answer

Permanent link
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. 

0 votes

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:

  1. Import the projects (oldest baseline) into Eclipse.
  2. Share the projects to their respective components in Jazz SCM.
  3. Baseline
  4. Deliver
  5. Delete the projects in Eclipse (also delete from disk)
  6. Start all over with 1 with the next higher baseline from your projects.

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.

Why is your commit before you actually change the content?

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

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.

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

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 149
× 15
× 8
× 4

Question asked: Sep 23 '13, 9:56 p.m.

Question was seen: 7,635 times

Last updated: Jun 09 '14, 3:16 p.m.

Confirmation Cancel Confirm