chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1513272 [2/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...
Date Mon, 12 Aug 2013 21:50:46 GMT
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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -19,11 +19,11 @@
 package org.apache.chemistry.opencmis.tck.impl;
 
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.FAILURE;
+import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.INFO;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.OK;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.UNEXPECTED_EXCEPTION;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
-import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.INFO;
 
 import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
@@ -89,6 +89,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
 import org.apache.chemistry.opencmis.tck.CmisTestResultStatus;
@@ -1389,10 +1390,7 @@ public abstract class AbstractSessionTes
         } catch (Exception e) {
             addResult(results, createResult(FAILURE, "Reading content failed: " + e, e, false));
         } finally {
-            try {
-                stream.close();
-            } catch (Exception e) {
-            }
+            IOUtils.closeQuietly(stream);
         }
     }
 
@@ -1460,10 +1458,7 @@ public abstract class AbstractSessionTes
                             } catch (Exception e) {
                                 addResult(results, createResult(FAILURE, "Reading content failed: " + e, e, false));
                             } finally {
-                                try {
-                                    stream.close();
-                                } catch (Exception e) {
-                                }
+                                IOUtils.closeQuietly(stream);
                             }
                         }
                     }
@@ -3176,10 +3171,7 @@ public abstract class AbstractSessionTes
             f = createResult(FAILURE, "Expected stream is null, but actual stream is not!");
             addResultChild(failure, f);
 
-            try {
-                actual.getStream().close();
-            } catch (Exception e) {
-            }
+            IOUtils.closeQuietly(actual);
 
             return failure;
         }
@@ -3188,10 +3180,7 @@ public abstract class AbstractSessionTes
             f = createResult(FAILURE, "Actual object is null, but expected object is not!");
             addResultChild(failure, f);
 
-            try {
-                expected.getStream().close();
-            } catch (Exception e) {
-            }
+            IOUtils.closeQuietly(expected);
 
             return failure;
         }
@@ -3241,15 +3230,8 @@ public abstract class AbstractSessionTes
             addResultChild(failure, f);
         }
 
-        try {
-            as.close();
-        } catch (Exception e) {
-        }
-
-        try {
-            es.close();
-        } catch (Exception e) {
-        }
+        IOUtils.closeQuietly(as);
+        IOUtils.closeQuietly(es);
 
         if (getWorst(results).getLevel() <= OK.getLevel()) {
             for (CmisTestResult result : results) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/AbstractRunner.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/runner/AbstractRunner.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/AbstractRunner.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/runner/AbstractRunner.java Mon Aug 12 21:50:45 2013
@@ -30,6 +30,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.chemistry.opencmis.commons.impl.ClassLoaderUtil;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.tck.CmisTest;
 import org.apache.chemistry.opencmis.tck.CmisTestGroup;
 import org.apache.chemistry.opencmis.tck.CmisTestProgressMonitor;
@@ -112,12 +113,7 @@ public abstract class AbstractRunner {
 
             setParameters(loadParams);
         } finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                } catch (Exception e) {
-                }
-            }
+            IOUtils.closeQuietly(reader);
         }
     }
 
