cancel
Showing results for 
Search instead for 
Did you mean: 

Getting document title when you don't have permission

Nuxeo_User
Confirmed Champ
Confirmed Champ

Hi people :) I need to take the title of a document using java code even when the user doesn't have permission to see it.Can someone tell me if this is possible?

3 REPLIES 3

Florent_Guillau
World-Class Innovator
World-Class Innovator

Use a privileged session:

DocumentRef ref = doc.getRef();
String title = CoreInstance.doPrivileged(doc.getCoreSession(), 
    (CoreSession privilegedSession) -> (String) privilegedSession.getDocument(ref).getPropertyValue("dc:title")
);

It's equivalent but UnrestrictedSessionRunner is more verbose.

Thank you Florent,but i found another way using UnrestrictedSessionRunner.I think this is better because i have to iterate through the parents of a document too.