chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1606578 - 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, 29 Jun 2014 19:32:33 GMT
Author: fmui
Date: Sun Jun 29 19:32:32 2014
New Revision: 1606578

URL: http://svn.apache.org/r1606578
Log:
more code clean up and minor improvements

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieStoreImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/Response.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractPortProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Base64.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/MimeHelper.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultipartParser.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/MultipartParserTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareTypeManager.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/filter/LoggingFilter.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TypesFrame.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.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/AtomEntryWriter.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomEntryWriter.java
Sun Jun 29 19:32:32 2014
@@ -56,7 +56,7 @@ import org.apache.chemistry.opencmis.com
  */
 public class AtomEntryWriter {
 
-    private static final int BUFFER_SIZE = 8 * 1024;
+    private static final int BUFFER_SIZE = 64 * 1024;
 
     private final CmisVersion cmisVersion;
     private final ObjectData object;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.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/browser/ObjectServiceImpl.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/ObjectServiceImpl.java
Sun Jun 29 19:32:32 2014
@@ -512,7 +512,7 @@ public class ObjectServiceImpl extends A
 
         if (resp.hasResponseStream()) {
             try {
-                InputStream responseStream = IOUtils.checkForBytes(resp.getStream(), 4096);
+                InputStream responseStream = IOUtils.checkForBytes(resp.getStream(), 8192);
                 if (responseStream != null) {
                     Map<String, Object> json = parseObject(responseStream, resp.getCharset());
                     return JSONConverter.convertFailedToDelete(json);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieStoreImpl.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/cookies/CmisCookieStoreImpl.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieStoreImpl.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisCookieStoreImpl.java
Sun Jun 29 19:32:32 2014
@@ -24,9 +24,9 @@ package org.apache.chemistry.opencmis.cl
 
 import java.io.Serializable;
 import java.net.URI;
+import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
 import java.util.regex.Pattern;
@@ -41,7 +41,7 @@ public class CmisCookieStoreImpl impleme
     private static final Pattern IP_ADDRESS_PATTERN = Pattern.compile(IP_ADDRESS_PATTERN_STR);
 
     private final int maxUrls;
-    private final LinkedList<CmisHttpCookie> storeList;
+    private final ArrayDeque<CmisHttpCookie> storeList;
 
     public CmisCookieStoreImpl() {
         this(300);
@@ -49,7 +49,7 @@ public class CmisCookieStoreImpl impleme
 
     public CmisCookieStoreImpl(final int maxUrls) {
         this.maxUrls = maxUrls;
-        storeList = new LinkedList<CmisHttpCookie>();
+        storeList = new ArrayDeque<CmisHttpCookie>(maxUrls);
     }
 
     public void add(final URI uri, final CmisHttpCookie cookie) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/Response.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/http/Response.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/Response.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/Response.java
Sun Jun 29 19:32:32 2014
@@ -97,9 +97,9 @@ public class Response {
                         if (encoding != null) {
                             String encLower = encoding.trim().toLowerCase(Locale.ENGLISH);
                             if (encLower.equals("gzip") && !isGZIP) {
-                                errorStream = new GZIPInputStream(errorStream, 4096);
+                                errorStream = new GZIPInputStream(errorStream, 64 * 1024);
                             } else if (encLower.equals("deflate")) {
-                                errorStream = new InflaterInputStream(errorStream, new Inflater(true),
4096);
+                                errorStream = new InflaterInputStream(errorStream, new Inflater(true),
64 * 1024);
                             }
                         }
 
@@ -157,7 +157,7 @@ public class Response {
                         // if the stream is gzip encoded, decode it
                         length = null;
                         try {
-                            stream = new GZIPInputStream(stream, 4096);
+                            stream = new GZIPInputStream(stream, 64 * 1024);
                         } catch (IOException e) {
                             errorContent = e.getMessage();
                             stream = null;
@@ -166,7 +166,7 @@ public class Response {
                     } else if (encLower.equals("deflate")) {
                         // if the stream is deflate encoded, decode it
                         length = null;
-                        stream = new InflaterInputStream(stream, new Inflater(true), 4096);
+                        stream = new InflaterInputStream(stream, new Inflater(true), 64 *
1024);
                     }
                 }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractPortProvider.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/AbstractPortProvider.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractPortProvider.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/AbstractPortProvider.java
Sun Jun 29 19:32:32 2014
@@ -579,7 +579,7 @@ public abstract class AbstractPortProvid
 
         // parse the WSDL
         try {
-            final Document doc = XMLUtils.parseDomDocument(new BufferedInputStream(wsdlStream,
16 * 1024));
+            final Document doc = XMLUtils.parseDomDocument(new BufferedInputStream(wsdlStream,
64 * 1024));
 
             NodeList serivceList = doc.getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/",
"service");
             for (int i = 0; i < serivceList.getLength(); i++) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Base64.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Base64.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Base64.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/Base64.java
Sun Jun 29 19:32:32 2014
@@ -1215,7 +1215,7 @@ public final class Base64 {
                 try {
                     baos = new java.io.ByteArrayOutputStream();
                     bais = new java.io.ByteArrayInputStream(bytes);
-                    gzis = new java.util.zip.GZIPInputStream(bais);
+                    gzis = new java.util.zip.GZIPInputStream(bais, 64 * 1024);
 
                     while ((length = gzis.read(buffer)) >= 0) {
                         baos.write(buffer, 0, length);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/MimeHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/MimeHelper.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/MimeHelper.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/MimeHelper.java
Sun Jun 29 19:32:32 2014
@@ -625,7 +625,7 @@ public final class MimeHelper {
     }
 
     protected static byte[] fromHex(String data) {
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ByteArrayOutputStream out = new ByteArrayOutputStream(data.length());
         for (int i = 0; i < data.length();) {
             char c = data.charAt(i++);
             if (c == '%') {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLConverter.java
Sun Jun 29 19:32:32 2014
@@ -24,7 +24,6 @@ import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.GregorianCalendar;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -1020,7 +1019,7 @@ public final class XMLConverter {
             return;
         }
 
-        LinkedList<String> ns = new LinkedList<String>();
+        List<String> ns = new ArrayList<String>();
 
         if (source.getExtensions() != null) {
             for (CmisExtensionElement element : source.getExtensions()) {
@@ -1033,7 +1032,7 @@ public final class XMLConverter {
         }
     }
 
-    private static void writeExtensionElement(XMLStreamWriter writer, CmisExtensionElement
source, LinkedList<String> ns)
+    private static void writeExtensionElement(XMLStreamWriter writer, CmisExtensionElement
source, List<String> ns)
             throws XMLStreamException {
         if (source == null || source.getName() == null) {
             return;
@@ -1083,7 +1082,7 @@ public final class XMLConverter {
         writer.writeEndElement();
 
         if (addedNamespace) {
-            ns.removeLast();
+            ns.remove(ns.size() - 1);
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
Sun Jun 29 19:32:32 2014
@@ -501,7 +501,7 @@ public final class AtomEntryParser {
      */
     private static byte[] copy(XMLStreamReader parser) throws XMLStreamException {
         // create a writer
-        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        ByteArrayOutputStream out = new ByteArrayOutputStream(32 * 1024);
         XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(out);
 
         writer.writeStartDocument();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultipartParser.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultipartParser.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultipartParser.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultipartParser.java
Sun Jun 29 19:32:32 2014
@@ -18,7 +18,6 @@
  */
 package org.apache.chemistry.opencmis.server.impl.browser;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
@@ -50,7 +49,7 @@ public class MultipartParser {
     private static final String CHARSET_FIELD = "_charset_";
 
     private static final int MAX_FIELD_BYTES = 10 * 1024 * 1024;
-    private static final int BUFFER_SIZE = 128 * 1024;
+    private static final int BUFFER_SIZE = 256 * 1024;
 
     private static final byte CR = 0x0D;
     private static final byte LF = 0x0A;
@@ -345,9 +344,10 @@ public class MultipartParser {
         int len = Math.min(BUFFER_SIZE, bufferCount) - bufferPosition;
         addFieldBytes(len);
 
-        ByteArrayOutputStream bos = new ByteArrayOutputStream(len + 32);
+        byte[] bodyBytes = new byte[len + BUFFER_SIZE];
+        int bodyBytesPos = len;
 
-        bos.write(buffer, bufferPosition, len);
+        System.arraycopy(buffer, bufferPosition, bodyBytes, 0, len);
         bufferPosition = bufferPosition + len;
 
         // read next chunk
@@ -357,22 +357,53 @@ public class MultipartParser {
             boundaryPosition = findBoundary();
 
             if (boundaryPosition > -1) {
+                // last chunk
                 len = boundaryPosition - bufferPosition;
                 addFieldBytes(len);
 
-                bos.write(buffer, bufferPosition, len);
+                if (bodyBytesPos + len >= bodyBytes.length) {
+                    byte[] newBodyBytes = new byte[bodyBytesPos + len];
+                    System.arraycopy(bodyBytes, 0, newBodyBytes, 0, bodyBytesPos);
+                    bodyBytes = newBodyBytes;
+                }
+                System.arraycopy(buffer, bufferPosition, bodyBytes, bodyBytesPos, len);
+                bodyBytesPos += len;
+
                 bufferPosition = boundaryPosition + boundary.length;
                 break;
             } else {
+                // not the last chunk
                 len = Math.min(BUFFER_SIZE, bufferCount) - bufferPosition;
                 addFieldBytes(len);
 
-                bos.write(buffer, bufferPosition, len);
+                if (bodyBytesPos + len >= bodyBytes.length) {
+                    int newSize = bodyBytes.length << 1;
+                    if (newSize < 0 || newSize > MAX_FIELD_BYTES) {
+                        newSize = MAX_FIELD_BYTES;
+                    }
+                    if (newSize < bodyBytesPos + len) {
+                        newSize = bodyBytesPos + BUFFER_SIZE;
+                    }
+                    
+                    byte[] newBodyBytes = new byte[newSize];
+                    System.arraycopy(bodyBytes, 0, newBodyBytes, 0, bodyBytesPos);
+                    bodyBytes = newBodyBytes;
+                }
+                System.arraycopy(buffer, bufferPosition, bodyBytes, bodyBytesPos, len);
+                bodyBytesPos += len;
+
                 bufferPosition = bufferPosition + len;
             }
         }
 
-        return bos.toByteArray();
+        if (bodyBytes.length == bodyBytesPos) {
+            return bodyBytes;
+        }
+
+        byte[] returnBytes = new byte[bodyBytesPos];
+        System.arraycopy(bodyBytes, 0, returnBytes, 0, returnBytes.length);
+
+        return returnBytes;
     }
 
     private void addFieldBytes(int len) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/MultipartParserTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/MultipartParserTest.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/MultipartParserTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/MultipartParserTest.java
Sun Jun 29 19:32:32 2014
@@ -34,6 +34,7 @@ import java.util.Random;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.server.impl.browser.MultipartParser;
 import org.apache.chemistry.opencmis.server.shared.ThresholdOutputStreamFactory;
 import org.junit.Test;
@@ -204,7 +205,7 @@ public class MultipartParserTest {
     }
 
     @Test
-    public void testManyField() throws Exception {
+    public void testManyFields() throws Exception {
         String boundary = "============";
 
         StringBuilder sb = new StringBuilder("\r\n");
@@ -223,7 +224,46 @@ public class MultipartParserTest {
 
         sb.append("\r\n" + "--" + boundary + "--");
 
-        MultipartParser parser = prepareParser(boundary, sb.toString().getBytes());
+        MultipartParser parser = prepareParser(boundary, sb.toString().getBytes(IOUtils.ISO_8859_1));
+
+        assertMultipartBasics(parser, values.size(), values, false, null, null, null);
+    }
+
+    @Test
+    public void testLargeFields() throws Exception {
+        testLargeFields(64 * 1024);
+        testLargeFields(128 * 1024);
+        testLargeFields(256 * 1024);
+        testLargeFields(512 * 1024);
+        testLargeFields(1024 * 1024);
+    }
+
+    private void testLargeFields(int size) throws Exception {
+        String boundary = "============";
+
+        StringBuilder sb = new StringBuilder("\r\n");
+
+        Random rnd = new Random();
+        Map<String, String> values = new HashMap<String, String>();
+
+        for (int i = 0; i < 5; i++) {
+            String name = "field" + i;
+
+            StringBuilder valueBuffer = new StringBuilder();
+            for (int j = 0; j < size; j++) {
+                valueBuffer.append((char) ('a' + rnd.nextInt(26)));
+            }
+            String value = valueBuffer.toString();
+
+            values.put(name, value);
+
+            sb.append("\r\n--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\""
+ name + "\"\r\n\r\n");
+            sb.append(value);
+        }
+
+        sb.append("\r\n" + "--" + boundary + "--");
+
+        MultipartParser parser = prepareParser(boundary, sb.toString().getBytes(IOUtils.ISO_8859_1));
 
         assertMultipartBasics(parser, values.size(), values, false, null, null, null);
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareRepository.java
Sun Jun 29 19:32:32 2014
@@ -1120,7 +1120,7 @@ public class FileShareRepository {
 
         InputStream stream = null;
         try {
-            stream = new BufferedInputStream(new FileInputStream(file), 4 * 1024);
+            stream = new BufferedInputStream(new FileInputStream(file), 64 * 1024);
             if (offset != null || length != null) {
                 stream = new ContentRangeInputStream(stream, offset, length);
             }
@@ -1614,7 +1614,7 @@ public class FileShareRepository {
         ObjectData obj = null;
         InputStream stream = null;
         try {
-            stream = new BufferedInputStream(new FileInputStream(propFile));
+            stream = new BufferedInputStream(new FileInputStream(propFile), 64 * 1024);
             XMLStreamReader parser = XMLUtils.createParser(stream);
             XMLUtils.findNextStartElemenet(parser);
             obj = XMLConverter.convertObject(parser);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareTypeManager.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareTypeManager.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareTypeManager.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-fileshare/src/main/java/org/apache/chemistry/opencmis/fileshare/FileShareTypeManager.java
Sun Jun 29 19:32:32 2014
@@ -138,7 +138,7 @@ public class FileShareTypeManager {
     }
 
     public void loadTypeDefinitionFromFile(String filename) throws IOException, XMLStreamException
{
-        loadTypeDefinitionFromStream(new BufferedInputStream(new FileInputStream(filename)));
+        loadTypeDefinitionFromStream(new BufferedInputStream(new FileInputStream(filename),
64 * 1024));
     }
 
     public void loadTypeDefinitionFromResource(String name) throws IOException, XMLStreamException
{

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/filter/LoggingFilter.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/filter/LoggingFilter.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/filter/LoggingFilter.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/filter/LoggingFilter.java
Sun Jun 29 19:32:32 2014
@@ -228,7 +228,7 @@ public class LoggingFilter implements Fi
         BufferedReader in = new BufferedReader(new StringReader(messageBody));
         StringBuffer out = new StringBuffer();
         String line;
-        ByteArrayOutputStream xmlBodyBuffer = new ByteArrayOutputStream();
+        ByteArrayOutputStream xmlBodyBuffer = new ByteArrayOutputStream(32 * 1024);
         boolean boundaryFound;
 
         boolean inXmlOrJsonBody = false;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/impl/AbstractSessionTest.java
Sun Jun 29 19:32:32 2014
@@ -3218,8 +3218,8 @@ public abstract class AbstractSessionTes
 
         boolean match = true;
 
-        BufferedInputStream as = new BufferedInputStream(actual.getStream());
-        BufferedInputStream es = new BufferedInputStream(expected.getStream());
+        BufferedInputStream as = new BufferedInputStream(actual.getStream(), 64 * 1024);
+        BufferedInputStream es = new BufferedInputStream(expected.getStream(), 64 * 1024);
 
         try {
             int ab = 0;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java
Sun Jun 29 19:32:32 2014
@@ -337,8 +337,8 @@ public class CreateDocumentDialog extend
         InputStream sourceContent = null;
         InputStream docContent = null;
         try {
-            sourceContent = new BufferedInputStream(sourceContentStream.getStream());
-            docContent = new BufferedInputStream(docContentStream.getStream());
+            sourceContent = new BufferedInputStream(sourceContentStream.getStream(), 64 *
1024);
+            docContent = new BufferedInputStream(docContentStream.getStream(), 64 * 1024);
 
             int fb = 0;
             int db = 0;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TypesFrame.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TypesFrame.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TypesFrame.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TypesFrame.java
Sun Jun 29 19:32:32 2014
@@ -180,7 +180,8 @@ public class TypesFrame extends JFrame {
                 int chooseResult = fileChooser.showDialog(getRootPane(), "Load XML");
                 if (chooseResult == JFileChooser.APPROVE_OPTION) {
                     try {
-                        InputStream in = new BufferedInputStream(new FileInputStream(fileChooser.getSelectedFile()));
+                        InputStream in = new BufferedInputStream(new FileInputStream(fileChooser.getSelectedFile()),
+                                64 * 1024);
                         TypeDefinition type = TypeUtils.readFromXML(in);
                         in.close();
 
@@ -206,7 +207,8 @@ public class TypesFrame extends JFrame {
                 int chooseResult = fileChooser.showDialog(getRootPane(), "Load JSON");
                 if (chooseResult == JFileChooser.APPROVE_OPTION) {
                     try {
-                        InputStream in = new BufferedInputStream(new FileInputStream(fileChooser.getSelectedFile()));
+                        InputStream in = new BufferedInputStream(new FileInputStream(fileChooser.getSelectedFile()),
+                                64 * 1024);
                         TypeDefinition type = TypeUtils.readFromJSON(in);
                         in.close();
 
@@ -269,7 +271,8 @@ public class TypesFrame extends JFrame {
                 int chooseResult = fileChooser.showDialog(getRootPane(), "Load XML");
                 if (chooseResult == JFileChooser.APPROVE_OPTION) {
                     try {
-                        InputStream in = new BufferedInputStream(new FileInputStream(fileChooser.getSelectedFile()));
+                        InputStream in = new BufferedInputStream(new FileInputStream(fileChooser.getSelectedFile()),
+                                64 * 1024);
                         TypeDefinition type = TypeUtils.readFromXML(in);
                         in.close();
 
@@ -295,7 +298,8 @@ public class TypesFrame extends JFrame {
                 int chooseResult = fileChooser.showDialog(getRootPane(), "Load JSON");
                 if (chooseResult == JFileChooser.APPROVE_OPTION) {
                     try {
-                        InputStream in = new BufferedInputStream(new FileInputStream(fileChooser.getSelectedFile()));
+                        InputStream in = new BufferedInputStream(new FileInputStream(fileChooser.getSelectedFile()),
+                                64 * 1024);
                         TypeDefinition type = TypeUtils.readFromJSON(in);
                         in.close();
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.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/ClientModel.java?rev=1606578&r1=1606577&r2=1606578&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
Sun Jun 29 19:32:32 2014
@@ -257,7 +257,7 @@ public class ClientModel {
         ContentStream content = null;
         if ((filename != null) && (filename.length() > 0)) {
             File file = new File(filename);
-            InputStream stream = new LoggingInputStream(new BufferedInputStream(new FileInputStream(file)),
+            InputStream stream = new LoggingInputStream(new BufferedInputStream(new FileInputStream(file),
512 * 1024),
                     file.getName());
 
             content = clientSession.getSession().getObjectFactory()



Mime
View raw message