You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Oliver Wehrens (JIRA)" <ji...@apache.org> on 2006/04/12 10:58:23 UTC

[jira] Commented: (JCR-392) Accessing element by number does not work

    [ http://issues.apache.org/jira/browse/JCR-392?page=comments#action_12374156 ] 

Oliver Wehrens commented on JCR-392:
------------------------------------

The full code for this example is:

import org.apache.jackrabbit.core.jndi.RegistryHelper;

import javax.jcr.*;
import javax.jcr.query.Query;
import javax.jcr.query.QueryManager;
import javax.jcr.query.QueryResult;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Hashtable;

public class JackrabbitBug {


    public static void main(String[] args) {
        String configFile = "repository.xml";
        String repHomeDir = "repository";

        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY,
                "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory");

        env.put(Context.PROVIDER_URL, "localhost");

        InitialContext ctx = null;
        try {

            ctx = new InitialContext(env);

            RegistryHelper.registerRepository(ctx,
                    "repo",
                    configFile,
                    repHomeDir,
                    true);

            Repository r = (Repository) ctx.lookup("repo");

            SimpleCredentials cred = new SimpleCredentials("userid", "".toCharArray());

            Session session = r.login(cred, null);
            Workspace ws = session.getWorkspace();
            Node rn = session.getRootNode();

            Query q;
            QueryManager qm = ws.getQueryManager();
            QueryResult qr;

            for (int i=0;i<6;i++) {
               Node child = rn.addNode("entry");
               child.setProperty("title", "title "+i);
               child.setProperty("content", "content "+i);
               session.save();
           }

            // try both position()=last() and entry[5] both do not work as expected
            System.out.println("Now it should display the last (or this 5th entry with //entry[5])");
            q = qm.createQuery("//entry[position()=last()]", Query.XPATH);
            qr = q.execute();
            NodeIterator it = qr.getNodes();
            while (it.hasNext()) {
                Node n = it.nextNode();
                System.out.println(n.getProperty("content").getValue().getString());
            }

        } catch (NamingException e) {
            e.printStackTrace();
        } catch (RepositoryException e) {
            e.printStackTrace();
        }
    }
}

> Accessing element by number does not work
> -----------------------------------------
>
>          Key: JCR-392
>          URL: http://issues.apache.org/jira/browse/JCR-392
>      Project: Jackrabbit
>         Type: Bug

>   Components: query
>  Environment: svn version 393179M
>     Reporter: Oliver Wehrens

>
> I have a bunch of wiki:entries stored in my workspace. If I create the following code:
>             q = qm.createQuery("//wiki:entry[5]", Query.XPATH);
>             qr = q.execute();
>             NodeIterator it = qr.getNodes();
> The Nodeiterator reports all entries back, bot just the 5th.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Re: my custom access manager

