chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1144926 - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/...
Date Sun, 10 Jul 2011 18:20:32 GMT
Author: fmui
Date: Sun Jul 10 18:20:32 2011
New Revision: 1144926

URL: http://svn.apache.org/viewvc?rev=1144926&view=rev
Log:
CMIS-398: added client compression

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/PortProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.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-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java?rev=1144926&r1=1144925&r2=1144926&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/HttpUtils.java
Sun Jul 10 18:20:32 2011
@@ -31,6 +31,7 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
 import java.util.zip.Inflater;
 import java.util.zip.InflaterInputStream;
 
@@ -148,12 +149,9 @@ public class HttpUtils {
             }
 
             // compression
-            if ((session.get(SessionParameter.COMPRESSION) instanceof String)
-                    && (Boolean.parseBoolean((String) session.get(SessionParameter.COMPRESSION))))
{
-                conn.setRequestProperty("Accept-Encoding", "gzip");
-            } else if ((session.get(SessionParameter.COMPRESSION) instanceof Boolean)
-                    && ((Boolean) session.get(SessionParameter.COMPRESSION)).booleanValue())
{
-                conn.setRequestProperty("Accept-Encoding", "gzip");
+            Object compression = session.get(SessionParameter.COMPRESSION);
+            if ((compression != null) && Boolean.parseBoolean(compression.toString()))
{
+                conn.setRequestProperty("Accept-Encoding", "gzip,deflate");
             }
 
             // locale
@@ -164,7 +162,18 @@ public class HttpUtils {
             // send data
             if (writer != null) {
                 conn.setChunkedStreamingMode(BUFFER_SIZE);
-                OutputStream out = new BufferedOutputStream(conn.getOutputStream(), BUFFER_SIZE);
+
+                OutputStream connOut = null;
+
+                Object clientCompression = session.get(SessionParameter.CLIENT_COMPRESSION);
+                if ((clientCompression != null) && Boolean.parseBoolean(clientCompression.toString()))
{
+                    conn.setRequestProperty("Content-Encoding", "gzip");
+                    connOut = new GZIPOutputStream(conn.getOutputStream(), 4096);
+                } else {
+                    connOut = conn.getOutputStream();
+                }
+
+                OutputStream out = new BufferedOutputStream(connOut, BUFFER_SIZE);
                 writer.write(out);
                 out.flush();
             }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/PortProvider.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/PortProvider.java?rev=1144926&r1=1144925&r2=1144926&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/PortProvider.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/PortProvider.java
Sun Jul 10 18:20:32 2011
@@ -61,6 +61,7 @@ public class PortProvider extends Abstra
     private static final Log log = LogFactory.getLog(PortProvider.class);
 
     private boolean useCompression;
+    private boolean useClientCompression;
     private String acceptLanguage;
 
     /**
@@ -69,15 +70,11 @@ public class PortProvider extends Abstra
     public PortProvider(BindingSession session) {
         this.session = session;
 
-        useCompression = false;
-        if ((session.get(SessionParameter.COMPRESSION) instanceof String)
-                && (Boolean.parseBoolean((String) session.get(SessionParameter.COMPRESSION))))
{
-            useCompression = true;
-        }
-        if ((session.get(SessionParameter.COMPRESSION) instanceof Boolean)
-                && ((Boolean) session.get(SessionParameter.COMPRESSION)).booleanValue())
{
-            useCompression = true;
-        }
+        Object compression = session.get(SessionParameter.COMPRESSION);
+        useCompression = (compression != null) && Boolean.parseBoolean(compression.toString());
+
+        Object clientCompression = session.get(SessionParameter.CLIENT_COMPRESSION);
+        useClientCompression = (clientCompression != null) && Boolean.parseBoolean(clientCompression.toString());
 
         if (session.get(CmisBindingsHelper.ACCEPT_LANGUAGE) instanceof String) {
             acceptLanguage = session.get(CmisBindingsHelper.ACCEPT_LANGUAGE).toString();
@@ -148,6 +145,14 @@ public class PortProvider extends Abstra
                 httpHeaders.put("Accept-Encoding", Collections.singletonList("gzip"));
             }
 
+            // client compression
+            if (useClientCompression) {
+                if (httpHeaders == null) {
+                    httpHeaders = new HashMap<String, List<String>>();
+                }
+                httpHeaders.put("Content-Encoding", Collections.singletonList("gzip"));
+            }
+
             // locale
             if (acceptLanguage != null) {
                 if (httpHeaders == null) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java?rev=1144926&r1=1144925&r2=1144926&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/SessionParameter.java
Sun Jul 10 18:20:32 2011
@@ -74,7 +74,8 @@ public final class SessionParameter {
     // --- connection ---
 
     public static final String COMPRESSION = "org.apache.chemistry.opencmis.binding.compression";
-
+    public static final String CLIENT_COMPRESSION = "org.apache.chemistry.opencmis.binding.clientcompression";
+    
     public static final String CONNECT_TIMEOUT = "org.apache.chemistry.opencmis.binding.connecttimeout";
     public static final String READ_TIMEOUT = "org.apache.chemistry.opencmis.binding.readtimeout";
 

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=1144926&r1=1144925&r2=1144926&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
Sun Jul 10 18:20:32 2011
@@ -87,6 +87,8 @@ public class LoginDialog extends JDialog
     private JRadioButton authenticationNTLMButton;
     private JRadioButton compressionOnButton;
     private JRadioButton compressionOffButton;
+    private JRadioButton clientCompressionOnButton;
+    private JRadioButton clientCompressionOffButton;
     private JTextArea sessionParameterTextArea;
     private JButton loadRepositoryButton;
     private JButton loginButton;
@@ -133,7 +135,9 @@ public class LoginDialog extends JDialog
 
         createCompressionButtons(basicPanel);
 
-        makeCompactGrid(basicPanel, 6, 2, 5, 10, 5, 5);
+        createClientCompressionButtons(basicPanel);
+
+        makeCompactGrid(basicPanel, 7, 2, 5, 10, 5, 5);
 
         loginTabs.addTab("Basic", basicPanel);
 
@@ -345,6 +349,24 @@ public class LoginDialog extends JDialog
         pane.add(compressionContainer);
     }
 
+    private void createClientCompressionButtons(Container pane) {
+        JPanel clientCompressionContainer = new JPanel();
+        clientCompressionContainer.setLayout(new BoxLayout(clientCompressionContainer, BoxLayout.LINE_AXIS));
+        boolean clientCompression = (System.getProperty(SYSPROP_BINDING, "clientcompression").equalsIgnoreCase("on"));
+        clientCompressionOnButton = new JRadioButton("On", clientCompression);
+        clientCompressionOffButton = new JRadioButton("Off", !clientCompression);
+        ButtonGroup clientCompressionGroup = new ButtonGroup();
+        clientCompressionGroup.add(clientCompressionOnButton);
+        clientCompressionGroup.add(clientCompressionOffButton);
+        clientCompressionContainer.add(clientCompressionOnButton);
+        clientCompressionContainer.add(Box.createRigidArea(new Dimension(10, 0)));
+        clientCompressionContainer.add(clientCompressionOffButton);
+        JLabel clientCompressionLabel = new JLabel("Client Compression:", JLabel.TRAILING);
+
+        pane.add(clientCompressionLabel);
+        pane.add(clientCompressionContainer);
+    }
+
     private JButton createButton(String title) {
         JButton button = new JButton(title);
         button.setPreferredSize(new Dimension(Short.MAX_VALUE, 30));
@@ -418,7 +440,7 @@ public class LoginDialog extends JDialog
         }
 
         return ClientSession.createSessionParameters(url, binding, username, password, authentication,
-                compressionOnButton.isSelected());
+                compressionOnButton.isSelected(), clientCompressionOnButton.isSelected());
     }
 
     private Map<String, String> createExpertSessionParameters() {

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=1144926&r1=1144925&r2=1144926&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
Sun Jul 10 18:20:32 2011
@@ -102,7 +102,7 @@ public class ClientSession {
     }
 
     public static Map<String, String> createSessionParameters(String url, BindingType
binding, String username,
-            String password, Authentication authentication, boolean compression) {
+            String password, Authentication authentication, boolean compression, boolean
clientCompression) {
         Map<String, String> parameters = new LinkedHashMap<String, String>();
 
         if (binding == BindingType.WEBSERVICES) {
@@ -138,6 +138,10 @@ public class ClientSession {
             parameters.put(SessionParameter.COMPRESSION, "true");
         }
 
+        if (clientCompression) {
+            parameters.put(SessionParameter.CLIENT_COMPRESSION, "true");
+        }
+
         // get additional workbench properties from system properties
         Properties sysProps = System.getProperties();
         for (String key : sysProps.stringPropertyNames()) {



Mime
View raw message