Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

check content fragments duplicate before creating new one

Avatar

Level 4

Hi All

Looking for any best practices/ API-level know-how followed to check programatically whether content fragment already exists before creating new one. Any inputs are highly appreciated. TIA

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi 

Duplicate Detection would only work during uploading of assets.

For Content Fragment, we are actually creating it (not uploading), so detection would not work.

For here is a quick workaround for you, duplicate detection checks dam.sha1 (It is Hash created for an asset), so when we upload another asset again sha1 hash is created for that asset and then sha1 for Assetes are compared, if they are same, then error pops up.

So For Content Fregment as well, sha1 is created, so you can create a custom service which check sha1 and notify you if sha1 matches.

 

Where to find sha1:-

/content/dam/cf_test-1/jcr:content/metadata

 

I hope this will help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

View solution in original post

6 Replies

Avatar

Level 10

There is no standard feature for this or a white paper explaining best practices for this use case.

We have a community article on how to use Content Fragments in AEM (for those reading this and want to know how to use it): 

https://helpx.adobe.com/experience-manager/using/content-fragments.html

When you create content fragments - they are simply nodes in the JCR. You can use standard query APIs, like QUeryBuilder or JCR SQL2 to search for them. 

Hope this helps...

Avatar

Level 4

Hi,

Have come across this documentation link https://docs.adobe.com/docs/en/aem/6-2/author/assets/managing-assets-touch-ui/duplicate-detection.ht... 

But this doesn't provide much insights. Just wanted to know whether any one tried it. It's mentioned that it detects, are there any examples around this in community forum?

Am looking for deduplication feature implementation since it helps in building organised and compact content library.

Avatar

Level 10

I will look into content fragments tomorrow and see what happens when a duplicate is created. However - as your original question was around APIs ( to check programatically whether content fragment), i was thinking about how to so this using code. 

So there is no Content Fragment API. You can still check with standard AEM APIs like JCR API/SQL. 

Avatar

Administrator

Just for you FYI by the time scott find answer to your question....

Link:- https://anotherdamblog.com/2010/02/11/avoid_duplicate_assets/

// How do I avoid duplicate assets in a DAM?

~kautuk



Kautuk Sahni

Avatar

Correct answer by
Administrator

Hi 

Duplicate Detection would only work during uploading of assets.

For Content Fragment, we are actually creating it (not uploading), so detection would not work.

For here is a quick workaround for you, duplicate detection checks dam.sha1 (It is Hash created for an asset), so when we upload another asset again sha1 hash is created for that asset and then sha1 for Assetes are compared, if they are same, then error pops up.

So For Content Fregment as well, sha1 is created, so you can create a custom service which check sha1 and notify you if sha1 matches.

 

Where to find sha1:-

/content/dam/cf_test-1/jcr:content/metadata

 

I hope this will help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni