jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r933144 - in /jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone: Main.java cli/JcrClient.java
Date Mon, 12 Apr 2010 08:46:15 GMT
Author: jukka
Date: Mon Apr 12 08:46:15 2010
New Revision: 933144

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

Automatic anonymous login at cli startup.

Display a * in the prompt when there are unsaved changes.

Modified:
    jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/Main.java
    jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrClient.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=933144&r1=933143&r2=933144&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 08:46:15 2010
@@ -22,6 +22,7 @@ import java.io.InputStream;
 import java.net.URL;
 
 import javax.jcr.Repository;
+import javax.jcr.Session;
 
 import org.apache.commons.chain.Context;
 import org.apache.commons.chain.impl.ContextBase;
@@ -119,7 +120,10 @@ public class Main {
             Context context = new ContextBase();
             String uri = command.getOptionValue("cli");
             Repository repository = JcrUtils.getRepository(uri);
+            Session session = repository.login();
             CommandHelper.setRepository(context, repository, uri);
+            CommandHelper.setSession(context, session);
+            CommandHelper.setCurrentNode(context, session.getRootNode());
             new JcrClient(context).runInteractive();
         } else {
             message("Welcome to Apache Jackrabbit!");

Modified: jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrClient.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrClient.java?rev=933144&r1=933143&r2=933144&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrClient.java
(original)
+++ jackrabbit/trunk/jackrabbit-standalone/src/main/java/org/apache/jackrabbit/standalone/cli/JcrClient.java
Mon Apr 12 08:46:15 2010
@@ -314,8 +314,9 @@ public class JcrClient {
             return bundle.getString("phrase.not.connected");
         }
 
+        boolean unsaved = false;
         try {
-            CommandHelper.getSession(ctx);
+            unsaved = CommandHelper.getSession(ctx).hasPendingChanges();
         } catch (CommandException e) {
             return bundle.getString("phrase.not.logged.in");
         }
@@ -323,12 +324,18 @@ public class JcrClient {
         try {
             Node n = CommandHelper.getCurrentNode(ctx);
             // the current node might be Invalid
+            String path;
             try {
-                return n.getPath();
+                path = n.getPath();
             } catch (InvalidItemStateException e) {
                 CommandHelper.setCurrentNode(ctx, CommandHelper.getSession(ctx)
                     .getRootNode());
-                return CommandHelper.getCurrentNode(ctx).getPath();
+                path = CommandHelper.getCurrentNode(ctx).getPath();
+            }
+            if (unsaved) {
+                return path + "*";
+            } else {
+                return path;
             }
         } catch (CommandException e) {
             return bundle.getString("phrase.not.logged.in");



Mime
View raw message