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/09/23 10:59:00 UTC

svn commit: r1525538 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench: ./ src/main/resources/scripts/

Author: fmui
Date: Mon Sep 23 08:58:59 2013
New Revision: 1525538

URL: http://svn.apache.org/r1525538
Log:
Workbench: Groovy update and script clean up

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/pom.xml
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/CMIS.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/counttypes.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/getdescendants.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/ping.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/query.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/startup.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/stats.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/template.groovy
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/upload.groovy

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/pom.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/pom.xml?rev=1525538&r1=1525537&r2=1525538&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/pom.xml (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/pom.xml Mon Sep 23 08:58:59 2013
@@ -250,7 +250,7 @@
         <dependency>
             <groupId>org.codehaus.groovy</groupId>
             <artifactId>groovy-all</artifactId>
-            <version>2.2.0-beta-1</version>
+            <version>2.2.0-beta-2</version>
         </dependency>
         <dependency>
             <groupId>org.slf4j</groupId>

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/CMIS.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/CMIS.groovy?rev=1525538&r1=1525537&r2=1525538&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/CMIS.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/CMIS.groovy Mon Sep 23 08:58:59 2013
@@ -18,160 +18,149 @@
  */
 package scripts
 
-import java.io.File;
-
-import org.apache.chemistry.opencmis.client.api.CmisObject;
-import org.apache.chemistry.opencmis.client.api.Document;
-import org.apache.chemistry.opencmis.client.api.Folder;
-import org.apache.chemistry.opencmis.client.api.Property;
-import org.apache.chemistry.opencmis.client.api.Relationship;
-import org.apache.chemistry.opencmis.client.api.Session;
-import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.commons.enums.*
+import org.apache.chemistry.opencmis.commons.definitions.*
+import org.apache.chemistry.opencmis.client.api.*
 
 class CMIS {
-    
+
     Session session
-    
+
     CMIS(Session session) {
         this.session = session
     }
-    
+
     CmisObject getObject(id) {
         CmisObject result = null
-        
-        if(id instanceof CmisObject) {
+
+        if (id instanceof CmisObject) {
             result = id
-        } else if(id instanceof ObjectId) {
+        } else if (id instanceof ObjectId) {
             result = session.getObject(id)
-        } else if(id instanceof String) {
-            if(id.startsWith("/")) {
+        } else if (id instanceof String) {
+            if (id.startsWith("/")) {
                 result = session.getObjectByPath(id)
             } else {
-                result = session.getObject(session.createObjectId(id))
+                result = session.getObject(id)
             }
         }
-        
-        if(result == null) {
+
+        if (result == null) {
             throw new Exception("Object not found!")
         }
-        
-        return result
+
+        result
     }
-    
+
     Folder getFolder(id) {
         CmisObject folder = getObject(id)
         if(!(folder instanceof Folder)) {
             throw new Exception("Object is not a folder!")
         }
-        
-        return folder
+
+        folder
     }
-    
+
     Document getDocument(id) {
         CmisObject doc = getObject(id)
         if(!(doc instanceof Document)) {
             throw new Exception("Object is not a document!")
         }
-        
-        return doc
+
+        doc
     }
-    
+
     void printProperties(id) {
         CmisObject object = getObject(id)
-        
-        if(object.getProperties() == null || object.getProperties().isEmpty()) {
+
+        if(!object.properties) {
             println "- no properties (???) -"
-            return
-        }
-        
-        for(Property prop: object.getProperties()) {
-            printProperty(prop)
+        } else {
+            object.properties.each { prop -> printProperty(prop) }
         }
     }
-    
+
     void printProperty(Property prop) {
-        println prop.getId() + ": " + prop.getValuesAsString()
+        println "${prop.id}: ${prop.valuesAsString}"
     }
-    
+
     void printAllowableActions(id) {
         CmisObject object = getObject(id)
-        
-        if(object.getAllowableActions() == null || 
-        object.getAllowableActions().getAllowableActions() == null || 
-        object.getAllowableActions().getAllowableActions().isEmpty()) {
+
+        if (!object.allowableActions || !object.allowableActions.allowableActions) {
             println "- no allowable actions -"
-            return
-        }
-        
-        for(Action action: object.getAllowableActions().getAllowableActions()) {
-            println action.value()
+        } else {
+            object.allowableActions.allowableActions.each { action ->
+                println action.value()
+            }
         }
     }
-    
+
     void printVersions(id) {
         Document doc = getDocument(id)
-        
-        List<Document> versions = doc.getAllVersions()
-        
-        if(versions == null || versions.isEmpty()) {
-            println "- no versions -"
+
+        if (!((DocumentType) doc.type).isVersionable()) {
+            println "- not versionsable -"
             return
         }
-        
-        for(Document version: doc.getAllVersions()) {
-            println(version.getVersionLabel() + " (" + version.getId() +") [" + version.getType().getId() + "]")
+
+        List<Document> versions = doc.allVersions
+
+        if (!versions) {
+            println "- no versions -"
+        } else {
+            versions.each { version -> println "${version.versionLabel} (${version.id}) [${version.type.id}]" }
         }
     }
-    
+
     void printChildren(id) {
         Folder folder = getFolder(id)
-        
+
         boolean hasChildren = false
-        for(CmisObject child: folder.getChildren()) {
-            println(child.getName() + " (" + child.getId() +") [" + child.getType().getId() + "]")
-            hasChildren = true;
+        folder.children.each { child ->
+            println "${child.name} (${child.id}) [${child.type.id}]"
+            hasChildren = true
         }
-        
-        if(!hasChildren) {
+
+        if (!hasChildren) {
             println "- no children -"
         }
     }
-    
+
     void printRelationships(id) {
         CmisObject object = getObject(id)
-        
+
         boolean hasRelationships = false
-        for(CmisObject rel: object.getRelationships()) {
-            println(rel.getName() + " (" + rel.getId() +") [" + rel.getType().getId() + "]")
+        object.relationships.each { rel ->
+            println "${rel.name} (${rel.id}) [${rel.type.id}]"
             hasRelationships = true
         }
-        
-        if(!hasRelationships) {
+
+        if (!hasRelationships) {
             println "- no relationships -"
         }
     }
-    
+
     void printRenditions(id) {
         Document doc = getDocument(id)
-        
-        List<Rendition> renditons = doc.getRenditions()
-        
-        if(renditons == null || renditons.isEmpty()) {
+
+        List<Rendition> renditons = doc.renditions
+
+        if(!renditons) {
             println "- no renditions -"
-            return
-        }
-        
-        for(Rendition rendition: renditons) {
-            println(rendition.getTitle() + " (MIME type: " + rendition.getMimeType() + ", length: "  + rendition.getLength() + " bytes)")
+        } else {
+            renditons.each { rendition -> println "${rendition.title} (MIME type: ${rendition.mimeType}, length: ${rendition.length} bytes" }
         }
     }
-    
+
     void printObjectSummary(id) {
         CmisObject object = getObject(id)
-        
-        println "Name:        " + object.getName()
-        println "Object Id:   " + object.getId()
-        println "Object Type: " + object.getType().getId()
+
+        println "Name:        ${object.name}"
+        println "Object Id:   ${object.id}"
+        println "Object Type: ${object.type.id}"
         println ""
         println "--------------------------------------------------"
         println "Properties:"
@@ -187,7 +176,7 @@ class CMIS {
         println "Relationships:"
         println "--------------------------------------------------"
         printRelationships(object)
-        
+
         if(object instanceof Document) {
             println ""
             println "--------------------------------------------------"
@@ -200,7 +189,7 @@ class CMIS {
             println "--------------------------------------------------"
             printRenditions(object)
         }
-        
+
         if(object instanceof Folder) {
             println ""
             println "--------------------------------------------------"
@@ -209,74 +198,79 @@ class CMIS {
             printChildren(id)
         }
     }
-    
+
     void download(id, destination) {
         Document doc = getDocument(id)
-        
+
         def file = new FileOutputStream(destination)
         def out = new BufferedOutputStream(file)
         out << doc.contentStream.stream
         out.close()
     }
-    
-    Folder createFolder(parent, String name, String type = "cmis:folder") {        
+
+    Folder createFolder(parent, String name, String type = "cmis:folder") {
         CmisObject parentFolder = getFolder(parent)
-        
+
         def properties = [
-                    (PropertyIds.OBJECT_TYPE_ID): type, 
-                    (PropertyIds.NAME): name
-                ]
-        
-        return parentFolder.createFolder(properties)
-    }
-    
-    Document createTextDocument(parent, String name, String content, String type = "cmis:document", 
-    VersioningState versioningState = VersioningState.MAJOR) {        
+            (PropertyIds.OBJECT_TYPE_ID): type,
+            (PropertyIds.NAME): name
+        ]
+
+        parentFolder.createFolder(properties)
+    }
+
+    Document createTextDocument(parent, String name, String content, String type = "cmis:document",
+            VersioningState versioningState = VersioningState.MAJOR) {
         CmisObject parentFolder = getFolder(parent)
-        
+
         def properties = [
-                    (PropertyIds.OBJECT_TYPE_ID): type,
-                    (PropertyIds.NAME): name
-                ]
-        
+            (PropertyIds.OBJECT_TYPE_ID): type,
+            (PropertyIds.NAME): name
+        ]
+
         def stream = new ByteArrayInputStream(content.bytes)
-        def contentStream = new ContentStreamImpl(name, content.bytes.length, "text/plain", stream)
-        
-        return parentFolder.createDocument(properties, contentStream, versioningState)
-    }
-    
-    Document createDocumentFromFile(parent, File file, String type = "cmis:document", 
-    VersioningState versioningState = VersioningState.MAJOR) {
+
+        def contentStream = session.objectFactory.createContentStream(name, content.bytes.length, "text/plain", stream)
+
+        parentFolder.createDocument(properties, contentStream, versioningState)
+    }
+
+    Document createDocumentFromFile(parent, File file, String type = "cmis:document",
+            VersioningState versioningState = VersioningState.MAJOR) {
         CmisObject parentFolder = getFolder(parent)
-        
-        def name = file.getName()
+
+        def name = file.name
         def mimetype = org.apache.chemistry.opencmis.commons.impl.MimeTypes.getMIMEType(file)
-        
+
         def properties = [
-                    (PropertyIds.OBJECT_TYPE_ID): type,
-                    (PropertyIds.NAME): name
-                ]
-        
-        def contentStream = new ContentStreamImpl(name, file.size(), mimetype, new FileInputStream(file))
-        
-        return parentFolder.createDocument(properties, contentStream, versioningState)
+            (PropertyIds.OBJECT_TYPE_ID): type,
+            (PropertyIds.NAME): name
+        ]
+
+        def contentStream = session.objectFactory.createContentStream(name, file.size(), mimetype, new FileInputStream(file))
+
+        parentFolder.createDocument(properties, contentStream, versioningState)
     }
-    
+
     Relationship createRelationship(source, target, name, type) {
         CmisObject sourceObject = getObject(source)
         CmisObject targetObject = getObject(target)
-        
+
         def properties = [
-                    (PropertyIds.OBJECT_TYPE_ID): type,
-                    (PropertyIds.NAME): name,
-                    (PropertyIds.SOURCE_ID): sourceObject.id,
-                    (PropertyIds.TARGET_ID): targetObject.id
-                ]
-        
-        return getObject(session.createRelationship(properties));
+            (PropertyIds.OBJECT_TYPE_ID): type,
+            (PropertyIds.NAME): name,
+            (PropertyIds.SOURCE_ID): sourceObject.id,
+            (PropertyIds.TARGET_ID): targetObject.id
+        ]
+
+        getObject(session.createRelationship(properties))
     }
-    
+
     void delete(id) {
-        getObject(id).delete(true)
+        if (id instanceof ObjectId) {
+            session.delete(id)
+        } else{
+            session.delete(session.createObjectId(id))
+        }
     }
 }
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/counttypes.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/counttypes.groovy?rev=1525538&r1=1525537&r2=1525538&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/counttypes.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/counttypes.groovy Mon Sep 23 08:58:59 2013
@@ -16,13 +16,17 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import org.apache.chemistry.opencmis.client.api.Tree;
 
-println "'cmis:document' and subtypes:     " + countTypes("cmis:document")
-println "'cmis:item' and subtypes:         " + countTypes("cmis:item")
-println "'cmis:folder' and subtypes:       " + countTypes("cmis:folder")
-println "'cmis:relationship' and subtypes: " + countTypes("cmis:relationship")
-println "'cmis:policy' and subtypes:       " + countTypes("cmis:policy")
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.commons.enums.*
+import org.apache.chemistry.opencmis.client.api.*
+
+println "'cmis:document' and subtypes:     ${countTypes('cmis:document')}"
+println "'cmis:item' and subtypes:         ${countTypes('cmis:item')}"
+println "'cmis:folder' and subtypes:       ${countTypes('cmis:folder')}"
+println "'cmis:relationship' and subtypes: ${countTypes('cmis:relationship')}"
+println "'cmis:policy' and subtypes:       ${countTypes('cmis:policy')}"
 
 
 
@@ -33,14 +37,15 @@ int countTypes(String typeId) {
         session.getTypeDescendants(typeId, -1, false).each { counter += 1 + count(it) }
         counter++
     }
-    catch(CmisBaseException e) { }
-    
-    return counter
+    catch (any) {
+    }
+
+    counter
 }
 
 int count(Tree tree) {
     def counter = 0
     tree.children.each { counter += 1 + count(it) }
-    
-    return counter
+
+    counter
 }
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy?rev=1525538&r1=1525537&r2=1525538&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy Mon Sep 23 08:58:59 2013
@@ -16,9 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import java.io.File;
 
-import org.apache.chemistry.opencmis.client.api.Folder;
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.commons.enums.*
+import org.apache.chemistry.opencmis.client.api.*
 
 cmis = new scripts.CMIS(session)
 
@@ -35,20 +37,19 @@ download(localFolder, sourceFolder)
 //--------------------------------------------------
 
 def download(File localFolder, Folder sourceFolder) {
+    println "\nDownloading ${sourceFolder.name} to ${localFolder.absolutePath}\n"
 
-    println "\nDownloading " + sourceFolder.name + " to " + localFolder.absolutePath + "\n"
-
-    for (CmisObject child: sourceFolder.getChildren()) {
+    sourceFolder.children.each { child ->
         File newFile = new File(localFolder, child.name)
 
         if (child instanceof Folder) {
-            println "[Folder] " + newFile.name
+            println "[Folder] ${newFile.name}"
             newFile.mkdir()
-            
+
             download(newFile, child)
         }
         else if (child instanceof Document) {
-            println "[File]   " + newFile.name
+            println "[File]   ${newFile.name}"
             cmis.download(child, newFile)
         }
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/getdescendants.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/getdescendants.groovy?rev=1525538&r1=1525537&r2=1525538&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/getdescendants.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/getdescendants.groovy Mon Sep 23 08:58:59 2013
@@ -16,20 +16,15 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import org.apache.chemistry.opencmis.client.api.Tree;
 
-session.rootFolder.getDescendants(-1).each {
-    printTree(it, 0)
-}
+import org.apache.chemistry.opencmis.client.api.*
+
+session.rootFolder.getDescendants(-1).each { printTree(it, 0) }
 
 def printTree(Tree tree, int depth) {
-    for(i in 0..depth) { print "  " }
+    depth.times { print "  " }
 
     println tree.item.name
-    
-    if(tree.children.size > 0) {
-        tree.children.each {
-            printTree(it, depth + 1)
-        }
-    }
+
+    tree.children.each { printTree(it, depth + 1) }
 }
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/ping.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/ping.groovy?rev=1525538&r1=1525537&r2=1525538&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/ping.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/ping.groovy Mon Sep 23 08:58:59 2013
@@ -17,43 +17,43 @@
  * under the License.
  */
 
-CmisObject root = session.getRootFolder();
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.commons.enums.*
+import org.apache.chemistry.opencmis.client.api.*
 
-ping({
-    root.refresh();
-});
+CmisObject root = session.getRootFolder()
 
+ping({ root.refresh() })
 
 
 
-def ping(func, int sleep = 2, int turns = 1000) {
-    func();
-    
-    int i = 0;
-    long total = 0;
-    long max = 0;
-    long min = Long.MAX_VALUE;
-
-    while(i <= turns) {
-        i++;
-        
-        long start = System.currentTimeMillis();
-        func();
-        long end = System.currentTimeMillis();
-        
-        long time = end - start;
-        total += time;
-        if(max < time) { max = time; }
-        if(min > time) { min = time; }
-        
-        println String.format('[%1s] %2$5d: %3$5d ms   (min: %4$5d ms, max: %5$5d ms, avg: %6$7.1f ms)', 
-            (new Date(start)).format('yyyy-MM-dd hh:mm:ss'), 
-            i,
-            time,
-            min,
-            max,
-            total / i);
 
-        Thread.sleep(sleep * 1000);
+def ping(func, int sleepSeconds = 2, int turns = 100) {
+    func()
+
+    long total = 0
+    long max = 0
+    long min = Long.MAX_VALUE
+
+    for (i in 1..turns) {
+        long start = System.currentTimeMillis()
+        func()
+        long end = System.currentTimeMillis()
+
+        long time = end - start
+        total += time
+        max = max < time ? time : max
+        min = min > time ? time : min
+
+        println String.format('[%1s] %2$5d: %3$5d ms   (min: %4$5d ms, max: %5$5d ms, avg: %6$7.1f ms)',
+                (new Date(start)).format('yyyy-MM-dd hh:mm:ss'),
+                i,
+                time,
+                min,
+                max,
+                total / i)
+
+        sleep sleepSeconds * 1000
     }
 }
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/query.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/query.groovy?rev=1525538&r1=1525537&r2=1525538&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/query.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/query.groovy Mon Sep 23 08:58:59 2013
@@ -17,6 +17,11 @@
  * under the License.
  */
 
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.commons.enums.*
+import org.apache.chemistry.opencmis.client.api.*
+
 String cql = "SELECT cmis:objectId, cmis:name, cmis:contentStreamLength FROM cmis:document"
 
 ItemIterable<QueryResult> results = session.query(cql, false)
@@ -24,12 +29,12 @@ ItemIterable<QueryResult> results = sess
 //ItemIterable<QueryResult> results = session.query(cql, false).getPage(10)
 //ItemIterable<QueryResult> results = session.query(cql, false).skipTo(10).getPage(10)
 
-results.each { hit ->  
+results.each { hit ->
     hit.properties.each { println "${it.queryName}: ${it.firstValue}" }
     println "--------------------------------------"
 }
 
-println "--------------------------------------"    
+println "--------------------------------------"
 println "Total number: ${results.totalNumItems}"
-println "Has more: ${results.hasMoreItems}" 
+println "Has more: ${results.hasMoreItems}"
 println "--------------------------------------"
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/startup.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/startup.groovy?rev=1525538&r1=1525537&r2=1525538&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/startup.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/startup.groovy Mon Sep 23 08:58:59 2013
@@ -17,13 +17,19 @@
  * under the License.
  */
 
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.commons.enums.*
+import org.apache.chemistry.opencmis.client.api.*
+
 // variable 'session' is bound to the current OpenCMIS session
 
+
 // print the repository name - Java style
 println "Repository: " + session.getRepositoryInfo().getName()
 
 // print the repository name - Groovy style
-println "Repository: " + session.repositoryInfo.name
+println "Repository: ${session.repositoryInfo.name}"
 
 
 // get root folder
@@ -31,15 +37,15 @@ Folder root = session.getRootFolder()
 println "--- Root Folder: " + root.getName() + " ---"
 
 // print root folder children
-for(CmisObject object: root.getChildren()) { 
+for(CmisObject object: root.getChildren()) {
     println object.getName() + " \t(" + object.getType().getId() + ")"
 }
 
 // run a quick query
-for(QueryResult hit: session.query("SELECT * FROM cmis:document", false)) {     
-     hit.properties.each{ println it.queryName + ": " + it.firstValue }
-     println "----------------------------------"
- }
+for(QueryResult hit: session.query("SELECT * FROM cmis:document", false)) {
+    hit.properties.each{ println "${it.queryName}: ${it.firstValue}" }
+    println "----------------------------------"
+}
 
 // CMIS helper script
 def cmis = new scripts.CMIS(session)

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/stats.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/stats.groovy?rev=1525538&r1=1525537&r2=1525538&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/stats.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/stats.groovy Mon Sep 23 08:58:59 2013
@@ -16,56 +16,62 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import org.apache.chemistry.opencmis.client.api.Folder;
-import org.apache.chemistry.opencmis.client.api.OperationContext;
 
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.commons.enums.*
+import org.apache.chemistry.opencmis.client.api.*
+
+Folder folder = (Folder) session.getObjectByPath("/")
+
+
+def stats = count(folder, true)
+
+println "Folder ${folder.name}"
+println "----------------------------------------------"
+println "Folders:   ${stats['folders']}"
+println "Documents: ${stats['documents']}"
+println "Items:     ${stats['items']}"
+println "Policies:  ${stats['policies']}"
+println "Content:   ${stats['bytes']} bytes"
 
-Folder folder = (Folder) session.getObjectByPath("/");
 
 
-def stats = count(folder, true);
-
-println "Folder " + folder.getName();
-println "----------------------------------------------";
-println "Folders:   " + stats["folders"];
-println "Documents: " + stats["documents"];
-println "Items:     " + stats["items"];
-println "Policies:  " + stats["policies"];
-println "Content:   " + stats["bytes"] + " bytes";
-
+def count(Folder folder, boolean tree = false) {
+    def stats = [:]
+    stats["folders"] = 0
+    stats["documents"] = 0
+    stats["items"] = 0
+    stats["policies"] = 0
+    stats["bytes"] = 0
+
+    OperationContext oc = session.createOperationContext()
+    oc.setFilterString("cmis:objectId,cmis:contentStreamLength")
+    oc.setIncludeAllowableActions(false)
+    oc.setMaxItemsPerPage(10000)
 
+    countInternal(folder, tree, oc, stats)
 
-def count(Folder folder, boolean tree = false) {
-    def stats = [:];
-    stats["folders"] = 0;
-    stats["documents"] = 0;
-    stats["items"] = 0;
-    stats["policies"] = 0;
-    stats["bytes"] = 0;
-
-    OperationContext oc = session.createOperationContext();
-    oc.setFilterString("cmis:objectId,cmis:contentStreamLength");
-    oc.setIncludeAllowableActions(false);
-    oc.setMaxItemsPerPage(10000);
-
-    countInternal(folder, tree, oc, stats);
-    
-    return stats;
+    stats
 }
 
 def countInternal(Folder folder, boolean tree, OperationContext oc, def stats) {
-    for(CmisObject child: folder.getChildren(oc)) {
-        if(child instanceof Folder) {
-            stats["folders"]++;
-            if (tree) { countInternal(child, true, oc, stats); }
-        } else if(child instanceof Document) {
-            stats["documents"]++;  
-            long size =((Document) child).getContentStreamLength();
-            if (size > 0) { stats["bytes"] += size; }
-        } else if(child instanceof Item) {
-            stats["item"]++;
-        } else if(child instanceof Policy) {
-            stats["policies"]++;
+    folder.getChildren(oc).each { child ->
+        if (child instanceof Folder) {
+            stats["folders"]++
+            if (tree) {
+                countInternal(child, true, oc, stats)
+            }
+        } else if (child instanceof Document) {
+            stats["documents"]++
+            long size = ((Document) child).getContentStreamLength()
+            if (size > 0) {
+                stats["bytes"] += size
+            }
+        } else if (child instanceof Item) {
+            stats["item"]++
+        } else if (child instanceof Policy) {
+            stats["policies"]++
         }
     }
 }
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/template.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/template.groovy?rev=1525538&r1=1525537&r2=1525538&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/template.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/template.groovy Mon Sep 23 08:58:59 2013
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 import org.apache.chemistry.opencmis.commons.*
 import org.apache.chemistry.opencmis.commons.data.*
 import org.apache.chemistry.opencmis.commons.enums.*

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/upload.groovy
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/upload.groovy?rev=1525538&r1=1525537&r2=1525538&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/upload.groovy (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/upload.groovy Mon Sep 23 08:58:59 2013
@@ -16,10 +16,11 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import java.io.File;
 
-import org.apache.chemistry.opencmis.client.api.Folder;
-import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+import org.apache.chemistry.opencmis.commons.*
+import org.apache.chemistry.opencmis.commons.data.*
+import org.apache.chemistry.opencmis.commons.enums.*
+import org.apache.chemistry.opencmis.client.api.*
 
 cmis = new scripts.CMIS(session)
 
@@ -35,31 +36,30 @@ upload(destFolder, localPath)
 
 //--------------------------------------------------
 
-def upload(destination, String localPath, 
-String folderType = "cmis:folder",
-String documentType = "cmis:document",
-VersioningState versioningState = VersioningState.MAJOR) {
-    
-    println "Uploading...\n"   
+def upload(destination, String localPath,
+        String folderType = "cmis:folder",
+        String documentType = "cmis:document",
+        VersioningState versioningState = VersioningState.MAJOR) {
+
+    println "Uploading...\n"
     doUpload(destination, new File(localPath), folderType, documentType, versioningState)
     println "\n...done."
 }
 
 def doUpload(Folder parent, File folder, String folderType, String documentType, VersioningState versioningState) {
     folder.eachFile {
-        
-        if (it.getName().startsWith(".")) {
-            println "Skipping " + it.getName()
-            return;
+        if (it.name.startsWith(".")) {
+            println "Skipping ${it.name}"
+            return
         }
 
-        println it.getName()
-        
-        if(it.isFile()) {
+        println it.name
+
+        if (it.isFile()) {
             cmis.createDocumentFromFile(parent, it, documentType, versioningState)
         }
         else if(it.isDirectory()) {
-            Folder newFolder = cmis.createFolder(parent, it.getName(), folderType)
+            Folder newFolder = cmis.createFolder(parent, it.name, folderType)
             doUpload(newFolder, it, folderType, documentType, versioningState)
         }
     }