chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1518960 [2/2] - in /chemistry/opencmis/trunk: chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/ chemistry-opencmis-client/chemistry-opencmis-client-binding...
Date Fri, 30 Aug 2013 13:14:42 GMT
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStreamNotSupportedException.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/exceptions/CmisStreamNotSupportedException.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStreamNotSupportedException.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisStreamNotSupportedException.java Fri Aug 30 13:14:41 2013
@@ -32,34 +32,97 @@ public class CmisStreamNotSupportedExcep
     private static final long serialVersionUID = 1L;
     public static final String EXCEPTION_NAME = "streamNotSupported";
 
+    /**
+     * Default constructor.
+     */
     public CmisStreamNotSupportedException() {
         super();
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     * @param cause
+     *            the cause
+     */
     public CmisStreamNotSupportedException(String message, BigInteger code, Throwable cause) {
         super(message, code, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param errorContent
+     *            error page content
+     */
     public CmisStreamNotSupportedException(String message, String errorContent) {
         super(message, errorContent);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     */
     public CmisStreamNotSupportedException(String message, BigInteger code) {
         super(message, code);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     * @param errorContent
+     *            error page content
+     */
     public CmisStreamNotSupportedException(String message, BigInteger code, String errorContent) {
         super(message, code, errorContent);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param errorContent
+     *            error page content
+     * @param cause
+     *            the cause
+     */
     public CmisStreamNotSupportedException(String message, String errorContent, Throwable cause) {
         super(message, errorContent, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param cause
+     *            the cause
+     */
     public CmisStreamNotSupportedException(String message, Throwable cause) {
         super(message, BigInteger.ZERO, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     */
     public CmisStreamNotSupportedException(String message) {
         super(message, BigInteger.ZERO);
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisUnauthorizedException.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/exceptions/CmisUnauthorizedException.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisUnauthorizedException.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisUnauthorizedException.java Fri Aug 30 13:14:41 2013
@@ -30,34 +30,97 @@ public class CmisUnauthorizedException e
 
     private static final long serialVersionUID = 1L;
 
+    /**
+     * Default constructor.
+     */
     public CmisUnauthorizedException() {
         super();
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     * @param cause
+     *            the cause
+     */
     public CmisUnauthorizedException(String message, BigInteger code, Throwable cause) {
         super(message, code, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param errorContent
+     *            error page content
+     */
     public CmisUnauthorizedException(String message, String errorContent) {
         super(message, errorContent);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     */
     public CmisUnauthorizedException(String message, BigInteger code) {
         super(message, code);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     * @param errorContent
+     *            error page content
+     */
     public CmisUnauthorizedException(String message, BigInteger code, String errorContent) {
         super(message, code, errorContent);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param errorContent
+     *            error page content
+     * @param cause
+     *            the cause
+     */
     public CmisUnauthorizedException(String message, String errorContent, Throwable cause) {
         super(message, errorContent, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param cause
+     *            the cause
+     */
     public CmisUnauthorizedException(String message, Throwable cause) {
         super(message, BigInteger.ZERO, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     */
     public CmisUnauthorizedException(String message) {
         super(message, BigInteger.ZERO);
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisUpdateConflictException.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/exceptions/CmisUpdateConflictException.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisUpdateConflictException.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisUpdateConflictException.java Fri Aug 30 13:14:41 2013
@@ -31,34 +31,97 @@ public class CmisUpdateConflictException
     private static final long serialVersionUID = 1L;
     public static final String EXCEPTION_NAME = "updateConflict";
 
+    /**
+     * Default constructor.
+     */
     public CmisUpdateConflictException() {
         super();
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     * @param cause
+     *            the cause
+     */
     public CmisUpdateConflictException(String message, BigInteger code, Throwable cause) {
         super(message, code, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param errorContent
+     *            error page content
+     */
     public CmisUpdateConflictException(String message, String errorContent) {
         super(message, errorContent);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     */
     public CmisUpdateConflictException(String message, BigInteger code) {
         super(message, code);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     * @param errorContent
+     *            error page content
+     */
     public CmisUpdateConflictException(String message, BigInteger code, String errorContent) {
         super(message, code, errorContent);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param errorContent
+     *            error page content
+     * @param cause
+     *            the cause
+     */
     public CmisUpdateConflictException(String message, String errorContent, Throwable cause) {
         super(message, errorContent, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param cause
+     *            the cause
+     */
     public CmisUpdateConflictException(String message, Throwable cause) {
         super(message, BigInteger.ZERO, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     */
     public CmisUpdateConflictException(String message) {
         super(message, BigInteger.ZERO);
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisVersioningException.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/exceptions/CmisVersioningException.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisVersioningException.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/CmisVersioningException.java Fri Aug 30 13:14:41 2013
@@ -31,34 +31,97 @@ public class CmisVersioningException ext
     private static final long serialVersionUID = 1L;
     public static final String EXCEPTION_NAME = "versioning";
 
+    /**
+     * Default constructor.
+     */
     public CmisVersioningException() {
         super();
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     * @param cause
+     *            the cause
+     */
     public CmisVersioningException(String message, BigInteger code, Throwable cause) {
         super(message, code, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param errorContent
+     *            error page content
+     */
     public CmisVersioningException(String message, String errorContent) {
         super(message, errorContent);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     */
     public CmisVersioningException(String message, BigInteger code) {
         super(message, code);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param code
+     *            error code
+     * @param errorContent
+     *            error page content
+     */
     public CmisVersioningException(String message, BigInteger code, String errorContent) {
         super(message, code, errorContent);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param errorContent
+     *            error page content
+     * @param cause
+     *            the cause
+     */
     public CmisVersioningException(String message, String errorContent, Throwable cause) {
         super(message, errorContent, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     * @param cause
+     *            the cause
+     */
     public CmisVersioningException(String message, Throwable cause) {
         super(message, BigInteger.ZERO, cause);
     }
 
+    /**
+     * Constructor.
+     * 
+     * @param message
+     *            error message
+     */
     public CmisVersioningException(String message) {
         super(message, BigInteger.ZERO);
     }

Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/package-info.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/exceptions/package-info.java?rev=1518960&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/package-info.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/package-info.java Fri Aug 30 13:14:41 2013
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * Contains all exceptions used by OpenCMIS.
+ */
+package org.apache.chemistry.opencmis.commons.exceptions;
+

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/exceptions/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/package-info.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/package-info.java?rev=1518960&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/package-info.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/package-info.java Fri Aug 30 13:14:41 2013
@@ -0,0 +1,23 @@
+/*
+ * 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.
+ */
+/**
+ * Contains interfaces, classes, exceptions, and constants shared by the client and server implementations.
+ */
+package org.apache.chemistry.opencmis.commons;
+

Propchange: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/IOUtils.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/IOUtils.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/IOUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/IOUtils.java Fri Aug 30 13:14:41 2013
@@ -23,6 +23,7 @@ import java.io.Closeable;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.io.OutputStream;
 import java.io.Reader;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
@@ -39,6 +40,8 @@ public final class IOUtils {
 
     /** UTF-8 character set name. */
     public static final String UTF8 = "UTF-8";
+    /** ISO-8859-1 character set name. */
+    public static final String ISO_8859_1 = "ISO-8859-1";
 
     private IOUtils() {
     }
@@ -46,6 +49,11 @@ public final class IOUtils {
     /**
      * Return UTF-8 bytes of the given string or throws a
      * {@link CmisRuntimeException} if the charset 'UTF-8' is not available.
+     * 
+     * @param s
+     *            the input string
+     * 
+     * @return the UTF-8 bytes
      */
     public static byte[] getUTF8Bytes(String s) {
         if (s == null) {
@@ -62,6 +70,11 @@ public final class IOUtils {
     /**
      * URL encodes the given string or throws a {@link CmisRuntimeException} if
      * the charset 'UTF-8' is not available.
+     * 
+     * @param s
+     *            the string to encode
+     * 
+     * @return the encoded
      */
     public static String encodeURL(String s) {
         if (s == null) {
@@ -76,8 +89,13 @@ public final class IOUtils {
     }
 
     /**
-     * URL dencodes the given string or throws a {@link CmisRuntimeException} if
+     * URL decodes the given string or throws a {@link CmisRuntimeException} if
      * the charset 'UTF-8' is not available.
+     * 
+     * @param s
+     *            the string to decode
+     * 
+     * @return the decoded string
      */
     public static String decodeURL(String s) {
         if (s == null) {
@@ -93,6 +111,9 @@ public final class IOUtils {
 
     /**
      * Closes a stream and ignores any exceptions.
+     * 
+     * @param closeable
+     *            the {@link Closeable} object
      */
     @SuppressWarnings("PMD.EmptyCatchBlock")
     public static void closeQuietly(final Closeable closeable) {
@@ -108,6 +129,9 @@ public final class IOUtils {
     /**
      * Closes the stream of a {@link ContentStream} object and ignores any
      * exceptions.
+     * 
+     * @param contentStream
+     *            the content stream
      */
     public static void closeQuietly(final ContentStream contentStream) {
         if (contentStream != null) {
@@ -117,6 +141,9 @@ public final class IOUtils {
 
     /**
      * Consumes and closes the provided stream.
+     * 
+     * @param stream
+     *            the stream
      */
     @SuppressWarnings({ "PMD.EmptyCatchBlock", "PMD.EmptyWhileStmt" })
     public static void consumeAndClose(final InputStream stream) {
@@ -125,7 +152,7 @@ public final class IOUtils {
         }
 
         try {
-            final byte[] buffer = new byte[4096];
+            final byte[] buffer = new byte[64 * 1024];
             while (stream.read(buffer) > -1) {
                 // just consume
             }
@@ -138,6 +165,9 @@ public final class IOUtils {
 
     /**
      * Consumes and closes the provided reader.
+     * 
+     * @param reader
+     *            the reader
      */
     @SuppressWarnings({ "PMD.EmptyCatchBlock", "PMD.EmptyWhileStmt" })
     public static void consumeAndClose(final Reader reader) {
@@ -146,7 +176,7 @@ public final class IOUtils {
         }
 
         try {
-            final char[] buffer = new char[4096];
+            final char[] buffer = new char[64 * 1024];
             while (reader.read(buffer) > -1) {
                 // just consume
             }
@@ -158,7 +188,48 @@ public final class IOUtils {
     }
 
     /**
-     * Reads lines from an UTF-8 encoded stream.
+     * Copies all bytes of an input stream to an output stream.
+     * 
+     * Neither the input stream nor the output stream will the closed after the
+     * copy.
+     * 
+     * @param in
+     *            the input stream, must not be {@code null}
+     * @param out
+     *            the output stream, must not be {@code null}
+     */
+    public static void copy(InputStream in, OutputStream out) throws IOException {
+        copy(in, out, 64 * 1024);
+    }
+
+    /**
+     * Copies all bytes of an input stream to an output stream.
+     * 
+     * Neither the input stream nor the output stream will the closed after the
+     * copy.
+     * 
+     * @param in
+     *            the input stream, must not be {@code null}
+     * @param out
+     *            the output stream, must not be {@code null}
+     * @param bufferSize
+     *            the size of the internal buffer, must be positive
+     */
+    public static void copy(InputStream in, OutputStream out, int bufferSize) throws IOException {
+        assert in != null;
+        assert out != null;
+        assert bufferSize > 0;
+
+        int b;
+        byte[] buffer = new byte[bufferSize];
+
+        while ((b = in.read(buffer)) > -1) {
+            out.write(buffer, 0, b);
+        }
+    }
+
+    /**
+     * Reads lines from an UTF-8 encoded stream and closes the stream.
      * 
      * @param stream
      *            the stream
@@ -186,7 +257,10 @@ public final class IOUtils {
     }
 
     /**
-     * Reads the first line from a stream.
+     * Reads the first line from a stream and closes the stream.
+     * 
+     * @param stream
+     *            the input stream
      */
     public static String readFirstLine(InputStream stream) throws IOException {
         final StringBuilder result = new StringBuilder();
@@ -202,7 +276,10 @@ public final class IOUtils {
     }
 
     /**
-     * Reads all lines from a stream.
+     * Reads all lines from a stream and closes the stream.
+     * 
+     * @param stream
+     *            the input stream
      */
     public static String readAllLines(InputStream stream) throws IOException {
         final StringBuilder result = new StringBuilder();
@@ -219,7 +296,10 @@ public final class IOUtils {
     }
 
     /**
-     * Reads all lines from a stream and removes the header.
+     * Reads all lines from a stream, removes the header, and closes the stream.
+     * 
+     * @param stream
+     *            the input stream
      */
     public static String readAllLinesAndRemoveHeader(InputStream stream) throws IOException {
         final StringBuilder result = new StringBuilder();
@@ -238,7 +318,11 @@ public final class IOUtils {
     }
 
     /**
-     * Reads all lines from a stream and ignore all comments.
+     * Reads all lines from a stream, ignores all comments, and closes the
+     * stream.
+     * 
+     * @param stream
+     *            the input stream
      */
     public static String readAllLinesAndIgnoreComments(InputStream stream) throws IOException {
         final StringBuilder result = new StringBuilder();
@@ -257,7 +341,11 @@ public final class IOUtils {
     }
 
     /**
-     * Reads all lines from a stream and ignore all comments.
+     * Reads all lines from a stream, ignores all comments, and closes the
+     * stream.
+     * 
+     * @param stream
+     *            the input stream
      */
     public static List<String> readAllLinesAsList(InputStream stream) throws IOException {
         final List<String> result = new ArrayList<String>();
@@ -275,7 +363,11 @@ public final class IOUtils {
     }
 
     /**
-     * Reads all lines from a stream and ignore all comments.
+     * Reads all lines from a stream, ignores all comments, and closes the
+     * stream.
+     * 
+     * @param stream
+     *            the input stream
      */
     public static Map<String, String> readAllLinesAsMap(InputStream stream) throws IOException {
         final Map<String, String> result = new HashMap<String, String>();

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=1518960&r1=1518959&r2=1518960&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 Fri Aug 30 13:14:41 2013
@@ -84,15 +84,14 @@ public final class MimeHelper {
      *         encoding was actually needed
      */
     protected static boolean encodeRFC2231value(String value, StringBuilder buf) {
-        String charset = "UTF-8";
+        assert value != null;
+        assert buf != null;
+
+        String charset = IOUtils.UTF8;
         buf.append(charset);
         buf.append("''"); // no language
-        byte[] bytes;
-        try {
-            bytes = value.getBytes(charset);
-        } catch (UnsupportedEncodingException e) {
-            return true;
-        }
+        byte[] bytes = IOUtils.getUTF8Bytes(value);
+
         boolean encoded = false;
         for (int i = 0; i < bytes.length; i++) {
             int ch = bytes[i] & 0xff;
@@ -274,7 +273,7 @@ public final class MimeHelper {
                 String boundaryStr = params.get("boundary");
                 if (boundaryStr != null && boundaryStr.length() > 0) {
                     try {
-                        return boundaryStr.getBytes("ISO-8859-1");
+                        return boundaryStr.getBytes(IOUtils.ISO_8859_1);
                     } catch (UnsupportedEncodingException e) {
                         // shouldn't happen...
                         throw new CmisRuntimeException("Unsupported encoding 'ISO-8859-1'", e);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.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/XMLUtils.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java Fri Aug 30 13:14:41 2013
@@ -83,7 +83,7 @@ public final class XMLUtils {
     public static XMLStreamWriter createWriter(OutputStream out) throws XMLStreamException {
         assert out != null;
 
-        return XML_OUTPUT_FACTORY.createXMLStreamWriter(out, "UTF-8");
+        return XML_OUTPUT_FACTORY.createXMLStreamWriter(out, IOUtils.UTF8);
     }
 
     /**

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/Base64Test.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/Base64Test.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/Base64Test.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/Base64Test.java Fri Aug 30 13:14:41 2013
@@ -50,11 +50,7 @@ public class Base64Test {
 
         ByteArrayOutputStream output = new ByteArrayOutputStream();
 
-        int b;
-        byte[] buffer = new byte[4096];
-        while ((b = base64stream.read(buffer)) > -1) {
-            output.write(buffer, 0, b);
-        }
+        IOUtils.copy(base64stream, output);
 
         base64stream.close();
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/IOUtilsTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/IOUtilsTest.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/IOUtilsTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/IOUtilsTest.java Fri Aug 30 13:14:41 2013
@@ -18,16 +18,26 @@
  */
 package org.apache.chemistry.opencmis.commons.impl.misc;
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.junit.Test;
 
@@ -48,6 +58,37 @@ public class IOUtilsTest {
 
         IOUtils.consumeAndClose(stream);
         assertEquals(0, stream.available());
+
+        ByteArrayInputStream stream2 = new ByteArrayInputStream(IOUtils.getUTF8Bytes("test"));
+        InputStreamReader reader = new InputStreamReader(stream2);
+
+        IOUtils.consumeAndClose(reader);
+        assertEquals(0, stream2.available());
+
+        try {
+            reader.read();
+            fail("Reader should be closed.");
+        } catch (IOException e) {
+            // expected
+        }
+
+        IOUtils.closeQuietly(reader);
+        IOUtils.closeQuietly((Closeable) null);
+        IOUtils.closeQuietly((ContentStream) null);
+    }
+
+    @Test
+    public void testCopy() throws Exception {
+        byte[] input = IOUtils.getUTF8Bytes("test");
+        ByteArrayInputStream in = new ByteArrayInputStream(input);
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+        IOUtils.copy(in, out);
+
+        assertArrayEquals(input, out.toByteArray());
+
+        IOUtils.closeQuietly(in);
+        IOUtils.closeQuietly(out);
     }
 
     @Test

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.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/ObjectService.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java Fri Aug 30 13:14:41 2013
@@ -18,8 +18,6 @@
  */
 package org.apache.chemistry.opencmis.server.impl.atompub;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PrintWriter;
@@ -48,6 +46,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.MimeHelper;
 import org.apache.chemistry.opencmis.commons.impl.ReturnVersion;
 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
@@ -537,17 +536,14 @@ public class ObjectService {
             }
 
             // send content
-            InputStream in = new BufferedInputStream(content.getStream(), BUFFER_SIZE);
-            OutputStream out = new BufferedOutputStream(response.getOutputStream());
-
-            byte[] buffer = new byte[BUFFER_SIZE];
-            int b;
-            while ((b = in.read(buffer)) > -1) {
-                out.write(buffer, 0, b);
+            InputStream in = content.getStream();
+            OutputStream out = response.getOutputStream();
+            try {
+                IOUtils.copy(in, out, BUFFER_SIZE);
+                out.flush();
+            } finally {
+                in.close();
             }
-
-            in.close();
-            out.flush();
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/XMLDocumentBase.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/XMLDocumentBase.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/XMLDocumentBase.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/XMLDocumentBase.java Fri Aug 30 13:14:41 2013
@@ -24,6 +24,7 @@ import java.util.Map;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.XMLConstants;
 import org.apache.chemistry.opencmis.commons.impl.XMLUtils;
 
@@ -71,7 +72,7 @@ public abstract class XMLDocumentBase {
         writer = XMLUtils.createWriter(out);
 
         // start the document
-        writer.writeStartDocument("UTF-8", "1.0");
+        writer.writeStartDocument(IOUtils.UTF8, "1.0");
         setNamespaces(namespaces);
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.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/AbstractBrowserServiceCall.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/AbstractBrowserServiceCall.java Fri Aug 30 13:14:41 2013
@@ -128,7 +128,7 @@ public abstract class AbstractBrowserSer
             response.setContentLength(0);
         } else {
             response.setContentType(JSON_MIME_TYPE);
-            response.setCharacterEncoding("UTF-8");
+            response.setCharacterEncoding(IOUtils.UTF8);
 
             String callback = getStringParameter(request, Constants.PARAM_CALLBACK);
             if (callback != null) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.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/ObjectService.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/ObjectService.java Fri Aug 30 13:14:41 2013
@@ -34,8 +34,6 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_TOKEN;
 import static org.apache.chemistry.opencmis.commons.impl.Constants.PARAM_VERSIONIG_STATE;
 
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.math.BigInteger;
@@ -61,6 +59,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
 import org.apache.chemistry.opencmis.commons.impl.MimeHelper;
 import org.apache.chemistry.opencmis.commons.impl.ReturnVersion;
@@ -664,17 +663,14 @@ public class ObjectService {
             }
 
             // send content
-            InputStream in = new BufferedInputStream(content.getStream(), BUFFER_SIZE);
-            OutputStream out = new BufferedOutputStream(response.getOutputStream());
-
-            byte[] buffer = new byte[BUFFER_SIZE];
-            int b;
-            while ((b = in.read(buffer)) > -1) {
-                out.write(buffer, 0, b);
+            InputStream in = content.getStream();
+            OutputStream out = response.getOutputStream();
+            try {
+                IOUtils.copy(in, out, BUFFER_SIZE);
+                out.flush();
+            } finally {
+                in.close();
             }
-
-            in.close();
-            out.flush();
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.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/POSTHttpServletRequestWrapper.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java Fri Aug 30 13:14:41 2013
@@ -27,6 +27,7 @@ import java.util.Map;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.server.shared.HttpUtils;
 import org.apache.chemistry.opencmis.server.shared.QueryStringHttpServletRequestWrapper;
 import org.apache.chemistry.opencmis.server.shared.ThresholdOutputStreamFactory;
@@ -72,7 +73,7 @@ public class POSTHttpServletRequestWrapp
             // form data processing
             StringBuilder sb = new StringBuilder();
 
-            InputStreamReader sr = new InputStreamReader(request.getInputStream(), "UTF-8");
+            InputStreamReader sr = new InputStreamReader(request.getInputStream(), IOUtils.UTF8);
             char[] buffer = new char[4096];
             int c = 0;
             while ((c = sr.read(buffer)) > -1) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.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/webservices/CmisWebServicesServlet.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java Fri Aug 30 13:14:41 2013
@@ -18,10 +18,8 @@
  */
 package org.apache.chemistry.opencmis.server.impl.webservices;
 
-import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.lang.reflect.Method;
 import java.util.HashMap;
@@ -109,21 +107,10 @@ public class CmisWebServicesServlet exte
             throw new ServletException("Cannot find file '" + path + "'!");
         }
 
-        StringBuilder result = new StringBuilder();
-        BufferedReader reader = null;
         try {
-            reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
-
-            String line;
-            while ((line = reader.readLine()) != null) {
-                result.append(line);
-            }
-
-            return result.toString();
+            return IOUtils.readAllLines(stream);
         } catch (IOException e) {
             throw new ServletException("Cannot read file '" + path + "': " + e.getMessage(), e);
-        } finally {
-            IOUtils.closeQuietly(reader);
         }
     }
 
@@ -171,7 +158,7 @@ public class CmisWebServicesServlet exte
             throws ServletException, IOException {
         response.setStatus(HttpServletResponse.SC_OK);
         response.setContentType("text/xml");
-        response.setCharacterEncoding("UTF-8");
+        response.setCharacterEncoding(IOUtils.UTF8);
 
         String respDoc = doc;
         respDoc = BASE_PATTERN.matcher(respDoc).replaceAll(baseUrl.toString());
@@ -189,7 +176,7 @@ public class CmisWebServicesServlet exte
             throws ServletException, IOException {
         response.setStatus(HttpServletResponse.SC_OK);
         response.setContentType("text/html");
-        response.setCharacterEncoding("UTF-8");
+        response.setCharacterEncoding(IOUtils.UTF8);
 
         String urlEscaped = StringEscapeUtils.escapeHtml((new UrlBuilder(baseUrl)).addPath("cmis").addParameter("wsdl")
                 .toString());
@@ -213,7 +200,7 @@ public class CmisWebServicesServlet exte
             throws ServletException, IOException {
         response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
         response.setContentType("text/xml");
-        response.setCharacterEncoding("UTF-8");
+        response.setCharacterEncoding(IOUtils.UTF8);
 
         PrintWriter pw = response.getWriter();
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.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/AtomEntryParserTest.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java Fri Aug 30 13:14:41 2013
@@ -30,6 +30,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.data.PropertyString;
 import org.apache.chemistry.opencmis.commons.impl.Base64;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.server.impl.atompub.AtomEntryParser;
 import org.apache.chemistry.opencmis.server.shared.ThresholdOutputStreamFactory;
 import org.junit.Test;
@@ -226,12 +227,7 @@ public class AtomEntryParserTest {
 
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
-        byte[] buffer = new byte[4096];
-        int b;
-
-        while ((b = contentStream.getStream().read(buffer)) > -1) {
-            baos.write(buffer, 0, b);
-        }
+        IOUtils.copy(contentStream.getStream(), baos);
 
         return baos.toByteArray();
     }

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=1518960&r1=1518959&r2=1518960&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 Fri Aug 30 13:14:41 2013
@@ -619,23 +619,14 @@ public class FileShareRepository {
      */
     private void writeContent(File newFile, InputStream stream) {
         OutputStream out = null;
-        InputStream in = null;
         try {
-            out = new BufferedOutputStream(new FileOutputStream(newFile), BUFFER_SIZE);
-            in = new BufferedInputStream(stream, BUFFER_SIZE);
-
-            byte[] buffer = new byte[BUFFER_SIZE];
-            int b;
-            while ((b = in.read(buffer)) > -1) {
-                out.write(buffer, 0, b);
-            }
-
-            out.flush();
+            out = new FileOutputStream(newFile);
+            IOUtils.copy(stream, out, BUFFER_SIZE);
         } catch (IOException e) {
             throw new CmisStorageException("Could not write content: " + e.getMessage(), e);
         } finally {
             IOUtils.closeQuietly(out);
-            IOUtils.closeQuietly(in);
+            IOUtils.closeQuietly(stream);
         }
     }
 
@@ -758,20 +749,15 @@ public class FileShareRepository {
         OutputStream out = null;
         InputStream in = null;
         try {
-            out = new BufferedOutputStream(new FileOutputStream(file, append), BUFFER_SIZE);
+            out = new FileOutputStream(file, append);
 
             if (contentStream == null || contentStream.getStream() == null) {
                 // delete content
                 out.write(new byte[0]);
             } else {
                 // set content
-                in = new BufferedInputStream(contentStream.getStream(), BUFFER_SIZE);
-
-                byte[] buffer = new byte[BUFFER_SIZE];
-                int b;
-                while ((b = in.read(buffer)) > -1) {
-                    out.write(buffer, 0, b);
-                }
+                in = contentStream.getStream();
+                IOUtils.copy(in, out, BUFFER_SIZE);
             }
         } catch (Exception e) {
             throw new CmisStorageException("Could not write content: " + e.getMessage(), e);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java Fri Aug 30 13:14:41 2013
@@ -75,6 +75,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateObjectIdAndChangeTokenImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
@@ -1443,12 +1444,8 @@ public class ObjectServiceTest extends A
         content.setMimeType(contentType);
 
         ByteArrayOutputStream ba = new ByteArrayOutputStream();
-        byte[] buffer = new byte[65536];
-        int noBytesRead = 0;
 
-        while ((noBytesRead = is.read(buffer)) >= 0) {
-            ba.write(buffer, 0, noBytesRead);
-        }
+        IOUtils.copy(is, ba, 64 * 1024);
 
         content.setContent(new ByteArrayInputStream(ba.toByteArray()));
 

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=1518960&r1=1518959&r2=1518960&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 Fri Aug 30 13:14:41 2013
@@ -235,7 +235,7 @@ public abstract class AbstractSessionTes
         }
 
         StringBuilder sb = new StringBuilder();
-        Reader reader = new InputStreamReader(contentStream.getStream(), "UTF-8");
+        Reader reader = new InputStreamReader(contentStream.getStream(), IOUtils.UTF8);
 
         try {
             final char[] buffer = new char[64 * 1024];

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/main/ObjGenApp.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/main/ObjGenApp.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/main/ObjGenApp.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/main/ObjGenApp.java Fri Aug 30 13:14:41 2013
@@ -168,7 +168,7 @@ public class ObjGenApp {
                     + BINDING_ATOM + " or " + BINDING_BROWSER);
             return;
         }
-        
+
         String kind = options.valueOf(fContentKindStr);
         if (null == kind) {
             if (options.valueOf(fContentSize) > 0) {
@@ -191,7 +191,7 @@ public class ObjGenApp {
         }
 
         initClientBindings();
-        
+
         if (null == options.valueOf(fCmd)) {
             System.out.println("No command given.");
             usage(parser);
@@ -246,8 +246,8 @@ public class ObjGenApp {
             String documentType, String folderType, int contentSizeInKB, String rootFolderId, boolean doCleanup) {
 
         MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator.prepareForCreateTree(
-                binding, repoId, docsPerFolder, foldersPerFolders, depth, documentType, folderType,
-                contentSizeInKB, rootFolderId, fContentKind, doCleanup);
+                binding, repoId, docsPerFolder, foldersPerFolders, depth, documentType, folderType, contentSizeInKB,
+                rootFolderId, fContentKind, doCleanup);
         ObjectGenerator gen = runner.getObjectGenerator();
         runner.doCreateTree();
 
@@ -270,8 +270,8 @@ public class ObjGenApp {
 
         // Step 2: fill each root folder with an object tree
         MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
-                .prepareForCreateTreeMT(binding, repoId, docsPerFolder, foldersPerFolders, depth,
-                        documentType, folderType, contentSizeInKB, folderIds, fContentKind, doCleanup);
+                .prepareForCreateTreeMT(binding, repoId, docsPerFolder, foldersPerFolders, depth, documentType,
+                        folderType, contentSizeInKB, folderIds, fContentKind, doCleanup);
 
         MultiThreadedObjectGenerator.runMultiThreaded(runners);
         System.out.println("Filling repository succeeded.");
@@ -356,8 +356,8 @@ public class ObjGenApp {
             int docCount, boolean doCleanup) {
 
         MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
-                .prepareForCreateDocument(binding, repoId, documentType, contentSizeInKB, rootFolderId,
-                        docCount, fContentKind, doCleanup);
+                .prepareForCreateDocument(binding, repoId, documentType, contentSizeInKB, rootFolderId, docCount,
+                        fContentKind, doCleanup);
         ObjectGenerator gen = runner.getObjectGenerator();
         String[] ids = runner.doCreateDocument();
         System.out.println();
@@ -380,8 +380,8 @@ public class ObjGenApp {
             String rootFolderId, int docCount, boolean doCleanup) {
 
         MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
-                .prepareForCreateDocumentMT(noThreads, binding, repoId, documentType, contentSizeInKB,
-                        rootFolderId, docCount, fContentKind, doCleanup);
+                .prepareForCreateDocumentMT(noThreads, binding, repoId, documentType, contentSizeInKB, rootFolderId,
+                        docCount, fContentKind, doCleanup);
 
         MultiThreadedObjectGenerator.runMultiThreaded(runners);
         System.out.println("Document creation succeeded. All threads terminated.");
@@ -412,8 +412,7 @@ public class ObjGenApp {
             boolean doCleanup) {
 
         MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
-                .prepareForCreateFolderMT(noThreads, binding, repoId, folderType, rootFolderId, noFolders,
-                        doCleanup);
+                .prepareForCreateFolderMT(noThreads, binding, repoId, folderType, rootFolderId, noFolders, doCleanup);
         MultiThreadedObjectGenerator.runMultiThreaded(runners);
         System.out.println("Folder creation succeeded.");
     }
@@ -479,11 +478,9 @@ public class ObjGenApp {
                 // write to a file:
                 is = contentStream.getStream();
                 os = new FileOutputStream(fileName);
-                byte[] b = new byte[BUFSIZE];
-                int read;
-                while ((read = is.read(b)) != -1) {
-                    os.write(b, 0, read);
-                }
+
+                IOUtils.copy(is, os, BUFSIZE);
+
                 is.close();
                 is = null;
                 os.close();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java Fri Aug 30 13:14:41 2013
@@ -21,7 +21,6 @@ package org.apache.chemistry.opencmis.ut
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -45,6 +44,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
 import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
 import org.apache.chemistry.opencmis.commons.spi.NavigationService;
@@ -519,11 +519,8 @@ public class ObjectGenerator {
 
         LoremIpsum ipsum = new LoremIpsum();
         String text = ipsum.generateParagraphsFullHtml(len, true);
-        try {
-            content.setStream(new ByteArrayInputStream(text.getBytes("UTF-8")));
-        } catch (UnsupportedEncodingException e) {
-            LOG.error("Unsupported Encoding Exception", e);
-        }
+
+        content.setStream(new ByteArrayInputStream(IOUtils.getUTF8Bytes(text)));
         return content;
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java?rev=1518960&r1=1518959&r2=1518960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.java Fri Aug 30 13:14:41 2013
@@ -34,7 +34,6 @@ import java.awt.datatransfer.StringSelec
 import java.awt.datatransfer.Transferable;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -343,14 +342,8 @@ public final class ClientHelper {
     private static void storeStream(InputStream in, File file) throws IOException {
         OutputStream out = null;
         try {
-            out = new BufferedOutputStream(new FileOutputStream(file), BUFFER_SIZE);
-
-            byte[] buffer = new byte[BUFFER_SIZE];
-            int b;
-            while ((b = in.read(buffer)) > -1) {
-                out.write(buffer, 0, b);
-            }
-
+            out = new FileOutputStream(file);
+            IOUtils.copy(in, out, BUFFER_SIZE);
         } finally {
             IOUtils.closeQuietly(in);
             IOUtils.closeQuietly(out);
@@ -700,7 +693,7 @@ public final class ClientHelper {
             engine.put("session", model.getClientSession().getSession());
             engine.put("binding", model.getClientSession().getSession().getBinding());
             engine.put("out", new PrintWriter(out));
-            engine.eval(new InputStreamReader(new FileInputStream(file), "UTF-8"));
+            engine.eval(new InputStreamReader(new FileInputStream(file), IOUtils.UTF8));
         } catch (Exception ex) {
             ClientHelper.showError(null, ex);
         } finally {



Mime
View raw message