Posted by Torgeir Veimo <to...@pobox.com>.
On Wed, 2006-04-12 at 16:59 +0200, Paco Avila wrote:
> El mié, 12-04-2006 a las 13:55 +0200, Torgeir Veimo escribió:
> > On Wed, 2006-04-12 at 13:35 +0200, Paco Avila wrote:
> > > I am developing my custom AccessManager for my jacrabbit based project.
> > > User access information is stored in the Nodes. So, I need to access
> > > this Node Properties in my custom AccessManager. But I can't because
> > > this property access is also checked for security access and will loop
> > > until infinite :(
> > > 
> > > How can I access this properties without invoking the AccessManager
> > > again?
> > 
> > I think it's the general concensus that the best way to implement node
> > stored ACLs in jackrabbit 1.0 is to set up a repository listener at
> > application start-up that logs in with special credentials that your
> > access manager recognises and honours. This listener then keeps a map
> > ACLs, keyed on nodeid, which your access manager uses to get at ACLs
> > when authorising operations on nodes. 
> 
> Can I look at any source with sample code?

I don't have any AccessManager implementation like just yet. There was
another member of this mailing list who said he'd implemented something
along this line. Search the archives for "overwrite isGranted"; maybe he
can share what he's got so far.

-- 
Torgeir Veimo <to...@pobox.com>


Re: my custom access manager

Posted by Paco Avila <pa...@git.es>.
El mié, 12-04-2006 a las 13:55 +0200, Torgeir Veimo escribió:
> On Wed, 2006-04-12 at 13:35 +0200, Paco Avila wrote:
> > I am developing my custom AccessManager for my jacrabbit based project.
> > User access information is stored in the Nodes. So, I need to access
> > this Node Properties in my custom AccessManager. But I can't because
> > this property access is also checked for security access and will loop
> > until infinite :(
> > 
> > How can I access this properties without invoking the AccessManager
> > again?
> 
> I think it's the general concensus that the best way to implement node
> stored ACLs in jackrabbit 1.0 is to set up a repository listener at
> application start-up that logs in with special credentials that your
> access manager recognises and honours. This listener then keeps a map
> ACLs, keyed on nodeid, which your access manager uses to get at ACLs
> when authorising operations on nodes. 

Can I look at any source with sample code?
-- 
Paco Avila <pa...@git.es>


Re: my custom access manager

Posted by Paul Skinner <sh...@hotmail.com>.
You can use Acegi to provide user security and ACL's

http://www.acegisecurity.org/

--
Paul Skinner




>From: Torgeir Veimo <to...@pobox.com>
>Reply-To: dev@jackrabbit.apache.org
>To: dev@jackrabbit.apache.org
>Subject: Re: my custom access manager
>Date: Wed, 12 Apr 2006 13:55:25 +0200
>
>On Wed, 2006-04-12 at 13:35 +0200, Paco Avila wrote:
> > I am developing my custom AccessManager for my jacrabbit based project.
> > User access information is stored in the Nodes. So, I need to access
> > this Node Properties in my custom AccessManager. But I can't because
> > this property access is also checked for security access and will loop
> > until infinite :(
> >
> > How can I access this properties without invoking the AccessManager
> > again?
>
>I think it's the general concensus that the best way to implement node
>stored ACLs in jackrabbit 1.0 is to set up a repository listener at
>application start-up that logs in with special credentials that your
>access manager recognises and honours. This listener then keeps a map
>ACLs, keyed on nodeid, which your access manager uses to get at ACLs
>when authorising operations on nodes.
>
>--
>Torgeir Veimo <to...@pobox.com>
>

_________________________________________________________________
Be the first to hear what's new at MSN - sign up to our free newsletters! 
http://www.msn.co.uk/newsletters


Re: my custom access manager

Posted by Torgeir Veimo <to...@pobox.com>.
On Wed, 2006-04-12 at 13:35 +0200, Paco Avila wrote:
> I am developing my custom AccessManager for my jacrabbit based project.
> User access information is stored in the Nodes. So, I need to access
> this Node Properties in my custom AccessManager. But I can't because
> this property access is also checked for security access and will loop
> until infinite :(
> 
> How can I access this properties without invoking the AccessManager
> again?

I think it's the general concensus that the best way to implement node
stored ACLs in jackrabbit 1.0 is to set up a repository listener at
application start-up that logs in with special credentials that your
access manager recognises and honours. This listener then keeps a map
ACLs, keyed on nodeid, which your access manager uses to get at ACLs
when authorising operations on nodes. 

-- 
Torgeir Veimo <to...@pobox.com>


my custom access manager

Posted by Paco Avila <pa...@git.es>.
I am developing my custom AccessManager for my jacrabbit based project.
User access information is stored in the Nodes. So, I need to access
this Node Properties in my custom AccessManager. But I can't because
this property access is also checked for security access and will loop
until infinite :(

How can I access this properties without invoking the AccessManager
again?

Thanks in advance.
 
-- 
Paco Avila <pa...@git.es>