chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1437224 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench: AbstractLoginTab.java LoginDialog.java model/ClientSession.java
Date Tue, 22 Jan 2013 22:48:03 GMT
Author: fmui
Date: Tue Jan 22 22:48:03 2013
New Revision: 1437224

URL: http://svn.apache.org/viewvc?rev=1437224&view=rev
Log:
Workbench: improved pluggable login dialog interface

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractLoginTab.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/LoginDialog.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractLoginTab.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractLoginTab.java?rev=1437224&r1=1437223&r2=1437224&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractLoginTab.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/AbstractLoginTab.java
Tue Jan 22 22:48:03 2013
@@ -23,8 +23,11 @@ import java.util.Map;
 
 import javax.swing.JPanel;
 
+import org.apache.chemistry.opencmis.client.api.ObjectFactory;
 import org.apache.chemistry.opencmis.client.api.Repository;
 import org.apache.chemistry.opencmis.client.api.Session;
+import org.apache.chemistry.opencmis.client.runtime.cache.Cache;
+import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider;
 
 /**
  * Abstract Login Tab.
@@ -49,6 +52,30 @@ public abstract class AbstractLoginTab e
     public abstract Map<String, String> getSessionParameters();
 
     /**
+     * Returns an <code>ObjectFactory</code> instance or <code>null</code>
for
+     * the default object factory.
+     */
+    public ObjectFactory getObjectFactory() {
+        return null;
+    }
+
+    /**
+     * Returns an <code>AuthenticationProvider</code> instance or
+     * <code>null</code> for the default authentication provider.
+     */
+    public AuthenticationProvider getAuthenticationProvider() {
+        return null;
+    }
+
+    /**
+     * Returns a <code>Cache</code> instance or <code>null</code>
for the
+     * default cache.
+     */
+    public Cache getCache() {
+        return null;
+    }
+
+    /**
      * Defines if the session parameters should be transfered to the expert tab
      * when the user switches from the this tab to the expert tab. The default
      * is <code>false</code>.
@@ -58,14 +85,26 @@ public abstract class AbstractLoginTab e
     }
 
     /**
+     * Called before the list of repositories is loaded.
+     */
+    public void beforeLoadRepositories() {
+    }
+
+    /**
      * Called after the list of repositories has been loaded.
      */
