chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1001432 - in /incubator/chemistry/opencmis-swingclient/trunk: ./ src/main/java/org/apache/chemistry/opencmis/swingclient/ src/main/java/org/apache/chemistry/opencmis/swingclient/model/ src/main/jnlp/ src/main/resources/scripts/
Date Sun, 26 Sep 2010 14:10:17 GMT
Author: fmui
Date: Sun Sep 26 14:10:16 2010
New Revision: 1001432

URL: http://svn.apache.org/viewvc?rev=1001432&view=rev
Log:
- added NTLM authentication
- improved Web Start build
- added build timestamp
- added more Groovy scripts

Added:
    incubator/chemistry/opencmis-swingclient/trunk/src/main/jnlp/
    incubator/chemistry/opencmis-swingclient/trunk/src/main/jnlp/template.vm   (with props)
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/counttypes.groovy
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/query.groovy
Modified:
    incubator/chemistry/opencmis-swingclient/trunk/pom.xml
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/InfoDialog.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LoginDialog.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientSession.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/script-library.properties

Modified: incubator/chemistry/opencmis-swingclient/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/pom.xml?rev=1001432&r1=1001431&r2=1001432&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/pom.xml (original)
+++ incubator/chemistry/opencmis-swingclient/trunk/pom.xml Sun Sep 26 14:10:16 2010
@@ -148,6 +148,26 @@
                 </configuration>
             </plugin>
             <plugin>
+                 <artifactId>maven-antrun-plugin</artifactId>
+                 <version>1.5</version>
+                 <executions>
+                     <execution>
+                         <phase>generate-resources</phase>
+                         <configuration>
+                             <target>
+                                 <property name="version" value="${maven.version}"/>
+                                 <property name="timestamp" value="${maven.build.timestamp}"/>
+                                 <property name="basedir" value="${maven.basedir} "/>
+                                 <echo file="${basedir}/src/main/resources/META-INF/build-timestamp.txt">Version:
${version} / Build: ${timestamp}</echo>
+                             </target>
+                         </configuration>
+                         <goals>
+                             <goal>run</goal>
+                         </goals>
+                     </execution>
+                 </executions>
+            </plugin>                  
+            <plugin>
                 <artifactId>maven-eclipse-plugin</artifactId>
                 <configuration>
                     <downloadSources>true</downloadSources>

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/InfoDialog.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/InfoDialog.java?rev=1001432&r1=1001431&r2=1001432&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/InfoDialog.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/InfoDialog.java
Sun Sep 26 14:10:16 2010
@@ -66,23 +66,9 @@ public class InfoDialog extends JDialog 
 
         StringBuilder readme = new StringBuilder();
 
-        InputStream stream = getClass().getResourceAsStream("/META-INF/README");
-        if (stream != null) {
-            try {
-                BufferedReader br = new BufferedReader(new InputStreamReader(stream));
-
-                String s = null;
-                while ((s = br.readLine()) != null) {
-                    readme.append(s);
-                    readme.append('\n');
-                }
-
-                br.close();
-            } catch (Exception e) {
-            }
-        } else {
-            readme.append("CMIS Swing Client");
-        }
+        readme.append(loadText("/META-INF/README", "OpenCMIS Swing Client"));
+        readme.append("\n\n");
+        readme.append(loadText("/META-INF/build-timestamp.txt", ""));
 
         TextArea ta = new TextArea(readme.toString());
         ta.setEditable(false);
@@ -100,4 +86,28 @@ public class InfoDialog extends JDialog 
     public void hideDialog() {
         setVisible(false);
     }
+
+    private String loadText(String file, String defaultText) {
+        StringBuilder result = new StringBuilder();
+
+        InputStream stream = getClass().getResourceAsStream(file);
+        if (stream != null) {
+            try {
+                BufferedReader br = new BufferedReader(new InputStreamReader(stream));
+
+                String s = null;
+                while ((s = br.readLine()) != null) {
+                    result.append(s);
+                    result.append('\n');
+                }
+
+                br.close();
+            } catch (Exception e) {
+            }
+        } else {
+            result.append(defaultText);
+        }
+
+        return result.toString();
+    }
 }

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LoginDialog.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LoginDialog.java?rev=1001432&r1=1001431&r2=1001432&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LoginDialog.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/LoginDialog.java
Sun Sep 26 14:10:16 2010
@@ -47,6 +47,7 @@ public class LoginDialog extends JDialog
 
     public static final String SYSPROP_URL = "swingclient.url";
     public static final String SYSPROP_BINDING = "swingclient.binding";
+    public static final String SYSPROP_AUTHENTICATION = "swingclient.authentication";
     public static final String SYSPROP_USER = "swingclient.user";
     public static final String SYSPROP_PASSWORD = "swingclient.password";
 
