How to access remote jackrabbit repository?
Asked Answered
C

3

9

I need to work with remote jackrabbit repository. I use following code to connect to the local repository:

Repository repository = new TransientRepository();
Session session = repository.login(new SimpleCredentials("username", "password".toCharArray()));

and this works for the local repository but what do I do incase of the remote jackrabbit?

Chiquia answered 2/5, 2011 at 12:38 Comment(0)
G
6

Have you tried using this?

import javax.jcr.Repository;
import org.apache.jackrabbit.commons.JcrUtils;

Repository repository = JcrUtils.getRepository("http://$SERVER_ADDRESS:$PORT/$CONTEXT");

That should work if the remote repository is exposing RMI services. Please note that RMI access is in general considered to be quite slow.

You'll find more info about accessing remote repositories here.

Grivation answered 2/5, 2011 at 12:43 Comment(1)
your link asks for a log inTrivium
L
6

Another option is WebDav, which is supposed to be somewhat faster than RMI, though not as fast as the native interface:

import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;

import org.apache.jackrabbit.commons.JcrUtils;

public class main {

/**
 * @param args
 */
public static void main(String[] args) throws Throwable{
    String url = "http://localhost:8080/server";
    System.out.println("Connecting to " + url);
    Repository repository = JcrUtils.getRepository(url);
    SimpleCredentials creds = new SimpleCredentials("admin",
            "admin".toCharArray());
    Session jcrSession = repository.login(creds, "default");
    System.out.println("Login successful, workspace: " + jcrSession.getWorkspace());
Lil answered 18/5, 2011 at 16:14 Comment(3)
I'm using both at the moment. There is no way WebDAV is faster than RMI in Jackrabbit. Where does it say so? Also WebDAV doesn't provide nearly the same amount of functionality.Geerts
Hello, EJP, I would like to update a node, but RMI and webdav failed. can you provide an example on how you do ?Vagrancy
You'll need to add the correct dependencies to the project. To use the webdav connector, you need to add jackrabbit-jcr2dav to your classpath: search.maven.org/remotecontent?filepath=org/apache/jackrabbit/…Lenka
R
2

We're using the REST interface provided by Sling to remotely access our repository.

Rubato answered 13/5, 2011 at 13:5 Comment(3)
How can we access a stand alone rackrabbit server through Sling without using its launch pad. I believe it should be a change in configuration. But where? Thanks.Glendoraglendower
I can't remember how I accomplished this. We're not using Sling any longer. I think we found the API too confusing/limiting or maybe it didn't have some functionality we were looking for (maybe it was the ability to encrypt files?). I wrote my own simplified REST API to call the Jackrabbit API. Good luck!Rubato
@Rubato Hi Vinnie, could you share some more info on the rest spi you wrote for accessing remote repository? Is it faster than RMI or webdav??Tarry

© 2022 - 2024 — McMap. All rights reserved.