@@ -204,12 +200,7 @@ public abstract class AbstractRunner {
                 addGroup(line);
             }
         } finally {
-            if (reader != null) {
-                try {
-                    reader.close();
-                } catch (Exception e) {
-                }
-            }
+            IOUtils.closeQuietly(reader);
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.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/tests/crud/CreateAndDeleteDocumentTest.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/CreateAndDeleteDocumentTest.java Mon Aug 12 21:50:45 2013
@@ -22,7 +22,6 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.INFO;
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.WARNING;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -38,6 +37,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.OperationContext;
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
 import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
 
@@ -63,7 +63,7 @@ public class CreateAndDeleteDocumentTest
 
         OperationContext orderContext = (isOrderByNameSupported(session) ? SELECT_ALL_NO_CACHE_OC_ORDER_BY_NAME
                 : SELECT_ALL_NO_CACHE_OC);
-        
+
         // create a test folder
         Folder testFolder = createTestFolder(session);
 
@@ -119,8 +119,7 @@ public class CreateAndDeleteDocumentTest
             CmisObject lastObject = null;
 
             int count = 0;
-            ItemIterable<CmisObject> page1 = testFolder.getChildren(orderContext).getPage(
-                    pageSize);
+            ItemIterable<CmisObject> page1 = testFolder.getChildren(orderContext).getPage(pageSize);
             for (CmisObject child : page1) {
                 count++;
                 lastObject = child;
@@ -141,8 +140,8 @@ public class CreateAndDeleteDocumentTest
 
             // check second page
             count = 0;
-            ItemIterable<CmisObject> page2 = testFolder.getChildren(orderContext)
-                    .skipTo(pageSize - 1).getPage(pageSize);
+            ItemIterable<CmisObject> page2 = testFolder.getChildren(orderContext).skipTo(pageSize - 1)
+                    .getPage(pageSize);
             for (CmisObject child : page2) {
                 count++;
 
@@ -168,8 +167,8 @@ public class CreateAndDeleteDocumentTest
 
             // check third page
             count = 0;
-            ItemIterable<CmisObject> page3 = testFolder.getChildren(orderContext)
-                    .skipTo(numOfDocuments - 5).getPage(10);
+            ItemIterable<CmisObject> page3 = testFolder.getChildren(orderContext).skipTo(numOfDocuments - 5)
+                    .getPage(10);
             for (@SuppressWarnings("unused")
             CmisObject child : page3) {
                 count++;
@@ -191,8 +190,8 @@ public class CreateAndDeleteDocumentTest
 
             // check non-existing page
             count = 0;
-            ItemIterable<CmisObject> pageNotExisting = testFolder.getChildren(orderContext)
-                    .skipTo(100000).getPage(pageSize);
+            ItemIterable<CmisObject> pageNotExisting = testFolder.getChildren(orderContext).skipTo(100000)
+                    .getPage(pageSize);
             for (@SuppressWarnings("unused")
             CmisObject child : pageNotExisting) {
                 count++;
@@ -218,10 +217,7 @@ public class CreateAndDeleteDocumentTest
                     addResult(createResult(FAILURE, "Document has no content! Id: " + document.getId()));
                     continue;
                 } else {
-                    try {
-                        contentStream.getStream().close();
-                    } catch (IOException e) {
-                    }
+                    IOUtils.closeQuietly(contentStream);
                 }
 
                 // TODO: content checks

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.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/tests/crud/SetAndDeleteContentTest.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/crud/SetAndDeleteContentTest.java Mon Aug 12 21:50:45 2013
@@ -40,6 +40,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
 import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
 import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
 
@@ -132,10 +133,7 @@ public class SetAndDeleteContentTest ext
 
                 ObjectId newObjectId = workDoc.setContentStream(contentStream, true, true);
 
-                try {
-                    contentStream.getStream().close();
-                } catch (Exception e) {
-                }
+                IOUtils.closeQuietly(contentStream);
 
                 // setContentStream may have created a new version
                 Document contentDoc = getNewVersion(session, workDoc, checkedout, newObjectId, "setContentStream()");

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersionDeleteTest.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/tests/versioning/VersionDeleteTest.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersionDeleteTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tck/src/main/java/org/apache/chemistry/opencmis/tck/tests/versioning/VersionDeleteTest.java Mon Aug 12 21:50:45 2013
@@ -22,7 +22,6 @@ import static org.apache.chemistry.openc
 import static org.apache.chemistry.opencmis.tck.CmisTestResultStatus.SKIPPED;
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
 import java.util.List;
@@ -34,6 +33,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.client.api.Session;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
 import org.apache.chemistry.opencmis.tck.CmisTestResult;
 import org.apache.chemistry.opencmis.tck.impl.AbstractSessionTest;
@@ -97,10 +97,8 @@ public class VersionDeleteTest extends A
                 "text/plain", new ByteArrayInputStream(contentBytes));
 
         ObjectId newVersionId = pwc.checkIn(true, null, contentStream, "test version " + version);
-        try {
-            contentStream.getStream().close();
-        } catch (IOException ioe) {
-        }
+
+        IOUtils.closeQuietly(contentStream);
 
         Document newVersion = (Document) session.getObject(newVersionId, SELECT_ALL_NO_CACHE_OC);
 

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -39,6 +39,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
 import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
 import org.apache.chemistry.opencmis.tools.filecopy.FileCopier;
@@ -514,15 +515,8 @@ public class ObjGenApp {
             System.err.println("Error generating file: " + e);
             e.printStackTrace();
         } finally {
-            try {
-                if (null != is) {
-                    is.close();
-                }
-                if (null != os) {
-                    os.close();
-                }
-            } catch (IOException e) {
-            }
+            IOUtils.closeQuietly(is);
+            IOUtils.closeQuietly(os);
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/specexamples/Main.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/specexamples/Main.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/specexamples/Main.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-tools/src/main/java/org/apache/chemistry/opencmis/tools/specexamples/Main.java Mon Aug 12 21:50:45 2013
@@ -54,6 +54,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl;
 import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
@@ -75,21 +76,33 @@ import org.slf4j.LoggerFactory;
 public class Main {
 
     private static final String MULTIFILED_DOCUMENT = "MultifiledDocument";
-	private static final String MULTIFILED_FOLDER_2 = "MultifiledFolder2";
-	private static final String MULTIFILED_FOLDER_1 = "MultifiledFolder1";
-	private static final Logger LOG = LoggerFactory.getLogger(Main.class.getName());
+    private static final String MULTIFILED_FOLDER_2 = "MultifiledFolder2";
+    private static final String MULTIFILED_FOLDER_1 = "MultifiledFolder1";
+    private static final Logger LOG = LoggerFactory.getLogger(Main.class.getName());
     private static final BigInteger TYPE_DEPTH_ALL = BigInteger.valueOf(-1);
     private static final BigInteger MAX_ITEMS = null;
     private static final BigInteger SKIP_COUNT = BigInteger.valueOf(0);
     private static final String TOPLEVEL_TYPE = "DocumentTopLevel";
     private static final String VERSIONED_TYPE = "VersionableType";
     private static final String VERSIONED_PROP = "VersionedStringProp";
-    private static String LOGDIR = System.getProperty("java.io.tmpdir");// + File.separator;
-    private static String ROOT_URL = "http://localhost:8080/inmemory"; 
-    private static String ROOT_URL_OASIS = "http://www.example.com:8080/inmemory"; // required by OASIS rules, add this host to your hosts file
+    private static String LOGDIR = System.getProperty("java.io.tmpdir");// +
+                                                                        // File.separator;
+    private static String ROOT_URL = "http://localhost:8080/inmemory";
+    private static String ROOT_URL_OASIS = "http://www.example.com:8080/inmemory"; // required
+                                                                                   // by
+                                                                                   // OASIS
+                                                                                   // rules,
+                                                                                   // add
+                                                                                   // this
+                                                                                   // host
+                                                                                   // to
+                                                                                   // your
+                                                                                   // hosts
+                                                                                   // file
     static int NO_FILES_LOGGED = 0;
 
-    private String targetDir = System.getProperty("java.io.tmpdir");// + File.separator;
+    private String targetDir = System.getProperty("java.io.tmpdir");// +
+                                                                    // File.separator;
     private BindingsObjectFactory objFactory = new BindingsObjectFactoryImpl();
     private BindingType bindingType;
     private String rootFolderId;
@@ -101,80 +114,79 @@ public class Main {
     private MultiFilingService multiSvc;
     private DiscoveryService discSvc;
     private AclService aclSvc;
-    
+
     private List<String> idsToDelete = new ArrayList<String>();
     private String multiFiledDoc;
     private String multiFiledFolder1;
     private String multiFiledFolder2;
-	private String changeToken;
-    
-    private static final String[] URLS = {ROOT_URL + "/atom", 
-        ROOT_URL + "/services", 
-        ROOT_URL + "/browser"};
-    private static final BindingType[] BINDINGS = {BindingType.ATOMPUB, BindingType.WEBSERVICES, BindingType.BROWSER};
+    private String changeToken;
+
+    private static final String[] URLS = { ROOT_URL + "/atom", ROOT_URL + "/services", ROOT_URL + "/browser" };
+    private static final BindingType[] BINDINGS = { BindingType.ATOMPUB, BindingType.WEBSERVICES, BindingType.BROWSER };
 
     public Main() {
     }
 
     public void runAllBindings() {
-    	cleanLogFilterDir(); // delete directory where Logging filter writes to ensure not to include unwanted files        
+        cleanLogFilterDir(); // delete directory where Logging filter writes to
+                             // ensure not to include unwanted files
+
+        for (int i = 0; i < BINDINGS.length; i++) {
+            bindingType = BINDINGS[i];
+            init(URLS[i], BINDINGS[i]);
+            run();
+        }
+        String dirs[] = { BindingType.ATOMPUB.value(), BindingType.WEBSERVICES.value(), BindingType.BROWSER.value() };
+        createZipFile("CMIS-Spec-Examples.zip", dirs);
 
-    	for (int i = 0; i < BINDINGS.length; i++) {
-    		bindingType = BINDINGS[i];
-    		init(URLS[i], BINDINGS[i]);
-    		run();
-    	}
-    	String dirs[] = {BindingType.ATOMPUB.value(), BindingType.WEBSERVICES.value(), BindingType.BROWSER.value() };        
-    	createZipFile("CMIS-Spec-Examples.zip", dirs);
-     
     }
-    
+
     public void run() {
         LOG.debug("Generating spec examples for Binding: " + bindingType.value());
-        
+
         try {
-        // Repository Service:
-        getRepositories();
+            // Repository Service:
+            getRepositories();
+
+            repositoryId = "A1";
+            getRepositoryInfo(); // get root folder id here!
+
+            getTypeDefinition("cmis:folder");
+
+            String docId = getTestDocId();
+            String folderId = getTestFolderId();
+
+            getTypeChildren(TOPLEVEL_TYPE);
+
+            // Navigation Service:
+            getChildren(folderId);
+            getDescendants(folderId);
+            getObjectParents(folderId);
+            removeObjectFromFolder();
+
+            // Object Service:
+            getObject(docId);
+            getAcl(docId);
+            String id1 = createDocument("SampleDocument", TOPLEVEL_TYPE, rootFolderId, VersioningState.NONE);
+            updateProperties(id1, PropertyIds.NAME, "RenamedDocument");
+            getAllowableActions(id1);
+
+            deleteObject(id1);
 
-        repositoryId = "A1";
-        getRepositoryInfo(); // get root folder id here!
+            // Discovery Service:
+            doQuery();
+            getContentChanges(changeToken);
 
-        getTypeDefinition("cmis:folder");
-        
-        String docId = getTestDocId();
-        String folderId = getTestFolderId();
-
-        getTypeChildren(TOPLEVEL_TYPE);
-
-        // Navigation Service:
-        getChildren(folderId);
-        getDescendants(folderId);
-        getObjectParents(folderId);
-        removeObjectFromFolder();
-
-        // Object Service:
-        getObject(docId);
-        getAcl(docId);
-        String id1 = createDocument("SampleDocument", TOPLEVEL_TYPE, rootFolderId, VersioningState.NONE);
-        updateProperties(id1, PropertyIds.NAME, "RenamedDocument");
-        getAllowableActions(id1);
-        
-        deleteObject(id1);
-
-        // Discovery Service:
-        doQuery();
-        getContentChanges(changeToken);
-
-        // Versioning Service
-        String id2 = prepareVersionSeries("VersionedDocument", VERSIONED_TYPE, rootFolderId);
-        checkOut(id2);
-        checkIn(id2, true, "final version in series");
-        getAllVersions(id2);
+            // Versioning Service
+            String id2 = prepareVersionSeries("VersionedDocument", VERSIONED_TYPE, rootFolderId);
+            checkOut(id2);
+            checkIn(id2, true, "final version in series");
+            getAllVersions(id2);
 
-        // collect all captured files and store them in a ZIP file
+            // collect all captured files and store them in a ZIP file
         } catch (Exception e) {
-        	LOG.error("Failed to create spec examples: ", e);
-        } 
+            LOG.error("Failed to create spec examples: ", e);
+        }
 
         // delete all generated objects
         cleanup();
@@ -194,24 +206,24 @@ public class Main {
         // get factory and create binding
         CmisBindingFactory factory = CmisBindingFactory.newInstance();
         CmisBinding binding = null;
-        
-        if (bindingType == BindingType.ATOMPUB)  {
+
+        if (bindingType == BindingType.ATOMPUB) {
             parameters.put(SessionParameter.ATOMPUB_URL, url);
             binding = factory.createCmisAtomPubBinding(parameters);
         } else if (bindingType == BindingType.WEBSERVICES) {
             parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url + "/ACLService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE,  url + "/DiscoveryService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE,  url + "/MultiFilingService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE,  url + "/NavigationService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE,  url + "/ObjectService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE,  url + "/PolicyService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE,  url + "/RelatinshipService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE,  url + "/RepositoryService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE,  url + "/VersioningService?wsdl");
-            binding = factory.createCmisWebServicesBinding(parameters);            
+            parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url + "/DiscoveryService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url + "/MultiFilingService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url + "/NavigationService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url + "/ObjectService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url + "/PolicyService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url + "/RelatinshipService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url + "/RepositoryService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url + "/VersioningService?wsdl");
+            binding = factory.createCmisWebServicesBinding(parameters);
         } else if (bindingType == BindingType.BROWSER) {
-            parameters.put(SessionParameter.BROWSER_URL, url); 
-            binding = factory.createCmisBrowserBinding(parameters);            
+            parameters.put(SessionParameter.BROWSER_URL, url);
+            binding = factory.createCmisBrowserBinding(parameters);
         } else {
             LOG.error("Unknown binding type: " + bindingType.value());
             return;
@@ -224,13 +236,14 @@ public class Main {
         multiSvc = binding.getMultiFilingService();
         discSvc = binding.getDiscoveryService();
         aclSvc = binding.getAclService();
-        
+
         // create a folder where target files will be stored:
         targetDir = bindingType.value();
         File in = new File(targetDir);
-        deleteDirRecursive(in); // avoid that there are unwanted files from previous runs
+        deleteDirRecursive(in); // avoid that there are unwanted files from
+                                // previous runs
         boolean ok = in.mkdir();
-        
+
         LOG.debug("creating target directory for files: " + ok);
         LOG.debug("Initializing done. ");
     }
@@ -245,13 +258,18 @@ public class Main {
 
     private void getRepositoryInfo() {
         LOG.debug("getting repository info for repository " + repositoryId);
-        
-        // Because some bindings silently retrieve all repositories on the first request we call it twice
+
+        // Because some bindings silently retrieve all repositories on the first
+        // request we call it twice
         // and use a dummy extension data element to prevent caching
         RepositoryInfo repoInfo = repSvc.getRepositoryInfo(repositoryId, null);
         ExtensionDataImpl dummyExt = new ExtensionDataImpl();
         @SuppressWarnings("serial")
-		List<CmisExtensionElement> extList = new ArrayList<CmisExtensionElement>() {{ add(new CmisExtensionElementImpl("foo", "foo", null, "bar")); }};
+        List<CmisExtensionElement> extList = new ArrayList<CmisExtensionElement>() {
+            {
+                add(new CmisExtensionElementImpl("foo", "foo", null, "bar"));
+            }
+        };
         dummyExt.setExtensions(extList);
         repoInfo = repSvc.getRepositoryInfo(repositoryId, dummyExt);
 
@@ -289,32 +307,34 @@ public class Main {
         renameFiles("getDescendants");
         LOG.debug("getDescendants() done.");
     }
-    
+
     private void getObjectParents(String folderId) {
-    	// get object parents first add object to two folders then get parents
+        // get object parents first add object to two folders then get parents
         LOG.debug("getObjectsParents " + folderId);
         multiFiledFolder1 = createFolderIntern(MULTIFILED_FOLDER_1, BaseTypeId.CMIS_FOLDER.value(), folderId);
         idsToDelete.add(multiFiledFolder1);
         multiFiledFolder2 = createFolderIntern(MULTIFILED_FOLDER_2, BaseTypeId.CMIS_FOLDER.value(), folderId);
         idsToDelete.add(multiFiledFolder2);
-        multiFiledDoc = createDocumentIntern(MULTIFILED_DOCUMENT, BaseTypeId.CMIS_DOCUMENT.value(), multiFiledFolder1, VersioningState.NONE);
-        idsToDelete.add(0, multiFiledDoc); // add at the beginning must be removed before folders!
-    	multiSvc.addObjectToFolder(repositoryId, multiFiledDoc, multiFiledFolder2, true, null);
-    	navSvc.getObjectParents(repositoryId, multiFiledDoc, "*", false, IncludeRelationships.NONE, null, true, null);
+        multiFiledDoc = createDocumentIntern(MULTIFILED_DOCUMENT, BaseTypeId.CMIS_DOCUMENT.value(), multiFiledFolder1,
+                VersioningState.NONE);
+        idsToDelete.add(0, multiFiledDoc); // add at the beginning must be
+                                           // removed before folders!
+        multiSvc.addObjectToFolder(repositoryId, multiFiledDoc, multiFiledFolder2, true, null);
+        navSvc.getObjectParents(repositoryId, multiFiledDoc, "*", false, IncludeRelationships.NONE, null, true, null);
         renameFiles("getObjectParents");
         LOG.debug("getObjectParents() done.");
     }
-    
+
     private void removeObjectFromFolder() {
         LOG.debug("removeObjectFromFolder");
         multiSvc.removeObjectFromFolder(repositoryId, multiFiledDoc, multiFiledFolder2, null);
-    	renameFiles("removeObjectFromFolder");
-    	try {
-			Thread.sleep(200);
-		} catch (InterruptedException e) {
+        renameFiles("removeObjectFromFolder");
+        try {
+            Thread.sleep(200);
+        } catch (InterruptedException e) {
 
-		}
-        LOG.debug("removeObjectFromFolder() done.");    	
+        }
+        LOG.debug("removeObjectFromFolder() done.");
     }
 
     private void doQuery() {
@@ -326,12 +346,12 @@ public class Main {
         LOG.debug("doQuery() done.");
     }
 
-    private void getContentChanges(String token) {    	
+    private void getContentChanges(String token) {
         LOG.debug("getContentChanges");
         Holder<String> changeLogToken = new Holder<String>("token");
-		discSvc.getContentChanges(repositoryId, changeLogToken, false, "*", false, false, null, null);
-    	renameFiles("getContentChanges");
-        LOG.debug("getContentChanges() done.");    	
+        discSvc.getContentChanges(repositoryId, changeLogToken, false, "*", false, false, null, null);
+        renameFiles("getContentChanges");
+        LOG.debug("getContentChanges() done.");
     }
 
     private void getTypeChildren(String typeId) {
@@ -367,17 +387,18 @@ public class Main {
 
         String id = null;
         try {
-            id = objSvc.createDocument(repositoryId, props, folderId, contentStream, versioningState, policies, addACEs,
-                    removeACEs, extension);
+            id = objSvc.createDocument(repositoryId, props, folderId, contentStream, versioningState, policies,
+                    addACEs, removeACEs, extension);
         } catch (CmisBaseException e) {
-        	// folder already there, get it:
+            // folder already there, get it:
             ObjectInFolderList result = navSvc.getChildren(repositoryId, folderId, "*", null, false,
                     IncludeRelationships.NONE, null, true, MAX_ITEMS, SKIP_COUNT, null);
 
             List<ObjectInFolderData> children = result.getObjects();
             LOG.debug(" found " + children.size() + " folders in getChildren()");
             for (ObjectInFolderData child : children) {
-            	String nameChild = (String) child.getObject().getProperties().getProperties().get(PropertyIds.NAME).getFirstValue();
+                String nameChild = (String) child.getObject().getProperties().getProperties().get(PropertyIds.NAME)
+                        .getFirstValue();
                 if (name.equals(nameChild))
                     return child.getObject().getId();
             }
@@ -398,17 +419,17 @@ public class Main {
 
         String id = null;
         try {
-        id = objSvc.createFolder(repositoryId, props, parentFolderId, policies, addACEs,
-                removeACEs, extension);
+            id = objSvc.createFolder(repositoryId, props, parentFolderId, policies, addACEs, removeACEs, extension);
         } catch (CmisBaseException e) {
-        	// folder already there, get it:
+            // folder already there, get it:
             ObjectInFolderList result = navSvc.getChildren(repositoryId, parentFolderId, "*", null, false,
                     IncludeRelationships.NONE, null, true, MAX_ITEMS, SKIP_COUNT, null);
 
             List<ObjectInFolderData> children = result.getObjects();
             LOG.debug(" found " + children.size() + " folders in getChildren()");
             for (ObjectInFolderData child : children) {
-            	String nameChild = (String) child.getObject().getProperties().getProperties().get(PropertyIds.NAME).getFirstValue();
+                String nameChild = (String) child.getObject().getProperties().getProperties().get(PropertyIds.NAME)
+                        .getFirstValue();
                 if (name.equals(nameChild))
                     return child.getObject().getId();
             }
@@ -457,16 +478,16 @@ public class Main {
         LOG.debug("deleteObject() done.");
     }
 
-    private void cleanup () {
+    private void cleanup() {
         LOG.debug("cleaning up...");
         for (String id : idsToDelete) {
             LOG.debug("deleting object " + id);
-            objSvc.deleteObject(repositoryId, id, true, null);            
+            objSvc.deleteObject(repositoryId, id, true, null);
         }
         idsToDelete.clear();
         LOG.debug("... cleaning up done");
     }
-    
+
     /**
      * enumerate the children of the root folder and return the id of the first
      * document
@@ -508,19 +529,19 @@ public class Main {
 
         verSvc.checkOut(repositoryId, idHolder, null, contentCopied);
         String checkinComment = "Checkin V2.0";
-        verSvc.checkIn(repositoryId, idHolder, true /*major*/, null /*properties*/, null /*content*/,
-                checkinComment, null/*policies*/, null/*addAcl*/, null /*removeAcl*/, null /*extension*/);
+        verSvc.checkIn(repositoryId, idHolder, true /* major */, null /* properties */, null /* content */,
+                checkinComment, null/* policies */, null/* addAcl */, null /* removeAcl */, null /* extension */);
 
         verSvc.checkOut(repositoryId, idHolder, null, contentCopied);
         checkinComment = "Checkin V2.1";
-        verSvc.checkIn(repositoryId, idHolder, false /*major*/, null /*properties*/, null /*content*/,
-                checkinComment, null/*policies*/, null/*addAcl*/, null /*removeAcl*/, null /*extension*/);
-        
+        verSvc.checkIn(repositoryId, idHolder, false /* major */, null /* properties */, null /* content */,
+                checkinComment, null/* policies */, null/* addAcl */, null /* removeAcl */, null /* extension */);
+
         return idHolder.getValue();
     }
-    
+
     private void checkOut(String id) {
-        LOG.debug("checkOut()");        
+        LOG.debug("checkOut()");
         Holder<String> idHolder = new Holder<String>(id);
         Holder<Boolean> contentCopied = new Holder<Boolean>(true);
         verSvc.checkOut(repositoryId, idHolder, null, contentCopied);
@@ -535,20 +556,20 @@ public class Main {
         Properties newProps = objFactory.createPropertiesData(properties);
 
         Holder<String> idHolder = new Holder<String>(id);
-        verSvc.checkIn(repositoryId, idHolder, major /*major*/, newProps /*properties*/, null /*content*/,
-                checkinComment, null/*policies*/, null/*addAcl*/, null /*removeAcl*/, null /*extension*/);
+        verSvc.checkIn(repositoryId, idHolder, major /* major */, newProps /* properties */, null /* content */,
+                checkinComment, null/* policies */, null/* addAcl */, null /* removeAcl */, null /* extension */);
         renameFiles("checkIn");
         LOG.debug("checkIn done.");
     }
 
     private void getAllVersions(String id) {
-        LOG.debug("getAllVersions()");     
+        LOG.debug("getAllVersions()");
         verSvc.getAllVersions(repositoryId, id/* object id */, id/* series id */, "*"/* filter */,
                 false /* includeAllowableActions */, null /* extension */);
         renameFiles("getAllVersions");
         LOG.debug("getAllVersions done.");
     }
-    
+
     private void getAcl(String objectId) {
         LOG.debug("getting Acl() " + objectId);
 
@@ -564,7 +585,7 @@ public class Main {
 
         // add the new ACL and remove the old one
         aclSvc.applyAcl(repositoryId, objectId, acl, oldAcl, AclPropagation.OBJECTONLY, null);
-            
+
         aclSvc.getAcl(repositoryId, objectId, true, null);
         renameFiles("getAcl");
         LOG.debug("getting Acl() done.");
@@ -622,46 +643,38 @@ public class Main {
         else
             LOG.warn("Renaming file " + in.getAbsolutePath() + " to " + out.getAbsolutePath() + " failed.");
     }
-    
+
     private void createZipFile(String zipFileName, String[] dirs) {
-        
+
         File out = new File(zipFileName);
         if (out.exists())
             out.delete();
-        
+
         FileOutputStream fout = null;
-        ZipOutputStream zout =null;
+        ZipOutputStream zout = null;
         try {
             fout = new FileOutputStream(zipFileName);
             zout = new ZipOutputStream(fout);
-            for (String dir: dirs) {
+            for (String dir : dirs) {
                 File dirToZip = new File(dir);
                 addDirectory(zout, dir, dirToZip);
             }
         } catch (Exception e) {
             LOG.error("Creating ZIP file failed: " + e);
         } finally {
-            try {
-                if (zout != null)
-                    zout.close();
-                if (fout != null)
-                    fout.close();
-            } catch (IOException e) {
-                LOG.error(e.toString(), e);
-            }
+            IOUtils.closeQuietly(zout);
+            IOUtils.closeQuietly(fout);
         }
     }
-    
+
     private static void addDirectory(ZipOutputStream zout, String prefix, File sourceDir) throws IOException {
-        
+
         File[] files = sourceDir.listFiles();
         LOG.debug("Create Zip, adding directory " + sourceDir.getName());
-               
+
         if (null != files) {
-            for(int i=0; i < files.length; i++)
-            {
-                if(files[i].isDirectory())
-                {
+            for (int i = 0; i < files.length; i++) {
+                if (files[i].isDirectory()) {
                     addDirectory(zout, prefix + File.separator + files[i].getName(), files[i]);
                 } else {
                     LOG.debug("Create Zip, adding file " + files[i].getName());
@@ -672,30 +685,29 @@ public class Main {
                     zout.putNextEntry(new ZipEntry(zipEntryName));
 
                     int length;
-                    while((length = fin.read(buffer)) > 0)
-                    {
+                    while ((length = fin.read(buffer)) > 0) {
                         zout.write(buffer, 0, length);
                     }
 
                     zout.closeEntry();
                     fin.close();
                 }
-            }      
+            }
         }
     }
-    
+
     public static void clean() {
         LOG.debug("Cleaning generated and captured request and response logs...");
-        
+
         cleanFilesWithFilter(LOGDIR, "*-request.log");
         cleanFilesWithFilter(LOGDIR, "*-response.log");
         for (int i = 0; i < BINDINGS.length; i++) {
             String dir = BINDINGS[i].value();
-            
+
             cleanFilesWithFilter(dir, "*-request.log");
             cleanFilesWithFilter(dir, "*-response.log");
 
-            File dirToDelete = new File (dir);
+            File dirToDelete = new File(dir);
             boolean ok = dirToDelete.delete();
             if (ok)
                 LOG.debug("Deleting dir " + dirToDelete.getAbsolutePath() + " succeeded.");
@@ -703,9 +715,9 @@ public class Main {
                 LOG.warn("Deleting dir " + dirToDelete.getAbsolutePath() + " failed.");
         }
         new File("./target/logs/log4j.log").delete();
-        LOG.debug("... done.");        
+        LOG.debug("... done.");
     }
-    
+
     private static void cleanFilesWithFilter(String directoryPath, String wildcardFilter) {
         File dir = new File(directoryPath);
         FileFilter fileFilter = new WildcardFileFilter(wildcardFilter);
@@ -714,32 +726,33 @@ public class Main {
             for (int i = 0; i < files.length; i++) {
                 boolean ok = files[i].delete();
                 LOG.debug("Deleting file: " + files[i] + ", success: " + ok);
-            }        
+            }
     }
-    
+
     private static String findLastFile(String directoryPath, String wildcardFilter) {
         File dir = new File(directoryPath);
         FileFilter fileFilter = new WildcardFileFilter(wildcardFilter);
         File[] files = dir.listFiles(fileFilter);
         LOG.debug("Number of files in filter dir " + files.length);
         if (files.length < NO_FILES_LOGGED) {
-        	LOG.warn("WARNING TOO FEW FILES!");
-        	// There might be some problem with disk caching, seems that listFiles
-        	// does not always get the most recent state, ugly workaround
-        	try {
-				Thread.sleep(250);
-			} catch (InterruptedException e) {
-			}
-        	files = dir.listFiles(fileFilter);
-            if (files.length < NO_FILES_LOGGED) 
-            	LOG.error("WARNING TOO FEW FILES EVEN AFTER SECOND TRY!!!");
+            LOG.warn("WARNING TOO FEW FILES!");
+            // There might be some problem with disk caching, seems that
+            // listFiles
+            // does not always get the most recent state, ugly workaround
+            try {
+                Thread.sleep(250);
+            } catch (InterruptedException e) {
+            }
+            files = dir.listFiles(fileFilter);
+            if (files.length < NO_FILES_LOGGED)
+                LOG.error("WARNING TOO FEW FILES EVEN AFTER SECOND TRY!!!");
         }
         NO_FILES_LOGGED = files.length;
         Arrays.sort(files);
         if (files.length == 0)
             return null;
         else
-            return files[files.length-1].getAbsolutePath();
+            return files[files.length - 1].getAbsolutePath();
     }
 
     public static void main(String[] args) {
@@ -754,21 +767,20 @@ public class Main {
             LOG.debug("... finished generating spec examples.");
         }
     }
-    
+
     static private boolean deleteDirRecursive(File path) {
-        if( path.exists() ) {
-          File[] files = path.listFiles();
-          for(int i=0; i<files.length; i++) {
-             if(files[i].isDirectory()) {
-                 deleteDirRecursive(files[i]);
-             }
-             else {
-               files[i].delete();
-             }
-          }
+        if (path.exists()) {
+            File[] files = path.listFiles();
+            for (int i = 0; i < files.length; i++) {
+                if (files[i].isDirectory()) {
+                    deleteDirRecursive(files[i]);
+                } else {
+                    files[i].delete();
+                }
+            }
         }
-        return( path.delete() );
-      }
+        return (path.delete());
+    }
 
     private void cleanLogFilterDir() {
         File dir = new File(LOGDIR);

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=1513272&r1=1513271&r2=1513272&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 Mon Aug 12 21:50:45 2013
@@ -85,6 +85,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.BindingType;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.MimeTypes;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 import org.slf4j.Logger;
@@ -352,18 +353,8 @@ public class ClientHelper {
             }
 
         } finally {
-            if (in != null) {
-                try {
-                    in.close();
-                } catch (Exception e) {
-                }
-            }
-            if (out != null) {
-                try {
-                    out.close();
-                } catch (Exception e) {
-                }
-            }
+            IOUtils.closeQuietly(in);
+            IOUtils.closeQuietly(out);
         }
     }
 
@@ -403,7 +394,7 @@ public class ClientHelper {
 
         for (int col = 0; col < cols; col++) {
             if (col > 0) {
-                sb.append(",");
+                sb.append(',');
             }
 
             sb.append(formatCSVValue(table.getModel().getColumnName(col)));
@@ -414,7 +405,7 @@ public class ClientHelper {
         for (int row = 0; row < rows; row++) {
             for (int col = 0; col < cols; col++) {
                 if (col > 0) {
-                    sb.append(",");
+                    sb.append(',');
                 }
 
                 Object value = table.getModel().getValueAt(row, col);
@@ -452,16 +443,16 @@ public class ClientHelper {
             return sb.toString();
         } else if (value instanceof Collection<?>) {
             StringBuffer sb = new StringBuffer();
-            sb.append("[");
+            sb.append('[');
 
             for (Object v : (Collection<?>) value) {
                 if (sb.length() > 1) {
-                    sb.append(",");
+                    sb.append(',');
                 }
                 sb.append(formatCSVValue(v));
             }
 
-            sb.append("]");
+            sb.append(']');
 
             return sb.toString();
         } else if (value instanceof ObjectId) {
@@ -497,11 +488,7 @@ public class ClientHelper {
 
         final String result = readStreamAndRemoveHeader(stream);
 
-        try {
-            stream.close();
-        } catch (IOException e) {
-            // ignore
-        }
+        IOUtils.closeQuietly(stream);
 
         return result;
     }
@@ -534,7 +521,7 @@ public class ClientHelper {
                 }
 
                 sb.append(s);
-                sb.append("\n");
+                sb.append('\n');
             }
 
             reader.close();
@@ -622,10 +609,7 @@ public class ClientHelper {
             LOG.error("Cannot read library file: " + propertiesFile);
             return null;
         } finally {
-            try {
-                stream.close();
-            } catch (IOException ioe) {
-            }
+            IOUtils.closeQuietly(stream);
         }
     }
 
@@ -786,6 +770,10 @@ public class ClientHelper {
 
         @Override
         public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+
             if (!(obj instanceof FileEntry)) {
                 return false;
             }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/CreateDocumentDialog.java Mon Aug 12 21:50:45 2013
@@ -53,6 +53,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 import org.apache.chemistry.opencmis.workbench.model.ClientSession;
 import org.apache.chemistry.opencmis.workbench.swing.CreateDialog;
@@ -372,17 +373,8 @@ public class CreateDocumentDialog extend
             JOptionPane.showMessageDialog(getOwner(), "Content test exception: " + e.getMessage(),
                     "Verification failed", JOptionPane.ERROR_MESSAGE);
         } finally {
-            try {
-                sourceContent.close();
-            } catch (Exception e) {
-            }
-            try {
-                while (docContent.read() > -1) {
-                }
-
-                docContent.close();
-            } catch (Exception e) {
-            }
+            IOUtils.closeQuietly(sourceContent);
+            IOUtils.consumeAndClose(docContent);
         }
     }
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ExpertLoginTab.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ExpertLoginTab.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ExpertLoginTab.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/ExpertLoginTab.java Mon Aug 12 21:50:45 2013
@@ -103,9 +103,9 @@ public class ExpertLoginTab extends Abst
         StringBuilder sb = new StringBuilder();
         for (Map.Entry<String, String> parameter : parameters.entrySet()) {
             sb.append(parameter.getKey());
-            sb.append("=");
+            sb.append('=');
             sb.append(parameter.getValue());
-            sb.append("\n");
+            sb.append('\n');
         }
 
         sessionParameterTextArea.setText(sb.toString());

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderPanel.java Mon Aug 12 21:50:45 2013
@@ -159,7 +159,7 @@ public class FolderPanel extends JPanel 
             if (id.length() == 0) {
                 id = "/";
             }
-            ObjectId objectId = model.loadFolder(id, id.startsWith("/"));
+            ObjectId objectId = model.loadFolder(id, id.charAt(0) == '/');
             model.loadObject(objectId.getId());
         } catch (Exception ex) {
             ClientHelper.showError(null, ex);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderTable.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderTable.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderTable.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/FolderTable.java Mon Aug 12 21:50:45 2013
@@ -374,7 +374,7 @@ public class FolderTable extends JTable 
                         }
 
                         public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
-                            return (List<File>) Collections.singletonList(tempTransFile);
+                            return Collections.singletonList(tempTransFile);
                         }
                     };
                 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/InfoDialog.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/InfoDialog.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/InfoDialog.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/InfoDialog.java Mon Aug 12 21:50:45 2013
@@ -38,6 +38,8 @@ import javax.swing.JScrollPane;
 import javax.swing.JTextArea;
 import javax.swing.UIManager;
 
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
+
 public class InfoDialog extends JDialog {
 
     private static final long serialVersionUID = 1L;
@@ -76,7 +78,7 @@ public class InfoDialog extends JDialog 
 
         Properties sysProps = System.getProperties();
         for (Object key : new TreeSet<Object>(sysProps.keySet())) {
-            readme.append(key).append(" = ").append(sysProps.get(key)).append("\n");
+            readme.append(key).append(" = ").append(sysProps.get(key)).append('\n');
         }
 
         readme.append("\n---------------------------------------------------------\n");
@@ -119,7 +121,7 @@ public class InfoDialog extends JDialog 
                     result.append('\n');
                 }
 
-                br.close();
+                IOUtils.closeQuietly(br);
             } catch (Exception e) {
             }
         } else {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TypesFrame.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TypesFrame.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TypesFrame.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/TypesFrame.java Mon Aug 12 21:50:45 2013
@@ -429,7 +429,7 @@ public class TypesFrame extends JFrame {
             for (ValidationError error : typeResult) {
                 sb.append("- ");
                 sb.append(error.toString());
-                sb.append("\n");
+                sb.append('\n');
             }
         }
 
@@ -443,7 +443,7 @@ public class TypesFrame extends JFrame {
                     for (ValidationError error : propResult) {
                         sb.append("- ");
                         sb.append(error.toString());
-                        sb.append("\n");
+                        sb.append('\n');
                     }
                 }
             }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/AppendContentStreamPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/AppendContentStreamPanel.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/AppendContentStreamPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/AppendContentStreamPanel.java Mon Aug 12 21:50:45 2013
@@ -18,8 +18,6 @@
  */
 package org.apache.chemistry.opencmis.workbench.actions;
 
-import java.io.IOException;
-
 import javax.swing.JCheckBox;
 import javax.swing.JTextField;
 
@@ -27,6 +25,7 @@ import org.apache.chemistry.opencmis.cli
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.enums.Action;
 import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 import org.apache.chemistry.opencmis.workbench.swing.ActionPanel;
 
@@ -75,13 +74,7 @@ public class AppendContentStreamPanel ex
         try {
             ((Document) getObject()).appendContentStream(content, isLastChunkBox.isSelected());
         } finally {
-            if (content != null && content.getStream() != null) {
-                try {
-                    content.getStream().close();
-                } catch (IOException e) {
-                    // ignore
-                }
-            }
+            IOUtils.closeQuietly(content);
         }
         return true;
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckInPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckInPanel.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckInPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/CheckInPanel.java Mon Aug 12 21:50:45 2013
@@ -18,14 +18,13 @@
  */
 package org.apache.chemistry.opencmis.workbench.actions;
 
-import java.io.IOException;
-
 import javax.swing.JCheckBox;
 import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.Document;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.enums.Action;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 import org.apache.chemistry.opencmis.workbench.swing.ActionPanel;
 
@@ -70,13 +69,7 @@ public class CheckInPanel extends Action
         try {
             ((Document) getObject()).checkIn(majorBox.isSelected(), null, content, null, null, null, null);
         } finally {
-            if (content != null && content.getStream() != null) {
-                try {
-                    content.getStream().close();
-                } catch (IOException e) {
-                    // ignore
-                }
-            }
+            IOUtils.closeQuietly(content);
         }
 
         return false;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/actions/SetContentStreamPanel.java Mon Aug 12 21:50:45 2013
@@ -18,14 +18,13 @@
  */
 package org.apache.chemistry.opencmis.workbench.actions;
 
-import java.io.IOException;
-
 import javax.swing.JCheckBox;
 import javax.swing.JTextField;
 
 import org.apache.chemistry.opencmis.client.api.Document;
 import org.apache.chemistry.opencmis.commons.data.ContentStream;
 import org.apache.chemistry.opencmis.commons.enums.Action;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.workbench.model.ClientModel;
 import org.apache.chemistry.opencmis.workbench.swing.ActionPanel;
 
@@ -70,12 +69,8 @@ public class SetContentStreamPanel exten
         try {
             ((Document) getObject()).setContentStream(content, overwriteBox.isSelected());
         } finally {
-            if (content != null && content.getStream() != null) {
-                try {
-                    content.getStream().close();
-                } catch (IOException e) {
-                    // ignore
-                }
+            if (content != null) {
+                IOUtils.closeQuietly(content);
             }
         }
         return true;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientModel.java Mon Aug 12 21:50:45 2013
@@ -52,6 +52,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.VersioningState;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.chemistry.opencmis.commons.impl.IOUtils;
 import org.apache.chemistry.opencmis.commons.impl.MimeTypes;
 import org.apache.chemistry.opencmis.workbench.RandomInputStream;
 
@@ -279,9 +280,7 @@ public class ClientModel {
             return clientSession.getSession().createDocument(properties, (unfiled ? null : currentFolder), content,
                     versioningState, null, null, null);
         } finally {
-            if (content != null && content.getStream() != null) {
-                content.getStream().close();
-            }
+            IOUtils.closeQuietly(content);
         }
     }
 
@@ -305,9 +304,7 @@ public class ClientModel {
             return clientSession.getSession().createDocument(properties, (unfiled ? null : currentFolder), content,
                     versioningState, null, null, null);
         } finally {
-            if (content != null && content.getStream() != null) {
-                content.getStream().close();
-            }
+            IOUtils.closeQuietly(content);
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/model/ClientSession.java Mon Aug 12 21:50:45 2013
@@ -266,7 +266,7 @@ public class ClientSession {
                 PropertyDefinition<?> propDef = type.getPropertyDefinitions().get(propId);
                 if (propDef != null) {
                     if (filter.length() > 0) {
-                        filter.append(",");
+                        filter.append(',');
                     }
                     filter.append(propDef.getQueryName());
                 }
@@ -294,7 +294,7 @@ public class ClientSession {
                 PropertyDefinition<?> propDef = type.getPropertyDefinitions().get(propId);
                 if (propDef != null) {
                     if (filter.length() > 0) {
-                        filter.append(",");
+                        filter.append(',');
                     }
                     filter.append(propDef.getQueryName());
                 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoPanel.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoPanel.java?rev=1513272&r1=1513271&r2=1513272&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoPanel.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/java/org/apache/chemistry/opencmis/workbench/swing/InfoPanel.java Mon Aug 12 21:50:45 2013
@@ -333,7 +333,7 @@ public abstract class InfoPanel extends 
 
         @Override
         public boolean isLink(String link) {
-            return link != null && link.length() > 0 && !link.startsWith("(");
+            return link != null && link.length() > 0 && link.charAt(0) != '(';
         }
 
         @Override



Mime
View raw message