jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Guggisberg" <stefan.guggisb...@gmail.com>
Subject Re: Jackrabbit access manager question
Date Fri, 02 Mar 2007 14:23:55 GMT
hi xiaohua

On 3/1/07, xiaohua lu <xilu1999@yahoo.com> wrote:
> <!-- DIV {margin:0px;}-->Hi,
> We are working on a prototype based on Jackrabbit and encoutered some problems with access
manager.
>
> The use case we have is we are trying to create a node with some properties, the code
looks like this
>
>       javax.jcr.Node newJCRNode = node.addNode(relPath, primaryNodeTypeName);
>       newJCRNode.setProperty(propName, propValue);
>       newJCRNode.save();

please note that the previous line will throw a
ConstraintViolationException since you
need to save the modified parent of the new node. but i guess that's
just a typo
in your code sample...

>
> We
> noticed that after we hookup the access manager, the setProperty always
> failed, The way our access manager works is we will do a repository
> lookup of the node  by uuid (if it is a property, we will check the
> parent node id), and depending on the path of the node, we decide if
> the current user has permission or not. The failure of setProperty is
> due to denial of access on its parent node newJCRNode. Since it has not
> been saved to repository yet, we can't resolve the path through
> repository lookup by uuid (we also tried HierachyManager and it can't
> resolve the path as well)
>

hmm... i tested the following on trunk:

i added the following lines at the beginning of the
SimpleAccessManager#isGranted(ItemId, int) method:

        try {
            String path = PathFormat.format(hierMgr.getPath(id), nsResolver);
            System.out.println("checking permission on " + path);
        } catch (RepositoryException re) {
            re.printStackTrace(System.out);
        } catch (NameException ne) {
            // erm
        }

when i run the follwoing code:

            Node foo = root.addNode("foo");
            foo.setProperty("bar", "blah blah");
            root.save();

i get the following console output:

checking permission on /
checking permission on /foo/bar
checking permission on /foo/jcr:primaryType

so everything seems to be working as expected. note that i
used the SimpleAccessManager's hierarchy manager for
resolving the paths.

cheers
stefan

> I
> was wondering if the permission check should be done before the save is
> called. Also I would like to know any workaround to this problem.
>
> Thanks.
>
> Xiaohua
>
>
> P.S.
>
> Caused by: javax.jcr.ItemNotFoundException: {http://abc.com/acr/1.0}name
>         at org.apache.jackrabbit.core.NodeImpl.getOrCreateProperty(NodeImpl.java:453)
>         at org.apache.jackrabbit.core.NodeImpl.getOrCreateProperty(NodeImpl.java:407)
>         at org.apache.jackrabbit.core.NodeImpl.setProperty(NodeImpl.java:2218)
>
>
>
>
>
>
>
>
>
> ____________________________________________________________________________________
> We won't tell. Get more on shows you hate to love
> (and love to hate): Yahoo! TV's Guilty Pleasures list.
> http://tv.yahoo.com/collections/265

Mime
View raw message