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/05/07 13:24:24 UTC

svn commit: r1479863 - in /chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts: download.groovy script-library.properties

Author: fmui
Date: Tue May  7 11:24:24 2013
New Revision: 1479863

URL: http://svn.apache.org/r1479863
Log:
Workbench: added download script

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/script-library.properties

Added: 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=1479863&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/download.groovy Tue May  7 11:24:24 2013
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+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)
+
+// destination folder
+File localFolder = new File("/some/local/folder")
+
+// source folder
+Folder sourceFolder = cmis.getFolder("/folder/to/download")
+
+// download folder tree
+download(localFolder, sourceFolder)
+
+
+//--------------------------------------------------
+
+def download(File localFolder, Folder sourceFolder) {
+
+    println "\nDownloading " + sourceFolder.name + " to " + localFolder.absolutePath + "\n"
+
+    for (CmisObject child: sourceFolder.getChildren()) {
+        File newFile = new File(localFolder, child.name)
+
+        if (child instanceof Folder) {
+            println "[Folder] " + newFile.name
+            newFile.mkdir()
+            
+            download(newFile, child)
+        }
+        else if (child instanceof Document) {
+            println "[File]   " + newFile.name
+            cmis.download(child, newFile)
+        }
+    }
+}
\ No newline at end of file

Modified: chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/script-library.properties
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/script-library.properties?rev=1479863&r1=1479862&r2=1479863&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/script-library.properties (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-workbench/chemistry-opencmis-workbench/src/main/resources/scripts/script-library.properties Tue May  7 11:24:24 2013
@@ -31,5 +31,6 @@ getdescendants.groovy = Print descendant
 query.groovy = Execute a query
 counttypes.groovy = Count types and sub types
 upload.groovy = Upload a local folder to the repository
+download.groovy = Download a repository folder to the local disk
 ping.groovy = Ping the repository
 stats.groovy = Count objects and bytes