jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r511907 - in /jackrabbit/trunk/contrib/jcr-commands: ./ src/java/org/apache/jackrabbit/command/ src/java/org/apache/jackrabbit/command/cli/ src/java/org/apache/jackrabbit/command/core/ src/java/org/apache/jackrabbit/command/ext/ src/java/or...
Date Mon, 26 Feb 2007 17:11:28 GMT
Author: jukka
Date: Mon Feb 26 09:11:27 2007
New Revision: 511907

URL: http://svn.apache.org/viewvc?view=rev&rev=511907
Log:
JCR-750: Applied the patch from Alexander Klimetschek. Thanks!

Added:
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Info.java
  (with props)
Modified:
    jackrabbit/trunk/contrib/jcr-commands/pom.xml
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandHelper.java
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrClient.java
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line.xml
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command.xml
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Login.java
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToJNDIServer.java
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToRmiServer.java
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbit.java
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbitSingleton.java
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StopJackrabbit.java
    jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/resources.properties

Modified: jackrabbit/trunk/contrib/jcr-commands/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/pom.xml?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/pom.xml (original)
+++ jackrabbit/trunk/contrib/jcr-commands/pom.xml Mon Feb 26 09:11:27 2007
@@ -1,144 +1,161 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-	Copyright 2006 The Apache Software Foundation
-	
-	Licensed under the Apache License, Version 2.0 (the "License");
-	you may not use this file except in compliance with the License.
-	You may obtain a copy of the License at
-	
-	http://www.apache.org/licenses/LICENSE-2.0
-	
-	Unless required by applicable law or agreed to in writing, software
-	distributed under the License is distributed on an "AS IS" BASIS,
-	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-	See the License for the specific language governing permissions and
-	limitations under the License.
-	
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-
-	<modelVersion>4.0.0</modelVersion>
-	<prerequisites>
-		<maven>2.0.4</maven>
-	</prerequisites>
-
-	<!-- POM Identification -->
-
-	<groupId>org.apache.jackrabbit</groupId>
-	<artifactId>jcr-commands</artifactId>
-	<version>1.1-SNAPSHOT</version>
-	<packaging>jar</packaging>
-
-	<name>JCR commands</name>
-
-	<description>JCR commands</description>
-
-	<!-- Dependencies -->
-
-	<dependencies>
-
-		<dependency>
-			<groupId>javax.jcr</groupId>
-			<artifactId>jcr</artifactId>
-			<version>1.0</version>
-			<scope>compile</scope>
-		</dependency>
-
-		<dependency>
-			<groupId>javax.servlet</groupId>
-			<artifactId>servlet-api</artifactId>
-			<scope>provided</scope>
-			<version>2.3</version>
-		</dependency>
-		
-		<dependency>
-			<groupId>org.apache.jackrabbit</groupId>
-			<artifactId>jackrabbit-core</artifactId>
-			<version>1.1-SNAPSHOT</version>
-			<scope>compile</scope>
-		</dependency>
-
-	    <dependency>
-	      <groupId>org.apache.derby</groupId>
-	      <artifactId>derby</artifactId>
-	      <version>10.1.3.1</version>
-          <scope>compile</scope>
-	    </dependency>
-    
-		<dependency>
-			<groupId>org.apache.jackrabbit</groupId>
-			<artifactId>jackrabbit-jcr-rmi</artifactId>
-			<version>1.1-SNAPSHOT</version>
-			<type>jar</type>
-		</dependency>
-
-		<dependency>
-			<groupId>commons-chain</groupId>
-			<artifactId>commons-chain</artifactId>
-			<version>1.0</version>
-			<scope>compile</scope>
-		</dependency>
-
-		<dependency>
-			<groupId>commons-cli</groupId>
-			<artifactId>commons-cli</artifactId>
-			<version>1.0</version>
-		</dependency>
-
-		<dependency>
-			<groupId>log4j</groupId>
-			<artifactId>log4j</artifactId>
-			<version>1.2.12</version>
-			<scope>compile</scope>
-		</dependency>
-
-		<dependency>
-			<groupId>commons-jexl</groupId>
-			<artifactId>commons-jexl</artifactId>
-			<version>1.0</version>
-			<scope>compile</scope>
-		</dependency>
-		
-		<dependency>
-			<groupId>commons-lang</groupId>
-			<artifactId>commons-lang</artifactId>
-			<version>2.1</version>
-			<scope>compile</scope>
-		</dependency>			
-
-	</dependencies>
-
-	<build>
-		<sourceDirectory>src/java</sourceDirectory>
-		<resources>
-			<resource>
-				<directory>src/java</directory>
-				<includes>
-					<include>**/*.xml</include>
-					<include>**/*.dtd</include>
-					<include>**/*.properties</include>
-				</includes>
-			</resource>
-		</resources>
-		<pluginManagement>
-			<plugins>
-				<!-- Compiler -->
-				<plugin>
-					<groupId>org.apache.maven.plugins</groupId>
-					<artifactId>maven-compiler-plugin</artifactId>
-					<inherited>true</inherited>
-					<configuration>
-						<source>1.5</source>
-						<target>1.5</target>
-						<debug>true</debug>
-						<showDeprecation>true</showDeprecation>
-						<showWarnings>true</showWarnings>
-						<optimize>false</optimize>
-					</configuration>
-				</plugin>
-			</plugins>
-		</pluginManagement>
-	</build>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+	Copyright 2006 The Apache Software Foundation
+	
+	Licensed under the Apache License, Version 2.0 (the "License");
+	you may not use this file except in compliance with the License.
+	You may obtain a copy of the License at
+	
+	http://www.apache.org/licenses/LICENSE-2.0
+	
+	Unless required by applicable law or agreed to in writing, software
+	distributed under the License is distributed on an "AS IS" BASIS,
+	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+	See the License for the specific language governing permissions and
+	limitations under the License.
+	
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+	<prerequisites>
+		<maven>2.0.4</maven>
+	</prerequisites>
+
+	<!-- POM Identification -->
+
+	<groupId>org.apache.jackrabbit</groupId>
+	<artifactId>jcr-commands</artifactId>
+	<version>1.3-SNAPSHOT</version>
+	<packaging>jar</packaging>
+
+	<name>JCR commands</name>
+
+	<description>JCR commands</description>
+
+	<!-- Dependencies -->
+
+	<dependencies>
+
+		<dependency>
+			<groupId>javax.jcr</groupId>
+			<artifactId>jcr</artifactId>
+			<version>1.0</version>
+			<scope>compile</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+			<scope>provided</scope>
+			<version>2.3</version>
+		</dependency>
+		
+		<dependency>
+			<groupId>org.apache.jackrabbit</groupId>
+			<artifactId>jackrabbit-core</artifactId>
+			<version>1.3-SNAPSHOT</version>
+			<scope>compile</scope>
+		</dependency>
+
+	    <dependency>
+	      <groupId>org.apache.derby</groupId>
+	      <artifactId>derby</artifactId>
+	      <version>10.1.3.1</version>
+          <scope>compile</scope>
+	    </dependency>
+    
+		<dependency>
+			<groupId>org.apache.jackrabbit</groupId>
+			<artifactId>jackrabbit-jcr-rmi</artifactId>
+			<version>1.3-SNAPSHOT</version>
+			<type>jar</type>
+		</dependency>
+
+		<dependency>
+			<groupId>commons-chain</groupId>
+			<artifactId>commons-chain</artifactId>
+			<version>1.0</version>
+			<scope>compile</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>commons-cli</groupId>
+			<artifactId>commons-cli</artifactId>
+			<version>1.0</version>
+		</dependency>
+
+		<dependency>
+			<groupId>log4j</groupId>
+			<artifactId>log4j</artifactId>
+			<version>1.2.12</version>
+			<scope>compile</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>commons-jexl</groupId>
+			<artifactId>commons-jexl</artifactId>
+			<version>1.0</version>
+			<scope>compile</scope>
+		</dependency>
+		
+		<dependency>
+			<groupId>commons-lang</groupId>
+			<artifactId>commons-lang</artifactId>
+			<version>2.1</version>
+			<scope>compile</scope>
+		</dependency>			
+
+		<dependency>
+			<groupId>jline</groupId>
+			<artifactId>jline</artifactId>
+			<version>0.9.9</version>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<sourceDirectory>src/java</sourceDirectory>
+		<resources>
+			<resource>
+				<directory>src/java</directory>
+				<includes>
+					<include>**/*.xml</include>
+					<include>**/*.dtd</include>
+					<include>**/*.properties</include>
+				</includes>
+			</resource>
+		</resources>
+		<pluginManagement>
+			<plugins>
+				<!-- Compiler -->
+				<plugin>
+					<groupId>org.apache.maven.plugins</groupId>
+					<artifactId>maven-compiler-plugin</artifactId>
+					<inherited>true</inherited>
+					<configuration>
+						<source>1.5</source>
+						<target>1.5</target>
+						<debug>true</debug>
+						<showDeprecation>true</showDeprecation>
+						<showWarnings>true</showWarnings>
+						<optimize>false</optimize>
+					</configuration>
+				</plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>
+            <manifest>
+              <mainClass>org.apache.jackrabbit.command.cli.JcrClient</mainClass>
+              <addClasspath>true</addClasspath>
+            </manifest>
+          </archive>
+        </configuration>
+      </plugin>
+			</plugins>
+		</pluginManagement>
+	</build>
+</project>

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandHelper.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandHelper.java?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandHelper.java
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/CommandHelper.java
Mon Feb 26 09:11:27 2007
@@ -49,9 +49,12 @@
     /** session key */
     public static final String SESSION_KEY = "jcr.session";
 
