jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r691319 - in /jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/server/jmx: JCRServer.java JCRServerMBean.java
Date Tue, 02 Sep 2008 16:56:04 GMT
Author: jukka
Date: Tue Sep  2 09:56:03 2008
New Revision: 691319

URL: http://svn.apache.org/viewvc?rev=691319&view=rev
Log:
JCR-1317: Add a MBean method to programatically create a new Workspace.

Applied a patch by Manual Duran.

Modified:
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/server/jmx/JCRServer.java
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/server/jmx/JCRServerMBean.java

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/server/jmx/JCRServer.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/server/jmx/JCRServer.java?rev=691319&r1=691318&r2=691319&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/server/jmx/JCRServer.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/server/jmx/JCRServer.java
Tue Sep  2 09:56:03 2008
@@ -20,9 +20,15 @@
 import java.io.InputStream;
 import java.util.Properties;
 
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
 import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
 import javax.naming.InitialContext;
 
+import org.apache.jackrabbit.api.JackrabbitWorkspace;
 import org.apache.jackrabbit.rmi.remote.RemoteRepository;
 import org.apache.jackrabbit.rmi.server.RemoteAdapterFactory;
 import org.apache.jackrabbit.rmi.server.ServerAdapterFactory;
@@ -57,6 +63,11 @@
      */
     RemoteRepository remote;
 
+    /**
+     * Local repository instance
+     */
+    private Repository localRepository;
+
     public void start() throws Exception {
 
         if (this.localAddress == null) {
@@ -69,8 +80,7 @@
 
         // local repository
         InitialContext localContext = createInitialContext(localEnvironment);
-        Repository localRepository = (Repository) localContext
-                .lookup(this.localAddress);
+        localRepository = (Repository) localContext.lookup(this.localAddress);
         if (localRepository == null) {
             throw new IllegalArgumentException("local repository not found at "
                     + this.localAddress);
@@ -114,6 +124,33 @@
         remote = null;
     }
 
+    public void createWorkspace( String username, String password, String workspace ) {
+        try {
+            Credentials cred = new SimpleCredentials( username, password.toCharArray() );
+            Session sesion = this.localRepository.login( cred );
+            JackrabbitWorkspace ws = ( JackrabbitWorkspace ) sesion.getWorkspace();
+            ws.createWorkspace( workspace );
+        } catch ( LoginException ex ) {
+            ex.printStackTrace();
+        } catch ( RepositoryException ex ) {
+            ex.printStackTrace();
+        }
+    }
+
+    /**
+     * Returns the local repository instance.
+     */
+    Repository getLocalRepository() {
+        return localRepository;
+    }
+
+    /**
+     * Sets the local repository instance.
+     */
+    public void setLocalRepository( Repository localRepository ) {
+        this.localRepository = localRepository;
+    }
+
     public String getLocalAddress() {
         return localAddress;
     }

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/server/jmx/JCRServerMBean.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/server/jmx/JCRServerMBean.java?rev=691319&r1=691318&r2=691319&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/server/jmx/JCRServerMBean.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/server/jmx/JCRServerMBean.java
Tue Sep  2 09:56:03 2008
@@ -22,6 +22,8 @@
 
     public void stop() throws Exception;
 
+    public void createWorkspace(String username, String password, String workspace);
+
     public String getLocalAddress();
 
     public void setLocalAddress(String address);



Mime
View raw message