# Avoid overriding properties in the existing document when updating using EXIM API

**URL:** <https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [October 5, 2018, 2:13pm UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473 "2018-10-05T14:13:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarthak.sharma](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sarthak.sharma](https://community.bloomreach.com/u/sarthak.sharma)\
**Post date:** [October 5, 2018, 2:13pm UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473/1 "2018-10-05T14:13:05Z")

</div>

As we were working on one of the feature, I came across a scenario.  
If I am setting 3(a,b,c) out of 4 properties (a,b,c,d) of a document, then  
EXIM API clears the property value for d. (Image in my case)

Based on some previous conversations, I had an idea that it doesn’t override and in fact, worked fine for some of the properties like taxonomy values.

Can you suggest , how to prevent overriding of a property which I don’t want to update?

---

<div class="post-metadata">

**Author:** ![sarthak.sharma](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sarthak.sharma](https://community.bloomreach.com/u/sarthak.sharma)\
**Post date:** [October 5, 2018, 2:13pm UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473/2 "2018-10-05T14:13:42Z")

</div>

@woonsanko As you suggested, I have created the new topic here.

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [October 5, 2018, 2:27pm UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473/3 "2018-10-05T14:27:44Z")

</div>

> [@sarthak.sharma](#):
>
> As we were working on one of the feature, I came across a scenario.  
> If I am setting 3(a,b,c) out of 4 properties (a,b,c,d) of a document, then  
> EXIM API clears the property value for d. (Image in my case)

Do you mean you set the 3 properties in ContentNode bean and when you update a document with the ContentNode you see Content-EXIM removes the other existing property, `d`, in the document?  
And, could you link to or upload an image?

Regards,

Woonsan

---

<div class="post-metadata">

**Author:** ![sarthak.sharma](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sarthak.sharma](https://community.bloomreach.com/u/sarthak.sharma)\
**Post date:** [October 5, 2018, 5:53pm UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473/4 "2018-10-05T17:53:30Z")

</div>

Yes You’re right @woonsanko

This is the mandatory attribute (property d as per example) which gets removed, when I set ,say, 3 properties in main ContentNode.  
 ![image](https://canada1.discourse-cdn.com/flex027/uploads/bloomreach1/original/1X/5940595861266060aa85fa3ebd63615140a31d1a.png)

This property is present at first level of parent ContentNode and I don’t set it anywhere in code.  
There are some sub content-nodes + properties as well, but that’s irrelevant for the use case I guess, so we can ignore them.  
I call this method for updating/creating document:

importTask.createOrUpdateDocumentFromVariantContentNode(contentNode,…)

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [October 8, 2018, 2:31pm UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473/5 "2018-10-08T14:31:06Z")

</div>

Hi Sarthak,

Basically, Content-EXIM’s `WorkflowDocumentVariantImportTask` keeps the existing JCR properties in a document variant, only updating data from the input `ContentNode` object. However, it _removes_ any **compound** nodes (any subnodes under the document variant node) first and _adds_ new **compound** nodes based on the input `ContentNode` object.  
This is the sensible default behavior, IMHO. For example, suppose you have three document link mirror (compound) nodes under the document variant node. If your input `ContentNode` now contains only two link mirror nodes, it makes sense to remove all the existing link mirror nodes and add again the new two link mirror nodes.

But, also, I understand the problem you met now. In your case, you seem to want to keep any existing compound nodes, the hero image link node in your case, even if the input `ContentNode` doesn’t include that one. So, it’s something to be covered by your customization, not by default in the forge project level, IMHO.

To customize the default behavior, you need to do the following:

- You can customize the `ContentNodeBinder` by `#setContentNodeBinder(ContentNodeBinder)` on the `WorkflowDocumentVariantImportTask`. The default implementation of `ContentNodeBinder` is `org.onehippo.forge.content.pojo.binder.jcr.DefaultJcrContentNodeBinder`.
- Extend `DefaultJcrContentNodeBinder` and override `#removeSubNodes(Node, ContentNode, ContentNodeBindingItemFilter<ContentItem>)` to include your custom logic.  
Customize the `if` block if your hero image link compound in direct child of the document variant, or `else` block if it is a child compound of another compound node like content-blocks plugin.

Regards,

Woonsan

---

<div class="post-metadata">

**Author:** ![sarthak.sharma](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sarthak.sharma](https://community.bloomreach.com/u/sarthak.sharma)\
**Post date:** [October 8, 2018, 4:26pm UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473/6 "2018-10-08T16:26:12Z")

</div>

> [@woonsanko](#):
>
> removeSubNodes

Thanks for the reply Woonsan.

I am using exim version 2.2.0  
I inspected DefaultJcrContentNodeBinder and interface ContentNodeBinder  
I couldn’t find ‘removeSubNodes’ method to override.

There is no remove\* method.

I don’t want both, Hero Image and properties of other child compound elements to be removed.  
I can try to figure that out, but firstly , I couldn’t find removeSubNodes to override.

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [October 8, 2018, 4:50pm UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473/7 "2018-10-08T16:50:34Z")

</div>

> [@sarthak.sharma](#):
>
> I am using exim version 2.2.0  
> I inspected DefaultJcrContentNodeBinder and interface ContentNodeBinder  
> I couldn’t find ‘removeSubNodes’ method to override.
> 
> There is no remove\* method.

Content-EXIM 2.2.0 should be pulling in jcr-pojo-binding-1.2.0 transitively. [1,2]  
You might have been looking at a different version of jcr-pojo-binding module for some reason, depending on how you inspected it.

Woonsan

[1] [https://onehippo-forge.github.io/content-export-import/release-notes.html](https://onehippo-forge.github.io/content-export-import/release-notes.html)  
[2] [https://onehippo-forge.github.io/jcr-pojo-binding/release-notes.html](https://onehippo-forge.github.io/jcr-pojo-binding/release-notes.html)

---

<div class="post-metadata">

**Author:** ![sarthak.sharma](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sarthak.sharma](https://community.bloomreach.com/u/sarthak.sharma)\
**Post date:** [October 9, 2018, 2:53am UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473/8 "2018-10-09T02:53:42Z")

</div>

> [@woonsanko](#):
>
> DefaultJcrContentNodeBinder

Sorry for miscommunication Woonsan,  
exim-core-2.2.0 was present in root POM and I referred to that by mistake.

As we are using hippo 10.2.\*, the compatible version for that is exim-core-1.2.14,  
which is defined in CMS POM.

![image](https://canada1.discourse-cdn.com/flex027/uploads/bloomreach1/original/1X/adb4d47c4973ffcb02d1331acf31adbbfbd08b4b.png)

Sorry for the confusion.  
We tried earlier with exim-core-2.2.0 , but it obviously didn’t work with hippo 10.2.\*  
Any suggestion you might have?

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [October 9, 2018, 1:17pm UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473/9 "2018-10-09T13:17:06Z")

</div>

You can write your own custom `ContentNodeBinder`, by either extending `DefaultJcrContentNodeBinder` or copying it, to meet your requirements. Find the relevant source here:

- [https://onehippo-forge.github.io/jcr-pojo-binding/release-notes.html](https://onehippo-forge.github.io/jcr-pojo-binding/release-notes.html)

Regards,

Woonsan

---

<div class="post-metadata">

**Author:** ![sarthak.sharma](https://avatars.discourse-cdn.com/v4/letter/s/5daacb/32.png) [@sarthak.sharma](https://community.bloomreach.com/u/sarthak.sharma)\
**Post date:** [October 11, 2018, 12:08pm UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473/10 "2018-10-11T12:08:58Z")

</div>

Thanks @woonsanko .  
I added new implementation for Binder.  
I have written the logic for merging now. So, Instead of removing and re-adding,  
bind method only updates the properties present in ContentNode.  
Its written in generic way, which I hope should work for any use cases.

Would you want me to contribute the same to the exim project as separate binder class?

---

<div class="post-metadata">

**Author:** ![woonsanko](https://avatars.discourse-cdn.com/v4/letter/w/b5a626/32.png) [@woonsanko](https://community.bloomreach.com/u/woonsanko)\
**Post date:** [October 11, 2018, 1:48pm UTC](https://community.bloomreach.com/t/avoid-overriding-properties-in-the-existing-document-when-updating-using-exim-api/473/11 "2018-10-11T13:48:59Z")

</div>

Hi Sarthak,

That would be great if you can contribute! 😄  
Perhaps your binder implementation could be named to something like `MergingJcrContentNodeBinder`.  
Also, the contribution should made for the JCR POJO Binding project [1] on which Content-EXIM depends, not Content-EXIM.

Thanks,

Woonsan

[1] \* [https://onehippo-forge.github.io/jcr-pojo-binding/release-notes.html](https://onehippo-forge.github.io/jcr-pojo-binding/release-notes.html)
