cancel
Showing results for 
Search instead for 
Did you mean: 

Problem to delete node in behaviour?!

nenad982
Champ on-the-rise
Champ on-the-rise
Hi all,

I have a problem to delete node in behavior. For example I implemented
NodeServicePolicies.OnMoveNodePolicy


and in the

NodeServicePolicies.OnMoveNodePolicy#onMoveNode


method I am creating new node, coping title, description and name of node that has been moved to new node properties (before that I had been renamed node that has been moved to some other name) and at the end I want to delete node that had been moved. I attached the exception that I had been received.

The node that is mentioned in exception

workspace://SpacesStore/ce287829-33e2-450e-a930-2fc9ec0639c0


is node that was moved and which I what to delete.

Does somebody know what is the problem here and how I can delete that node?

Thanks…
6 REPLIES 6

kaynezhang
World-Class Innovator
World-Class Innovator
In your log it seems a rule is triggered and in your rule an action is executed
The action try to load the node that has possiblely been deleted by your OnMoveNodePolicy.

I guess you may have defined some rule that is triggered at the same time with you OnMoveNodePolicy,please check it.

Hi kaynezhang,

thank you for your answer. Based on your response I added additionally disabling of all rules on the node which I want to delete using Java API:

ruleService.disableRules(nodeRef);

But still sometimes I am experiencing the same error. I say sometimes because it worked in one moment but after I restarted server I started to experience the same error again.

Is there any other suggestion?

Thanks…

mrogers
Star Contributor
Star Contributor
That's a real nasty thing to do in a move node policy.   What if there is more than one move node policy and you have deleted the source node.    If you need to do this then at least do your delete in a post commit handler.

But what are you really wanting to do?

nenad982
Champ on-the-rise
Champ on-the-rise
Hi mrogers,

we have some folders and rules on them. Rules will specialize type of the content that is created or entered this folder. So sometimes our customer make mistakes and documents are added to wrong folders and for these document type will be changed based on rule on folder, but this will be unwanted type. So they want functionality that will fix that document type. So when they move again document with invalid type to right folder (with rule also) they what to created document with valid type. So in behavior I create new document and copy properties and content from document with bad type and at the end I have to delete document with bad type (rule on folder will change type of new document to right type).

So do you have some suggestion how to delete that node in behavior? You mentioned post commit handler, is there any example how to use it?

Thanks a lot

kaynezhang
World-Class Innovator
World-Class Innovator
When a node is changed to an unwanted bype,Why not use the change type function to  Re-sets the type of the node to corrrect type.
You don't need to create new document and copy properties and content from document with bad type,just change to document with bad type to the type you want and move it to  specified folder.

This can be solution, but not in my case because I have onChageType behavior also involved so I decided to move all bad nodes in specific folder after valid nodes are created and to use chron job that will delete bad documents.

Thanks all for you help…