-    /** session key */
+    /** output key */
     public static final String OUTPUT_KEY = "jcr.output";
 
+    /** address key */
+    public static final String REPO_ADDRESS_KEY = "jcr.repo.address";
+    
     /**
      * should never get called
      */
@@ -96,11 +99,13 @@
      * @param repository
      *        the current working <code>Repository</code>
      */
-    public static void setRepository(Context ctx, Repository repository) {
+    public static void setRepository(Context ctx, Repository repository, String address)
{
         if (repository == null) {
             ctx.remove(REPOSITORY_KEY);
+            ctx.remove(REPO_ADDRESS_KEY);
         } else {
             ctx.put(REPOSITORY_KEY, repository);
+            ctx.put(REPO_ADDRESS_KEY, address);
         }
     }
 
@@ -167,6 +172,14 @@
             throw new CommandException("exception.no.current.repository");
         }
         return r;
+    }
+    
+    public static String getRepositoryAddress(Context ctx) throws CommandException {
+        String a = (String) ctx.get(REPO_ADDRESS_KEY);
+        if (a == null) {
+            throw new CommandException("exception.no.current.repository");
+        }
+        return a;        
     }
 
     /**

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrClient.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrClient.java?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrClient.java
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/JcrClient.java
Mon Feb 26 09:11:27 2007
@@ -20,13 +20,23 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 import java.util.Locale;
 import java.util.ResourceBundle;
 
 import javax.jcr.InvalidItemStateException;
+import javax.jcr.Item;
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
 
+import jline.ArgumentCompletor;
+import jline.Completor;
+import jline.ConsoleReader;
+import jline.History;
+import jline.SimpleCompletor;
+
 import org.apache.commons.chain.Context;
 import org.apache.commons.chain.impl.ContextBase;
 import org.apache.commons.cli.BasicParser;
@@ -39,6 +49,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.jackrabbit.command.CommandException;
 import org.apache.jackrabbit.command.CommandHelper;
+import org.apache.jackrabbit.util.ChildrenCollectorFilter;
 
 /**
  * Command line interface client
@@ -118,6 +129,45 @@
             return;
         }
     }
+    
+    /**
+     * jline ConsoleReader tab completor that completes on the children of the
+     * current jcr node (both nodes and properties).
+     * 
+     * @author <a href="mailto:alexander(dot)klimetschek(at)mindquarry(dot)com">
+     *         Alexander Klimetschek</a>
+     *
+     */
+    private class JcrChildrenCompletor implements Completor {
+
+        public int complete(String buffer, int cursor, List clist) {
+            String start = (buffer == null) ? "" : buffer;
+            
+            Node node;
+            try {
+                node = CommandHelper.getNode(ctx, ".");
+                Collection items = new ArrayList();
+                ChildrenCollectorFilter collector = new ChildrenCollectorFilter(
+                    "*", items, true, true, 1);
+                collector.visit(node);
+                for (Object item : items) {
+                    String can = ((Item) item).getName();
+                    if (can.startsWith(start)) {
+                        clist.add(can);
+                    }
+                }
+                
+                return 0;
+            } catch (CommandException e) {
+                e.printStackTrace();
+            } catch (RepositoryException e) {
+                e.printStackTrace();
+            }
+            
+            return -1;
+        }
+        
+    }
 
     /**
      * Run in interactive mode
@@ -127,18 +177,38 @@
      *         if an Exception occurs
      */
     private void runInteractive(CommandLine cl) throws Exception {
-        // Prompt command
+        // built jline console reader with history + tab completion
+        ConsoleReader reader = new ConsoleReader();
+        reader.setHistory(new History());
+        reader.setUseHistory(true);
+        
+        // get all available commands for command tab completion
+        Collection<org.apache.jackrabbit.command.cli.CommandLine> commands =
+            CommandLineFactory.getInstance().getCommandLines();
+        List<String> commandNames = new ArrayList<String>();
+        for (org.apache.jackrabbit.command.cli.CommandLine c : commands) {
+            commandNames.add(c.getName());
+            for (Object alias : c.getAlias()) {
+                commandNames.add((String) alias);
+            }
+        }
+        commandNames.add("exit");
+        commandNames.add("quit");
+        
+        // first part is the command, then all arguments will get children tab completion
+        reader.addCompletor(new ArgumentCompletor( new Completor[] {
+                new SimpleCompletor(commandNames.toArray(new String[] {} )),
+                new JcrChildrenCompletor()
+        }));
+        
         while (!exit) {
             try {
-                System.out.print(this.getPrompt() + ">");
-                // Read input
-                BufferedReader br = new BufferedReader(new InputStreamReader(
-                    System.in));
-                String input = br.readLine();
+                String input = reader.readLine("[" + this.getPrompt() + "] > ");
+                
                 log.debug("running: " + input);
                 if (input.trim().equals("exit") || input.trim().equals("quit")) { // exit?
                     exit = true;
-                    System.out.println("Good bye..");
+                    System.out.println("Good bye...");
                 } else if (input.trim().length() == 0) {
                     // Do nothing
                 } else {
@@ -148,7 +218,7 @@
                 System.out.println(e.getLocalizedMessage());
                 System.out.println();
             } catch (Exception e) {
-                handleException(e);
+                handleException(reader, e);
             }
         }
     }
@@ -206,7 +276,7 @@
      * @param ex
      *        the <code>Exception</code> to handle
      */
-    private void handleException(Exception ex) {
+    private void handleException(ConsoleReader cr, Exception ex) {
         System.out.println();
         System.out.println(bundle.getString("exception.occurred"));
         System.out.println();
@@ -217,14 +287,14 @@
         System.out.println();
         String prompt = bundle.getString("phrase.display.stacktrace")
                 + "? [y/n]";
-        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+
         String str = "";
         int tries = 0;
         while (!str.equals("y") && !str.equals("n") && tries < 3) {
             tries++;
-            System.out.print(prompt);
+
             try {
-                str = in.readLine();
+                str = cr.readLine(prompt);
             } catch (IOException e) {
                 e.printStackTrace();
             }

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line.xml?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line.xml
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command-line.xml
Mon Feb 26 09:11:27 2007
@@ -940,4 +940,8 @@
     <flag name="locktoken" description="cmd.lsnodes.locktoken"/>
   </command>
 
+  <command name="info">
+    <alias name="status"/>    
+  </command>
+  
 </commands>

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command.xml?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command.xml
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/cli/command.xml
Mon Feb 26 09:11:27 2007
@@ -283,5 +283,8 @@
 				fromKey="collected"/>
 		</chain>
 
+		<command name="info"
+			className="org.apache.jackrabbit.command.info.Info"/>
+		
 	</catalog>
 </chains>

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Login.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Login.java?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Login.java
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/core/Login.java
Mon Feb 26 09:11:27 2007
@@ -21,6 +21,8 @@
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 
+import jline.ConsoleReader;
+
 import org.apache.commons.chain.Command;
 import org.apache.commons.chain.Context;
 import org.apache.commons.logging.Log;
@@ -58,10 +60,11 @@
             user = anon;
         }
 
-        if (password == null) {
-            password = anon;
+        if (password == null || (password.equals(anon) && !user.equals(anon))) {
+            ConsoleReader reader = new ConsoleReader();
+            password = reader.readLine("Password: ", (char) 0);
         }
-
+        
         if (log.isDebugEnabled()) {
             log.debug("logging in as " + user);
         }

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToJNDIServer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToJNDIServer.java?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToJNDIServer.java
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToJNDIServer.java
Mon Feb 26 09:11:27 2007
@@ -50,7 +50,7 @@
 		ClientAdapterFactory adapter = new ClientAdapterFactory();
 		RemoteRepository remote = (RemoteRepository) iCtx.lookup(url);
 		Repository repo = adapter.getRepository(remote);
-		CommandHelper.setRepository(ctx, repo);
+		CommandHelper.setRepository(ctx, repo, "jndi " + url);
 		return false;
 	}
 

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToRmiServer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToRmiServer.java?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToRmiServer.java
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/ConnectToRmiServer.java
Mon Feb 26 09:11:27 2007
@@ -46,7 +46,7 @@
         }
         ClientRepositoryFactory factory = new ClientRepositoryFactory();
         Repository repository = factory.getRepository(url);
-        CommandHelper.setRepository(ctx, repository);
+        CommandHelper.setRepository(ctx, repository, "jcr-rmi " + url);
         return false;
     }
 

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbit.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbit.java?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbit.java
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbit.java
Mon Feb 26 09:11:27 2007
@@ -52,7 +52,7 @@
         }
         RepositoryConfig conf = RepositoryConfig.create(config, home);
         Repository repo = RepositoryImpl.create(conf);
