Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] How does CDOResourceNode.setFolder(...) work?
[CDO] How does CDOResourceNode.setFolder(...) work? [message #1795177] Mon, 17 September 2018 21:57 Go to next message
Reinhold Usolf is currently offline Reinhold UsolfFriend
Messages: 18
Registered: December 2016
Junior Member
Hi,

I want to move an existing CDOResourceNode to a different folder. When I call
node.setFolder("the/destination/folder")

on a node with name "mynode", I get this exception:
org.eclipse.emf.cdo.common.util.CDOException: Duplicate path: "the/destination/folder/mynode"
org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl.checkDuplicates(CDOResourceNodeImpl.java:307)
org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl.basicSetFolder(CDOResourceNodeImpl.java:123)
org.eclipse.emf.cdo.eresource.impl.CDOResourceNodeImpl.setFolder(CDOResourceNodeImpl.java:106)
org.eclipse.emf.cdo.eresource.impl.CDOResourceImpl.setFolder(CDOResourceImpl.java:472)

The exception happens always, independently of what the new path is and whether the path is really a duplicate or not.

As a work-around, I try to disable the check for duplicates like this:
((CDOResourceNodeImpl)node).basicSetFolder("the/destination/folder",false)

Not nice, but this works actually!

But: I cannot move a node to the root with this:
node.setFolder(null)    (or with basicSetFolder)

When I do this, the node just disappears forever. It does not appear in the contents of the root node. When I have a write lock on the node, unlock() gives a NullPointerException. This is strange because you can see in the source code of basicSetFolder that it can handle the case where the destination folder is null (i.e. root).

Obviously, setFolder works very differently from what I expected intuitively. How do you use the method correctly?

Edit: Better formulation: What is the correct way to move an existing resource to a different folder or to the root?

I am using version 4.5. I have checked the release notes of 4.6 and 4.7 but I don't see any related bugfixes.

[Updated on: Tue, 18 September 2018 09:00]

Report message to a moderator

Re: [CDO] How does CDOResourceNode.setFolder(...) work? [message #1796019 is a reply to message #1795177] Thu, 04 October 2018 08:06 Go to previous messageGo to next message
Reinhold Usolf is currently offline Reinhold UsolfFriend
Messages: 18
Registered: December 2016
Junior Member
Hi,

Me again, coming back to my question.

Does anybody have an example how to correctly change the parent folder of a resource node?
Re: [CDO] How does CDOResourceNode.setFolder(...) work? [message #1796773 is a reply to message #1796019] Thu, 18 October 2018 17:29 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6433
Registered: July 2009
Senior Member
Hi Reinhold,

Sorry for the delay!

Your attempt to move a resource to a new folder was totally correct. But there was a bug in the checkDuplicates() method, which I've now fixed via https://bugs.eclipse.org/bugs/show_bug.cgi?id=540266

Please let me know if you still encounter a problem.

BTW. most people didn't notice the problem because they're doing:
newFolder.getNodes().add(resource)

instead of:
resource.setFolder(newFolder)


Previous Topic:[EcoreGen] State-of-the-art way to generate code from Ecore in Maven?
Next Topic:CDO failover configuration
Goto Forum:
  


Current Time: Sun Jun 16 17:45:09 GMT 2019

Powered by FUDForum. Page generated in 0.03177 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top