@@ -57,6 +58,9 @@ public class LoginDialog extends JDialog
     private JRadioButton bindingWebServicesButton;
     private JTextField usernameField;
     private JPasswordField passwordField;
+    private JRadioButton authenticationNoneButton;
+    private JRadioButton authenticationStandardButton;
+    private JRadioButton authenticationNTLMButton;
     private JButton connectButton;
     private JButton loginButton;
     private JComboBox repositoryBox;
@@ -71,7 +75,7 @@ public class LoginDialog extends JDialog
     }
 
     private void createGUI() {
-        setPreferredSize(new Dimension(500, 250));
+        setPreferredSize(new Dimension(520, 280));
 
         Container pane = getContentPane();
 
@@ -88,11 +92,13 @@ public class LoginDialog extends JDialog
         passwordField = createPasswordField(pane, "Password:", 4);
         passwordField.setText(System.getProperty(SYSPROP_PASSWORD, ""));
 
-        connectButton = createButton(pane, "Connect", 5);
+        createAuthenticationButtons(pane, 5);
 
-        createRepositoryBox(pane, 6);
+        connectButton = createButton(pane, "Connect", 6);
 
-        loginButton = createButton(pane, "Login", 7);
+        createRepositoryBox(pane, 7);
+
+        loginButton = createButton(pane, "Login", 8);
         loginButton.setEnabled(false);
 
         connectButton.addActionListener(new ActionListener() {
@@ -203,6 +209,32 @@ public class LoginDialog extends JDialog
         pane.add(bindingContainer, c);
     }
 
+    private void createAuthenticationButtons(Container pane, int row) {
+        JPanel authenticationContainer = new JPanel();
+        boolean standard = (System.getProperty(SYSPROP_BINDING, "standard").toLowerCase().equals("standard"));
+        boolean ntlm = (System.getProperty(SYSPROP_BINDING, "").toLowerCase().equals("ntlm"));
+        boolean none = !standard && !ntlm;
+        authenticationNoneButton = new JRadioButton("None", none);
+        authenticationStandardButton = new JRadioButton("Standard", standard);
+        authenticationNTLMButton = new JRadioButton("NTLM", ntlm);
+        ButtonGroup authenticationGroup = new ButtonGroup();
+        authenticationGroup.add(authenticationNoneButton);
+        authenticationGroup.add(authenticationStandardButton);
+        authenticationGroup.add(authenticationNTLMButton);
+        authenticationContainer.add(authenticationNoneButton);
+        authenticationContainer.add(authenticationStandardButton);
+        authenticationContainer.add(authenticationNTLMButton);
+        JLabel authenticatioLabel = new JLabel("Authentication:");
+
+        GridBagConstraints c = new GridBagConstraints();
+        c.anchor = GridBagConstraints.LINE_START;
+        c.gridx = 0;
+        c.gridy = row;
+        pane.add(authenticatioLabel, c);
+        c.gridx = 1;
+        pane.add(authenticationContainer, c);
+    }
+
     private JButton createButton(Container pane, String label, int row) {
         JButton button = new JButton(label);
 
@@ -238,7 +270,14 @@ public class LoginDialog extends JDialog
         String username = usernameField.getText();
         String password = new String(passwordField.getPassword());
 
-        clientSession = new ClientSession(url, binding, username, password);
+        ClientSession.Authentication authentication = ClientSession.Authentication.NONE;
+        if (authenticationStandardButton.isSelected()) {
+            authentication = ClientSession.Authentication.STANDARD;
+        } else if (authenticationNTLMButton.isSelected()) {
+            authentication = ClientSession.Authentication.NTLM;
+        }
+
+        clientSession = new ClientSession(url, binding, username, password, authentication);
     }
 
     public void showDialog() {

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientSession.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientSession.java?rev=1001432&r1=1001431&r2=1001432&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientSession.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/model/ClientSession.java
Sun Sep 26 14:10:16 2010
@@ -18,22 +18,28 @@
  */
 package org.apache.chemistry.opencmis.swingclient.model;
 
+import java.net.Authenticator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 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.commons.SessionParameter;
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
 
 public class ClientSession {
 
+    public enum Authentication {
+        NONE, STANDARD, NTLM
+    }
+
     private List<Repository> repositories;
     private Session session;
 
-    public ClientSession(String url, BindingType binding, String username, String password)
{
+    public ClientSession(String url, BindingType binding, String username, String password,
Authentication authenticaion) {
         Map<String, String> parameters = new HashMap<String, String>();
 
         if (binding == BindingType.WEBSERVICES) {
@@ -51,8 +57,19 @@ public class ClientSession {
             parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
             parameters.put(SessionParameter.ATOMPUB_URL, url);
         }
-        parameters.put(SessionParameter.USER, username);
-        parameters.put(SessionParameter.PASSWORD, password);
+
+        switch (authenticaion) {
+        case STANDARD:
+            parameters.put(SessionParameter.USER, username);
+            parameters.put(SessionParameter.PASSWORD, password);
+            break;
+        case NTLM:
+            parameters.put(SessionParameter.USER, username);
+            parameters.put(SessionParameter.PASSWORD, password);
+            parameters.put(SessionParameter.AUTHENTICATION_PROVIDER_CLASS,
+                    CmisBindingFactory.NTLM_AUTHENTICATION_PROVIDER);
+            break;
+        }
 
         connect(parameters);
     }
@@ -66,6 +83,11 @@ public class ClientSession {
     }
 
     private void connect(Map<String, String> sessionParameters) {
+        // set a new dummy authenticator
+        // don't send previous credentials to another server
+        Authenticator.setDefault(new Authenticator() {
+        });
+
         repositories = SessionFactoryImpl.newInstance().getRepositories(sessionParameters);
     }
 

Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/jnlp/template.vm
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/jnlp/template.vm?rev=1001432&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/jnlp/template.vm (added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/jnlp/template.vm Sun Sep 26 14:10:16
2010
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.5+" codebase="!server!">
+  <information>
+    <title>$project.Name</title>
+    <vendor>$project.Organization.Name</vendor>
+    <homepage href="$project.Url"/>
+    <description>$project.Description</description>
+    <offline-allowed/>
+    <update check="timeout" policy="prompt-update"/>
+  </information>
+  <security>
+     <all-permissions/>
+  </security>
+  <resources>
+    <j2se version="1.6+" initial-heap-size="64m" max-heap-size="256m"/>
+     $dependencies
+    <property name="swingclient.url" value="!repository!"/>  
+    <property name="swingclient.user" value="!user!"/>  
+    <property name="swingclient.password" value="!password!"/>
+    <property name="swingclient.binding" value="!binding!"/>
+  </resources>
+  <application-desc main-class="$mainClass"/>
+</jnlp>
+

Propchange: incubator/chemistry/opencmis-swingclient/trunk/src/main/jnlp/template.vm
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/counttypes.groovy
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/counttypes.groovy?rev=1001432&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/counttypes.groovy
(added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/counttypes.groovy
Sun Sep 26 14:10:16 2010
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.commons.enums.*
+import org.apache.chemistry.opencmis.commons.exceptions.*
+import org.apache.chemistry.opencmis.client.api.*
+
+println "'cmis:document' and subtypes:     " + countTypes("cmis:document")
+println "'cmis:folder' and subtypes:       " + countTypes("cmis:folder")
+println "'cmis:relationship' and subtypes: " + countTypes("cmis:relationship")
+println "'cmis:policy' and subtypes:       " + countTypes("cmis:policy")
+
+
+
+int countTypes(String typeId) {
+    def counter = 0
+
+    try {
+        session.getTypeDescendants(typeId, -1, false).each { counter += 1 + count(it) }
+    }
+    catch(CmisBaseException e) { }
+    
+    return counter
+}
+
+int count(Tree tree) {
+    def counter = 0
+    tree.children.each { counter += 1 + count(it) }
+    
+    return counter
+}
\ No newline at end of file

Added: incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/query.groovy
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/query.groovy?rev=1001432&view=auto
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/query.groovy
(added)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/query.groovy
Sun Sep 26 14:10:16 2010
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.commons.enums.*
+import org.apache.chemistry.opencmis.client.api.*
+
+String cql = "SELECT cmis:objectId, cmis:name, cmis:contentStreamLength FROM cmis:document"
+
+ItemIterable<QueryResult> results = session.query(cql, false)
+
+//ItemIterable<QueryResult> results = session.query(cql, false).getPage(10)
+//ItemIterable<QueryResult> results = session.query(cql, false).skipTo(10).getPage(10)
+
+results.each { hit ->  
+    hit.properties.each { println "${it.queryName}: ${it.firstValue}" }
+    println "--------------------------------------"
+}
+
+println "--------------------------------------"    
+println "Total number: ${results.totalNumItems}"
+println "Has more: ${results.hasMoreItems}" 
+println "--------------------------------------"
\ No newline at end of file

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/script-library.properties
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/script-library.properties?rev=1001432&r1=1001431&r2=1001432&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/script-library.properties
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/script-library.properties
Sun Sep 26 14:10:16 2010
@@ -26,4 +26,7 @@
 
 startup.groovy = - Demo -
 template.groovy = - Basic template -
+
 getdescendants.groovy = Print descendants tree
+query.groovy = Execute a query
+counttypes.groovy = Count types and sub types



Mime
View raw message