Expand my Community achievements bar.

SOLVED

Third-party APIs and external data with Content Fragments Models

Avatar

Level 2
Hi everybody.

I'm new to AEM and experimenting with headless mode. I was wondering if there is a way to "attach" a third-party API on a Content Fragment Model making its content Data Driven. The reason to make something like this, is that i want to customize the resulting content JSON, based on the user accessing the page.

Is there any light on the end of this tunnel? Or the Content Fragments will always be static after authored?

I could also misunderstood the concept involving headless mode. If i do, could you point me to right direction?

Thanks in advance.
1 Accepted Solution

Avatar

Correct answer by
Level 5

The whole idea of content fragments is to store static content that can be Ui agnostic so it can be delivered to various channels. Now the issue with your requirement is validating user access which again forces you to right a custom layer that will call the cf api and then filters based on your requirement. This custom layer can probably be a sling filter (I am assuming all requests including the cf apis come as servlet request) or probably another custom servlet that can act as a proxy to respond back in your desired fashion. But then again I would rethink going through this route. See if the permissions are for end users there is no easy way to validate them inside aem without writing another custom adapter like I mentioned above. Understand if it's the content that is secured or if it's part of the cf that needs filtering because certain fields are not meant to be visible for users based on their roles. If it's the first one may be attaching tags to your cf model and querying based on tags probably using graphql is an option. But if it's actual content filtering custom layer becomes inevitable. In a prev project that I worked a. Similar solution is built using pages and components where ad groups are stored on each page or component properties and there is a node JS lambda on aws whose job is to filter the content. So going headless in this manner is not a bad thought, it's perfectly fine. But determine the volume of requests and caching strategy to improve response time etc and make a choice of simple tags and query using graphql or full blown solution that does the job. Hope this insights help you. Thanks 

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

The whole idea of content fragments is to store static content that can be Ui agnostic so it can be delivered to various channels. Now the issue with your requirement is validating user access which again forces you to right a custom layer that will call the cf api and then filters based on your requirement. This custom layer can probably be a sling filter (I am assuming all requests including the cf apis come as servlet request) or probably another custom servlet that can act as a proxy to respond back in your desired fashion. But then again I would rethink going through this route. See if the permissions are for end users there is no easy way to validate them inside aem without writing another custom adapter like I mentioned above. Understand if it's the content that is secured or if it's part of the cf that needs filtering because certain fields are not meant to be visible for users based on their roles. If it's the first one may be attaching tags to your cf model and querying based on tags probably using graphql is an option. But if it's actual content filtering custom layer becomes inevitable. In a prev project that I worked a. Similar solution is built using pages and components where ad groups are stored on each page or component properties and there is a node JS lambda on aws whose job is to filter the content. So going headless in this manner is not a bad thought, it's perfectly fine. But determine the volume of requests and caching strategy to improve response time etc and make a choice of simple tags and query using graphql or full blown solution that does the job. Hope this insights help you. Thanks 

Avatar

Level 2
Hi.

Thank you for the quick response.

Indeed you help me. I will probably have to follow something like the last approach.

Thanks again for your time.