-
1. Re: How to get access to javax.jcr.Repository
johnnythehun Nov 27, 2008 7:34 AM (in response to bgiddins)I was looking for the same thing, luckily I found it via the JMX console:
InitialContext ctx = new InitialContext(); org.jboss.portal.cms.impl.jcr.JCRCMS jack = (org.jboss.portal.cms.impl.jcr.JCRCMS)ctx.lookup("java:portal/CMS"); Repository repository = jack.getRepository(); Session session = repository.login();
My only problem is, that with the above mentioned login usage I always get a
javax.jcr.AccessDeniedException: /default: not allowed to modify item
if I try to modify either the root or the "default" node.
Can anyone help me on that? -
2. Re: How to get access to javax.jcr.Repository
dkrieger Nov 27, 2008 12:05 PM (in response to bgiddins)trouble is your login() statement is more than likely logging in with anonymous access (read-only only). You'll need to pass credentials to the login statement:
Repository repository = jack.getRepository(); //Anonymous login //Session session = repository.login(); //User authenticated login Session session = repository.login(new SimpleCredentials("username", "password".toCharArray()));
I'm not familiar with the Jackrabbit configuration for JBoss Portal CMS so I'm not sure what the username and password should be for you to get write access on the repository. But this should at least get you closer. -
3. Re: How to get access to javax.jcr.Repository
bgiddins Nov 27, 2008 9:38 PM (in response to bgiddins)Thanks guys - I will try a combination of that code. I believe that you can use any JBoss Portal user to access the CMS, so I will look at setting up a "cmsadmin" type user for my code.
cheers -
4. Re: How to get access to javax.jcr.Repository
soshah Nov 28, 2008 10:04 PM (in response to bgiddins)Actually the SimpleCredential way will not work since the fine grained CMS Security is performed via the Portal CMS Security Engine and not by the JackRabbit Engine.
To achieve what you want to do, you can disable this interceptor when making a CMS Request. This approach is used in the Workflow components as well:
Check this sample code from the workflow components for some ideas:ACLInterceptor.turnOff(); //create this content in the CMS and make it live Command command = cms.getCommandFactory().createContentGetVersionsCommand(content.getPath()); List versions = (List)cms.execute(command); ACLInterceptor.turnOn();
Thanks -
5. Re: How to get access to javax.jcr.Repository
bgiddins Nov 29, 2008 12:23 AM (in response to bgiddins)I've been able to access the repository using the code supplied - thanks all. That was using login() - I can check the user and it is indeed the anonymous user. I haven't tried creating content in my repository using the anonymous user though.