2

Requirement: Java web application (non-MVC) needs to fetch required Component Presentations objects from Tridion Broker DB. Some basic conditions to fetch DCPs will be:

  • Schema=S1
  • CustomMetaAttribute1Val="abc"
  • CustomMetaAttribute2Val="def'

Tridion Broker DB will return more than one Component Presentations objects and should be served to web application as array of JSON objects (Component Presentations).

Trying to use 8.5 CIL client APIs but com.tridion.dcp.ComponentPresentationFactory seems not good enough to fullfill this requirement. What can be the best approach to achieve this if not using DD4T/DXA APIs at all.

1

Why do you say that the ComponentPresentationFactory is not good enough, what difficulty did you encounter? I'm guessing the "conditions" part, so my answer will be towards that.

To achieve what you want, you need to make use of the Criteria API in combination with the ComponentPresentationFactory or ComponentPresentationAssembler. The Criteria API will give you a list of IDs which fulfill your conditions, afterwards you need to get the actual contents using the CPF or CPA. Example of a CustomMetaValueCriteria here.

Just an obvious remark, if you need the CPs as JSON, the Components have to be published (also) in that format.

  • Expectation is to directly get all required component presentation objects in one go rather than getting IDs first and then looping for each id to get CP one by one. Dont want to repeat what we did while using Broker APis in Past. If CIL APIs are Restful then expecting CP objects returned by APIs should be in JSON, I agree that components needs to be published in JSON format. – Gulshan Thakur Dec 20 '18 at 20:37
  • The CIL API is exactly same as the Broker API, only the "back end mechanism" has changed. Now it transforms your methods into REST requests towards the CIS layer (more specifically the Content Service). – Atila Sos Dec 21 '18 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.