chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f...@apache.org
Subject svn commit: r1000389 - in /incubator/chemistry/opencmis-swingclient/trunk/src/main: java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java resources/scripts/CMIS.groovy resources/scripts/startup.groovy
Date Thu, 23 Sep 2010 10:10:38 GMT
Author: fmui
Date: Thu Sep 23 10:10:37 2010
New Revision: 1000389

URL: http://svn.apache.org/viewvc?rev=1000389&view=rev
Log:
- fixed 100% CPU load
- some script improvements

Modified:
    incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/CMIS.groovy
    incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/startup.groovy

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java?rev=1000389&r1=1000388&r2=1000389&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/java/org/apache/chemistry/opencmis/swingclient/swing/CollectionRenderer.java
Thu Sep 23 10:10:37 2010
@@ -38,7 +38,9 @@ public class CollectionRenderer extends 
 
         int height = (int) getPreferredSize().getHeight();
         if (height > (getFontMetrics(getFont()).getHeight() + getInsets().bottom + getInsets().top))
{
-            table.setRowHeight(row, height);
+            if (table.getRowHeight(row) != height) {
+                table.setRowHeight(row, height);
+            }
         }
 
         return comp;

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/CMIS.groovy
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/CMIS.groovy?rev=1000389&r1=1000388&r2=1000389&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/CMIS.groovy
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/CMIS.groovy
Thu Sep 23 10:10:37 2010
@@ -38,6 +38,24 @@ class CMIS {
         return result
     }
     
+    Folder getFolder(id) {
+        CmisObject folder = getObject(id)
+        if(!(folder instanceof Folder)) {
+            throw new Exception("Object is not a folder!")
+        }
+        
+        return folder
+    }
+    
+    Document getDocument(id) {
+        CmisObject doc = getObject(id)
+        if(!(doc instanceof Document)) {
+            throw new Exception("Object is not a document!")
+        }
+        
+        return doc
+    }
+    
     void printProperties(id) {
         CmisObject object = getObject(id)
         
@@ -50,28 +68,29 @@ class CMIS {
         println prop.getId() + ": " + prop.getValuesAsString()
     }
     
-    Folder createFolder(parent, String name, String type = "cmis:folder") {
+    void download(id, destination) {
+        Document doc = getDocument(id)
         
-        CmisObject parentFolder = getObject(parent)
-        if(!(parentFolder instanceof Folder)) {
-            throw new Exception("Parent is not a folder!")
-        }
+        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") {        
+        CmisObject parentFolder = getFolder(parent)
         
         def properties = [
                     (PropertyIds.OBJECT_TYPE_ID): type, 
                     (PropertyIds.NAME): name
                 ]
         
-        return ((Folder) parentFolder).createFolder(properties, session.getDefaultContext())
+        return parentFolder.createFolder(properties, session.getDefaultContext())
     }
     
     Document createTextDocument(parent, String name, String content, String type = "cmis:document",

-    VersioningState versioningState = VersioningState.MAJOR) {
-        
-        CmisObject parentFolder = getObject(parent)
-        if(!(parentFolder instanceof Folder)) {
-            throw new Exception("Parent is not a folder!")
-        }
+    VersioningState versioningState = VersioningState.MAJOR) {        
+        CmisObject parentFolder = getFolder(parent)
         
         def properties = [
                     (PropertyIds.OBJECT_TYPE_ID): type,
@@ -81,7 +100,7 @@ class CMIS {
         def stream = new ByteArrayInputStream(content.bytes)
         def contentStream = new ContentStreamImpl(name, content.bytes.length, "text/plain",
stream)
         
-        return ((Folder) parentFolder).createDocument(properties, contentStream, 
+        return parentFolder.createDocument(properties, contentStream, 
         versioningState, session.getDefaultContext())
     }
     

Modified: incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/startup.groovy
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/startup.groovy?rev=1000389&r1=1000388&r2=1000389&view=diff
==============================================================================
--- incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/startup.groovy
(original)
+++ incubator/chemistry/opencmis-swingclient/trunk/src/main/resources/scripts/startup.groovy
Thu Sep 23 10:10:37 2010
@@ -18,9 +18,15 @@ println "--- Root Folder: " + root.getNa
 
 // print root folder children
 for(CmisObject object: root.getChildren()) { 
-  println object.getName() + " \t(" + object.getType().getId() + ")"
+    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 "----------------------------------"
+ }
+
 // CMIS helper script
 def cmis = new scripts.CMIS(session)
 
@@ -29,8 +35,13 @@ cmis.printProperties session.rootFolder.
 cmis.printProperties session.rootFolder     // access by object
 
 // Folder folder = cmis.createFolder("/", "test-folder", "cmis:folder")
+
+// Document doc = cmis.createTextDocument(folder, "test.txt", "Hello World!", "cmis:document")
+// cmis.printProperties doc
+// cmis.download(doc, "/some/path/helloWorld.txt")
+// cmis.delete doc.id
+
 // cmis.delete folder
 
-// Document doc = cmis.createTextDocument("/", "test.txt", "Hello World!", "cmis:document")
 
 // see /scripts/CMIS.groovy for more methods
\ No newline at end of file



Mime
View raw message