Adapting metadata node to object is returning null | Community
Skip to main content
Level 3
Jan 24, 2018 11:26 AM UTC
Solved

Adapting metadata node to object is returning null

I need to adapt document metadata node to an object. The code is as below. But the object returns null. Did anyone face similar issue?

Resource resource = resourceResolver.getResource(destinationPath+"/"+JcrConstants.JCR_CONTENT+"/metadata");

DocumentInfo documentInfo = resource.adaptTo(DocumentInfo.class);

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
joerghoh
joerghohAccepted solution
Employee
Jan 30, 2018 10:16 PM UTC

Hi,

I don't know the DocumentInfo class, can you please give the full package name? Is there an adapter factory available for this at all? Check localhost:4502/system/console/adapters if an adapter with adapter class "Resource.class" and adaptable class "DocumentInfo.class" is registered.

adaptTo() is allowed to return "null" in case the adaption fails. Depending on the adapter factory the reasons are logged or not. So we clearly need to know much more information about the resource (or sub-resources) you are trying to adapt.

Jörg

11 replies

manoj_devapath
Level 5
Jan 24, 2018 2:42 PM UTC

Can you pls confirm whats the mine type of  resource of destinationPath is ?

Translate