You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2013/08/12 23:50:46 UTC

svn commit: r1513272 [1/2] - in /chemistry/opencmis/trunk: chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/ chemistry-opencmis-client/chemistry-opencmis-client-bindings...

Author: fmui
Date: Mon Aug 12 21:50:45 2013
New Revision: 1513272

URL: http://svn.apache.org/r1513272
Log:
more code clean up

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/IOUtils.java
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/ContentTypeCacheLevelImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.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/cookies/CmisHttpCookie.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/AbstractApacheClientHttpInvoker.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/ApacheClientHttpInvoker.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/DefaultHttpInvoker.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-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CXFPortProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunJREPortProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunRIPortProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/WebSpherePortProvider.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
    chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/util/FileUtils.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/DateTimeHelper.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/XMLUtils.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/JSONParseException.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/Yytoken.java
    chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/DateTimeTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/filter/ProxyHttpServletRequestWrapper.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.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/AbstractBrowserServiceCall.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserCallContextImpl.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/main/java/org/apache/chemistry/opencmis/server/impl/webservices/CmisWebServicesServlet.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/AbstractServiceCall.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.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-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/AbstractRunner.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersionDeleteTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/main/ObjGenApp.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/specexamples/Main.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ClientHelper.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/ExpertLoginTab.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderTable.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/InfoDialog.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/actions/AppendContentStreamPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckInPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoPanel.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/ContentTypeCacheLevelImpl.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/cache/impl/ContentTypeCacheLevelImpl.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/ContentTypeCacheLevelImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/cache/impl/ContentTypeCacheLevelImpl.java Mon Aug 12 21:50:45 2013