-    public void repositoriesLoaded(List<Repository> repositories) {
+    public void afterLoadRepositories(List<Repository> repositories) {
+    }
+
+    /**
+     * Called before the Workbench session is created.
+     */
+    public void beforeLogin(Repository repository) {
     }
 
     /**
      * Called after the Workbench session has been created.
      */
-    public void loggedIn(Session session) {
+    public void afterLogin(Session session) {
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/LoginDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/LoginDialog.java?rev=1437224&r1=1437223&r2=1437224&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/LoginDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/LoginDialog.java
Tue Jan 22 22:48:03 2013
@@ -113,6 +113,9 @@ public class LoginDialog extends JDialog
 
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+                    currentTab.beforeLoadRepositories();
+
                     createClientSession();
 
                     List<Repository> repositories = clientSession.getRepositories();
@@ -147,7 +150,7 @@ public class LoginDialog extends JDialog
                         getRootPane().setDefaultButton(loadRepositoryButton);
                     }
 
-                    currentTab.repositoriesLoaded(repositories);
+                    currentTab.afterLoadRepositories(repositories);
                 } catch (Exception ex) {
                     repositoryBox.setEnabled(false);
                     loginButton.setEnabled(false);
@@ -165,9 +168,11 @@ public class LoginDialog extends JDialog
                 try {
                     setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
 
+                    currentTab.beforeLogin(clientSession.getRepositories().get(repositoryBox.getSelectedIndex()));
+
                     clientSession.createSession(repositoryBox.getSelectedIndex());
 
-                    currentTab.loggedIn(clientSession.getSession());
+                    currentTab.afterLogin(clientSession.getSession());
 
                     canceled = false;
                     hideDialog();
@@ -277,7 +282,8 @@ public class LoginDialog extends JDialog
     }
 
     public void createClientSession() {
-        setClientSession(new ClientSession(currentTab.getSessionParameters()));
+        setClientSession(new ClientSession(currentTab.getSessionParameters(), currentTab.getObjectFactory(),
+                currentTab.getAuthenticationProvider(), currentTab.getCache()));
     }
 
     public void showDialog() {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java?rev=1437224&r1=1437223&r2=1437224&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java
Tue Jan 22 22:48:03 2013
@@ -33,12 +33,14 @@ import javax.net.ssl.SSLContext;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
 
+import org.apache.chemistry.opencmis.client.api.ObjectFactory;
 import org.apache.chemistry.opencmis.client.api.ObjectType;
 import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.Repository;
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
 import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
+import org.apache.chemistry.opencmis.client.runtime.cache.Cache;
 import org.apache.chemistry.opencmis.commons.PropertyIds;
 import org.apache.chemistry.opencmis.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
@@ -47,6 +49,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
 import org.apache.chemistry.opencmis.commons.enums.CapabilityAcl;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.spi.AuthenticationProvider;
 
 public class ClientSession {
 
@@ -97,12 +100,13 @@ public class ClientSession {
     private OperationContext folderOperationContext;
     private OperationContext versionOperationContext;
 
-    public ClientSession(Map<String, String> sessionParameters) {
+    public ClientSession(Map<String, String> sessionParameters, ObjectFactory objectFactory,
+            AuthenticationProvider authenticationProvider, Cache cache) {
         if (sessionParameters == null) {
             throw new IllegalArgumentException("Parameters must not be null!");
         }
 
-        connect(sessionParameters);
+        connect(sessionParameters, objectFactory, authenticationProvider, cache);
     }
 
     public static Map<String, String> createSessionParameters(String url, BindingType
binding, String username,
@@ -172,7 +176,8 @@ public class ClientSession {
         return parameters;
     }
 
-    private void connect(Map<String, String> sessionParameters) {
+    private void connect(Map<String, String> sessionParameters, ObjectFactory objectFactory,
+            AuthenticationProvider authenticationProvider, Cache cache) {
         this.sessionParameters = sessionParameters;
 
         // set a new dummy authenticator
@@ -184,7 +189,8 @@ public class ClientSession {
             acceptSelfSignedCertificates();
         }
 
-        repositories = SessionFactoryImpl.newInstance().getRepositories(sessionParameters);
+        repositories = SessionFactoryImpl.newInstance().getRepositories(sessionParameters,
objectFactory,
+                authenticationProvider, cache);
     }
 
     public List<Repository> getRepositories() {
@@ -193,7 +199,9 @@ public class ClientSession {
 
     public Session createSession(int index) {
         session = repositories.get(index).createSession();
-        createOperationContexts();
+        objectOperationContext = null;
+        folderOperationContext = null;
+        versionOperationContext = null;
         return getSession();
     }
 
@@ -205,15 +213,24 @@ public class ClientSession {
         return Collections.unmodifiableMap(sessionParameters);
     }
 
-    public OperationContext getObjectOperationContext() {
+    public synchronized OperationContext getObjectOperationContext() {
+        if (objectOperationContext == null) {
+            createOperationContexts();
+        }
         return objectOperationContext;
     }
 
-    public OperationContext getFolderOperationContext() {
+    public synchronized OperationContext getFolderOperationContext() {
+        if (folderOperationContext == null) {
+            createOperationContexts();
+        }
         return folderOperationContext;
     }
 
-    public OperationContext getVersionOperationContext() {
+    public synchronized OperationContext getVersionOperationContext() {
+        if (versionOperationContext == null) {
+            createOperationContexts();
+        }
         return versionOperationContext;
     }
 



Mime
View raw message