Dealing with documents where getPathAsString() == null
We are making an application that is using Relation document extensively. Documents subclassing the relation object are created using
createDocumentModel(relationTypeName). This means that they are attached to no particular path in the tree.
This technique doesn't cause any problem when the client is connecting as Administrator but when connecting as another user, it means the user has no access to those documents. I have investigated Nuxeo source and subprojects and I found the following solutions may be possible.
- Set the ACL of the Relation documents so that anybody and find (Browse) and read (Read) them. This technique alone doesn't seem to work of I have not found the right way to do it.
- Create a directory for Relation objects and put every relation object there. It should be possible to give anyone read and browse right on the directory. I believe the comment service is doing that.
- Use a service or adapter to access the relation documents and use
UnrestrictedSessionRunneraccess the documents. The tagging service is doing that.
Approach 3 is the most heavyweight and error-prone but would certainly work. Approach 2 is preferable but I would rather stick with my path-less documents and get approach 1 to work. I'm not sure what it takes for documents to be findable by non-administrator using in an NXQL document. Reference to relevant document is appreciated.
Correct. I have retried solution 1 and now everything seems to be working. Here is an example of correct configuration.
<extension point="factoryBinding" target="org.nuxeo.ecm.platform.content.template.service.ContentTemplateService"> <factoryBinding name="ConservationRelationFactory" factoryName="SimpleTemplateFactory" targetType="ConservationRelation"> <acl> <ace granted="true" permission="Read" principal="members"/> </acl> </factoryBinding> </extension>