-        CommandHelper.setRepository(ctx, repo);
+        CommandHelper.setRepository(ctx, repo, "local " + home);
         return false;
     }
 

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbitSingleton.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbitSingleton.java?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbitSingleton.java
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StartJackrabbitSingleton.java
Mon Feb 26 09:11:27 2007
@@ -75,7 +75,7 @@
                     repo = RepositoryImpl.create(conf);
                     cache.put(key, repo);
                 }
-                CommandHelper.setRepository(ctx, repo);
+                CommandHelper.setRepository(ctx, repo, "local singleton " + home);
             }
         } catch (Exception e) {
             log.error("Unable to start jackrabbit", e);

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StopJackrabbit.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StopJackrabbit.java?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StopJackrabbit.java
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/ext/StopJackrabbit.java
Mon Feb 26 09:11:27 2007
@@ -47,7 +47,7 @@
                     "Jackrabbit is not the current working repository");
         }
         repo.shutdown();
-        CommandHelper.setRepository(ctx, null);
+        CommandHelper.setRepository(ctx, null, null);
         return false;
     }
 }

Added: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Info.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Info.java?view=auto&rev=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Info.java
(added)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Info.java
Mon Feb 26 09:11:27 2007
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.command.info;
+
+import java.io.PrintWriter;
+
+import javax.jcr.Session;
+
+import org.apache.commons.chain.Command;
+import org.apache.commons.chain.Context;
+import org.apache.jackrabbit.command.CommandException;
+import org.apache.jackrabbit.command.CommandHelper;
+
+public class Info implements Command {
+
+    public boolean execute(Context ctx) throws Exception {
+        PrintWriter out = CommandHelper.getOutput(ctx);
+
+        out.println();
+
+        try {
+            CommandHelper.getRepository(ctx);
+        } catch (CommandException e) {
+            out.println("No connection to a repository.");
+            return false;
+        }
+
+        out.println("Repository: " + CommandHelper.getRepositoryAddress(ctx));
+
+        Session session;
+        String currentPath;
+        try {
+            session = CommandHelper.getSession(ctx);
+            currentPath = CommandHelper.getCurrentNode(ctx).getPath();
+        } catch (CommandException e) {
+            out.println("Not logged in / no session.");
+            return false;
+        }
+
+        out.println("User      : " + session.getUserID());
+        out.println("Workspace : " + session.getWorkspace().getName());
+        out.println("Node      : " + currentPath);
+
+        out.println();
+
+        if (session.isLive()) {
+            out.println("Session is live.");
+        } else {
+            out.println("Session is not live.");
+        }
+
+        if (session.hasPendingChanges()) {
+            out.println("Session has pending changes.");
+        } else {
+            out.println("Session has no changes.");
+        }
+
+        return false;
+    }
+
+}

Propchange: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/info/Info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/resources.properties
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/resources.properties?view=diff&rev=511907&r1=511906&r2=511907
==============================================================================
--- jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/resources.properties
(original)
+++ jackrabbit/trunk/contrib/jcr-commands/src/java/org/apache/jackrabbit/command/resources.properties
Mon Feb 26 09:11:27 2007
@@ -48,6 +48,7 @@
 cmd.help                           = Show available Commands. If a Command is specified it
will show its description, usage and parameters.
 cmd.help.command                   = name
 cmd.help.command.desc              = name of the command to describe
+cmd.info						   = Show status information, including repository, username, workspace and
session status
 cmd.importfilesystem               = Import data from the file system. If the given path
refers to a file it's imported to a Node of type nt:file under the current working Node. If
the given path refers to a folder, the given folder and all the subtree is imported.
 cmd.importxml                      = Imports the xml view from the given file to the current
working Node
 cmd.jndi                           = Connect to a repository through jndi
@@ -239,6 +240,7 @@
 word.overview      = overview
 word.overwrite     = overwrite
 word.password      = password
+word.path          = path
 word.pattern       = pattern
 word.prefix        = prefix
 word.preview       = preview



Mime
View raw message