@@ -126,9 +126,9 @@ public class ContentTypeCacheLevelImpl e
 
             // write parameters sorted by key
             for (Map.Entry<String, String> entry : parameter.entrySet()) {
-                sb.append(";");
+                sb.append(';');
                 sb.append(entry.getKey());
-                sb.append("=");
+                sb.append('=');
                 sb.append(entry.getValue());
             }
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.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/StandardAuthenticationProvider.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/StandardAuthenticationProvider.java Mon Aug 12 21:50:45 2013
@@ -223,7 +223,7 @@ public class StandardAuthenticationProvi
                     + Base64.encodeBytes((username + ":" + password).getBytes("UTF-8")));
         } catch (UnsupportedEncodingException e) {
             // shouldn't happen...
-            return Collections.emptyList();
+            throw new CmisRuntimeException("Unsupported encoding 'UTF-8'", e);
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.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/AtomPubParser.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/AtomPubParser.java Mon Aug 12 21:50:45 2013
@@ -66,6 +66,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.commons.data.ObjectData;
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.XMLConstants;
 import org.apache.chemistry.opencmis.commons.impl.XMLConstraints;
 import org.apache.chemistry.opencmis.commons.impl.XMLConverter;
@@ -144,10 +145,7 @@ public class AtomPubParser {
             } catch (Exception e) {
             }
 
-            try {
-                stream.close();
-            } catch (Exception e) {
-            }
+            IOUtils.closeQuietly(stream);
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.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/AbstractBrowserBindingService.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/browser/AbstractBrowserBindingService.java Mon Aug 12 21:50:45 2013
@@ -52,6 +52,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException;
 import org.apache.chemistry.opencmis.commons.impl.Constants;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.JSONConstants;
 import org.apache.chemistry.opencmis.commons.impl.JSONConverter;
 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
@@ -370,20 +371,7 @@ public abstract class AbstractBrowserBin
      */
     protected void postAndConsume(UrlBuilder url, String contentType, Output writer) {
         Response resp = post(url, contentType, writer);
-
-        InputStream stream = resp.getStream();
-        try {
-            byte[] buffer = new byte[4096];
-            while (stream.read(buffer) > -1) {
-            }
-        } catch (Exception e) {
-            // ignore
-        } finally {
-            try {
-                stream.close();
-            } catch (Exception e) {
-            }
-        }
+        IOUtils.consumeAndClose(resp.getStream());
     }
 
     // ---- URL ----

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -132,7 +132,7 @@ public class CmisCookieStoreImpl impleme
                                 if (newHost.endsWith(newDomain)) {
                                     if (newHost.length() == newDomain.length()) {
                                         cookies.add(cookie);
-                                    } else if (newDomain.startsWith(".")) {
+                                    } else if (newDomain.charAt(0) == '.') {
                                         cookies.add(cookie);
                                     }
                                 }
@@ -152,7 +152,7 @@ public class CmisCookieStoreImpl impleme
     }
 
     private boolean isIPAddress(String s) {
-        if (s.startsWith("[")) {
+        if (s.charAt(0) == '[') {
             // IPv6
             return true;
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisHttpCookie.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/CmisHttpCookie.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisHttpCookie.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/cookies/CmisHttpCookie.java Mon Aug 12 21:50:45 2013
@@ -258,7 +258,7 @@ public final class CmisHttpCookie implem
     private String commentURL;
     private boolean discard;
     private String domain;
-    private long maxAge = -1l;
+    private long maxAge = -1L;
     private String name;
     private String path;
     private String portList;
@@ -428,8 +428,8 @@ public final class CmisHttpCookie implem
 
     private void attrToString(StringBuilder builder, String attrName, String attrValue) {
         if (attrValue != null && builder != null) {
-            builder.append(";");
-            builder.append("$");
+            builder.append(';');
+            builder.append('$');
             builder.append(attrName);
             builder.append("=\"");
             builder.append(attrValue);
@@ -445,7 +445,7 @@ public final class CmisHttpCookie implem
     @Override
     public Object clone() {
         try {
-            return (CmisHttpCookie) super.clone();
+            return super.clone();
         } catch (CloneNotSupportedException e) {
             return null;
         }
@@ -595,12 +595,12 @@ public final class CmisHttpCookie implem
     public boolean hasExpired() {
         // -1 indicates the cookie will persist until browser shutdown
         // so the cookie is not expired.
-        if (maxAge == -1l) {
+        if (maxAge == -1L) {
             return false;
         }
 
         boolean expired = false;
-        if (maxAge <= 0l) {
+        if (maxAge <= 0L) {
             expired = true;
         }
         return expired;
@@ -625,7 +625,7 @@ public final class CmisHttpCookie implem
     private boolean isValidName(String n) {
         // name cannot be empty or begin with '$' or equals the reserved
         // attributes (case-insensitive)
-        boolean isValid = !(n.length() == 0 || n.startsWith("$") || attributeSet.containsKey(n.toLowerCase()));
+        boolean isValid = !(n.length() == 0 || n.charAt(0) == '$' || attributeSet.containsKey(n.toLowerCase()));
         if (isValid) {
             for (int i = 0; i < n.length(); i++) {
                 char nameChar = n.charAt(i);
@@ -776,7 +776,7 @@ public final class CmisHttpCookie implem
     public String toString() {
         StringBuilder cookieStr = new StringBuilder();
         cookieStr.append(name);
-        cookieStr.append("=");
+        cookieStr.append('=');
         if (version == 0) {
             cookieStr.append(value);
         } else if (version == 1) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/AbstractApacheClientHttpInvoker.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/AbstractApacheClientHttpInvoker.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/AbstractApacheClientHttpInvoker.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/AbstractApacheClientHttpInvoker.java Mon Aug 12 21:50:45 2013
@@ -171,7 +171,7 @@ public abstract class AbstractApacheClie
                 }
 
                 sb.append(offset.toString());
-                sb.append("-");
+                sb.append('-');
 
                 if ((length != null) && (length.signum() == 1)) {
                     sb.append(offset.add(length.subtract(BigInteger.ONE)).toString());

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/ApacheClientHttpInvoker.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/ApacheClientHttpInvoker.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/ApacheClientHttpInvoker.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/ApacheClientHttpInvoker.java Mon Aug 12 21:50:45 2013
@@ -119,7 +119,7 @@ public class ApacheClientHttpInvoker ext
             }
 
             public Socket createSocket(HttpParams params) throws IOException {
-                return (SSLSocket) sf.createSocket();
+                return sf.createSocket();
             }
 
             public Socket connectSocket(final Socket socket, final InetSocketAddress remoteAddress,

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/DefaultHttpInvoker.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/DefaultHttpInvoker.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/DefaultHttpInvoker.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/DefaultHttpInvoker.java Mon Aug 12 21:50:45 2013
@@ -154,7 +154,7 @@ public class DefaultHttpInvoker implemen
                 }
 
                 sb.append(offset.toString());
-                sb.append("-");
+                sb.append('-');
 
                 if ((length != null) && (length.signum() == 1)) {
                     sb.append(offset.add(length.subtract(BigInteger.ONE)).toString());

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -33,6 +33,7 @@ import java.util.zip.InflaterInputStream
 
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
 import org.apache.chemistry.opencmis.commons.impl.Base64;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 
 /**
  * HTTP Response.
@@ -112,18 +113,10 @@ public class Response {
                     }
                 }
             } else {
-                try {
-                    errorStream.close();
-                } catch (IOException e) {
-                }
+                IOUtils.closeQuietly(errorStream);
             }
 
-            if (responseStream != null) {
-                try {
-                    responseStream.close();
-                } catch (IOException e) {
-                }
-            }
+            IOUtils.closeQuietly(responseStream);
 
             return;
         }
@@ -164,10 +157,7 @@ public class Response {
                         } catch (IOException e) {
                             errorContent = e.getMessage();
                             stream = null;
-                            try {
-                                responseStream.close();
-                            } catch (IOException ec) {
-                            }
+                            IOUtils.closeQuietly(responseStream);
                         }
                     } else if (encoding.toLowerCase().trim().equals("deflate")) {
                         // if the stream is deflate encoded, decode it

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -585,8 +585,7 @@ public abstract class AbstractPortProvid
                     continue;
                 }
 
-                NodeList portList = ((Element) serviceNode).getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/",
-                        "port");
+                NodeList portList = serviceNode.getElementsByTagNameNS("http://schemas.xmlsoap.org/wsdl/", "port");
                 if (portList.getLength() < 1) {
                     throw new CmisRuntimeException("This service has no ports: " + service.getServiceName());
                 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CXFPortProvider.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/CXFPortProvider.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CXFPortProvider.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/CXFPortProvider.java Mon Aug 12 21:50:45 2013
@@ -61,7 +61,7 @@ public class CXFPortProvider extends Abs
             // create port object
             BindingProvider portObject = createPortObjectFromServiceHolder(serviceHolder, new MTOMFeature());
 
-            Binding binding = ((BindingProvider) portObject).getBinding();
+            Binding binding = portObject.getBinding();
             ((SOAPBinding) binding).setMTOMEnabled(true);
 
             // add SOAP and HTTP authentication headers
@@ -71,7 +71,7 @@ public class CXFPortProvider extends Abs
                 // SOAP header
                 Element soapHeader = authProvider.getSOAPHeaders(portObject);
                 if (soapHeader != null) {
-                    ((BindingProvider) portObject).getRequestContext().put(
+                    portObject.getRequestContext().put(
                             Header.HEADER_LIST,
                             Collections.singletonList(new Header(new QName(soapHeader.getNamespaceURI(), soapHeader
                                     .getLocalName()), soapHeader)));

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunJREPortProvider.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/SunJREPortProvider.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunJREPortProvider.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunJREPortProvider.java Mon Aug 12 21:50:45 2013
@@ -71,8 +71,7 @@ public class SunJREPortProvider extends 
 
             // set streaming for services that transport content
             if (serviceHolder.getService().handlesContent()) {
-                ((BindingProvider) portObject).getRequestContext().put(
-                        JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, CHUNK_SIZE);
+                portObject.getRequestContext().put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, CHUNK_SIZE);
             }
 
             // add SOAP and HTTP authentication headers

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunRIPortProvider.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/SunRIPortProvider.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunRIPortProvider.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/SunRIPortProvider.java Mon Aug 12 21:50:45 2013
@@ -71,8 +71,7 @@ public class SunRIPortProvider extends A
 
             // set streaming for services that transport content
             if (serviceHolder.getService().handlesContent()) {
-                ((BindingProvider) portObject).getRequestContext().put(
-                        JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, CHUNK_SIZE);
+                portObject.getRequestContext().put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, CHUNK_SIZE);
             }
 
             // add SOAP and HTTP authentication headers

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/WebSpherePortProvider.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/WebSpherePortProvider.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/WebSpherePortProvider.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/webservices/WebSpherePortProvider.java Mon Aug 12 21:50:45 2013
@@ -98,12 +98,12 @@ public class WebSpherePortProvider exten
             // timeouts
             int connectTimeout = getSession().get(SessionParameter.CONNECT_TIMEOUT, -1);
             if (connectTimeout >= 0) {
-                ((BindingProvider) portObject).getRequestContext().put("connection_timeout", connectTimeout);
+                portObject.getRequestContext().put("connection_timeout", connectTimeout);
             }
 
             int readTimeout = getSession().get(SessionParameter.READ_TIMEOUT, -1);
             if (readTimeout >= 0) {
-                ((BindingProvider) portObject).getRequestContext().put("request_timeout", readTimeout);
+                portObject.getRequestContext().put("request_timeout", readTimeout);
             }
 
             return portObject;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/OperationContextImpl.java Mon Aug 12 21:50:45 2013
@@ -188,7 +188,7 @@ public class OperationContextImpl implem
 
         for (String oid : this.filter) {
             if (sb.length() > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             sb.append(oid);
@@ -304,7 +304,7 @@ public class OperationContextImpl implem
 
         for (String rf : this.renditionFilter) {
             if (sb.length() > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             sb.append(rf);
@@ -352,15 +352,15 @@ public class OperationContextImpl implem
 
         StringBuilder sb = new StringBuilder();
 
-        sb.append(includeAcls ? "1" : "0");
-        sb.append(includeAllowableActions ? "1" : "0");
-        sb.append(includePolicies ? "1" : "0");
-        sb.append("|");
+        sb.append(includeAcls ? '1' : '0');
+        sb.append(includeAllowableActions ? '1' : '0');
+        sb.append(includePolicies ? '1' : '0');
+        sb.append('|');
         sb.append(filter == null ? "" : getFilterString());
-        sb.append("|");
+        sb.append('|');
         sb.append(includeRelationships == null ? "" : includeRelationships.value());
 
-        sb.append("|");
+        sb.append('|');
         sb.append(renditionFilter == null ? "" : getRenditionFilterString());
 
         cacheKey = sb.toString();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementImpl.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/QueryStatementImpl.java Mon Aug 12 21:50:45 2013
@@ -112,7 +112,7 @@ public class QueryStatementImpl implemen
             }
 
             if (sb.length() > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             sb.append(n.toString());
@@ -133,7 +133,7 @@ public class QueryStatementImpl implemen
             }
 
             if (sb.length() > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             sb.append(escape(s));
@@ -142,7 +142,6 @@ public class QueryStatementImpl implemen
         parametersMap.put(parameterIndex, sb.toString());
     }
 
-
     public void setStringContains(int parameterIndex, String str) {
         if (str == null) {
             throw new IllegalArgumentException("String must be set!");
@@ -171,7 +170,7 @@ public class QueryStatementImpl implemen
             }
 
             if (sb.length() > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             sb.append(escape(oid.getId()));
@@ -192,7 +191,7 @@ public class QueryStatementImpl implemen
             }
 
             if (sb.length() > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             sb.append(escape(u.toString()));
@@ -213,7 +212,7 @@ public class QueryStatementImpl implemen
             }
 
             if (sb.length() > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             sb.append(escape(u.toString()));
@@ -230,7 +229,7 @@ public class QueryStatementImpl implemen
         StringBuilder sb = new StringBuilder();
         for (boolean b : bool) {
             if (sb.length() > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             sb.append(b ? "TRUE" : "FALSE");
@@ -259,7 +258,7 @@ public class QueryStatementImpl implemen
             }
 
             if (sb.length() > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             if (prefix) {
@@ -292,7 +291,7 @@ public class QueryStatementImpl implemen
             }
 
             if (sb.length() > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             if (prefix) {
@@ -321,7 +320,7 @@ public class QueryStatementImpl implemen
         StringBuilder sb = new StringBuilder();
         for (long l : ms) {
             if (sb.length() > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             if (prefix) {
@@ -394,13 +393,13 @@ public class QueryStatementImpl implemen
             char c = str.charAt(i);
 
             if (c == '\'' || c == '\\') {
-                sb.append("\\");
+                sb.append('\\');
             }
 
             sb.append(c);
         }
 
-        sb.append("'");
+        sb.append('\'');
 
         return sb.toString();
     }
@@ -411,19 +410,19 @@ public class QueryStatementImpl implemen
             char c = str.charAt(i);
 
             if (c == '\'') {
-                sb.append("\\");
+                sb.append('\\');
             } else if (c == '\\') {
                 if (i + 1 < str.length() && (str.charAt(i + 1) == '%' || str.charAt(i + 1) == '_')) {
                     // no additional back slash
                 } else {
-                    sb.append("\\");
+                    sb.append('\\');
                 }
             }
 
             sb.append(c);
         }
 
-        sb.append("'");
+        sb.append('\'');
 
         return sb.toString();
     }
@@ -434,7 +433,7 @@ public class QueryStatementImpl implemen
             char c = str.charAt(i);
 
             if (c == '\\') {
-                sb.append("\\");
+                sb.append('\\');
             } else if (c == '\'' || c == '\"') {
                 sb.append("\\\\\\");
             }
@@ -442,7 +441,7 @@ public class QueryStatementImpl implemen
             sb.append(c);
         }
 
-        sb.append("'");
+        sb.append('\'');
 
         return sb.toString();
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/runtime/SessionImpl.java Mon Aug 12 21:50:45 2013
@@ -637,7 +637,7 @@ public class SessionImpl implements Sess
 
         String select = ctxt.getFilterString();
         if (select == null) {
-            statement.append("*");
+            statement.append('*');
         } else {
             statement.append(select);
         }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/util/FileUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/util/FileUtils.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/util/FileUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/main/java/org/apache/chemistry/opencmis/client/util/FileUtils.java Mon Aug 12 21:50:45 2013
@@ -70,12 +70,12 @@ public class FileUtils {
         if (session == null) {
             throw new IllegalArgumentException("session must be set!");
         }
-        if (pathOrIdOfObject == null) {
+        if (pathOrIdOfObject == null || pathOrIdOfObject.length() == 0) {
             throw new IllegalArgumentException("pathOrIdOfObject must be set!");
         }
 
         CmisObject result = null;
-        if (pathOrIdOfObject.startsWith("/")) {
+        if (pathOrIdOfObject.charAt(0) == '/') {
             result = session.getObjectByPath(pathOrIdOfObject);
         } else {
             result = session.getObject(pathOrIdOfObject);

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -88,8 +88,8 @@ public final class Base64 {
 
     private static final byte WHITE_SPACE_ENC = -5; // Indicates white space in
                                                     // encoding
-                                                    private static final byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in
-                                                    // encoding
+    private static final byte EQUALS_SIGN_ENC = -1; // Indicates equals sign in
+    // encoding
 
     /* ******** S T A N D A R D B A S E 6 4 A L P H A B E T ******** */
 
@@ -594,22 +594,10 @@ public final class Base64 {
             throw e;
         } // end catch
         finally {
-            try {
-                oos.close();
-            } catch (Exception e) {
-            }
-            try {
-                gzos.close();
-            } catch (Exception e) {
-            }
-            try {
-                b64os.close();
-            } catch (Exception e) {
-            }
-            try {
-                baos.close();
-            } catch (Exception e) {
-            }
+            IOUtils.closeQuietly(oos);
+            IOUtils.closeQuietly(gzos);
+            IOUtils.closeQuietly(b64os);
+            IOUtils.closeQuietly(baos);
         } // end finally
 
         // Return value according to relevant encoding.
@@ -872,18 +860,9 @@ public final class Base64 {
                 throw e;
             } // end catch
             finally {
-                try {
-                    gzos.close();
-                } catch (Exception e) {
-                }
-                try {
-                    b64os.close();
-                } catch (Exception e) {
-                }
-                try {
-                    baos.close();
-                } catch (Exception e) {
-                }
+                IOUtils.closeQuietly(gzos);
+                IOUtils.closeQuietly(b64os);
+                IOUtils.closeQuietly(baos);
             } // end finally
 
             return baos.toByteArray();
@@ -1246,18 +1225,9 @@ public final class Base64 {
                     // Just return originally-decoded bytes
                 } // end catch
                 finally {
-                    try {
-                        baos.close();
-                    } catch (Exception e) {
-                    }
-                    try {
-                        gzis.close();
-                    } catch (Exception e) {
-                    }
-                    try {
-                        bais.close();
-                    } catch (Exception e) {
-                    }
+                    IOUtils.closeQuietly(baos);
+                    IOUtils.closeQuietly(gzis);
+                    IOUtils.closeQuietly(bais);
                 } // end finally
 
             } // end if: gzipped
@@ -1352,14 +1322,8 @@ public final class Base64 {
             throw e; // Catch and throw in order to execute finally{}
         } // end catch
         finally {
-            try {
-                bais.close();
-            } catch (Exception e) {
-            }
-            try {
-                ois.close();
-            } catch (Exception e) {
-            }
+            IOUtils.closeQuietly(bais);
+            IOUtils.closeQuietly(ois);
         } // end finally
 
         return obj;
@@ -1400,10 +1364,7 @@ public final class Base64 {
             throw e; // Catch and throw to execute finally{} block
         } // end catch: java.io.IOException
         finally {
-            try {
-                bos.close();
-            } catch (Exception e) {
-            }
+            IOUtils.closeQuietly(bos);
         } // end finally
 
     } // end encodeToFile
@@ -1437,10 +1398,7 @@ public final class Base64 {
             throw e; // Catch and throw to execute finally{} block
         } // end catch: java.io.IOException
         finally {
-            try {
-                bos.close();
-            } catch (Exception e) {
-            }
+            IOUtils.closeQuietly(bos);
         } // end finally
 
     } // end decodeToFile
@@ -1498,10 +1456,7 @@ public final class Base64 {
             throw e; // Catch and release to execute finally{}
         } // end catch: java.io.IOException
         finally {
-            try {
-                bis.close();
-            } catch (Exception e) {
-            }
+            IOUtils.closeQuietly(bis);
         } // end finally
 
         return decodedData;
@@ -1567,10 +1522,7 @@ public final class Base64 {
             throw e; // Catch and release to execute finally{}
         } // end catch: java.io.IOException
         finally {
-            try {
-                bis.close();
-            } catch (Exception e) {
-            }
+            IOUtils.closeQuietly(bis);
         } // end finally
 
         return encodedData;
@@ -1599,10 +1551,7 @@ public final class Base64 {
             throw e; // Catch and release to execute finally{}
         } // end catch
         finally {
-            try {
-                out.close();
-            } catch (Exception ex) {
-            }
+            IOUtils.closeQuietly(out);
         } // end finally
     } // end encodeFileToFile
 
@@ -1629,10 +1578,7 @@ public final class Base64 {
             throw e; // Catch and release to execute finally{}
         } // end catch
         finally {
-            try {
-                out.close();
-            } catch (Exception ex) {
-            }
+            IOUtils.closeQuietly(out);
         } // end finally
     } // end decodeFileToFile
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/DateTimeHelper.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/DateTimeHelper.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/DateTimeHelper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/DateTimeHelper.java Mon Aug 12 21:50:45 2013
@@ -145,16 +145,16 @@ public class DateTimeHelper {
 
         int tz = cal.getTimeZone().getOffset(cal.getTimeInMillis());
         if (tz == 0) {
-            sb.append("Z");
+            sb.append('Z');
         } else {
             if (tz > 0) {
-                sb.append("+");
+                sb.append('+');
             } else {
-                sb.append("-");
+                sb.append('-');
                 tz *= -1;
             }
             add2d(sb, tz / 3600000);
-            sb.append(":");
+            sb.append(':');
             int tzm = tz % 3600000;
             add2d(sb, tzm == 0 ? 0 : tzm / 60000);
         }
@@ -171,7 +171,7 @@ public class DateTimeHelper {
         }
 
         s = s.trim();
-        if (s.length() > 1 && s.startsWith("'") && s.endsWith("'")) {
+        if (s.length() > 1 && s.charAt(0) == '\'' && s.endsWith("'")) {
             s = s.substring(1, s.length() - 1);
         }
 

Added: 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=1513272&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/IOUtils.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/IOUtils.java Mon Aug 12 21:50:45 2013
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+package org.apache.chemistry.opencmis.commons.impl;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+
+public class IOUtils {
+
+    /**
+     * Closes a stream and ignores any exceptions.
+     */
+    public static void closeQuietly(final Closeable closeable) {
+        try {
+            if (closeable != null) {
+                closeable.close();
+            }
+        } catch (final IOException ioe) {
+            // ignore
+        }
+    }
+
+    /**
+     * Closes the stream of a {@link ContentStream} object and ignores any
+     * exceptions.
+     */
+    public static void closeQuietly(final ContentStream contentStream) {
+        if (contentStream != null) {
+            closeQuietly(contentStream.getStream());
+        }
+    }
+
+    /**
+     * Consumes and closes the provided stream.
+     */
+    public static void consumeAndClose(final InputStream stream) {
+        try {
+            byte[] buffer = new byte[4096];
+            while (stream.read(buffer) > -1) {
+            }
+        } catch (IOException e) {
+            // ignore
+        } finally {
+            IOUtils.closeQuietly(stream);
+        }
+    }
+}

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.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/JSONConverter.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/JSONConverter.java Mon Aug 12 21:50:45 2013
@@ -579,7 +579,7 @@ public final class JSONConverter {
         if (permissions != null) {
             List<PermissionDefinition> permissionDefinitionList = new ArrayList<PermissionDefinition>();
 
-            for (Object permission : (List<Object>) permissions) {
+            for (Object permission : permissions) {
                 Map<String, Object> permissionMap = getMap(permission);
                 if (permissionMap != null) {
                     PermissionDefinitionDataImpl permDef = new PermissionDefinitionDataImpl();
@@ -600,7 +600,7 @@ public final class JSONConverter {
         if (permissionMapping != null) {
             Map<String, PermissionMapping> permMap = new HashMap<String, PermissionMapping>();
 
-            for (Object permission : (List<Object>) permissionMapping) {
+            for (Object permission : permissionMapping) {
                 Map<String, Object> permissionMap = getMap(permission);
                 if (permissionMap != null) {
                     PermissionMappingDataImpl mapping = new PermissionMappingDataImpl();
@@ -1777,7 +1777,7 @@ public final class JSONConverter {
                 if (children instanceof List) {
                     container.setChildren(convertTypeDescendants((List<Object>) children));
                 } else {
-                    container.setChildren((List<TypeDefinitionContainer>) Collections.EMPTY_LIST);
+                    container.setChildren(Collections.<TypeDefinitionContainer> emptyList());
                 }
 
                 convertExtension(jsonContainer, container, TYPESCONTAINER_KEYS);
@@ -2791,12 +2791,12 @@ public final class JSONConverter {
             throw new CmisRuntimeException("Invalid Boolean value!");
         case INTEGER:
             if (value instanceof BigInteger) {
-                return (BigInteger) value;
+                return value;
             }
             throw new CmisRuntimeException("Invalid Integer value!");
         case DECIMAL:
             if (value instanceof BigDecimal) {
-                return (BigDecimal) value;
+                return value;
             }
             throw new CmisRuntimeException("Invalid Decimal value!");
         case DATETIME:

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.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/UrlBuilder.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/UrlBuilder.java Mon Aug 12 21:50:45 2013
@@ -27,6 +27,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.RelationshipDirection;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 
 /**
  * Utility class that helps building URLs.
@@ -89,7 +90,7 @@ public class UrlBuilder {
         urlPart.append("://");
         urlPart.append(host);
         if (port > 0) {
-            urlPart.append(":").append(port);
+            urlPart.append(':').append(port);
         }
         if (path != null) {
             urlPart.append(path);
@@ -127,6 +128,7 @@ public class UrlBuilder {
         try {
             queryPart.append(URLEncoder.encode(valueStr, "UTF-8"));
         } catch (UnsupportedEncodingException e) {
+            throw new CmisRuntimeException("Unsupported encoding 'UTF-8'.", e);
         }
 
         return this;

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -50,6 +50,7 @@ public class XMLUtils {
             XML_INPUT_FACTORY.setProperty("reuse-instance", Boolean.FALSE);
             LOG.warn("You are using an unsupported StAX parser.");
         } catch (IllegalArgumentException ex) {
+            // expected for Woodstox
         }
 
         XML_INPUT_FACTORY.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/JSONParseException.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/json/parser/JSONParseException.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/JSONParseException.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/JSONParseException.java Mon Aug 12 21:50:45 2013
@@ -95,17 +95,17 @@ public class JSONParseException extends 
         switch (errorType) {
         case ERROR_UNEXPECTED_CHAR:
             sb.append("Unexpected character (").append(unexpectedObject).append(") at position ").append(position)
-                    .append(".");
+                    .append('.');
             break;
         case ERROR_UNEXPECTED_TOKEN:
             sb.append("Unexpected token ").append(unexpectedObject).append(" at position ").append(position)
-                    .append(".");
+                    .append('.');
             break;
         case ERROR_UNEXPECTED_EXCEPTION:
             sb.append("Unexpected exception at position ").append(position).append(": ").append(unexpectedObject);
             break;
         default:
-            sb.append("Unkown error at position ").append(position).append(".");
+            sb.append("Unkown error at position ").append(position).append('.');
             break;
         }
         return sb.toString();

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/Yytoken.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/json/parser/Yytoken.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/Yytoken.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/json/parser/Yytoken.java Mon Aug 12 21:50:45 2013
@@ -47,7 +47,7 @@ public class Yytoken {
         StringBuilder sb = new StringBuilder();
         switch (type) {
         case TYPE_VALUE:
-            sb.append("VALUE(").append(value).append(")");
+            sb.append("VALUE(").append(value).append(')');
             break;
         case TYPE_LEFT_BRACE:
             sb.append("LEFT BRACE({)");

Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/DateTimeTest.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/DateTimeTest.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/DateTimeTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/test/java/org/apache/chemistry/opencmis/commons/impl/misc/DateTimeTest.java Mon Aug 12 21:50:45 2013
@@ -56,9 +56,9 @@ public class DateTimeTest {
         GregorianCalendar cal3 = DateTimeHelper.parseXmlDateTime("2013-01-02T03:04:05.678+05:00");
         assertEquals(2013, cal3.get(Calendar.YEAR));
         assertEquals(0, cal3.get(Calendar.MONTH));
-        assertEquals(02, cal3.get(Calendar.DAY_OF_MONTH));
-        assertEquals(03, cal3.get(Calendar.HOUR_OF_DAY));
-        assertEquals(04, cal3.get(Calendar.MINUTE));
+        assertEquals(2, cal3.get(Calendar.DAY_OF_MONTH));
+        assertEquals(3, cal3.get(Calendar.HOUR_OF_DAY));
+        assertEquals(4, cal3.get(Calendar.MINUTE));
         assertEquals(5, cal3.get(Calendar.SECOND));
         assertEquals(678, cal3.get(Calendar.MILLISECOND));
         assertEquals(5 * 60 * 60 * 1000, cal3.getTimeZone().getRawOffset());

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/filter/ProxyHttpServletRequestWrapper.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/filter/ProxyHttpServletRequestWrapper.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/filter/ProxyHttpServletRequestWrapper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/filter/ProxyHttpServletRequestWrapper.java Mon Aug 12 21:50:45 2013
@@ -65,11 +65,11 @@ public class ProxyHttpServletRequestWrap
 
         servletPath = request.getServletPath();
 
-        if (basePath != null) {
+        if (basePath != null && basePath.length() > 0) {
             final String path = request.getRequestURI().substring(
                     request.getContextPath().length() + request.getServletPath().length());
 
-            contextPath = (basePath.startsWith("/") ? basePath : "/" + basePath);
+            contextPath = (basePath.charAt(0) == '/' ? basePath : "/" + basePath);
             requestURI = contextPath + servletPath + path;
         } else {
             contextPath = request.getContextPath();
@@ -121,7 +121,7 @@ public class ProxyHttpServletRequestWrap
         sb.append(scheme);
         sb.append("://");
         sb.append(serverName);
-        sb.append(":");
+        sb.append(':');
         sb.append(serverPort);
         sb.append(getRequestURI());
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.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/CmisRepositoryContextListener.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CmisRepositoryContextListener.java Mon Aug 12 21:50:45 2013
@@ -29,6 +29,7 @@ import javax.servlet.ServletContextEvent
 import javax.servlet.ServletContextListener;
 
 import org.apache.chemistry.opencmis.commons.impl.ClassLoaderUtil;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -87,10 +88,7 @@ public class CmisRepositoryContextListen
             LOG.warn("Cannot load configuration: " + e, e);
             return null;
         } finally {
-            try {
-                stream.close();
-            } catch (IOException ioe) {
-            }
+            IOUtils.closeQuietly(stream);
         }
 
         // get 'class' property

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.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/AtomDocumentBase.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomDocumentBase.java Mon Aug 12 21:50:45 2013
@@ -26,6 +26,7 @@ import java.util.GregorianCalendar;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.Base64;
 import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.impl.DateTimeHelper;
@@ -180,6 +181,7 @@ public abstract class AtomDocumentBase e
             writeLink(Constants.REL_SERVICE, href + "?repositoryId=" + URLEncoder.encode(repositoryId, "UTF-8"),
                     Constants.MEDIATYPE_SERVICE, null);
         } catch (UnsupportedEncodingException e) {
+            throw new CmisRuntimeException("Unsupported encoding 'UTF-8'", e);
         }
     }
 

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -591,7 +591,7 @@ public class AtomEntryParser {
             prefix = "";
         }
 
-        Iterator<String> iter = (Iterator<String>) writer.getNamespaceContext().getPrefixes(namespaceUri);
+        Iterator<String> iter = writer.getNamespaceContext().getPrefixes(namespaceUri);
         if (iter == null) {
             return;
         }

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -44,6 +44,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
 import org.apache.chemistry.opencmis.commons.impl.Base64;
 import org.apache.chemistry.opencmis.commons.impl.Constants;
 import org.apache.chemistry.opencmis.commons.impl.TypeCache;
@@ -208,6 +209,7 @@ public abstract class AbstractBrowserSer
             try {
                 cookieValue = URLEncoder.encode(value, "UTF-8");
             } catch (UnsupportedEncodingException e) {
+                throw new CmisRuntimeException("Unsupported encoding 'UTF-8'", e);
             }
 
             Cookie transactionCookie = new Cookie(getCookieName(token), cookieValue);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserCallContextImpl.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/BrowserCallContextImpl.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserCallContextImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/BrowserCallContextImpl.java Mon Aug 12 21:50:45 2013
@@ -153,7 +153,7 @@ public class BrowserCallContextImpl exte
                 continue;
             }
 
-            sb.append("/");
+            sb.append('/');
             sb.append(pathFragments[i]);
         }
 

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -34,6 +34,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.server.shared.ThresholdOutputStream;
 import org.apache.chemistry.opencmis.server.shared.ThresholdOutputStreamFactory;
@@ -534,13 +535,7 @@ public class MultipartParser {
 
             return true;
         } catch (IOException e) {
-            if (contentStream != null) {
-                try {
-                    contentStream.close();
-                } catch (Exception e2) {
-                    // ignore
-                }
-            }
+            IOUtils.closeQuietly(contentStream);
 
             skipEpilogue();
 
@@ -575,11 +570,7 @@ public class MultipartParser {
             }
         } catch (Exception e) {
             if (contentStream != null) {
-                try {
-                    contentStream.close();
-                } catch (Exception e2) {
-                    // ignore
-                }
+                IOUtils.closeQuietly(contentStream);
             }
 
             skipEpilogue();

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -37,6 +37,7 @@ import javax.xml.ws.WebServiceFeature;
 
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.UrlBuilder;
 import org.apache.chemistry.opencmis.commons.server.CmisServiceFactory;
 import org.apache.chemistry.opencmis.server.impl.CmisRepositoryContextListener;
@@ -122,13 +123,7 @@ public class CmisWebServicesServlet exte
         } catch (IOException e) {
             throw new ServletException("Cannot read file '" + path + "': " + e.getMessage(), e);
         } finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                } catch (IOException e) {
-                    // ignore
-                }
-            }
+            IOUtils.closeQuietly(reader);
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/AbstractServiceCall.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/shared/AbstractServiceCall.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/AbstractServiceCall.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/AbstractServiceCall.java Mon Aug 12 21:50:45 2013
@@ -33,6 +33,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.impl.CmisEnumHelper;
 import org.apache.chemistry.opencmis.commons.impl.DateTimeHelper;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 
 public abstract class AbstractServiceCall implements ServiceCall {
 
@@ -106,13 +107,7 @@ public abstract class AbstractServiceCal
      * Closes a content stream.
      */
     public void closeContentStream(ContentStream contentStream) {
-        if (contentStream != null && contentStream.getStream() != null) {
-            try {
-                contentStream.getStream().close();
-            } catch (IOException e) {
-                // we tried our best
-            }
-        }
+        IOUtils.closeQuietly(contentStream);
     }
 
     /**
@@ -157,7 +152,7 @@ public abstract class AbstractServiceCal
             if (chcs.getETag() != null) {
                 String etag = request.getHeader("If-None-Match");
                 if (etag != null && !etag.equals("*")) {
-                    if (etag.length() > 2 && etag.startsWith("\"") && etag.endsWith("\"")) {
+                    if (etag.length() > 2 && etag.charAt(0) == '"' && etag.endsWith("\"")) {
                         etag = etag.substring(1, etag.length() - 1);
                     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.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/shared/HttpUtils.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java Mon Aug 12 21:50:45 2013
@@ -37,7 +37,7 @@ public class HttpUtils {
         }
 
         @SuppressWarnings("unchecked")
-        Map<String, String[]> parameters = (Map<String, String[]>) request.getParameterMap();
+        Map<String, String[]> parameters = request.getParameterMap();
         for (Map.Entry<String, String[]> parameter : parameters.entrySet()) {
             if (name.equalsIgnoreCase(parameter.getKey())) {
                 if (parameter.getValue() == null) {
@@ -67,7 +67,7 @@ public class HttpUtils {
                 result[i] = URLDecoder.decode(result[i], "UTF-8");
             } catch (UnsupportedEncodingException e) {
                 // should not happen
-                throw new CmisRuntimeException(e.getMessage(), e);
+                throw new CmisRuntimeException("Unsupported encoding 'UTF-8'", e);
             }
         }
 

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -54,6 +54,7 @@ import javax.xml.transform.TransformerFa
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -192,13 +193,7 @@ public class LoggingFilter implements Fi
             if (pw != null) {
                 pw.close();
             }
-            if (fw != null) {
-                try {
-                    fw.close();
-                } catch (IOException e) {
-                    e.printStackTrace();
-                }
-            }
+            IOUtils.closeQuietly(fw);
         }
     }