Hello

there has been a bug regarding the creation of autogenerated paragraphs on
public instances. The problem was that the 'anonimous' user did'nt have the
privs. to create those nodes.
The issue was: http://jira.magnolia-cms.com/browse/MGNLSTK-499 and was
supposedly fixed in stk version 1.2
Well we still had some problems with it, so I took a closer look and learned
some interesting fact I thought i should share.

the idea of the fix was that if you would create the paragraphs in the
system context all would be well. So this is how it looks
in 
info.magnolia.module.templatingkit.templates.SingletonParagraphTemplateModel#execute:

public String execute() {
        final STKTemplate templateDef = this.getDefinition();
        MgnlContext.doInSystemContext(new MgnlContext.VoidOp() {
            public void doExec() {
                createMainArea(templateDef);
                createExtrasArea(templateDef);
            }
        });
        return super.execute();
    }

But when we look at createMainArea() for instance we see:

Content extrasNode = ContentUtil.getOrCreateContent(content, "extras",
ItemType.CONTENTNODE, true);

The parent node parameter of the method call is 'content' which was not
created in the system context, it is actually a field
of info.magnolia.module.templating.RenderingModelImpl.

When I take a closer look at what happens in getOrCreate(), I finally end up
in the constructor of info.magnolia.cms.core.DefaultContent where
hierarcyManager of the parent node is used to obtain the accessManager. And
according to this access manager permission is denied, system context or
not.

What I did to fix this is something like:

Content systemContextcontent =
MgnlContext.getHierarchyManager(content.getHierarchyManager().getName()).getContentByUUID(content.getUUID());

And then I use the systemContextcontent content node to create the
paragrphs, and it works.

that's it. I'm not sure why this thing appears to be fixed but still seems
broken. We have our own template classes for creating autogenerated
paragraphs, but I can see no difference between our (broken) approach and
the stk approach

cheers,

Ernst



-- 
Ernst Bunders
Ontwikkelaar VPRO


----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------

Reply via email to