jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r933216 - /jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/Main.java
Date Mon, 12 Apr 2010 12:43:32 GMT
Author: jukka
Date: Mon Apr 12 12:43:32 2010
New Revision: 933216

URL: http://svn.apache.org/viewvc?rev=933216&view=rev
Log:
JCR-2457: Command line access to remote repositories

Do an anonymous login automatically at CLI startup

Modified:
    jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/Main.java

Modified: jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/Main.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/Main.java?rev=933216&r1=933215&r2=933216&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/Main.java
(original)
+++ jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/Main.java
Mon Apr 12 12:43:32 2010
@@ -22,6 +22,7 @@ import java.io.InputStream;
 import java.net.URL;
 
 import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import org.apache.commons.chain.Context;
@@ -36,6 +37,7 @@ import org.apache.jackrabbit.commons.Jcr
 import org.apache.jackrabbit.core.RepositoryCopier;
 import org.apache.jackrabbit.core.config.RepositoryConfig;
 import org.apache.jackrabbit.servlet.jackrabbit.JackrabbitRepositoryServlet;
+import org.apache.jackrabbit.standalone.cli.CommandException;
 import org.apache.jackrabbit.standalone.cli.CommandHelper;
 import org.apache.jackrabbit.standalone.cli.JcrClient;
 import org.mortbay.jetty.Connector;
@@ -119,12 +121,26 @@ public class Main {
         } else if (command.hasOption("cli")) {
             System.setProperty("logback.configurationFile", "logback-cli.xml");
 
-            Context context = new ContextBase();
             String uri = command.getOptionValue("cli");
             Repository repository = JcrUtils.getRepository(uri);
+
+            Context context = new ContextBase();
             CommandHelper.setRepository(context, repository, uri);
+            try {
+                Session session = repository.login();
+                CommandHelper.setSession(context, session);
+                CommandHelper.setCurrentNode(context, session.getRootNode());
+            } catch (RepositoryException ignore) {
+                // anonymous login not possible
+            }
 
             new JcrClient(context).runInteractive();
+
+            try {
+                CommandHelper.getSession(context).logout();
+            } catch (CommandException ignore) {
+                // already logged out
+            }
         } else {
             message("Welcome to Apache Jackrabbit!");
             message("-------------------------------");



Mime
View raw message