chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1302466 [1/2] - in /chemistry/opencmis/trunk: ./ chemistry-opencmis-test/chemistry-opencmis-test-client/ chemistry-opencmis-test/chemistry-opencmis-test-client/src/ chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/ chemistry...
Date Mon, 19 Mar 2012 14:18:38 GMT
Author: jens
Date: Mon Mar 19 14:18:36 2012
New Revision: 1302466

URL: http://svn.apache.org/viewvc?rev=1302466&view=rev
Log:
get rid of some ugly dependencies by splitting test-util in a client and a server part

Added:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/GenSpecExamples.bat
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/cp.bat
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/pom.xml
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runCreate.bat
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runcmd.bat
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runfill.bat
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/main/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/main/ObjGenApp.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/specexamples/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/specexamples/Main.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/util/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/resources/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/resources/META-INF/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/resources/META-INF/ExifPropertyDefinitions.txt
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/resources/META-INF/ExifTypeDefinitions.txt
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/resources/META-INF/MANIFEST.MF
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/resources/log4j.properties
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/test/
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/test/java/
Removed:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runCreate.bat
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runcmd.bat
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runfill.bat
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjGenApp.java
Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/pom.xml
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/test/resources/log4j.properties
    chemistry/opencmis/trunk/pom.xml

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/GenSpecExamples.bat
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/GenSpecExamples.bat?rev=1302466&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/GenSpecExamples.bat (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/GenSpecExamples.bat Mon Mar 19 14:18:36 2012
@@ -0,0 +1,5 @@
+@echo OFF
+set JAVA_HOME=D:\Java\jdk1.6.0_22-x64
+set PATH=%JAVA_HOME%\bin;%PATH%
+call cp.bat
+java -cp %CP% org.apache.chemistry.opencmis.client.specexamples.Main

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/cp.bat
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/cp.bat?rev=1302466&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/cp.bat (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/cp.bat Mon Mar 19 14:18:36 2012
@@ -0,0 +1,30 @@
+set VER=0.7.0-SNAPSHOT
+set M2_REPO=d:\java\maven-repository
+set CP=target\classes;^
+%M2_REPO%/javax/activation/activation/1.1/activation-1.1.jar;^
+%M2_REPO%/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar;^
+%M2_REPO%/javax/xml/ws/jaxws-api/2.1/jaxws-api-2.1.jar;^
+%M2_REPO%/javax/jws/jsr181-api/1.0-MR1/jsr181-api-1.0-MR1.jar;^
+%M2_REPO%/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar;^
+%M2_REPO%/javax/xml/soap/saaj-api/1.3/saaj-api-1.3.jar;^
+%M2_REPO%/javax/xml/stream/stax-api/1.0/stax-api-1.0.jar;^
+%M2_REPO%/commons-codec/commons-codec/1.4/commons-codec-1.4.jar;^
+%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-client-api/%VER%/chemistry-opencmis-client-api-%VER%.jar;^
+%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-client-bindings/%VER%/chemistry-opencmis-client-bindings-%VER%.jar;^
+%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-client-impl/%VER%/chemistry-opencmis-client-impl-%VER%.jar;^
+%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-commons-api/%VER%/chemistry-opencmis-commons-api-%VER%.jar;^
+%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-commons-impl/%VER%/chemistry-opencmis-commons-impl-%VER%.jar;^
+%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-test-util/%VER%/chemistry-opencmis-test-util-%VER%.jar;^
+%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-test-client/%VER%/chemistry-opencmis-test-client-%VER%.jar;^
+%M2_REPO%/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar;^
+%M2_REPO%/com/sun/xml/bind/jaxb-impl/2.1.11/jaxb-impl-2.1.11.jar;^
+%M2_REPO%/com/sun/xml/ws/jaxws-rt/2.1.7/jaxws-rt-2.1.7.jar;^
+%M2_REPO%/log4j/log4j/1.2.16/log4j-1.2.16.jar;^
+%M2_REPO%/org/jvnet/mimepull/1.3/mimepull-1.3.jar;^
+%M2_REPO%/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar;^
+%M2_REPO%/com/sun/xml/messaging/saaj/saaj-impl/1.3.3/saaj-impl-1.3.3.jar;^
+%M2_REPO%/stax/stax-api/1.0.1/stax-api-1.0.1.jar;^
+%M2_REPO%/org/jvnet/staxex/stax-ex/1.2/stax-ex-1.2.jar;^
+%M2_REPO%/com/sun/xml/stream/buffer/streambuffer/0.9/streambuffer-0.9.jar;^
+%M2_REPO%/org/codehaus/woodstox/wstx-asl/3.2.3/wstx-asl-3.2.3.jar;^
+%M2_REPO%/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2.jar

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/pom.xml
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/pom.xml?rev=1302466&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/pom.xml (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/pom.xml Mon Mar 19 14:18:36 2012
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+    <!--
+        Licensed 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.
+    -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.chemistry.opencmis</groupId>
+        <artifactId>chemistry-opencmis</artifactId>
+        <version>0.7.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>chemistry-opencmis-test-client</artifactId>
+    <name>OpenCMIS Test Client App</name>
+    
+    <properties>
+        <parentBasedir>../../</parentBasedir>
+    </properties>
+    
+	<build>
+		<plugins>
+			<plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <addMavenDescriptor>false</addMavenDescriptor>
+                        <manifest>
+                            <mainClass>org.apache.chemistry.opencmis.client.main.ObjGenApp</mainClass>
+                            <addClasspath>true</addClasspath>
+                            <classpathPrefix />
+                        </manifest>
+                        <manifestEntries>
+                            <X-Compile-Source-JDK>${maven.compile.source}</X-Compile-Source-JDK>
+                            <X-Compile-Target-JDK>${maven.compile.target}</X-Compile-Target-JDK>
+                        </manifestEntries>
+                    </archive>
+                </configuration>
+            </plugin>
+		</plugins>
+	</build>
+	
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>chemistry-opencmis-client-impl</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>chemistry-opencmis-test-util</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <!--
+		<dependency>
+            <groupId>org.apache.tika</groupId>
+            <artifactId>tika-parsers</artifactId>
+            <version>1.0</version>
+        </dependency>
+        -->
+        <dependency>
+            <groupId>net.sf.jopt-simple</groupId>
+            <artifactId>jopt-simple</artifactId>
+            <version>3.2</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>chemistry-opencmis-client-bindings</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+            <version>2.0.1</version>
+        </dependency>     
+    </dependencies>
+</project>

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runCreate.bat
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runCreate.bat?rev=1302466&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runCreate.bat (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runCreate.bat Mon Mar 19 14:18:36 2012
@@ -0,0 +1,21 @@
+rem
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one
+rem or more contributor license agreements.  See the NOTICE file
+rem distributed with this work for additional information
+rem regarding copyright ownership.  The ASF licenses this file
+rem to you under the Apache License, Version 2.0 (the
+rem "License"); you may not use this file except in compliance
+rem with the License.  You may obtain a copy of the License at
+rem
+rem   http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing,
+rem software distributed under the License is distributed on an
+rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+rem KIND, either express or implied.  See the License for the
+rem specific language governing permissions and limitations
+rem under the License.
+rem
+rem
+call runcmd.bat --Command=CreateDocument --RepositoryId=A1 --ContentSizeInKB=25

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runcmd.bat
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runcmd.bat?rev=1302466&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runcmd.bat (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runcmd.bat Mon Mar 19 14:18:36 2012
@@ -0,0 +1,27 @@
+rem
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one
+rem or more contributor license agreements.  See the NOTICE file
+rem distributed with this work for additional information
+rem regarding copyright ownership.  The ASF licenses this file
+rem to you under the Apache License, Version 2.0 (the
+rem "License"); you may not use this file except in compliance
+rem with the License.  You may obtain a copy of the License at
+rem
+rem   http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing,
+rem software distributed under the License is distributed on an
+rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+rem KIND, either express or implied.  See the License for the
+rem specific language governing permissions and limitations
+rem under the License.
+rem
+rem
+set M2_REPO=d:\java\maven-repository
+set JAVA_HOME=d:\Java\jdk1.6.0_22-x64
+set PATH=%JAVA_HOME%\bin
+call cp.bat
+java -Dorg.apache.chemistry.opencmis.binding.atompub.url=http://localhost:8080/inmemory/atom ^
+-Dorg.apache.chemistry.opencmis.binding.spi.type=atompub -cp %CP% ^
+org.apache.chemistry.opencmis.client.main.ObjGenApp %*

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runfill.bat
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runfill.bat?rev=1302466&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runfill.bat (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/runfill.bat Mon Mar 19 14:18:36 2012
@@ -0,0 +1,22 @@
+rem
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one
+rem or more contributor license agreements.  See the NOTICE file
+rem distributed with this work for additional information
+rem regarding copyright ownership.  The ASF licenses this file
+rem to you under the Apache License, Version 2.0 (the
+rem "License"); you may not use this file except in compliance
+rem with the License.  You may obtain a copy of the License at
+rem
+rem   http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing,
+rem software distributed under the License is distributed on an
+rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+rem KIND, either express or implied.  See the License for the
+rem specific language governing permissions and limitations
+rem under the License.
+rem
+rem
+call runcmd.bat --Command=FillRepository --RepositoryId=A1 --Depth=1 --DocsPerFolder=1 ^
+--FoldersPerFolder=0  --ContentSizeInKB=25

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/main/ObjGenApp.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/main/ObjGenApp.java?rev=1302466&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/main/ObjGenApp.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/main/ObjGenApp.java Mon Mar 19 14:18:36 2012
@@ -0,0 +1,737 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.client.main;
+
+import java.io.BufferedReader;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import joptsimple.OptionParser;
+import joptsimple.OptionSet;
+import joptsimple.OptionSpec;
+
+import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
+import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+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.spi.CmisBinding;
+import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
+import org.apache.chemistry.opencmis.util.repository.MultiThreadedObjectGenerator;
+import org.apache.chemistry.opencmis.util.repository.ObjectGenerator;
+import org.apache.chemistry.opencmis.util.repository.ObjectGenerator.CONTENT_KIND;
+import org.apache.chemistry.opencmis.util.repository.TimeLogger;
+
+public class ObjGenApp {
+
+    private static final String PROP_USER = SessionParameter.USER;
+    private static final String PROP_PASSWORD = SessionParameter.PASSWORD;
+    private static final String DEFAULT_USER = "user";
+    private static final String DEFAULT_PASSWORD = "dummy";
+    private static final String PROP_ATOMPUB_URL = SessionParameter.ATOMPUB_URL;
+    private static final String PROP_WS_URL = "org.apache.chemistry.opencmis.binding.webservices.url";
+    private static final String PROP_BROWSER_URL = SessionParameter.BROWSER_URL;
+    private static final String PROP_BINDING = SessionParameter.BINDING_TYPE;
+    private static final String DEFAULT_ATOMPUB_URL = "http://localhost:8080/inmemory/atom";
+    private static final String DEFAULT_WS_URL = "http://localhost:8080/inmemory/services/";
+    private static final String DEFAULT_BROWSER_BINDING_URL  = "http://localhost:8080/inmemory/browser/";
+    private static final String DEFAULT_BINDING = "atompub";
+    private static final String CMD = "Command";
+    private static final String REPOSITORY_ID = "RepositoryId";
+    private static final String FILLER_DOCUMENT_TYPE_ID = "DocumentTypeId";
+    private static final String FILLER_FOLDER_TYPE_ID = "FolderTypeId";
+    private static final String FILLER_DOCS_PER_FOLDER = "DocsPerFolder";
+    private static final String FILLER_FOLDERS_PER_FOLDER = "FoldersPerFolder";
+    private static final String FILLER_DEPTH = "Depth";
+    private static final String FILLER_CONTENT_SIZE = "ContentSizeInKB";
+    private static final String COUNT = "Count";
+    private static final String CLEANUP = "Cleanup";
+    private static final String ROOTFOLDER = "RootFolder";
+    private static final String THREADS = "Threads";
+    private static final String CONTENT_KIND = "ContentKind";
+    private static final String FILE_NAME_PATTERN = "FileName";
+    private static final String LOCAL_FILE = "File";
+    private static final String LOCAL_DIR = "Dir";
+
+    private static final String BINDING_ATOM = "atompub";
+    private static final String BINDING_WS = "webservices";
+    private static final String BINDING_BROWSER = "browser";
+
+    BindingType fBindingType;
+    private CONTENT_KIND fContentKind;
+    CmisBinding binding;
+    
+    OptionSpec<String> fCmd;
+    OptionSpec<Integer> fDepth;
+    OptionSpec<Integer> fContentSize;
+    OptionSpec<Integer> fFolderPerFolder;
+    OptionSpec<Integer> fDocsPerFolder;
+    OptionSpec<String> fFolderType;
+    OptionSpec<String> fDocType;
+    OptionSpec<String> fRepoId;
+    OptionSpec<Integer> fCount;
+    OptionSpec<Boolean> fCleanup;
+    OptionSpec<String> fRootFolder;
+    OptionSpec<Integer> fThreads;
+    OptionSpec<String> fFileName;
+    OptionSpec<String> fContentKindStr;
+    OptionSpec<String> fFileNamePattern;
+    OptionSpec<String> fLocalDir;
+    OptionSpec<String> fLocalFile;
+    
+    public static void main(String[] args) {
+
+        ObjGenApp app = new ObjGenApp();
+        try {
+            app.processCmdLine(args);
+        } catch (CmisBaseException ce) {
+            System.out.println("Error: Could not process command. " + ce);
+            System.out.println("Extended error: " + ce.getErrorContent());
+            ce.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("Could not fill repository " + e);
+            e.printStackTrace();
+        }
+    }
+
+    private void processCmdLine(String[] args) {
+
+        OptionParser parser = new OptionParser();
+        fCmd = parser.accepts(CMD).withRequiredArg().describedAs("Command to perform (see below)");
+        fRepoId = parser.accepts(REPOSITORY_ID).withOptionalArg().describedAs("Repository used");
+        fDocType = parser.accepts(FILLER_DOCUMENT_TYPE_ID).withOptionalArg().defaultsTo(
+                BaseTypeId.CMIS_DOCUMENT.value()).describedAs("Document type created");
+        fFolderType = parser.accepts(FILLER_FOLDER_TYPE_ID).withOptionalArg()
+                .defaultsTo(BaseTypeId.CMIS_FOLDER.value()).describedAs("Folder type created");
+        fDocsPerFolder = parser.accepts(FILLER_DOCS_PER_FOLDER).withOptionalArg().ofType(Integer.class).describedAs(
+                "Documents on each level").defaultsTo(1);
+        fFolderPerFolder = parser.accepts(FILLER_FOLDERS_PER_FOLDER).withOptionalArg().ofType(Integer.class)
+                .describedAs(" Folders on each level").defaultsTo(0);
+        fDepth = parser.accepts(FILLER_DEPTH).withOptionalArg().ofType(Integer.class).describedAs("Levels of folders")
+                .defaultsTo(1);
+        fContentSize = parser.accepts(FILLER_CONTENT_SIZE).withOptionalArg().ofType(Integer.class).describedAs(
+                "Content size of each doc").defaultsTo(0);
+        fCount = parser.accepts(COUNT).withOptionalArg().ofType(Integer.class).defaultsTo(1).describedAs(
+                "Repeat a command n times (partially implemented)");
+        fCleanup = parser.accepts(CLEANUP).withOptionalArg().ofType(Boolean.class).defaultsTo(false).describedAs(
+                "Clean all created objects at the end");
+        fRootFolder = parser.accepts(ROOTFOLDER).withOptionalArg().ofType(String.class).describedAs(
+                "folder id used as root to create objects (default repository root folder)");
+        fThreads = parser.accepts(THREADS).withOptionalArg().ofType(Integer.class).defaultsTo(1).describedAs(
+                "Number of threads to start in parallel");
+//        fFileName = parser.accepts(FILE).withRequiredArg().ofType(String.class).describedAs("Input File");
+        fContentKindStr = parser.accepts(CONTENT_KIND).withOptionalArg().ofType(String.class).defaultsTo("lorem/text")
+                .describedAs("kind of content: static/text, lorem/text, lorem/html, fractal/jpeg");
+        fFileNamePattern = parser.accepts(FILE_NAME_PATTERN).withOptionalArg().ofType(String.class).defaultsTo("ContentData-%03d.bin")
+                .describedAs("file name pattern to be used with CreateFiles action");
+        fLocalDir = parser.accepts(LOCAL_DIR).withOptionalArg().ofType(String.class).defaultsTo(".")
+                .describedAs("name of a directory to be recursively copied to the repository");
+        fLocalFile = parser.accepts(LOCAL_FILE).withOptionalArg().ofType(String.class)
+                .describedAs("file name of a file to be copied to the repository");
+        OptionSet options = parser.parse(args);
+
+        if (options.valueOf(fCmd) == null || options.has("?")) {
+            usage(parser);
+        }
+
+        String binding = getBinding();
+        
+        if (binding.equals(BINDING_WS)) {
+            fBindingType = BindingType.WEBSERVICES;
+        } else if (binding.equals(BINDING_ATOM)) {
+            fBindingType = BindingType.ATOMPUB;
+        } else if (binding.equals(BINDING_BROWSER)) {
+            fBindingType = BindingType.BROWSER;
+        } else {
+            System.out.println("Error: Unknown binding: " + binding + " allowed values: "
+                    + BINDING_WS + " or " + BINDING_ATOM + " or " + BINDING_BROWSER);
+            return;
+        }
+
+        String kind = options.valueOf(fContentKindStr);
+        if (null == kind) {
+            if (options.valueOf(fContentSize) > 0)
+                fContentKind = ObjectGenerator.CONTENT_KIND.StaticText;
+            else
+                fContentKind = null;
+        } if (kind.equals("static/text"))
+            fContentKind = ObjectGenerator.CONTENT_KIND.StaticText;
+        else if (kind.equals("lorem/text"))
+            fContentKind = ObjectGenerator.CONTENT_KIND.LoremIpsumText;
+        else if (kind.equals("lorem/html"))
+            fContentKind = ObjectGenerator.CONTENT_KIND.LoremIpsumHtml;
+        else if (kind.equals("fractal/jpeg"))
+            fContentKind = ObjectGenerator.CONTENT_KIND.ImageFractalJpeg;
+        else {
+            System.out.println("Unknown content kind: " + options.valueOf(fContentKindStr));
+            System.out.println("  must be one of static/text, lorem/text, lorem/html, fractal/jpeg");
+            usage(parser);
+        }
+
+        if (null == options.valueOf(fCmd)) {
+            System.out.println("No command given.");
+            usage(parser);
+        } else if (options.valueOf(fCmd).equals("FillRepository")) {
+            fillRepository(options);
+        } else if (options.valueOf(fCmd).equals("CreateDocument")) {
+            createSingleDocument(options);
+        } else if (options.valueOf(fCmd).equals("CreateFolder")) {
+            createFolders(options);
+        } else if (options.valueOf(fCmd).equals("RepositoryInfo")) {
+            repositoryInfo(options);
+//        } else if (options.valueOf(fCmd).equals("CreateTypes")) {
+//            createTypes(options);
+        } else if (options.valueOf(fCmd).equals("CreateFiles")) {
+            createFiles(options);
+        } else if (options.valueOf(fCmd).equals("CopyFiles")) {
+            transferFiles(options);
+        } else {
+            System.out.println("Unknown cmd: " + options.valueOf(fCmd));
+            usage(parser);
+        }
+    }
+
+    // private void preInitExpensiveTasks() {
+    // // JAXB initialization is very expensive, count this separate:
+    // TimeLogger logger = new TimeLogger("Initialization");
+    // logger.start();
+    // try {
+    // JaxBHelper.createMarshaller();
+    // }
+    // catch (JAXBException e) {
+    // System.out.print("Failuer in JAXB init: " + e);
+    // e.printStackTrace();
+    // } // dummy call just to get initialized
+    // logger.stop();
+    // logger.printTimes();
+    // }
+
+    private static void usage(OptionParser parser) {
+        try {
+            System.out.println();
+            System.out.println("ObjGenApp is a command line tool for testing a CMIS repository.");
+            System.out.println("Usage:");
+            parser.printHelpOn(System.out);
+            System.out.println();
+            System.out.println("Command is one of [CreateDocument, CreateFolder, FillRepository, RepositoryInfo, CreateFiles]");
+            System.out.println("JVM system properties: " + PROP_ATOMPUB_URL + ", " + PROP_WS_URL + ", " + PROP_BROWSER_URL);
+            System.out.println("                       " + PROP_USER + ", " + PROP_PASSWORD);
+            System.out.println();
+            System.out.println("Example: ");
+            System.out.println("java -D"
+                    + PROP_ATOMPUB_URL
+                    + "=http://localhost:8080/opencmis/atom -cp ... "
+                    + "org.apache.chemistry.opencmis.util.repository.ObjGenApp --Binding=AtomPub --Command=CreateDocument "
+                    + "--RepositoryId=A1 --ContentSizeInKB=25 --ContentKind=lorem/text");
+            return;
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void fillRepository(String repoId, int docsPerFolder, int foldersPerFolders, int depth,
+            String documentType, String folderType, int contentSizeInKB, String rootFolderId, boolean doCleanup) {
+
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator.prepareForCreateTree(
+                getClientBindings(), repoId, docsPerFolder, foldersPerFolders, depth, documentType, folderType,
+                contentSizeInKB, rootFolderId, fContentKind, doCleanup);
+        ObjectGenerator gen = runner.getObjectGenerator();
+        runner.doCreateTree();
+
+        System.out.println();
+        System.out.println("Result:");
+        System.out.println("Filling repository succeeded.");
+        System.out.println("Folder used as root for creation (null=rootFolderId): " + rootFolderId);
+        System.out.println("Number of documents created: " + gen.getDocumentsInTotal());
+        System.out.println("Number of folders created: " + gen.getFoldersInTotal());
+        gen.printTimings();
+    }
+
+    private void fillRepositoryMT(int noThreads, String repoId, int docsPerFolder, int foldersPerFolders, int depth,
+            String documentType, String folderType, int contentSizeInKB, String rootFolderId, boolean doCleanup) {
+
+        // Step 1: create a root folder for each thread
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
+                .prepareForCreateFolder(getClientBindings(), repoId, folderType, rootFolderId, noThreads, doCleanup);
+        String[] folderIds = runner.doCreateFolder();
+
+        // Step 2: fill each root folder with an object tree
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
+                .prepareForCreateTreeMT(getClientBindings(), repoId, docsPerFolder, foldersPerFolders, depth, documentType,
+                        folderType, contentSizeInKB, folderIds, fContentKind, doCleanup);
+
+        MultiThreadedObjectGenerator.runMultiThreaded(runners);
+        System.out.println("Filling repository succeeded.");
+    }
+
+    private void printParameters(OptionSet options) {
+        if (fBindingType == BindingType.ATOMPUB) {
+            System.out.println("Using AtomPub, connecting to  " + getAtomPubUrl());
+        } else if (fBindingType == BindingType.WEBSERVICES) {
+            System.out.println("Using WebService, connecting to  " + getWsUrl());
+        } else if (fBindingType == BindingType.BROWSER) {
+            System.out.println("Using Browser binding, connecting to  " + getBrowserUrl());
+        } else
+            System.out.println("Unknown binding type.");
+
+        System.out.println("Repository id is: " + options.valueOf(fRepoId));
+        System.out.println("Content size: " + options.valueOf(fContentSize));
+        System.out.println("Document Type: " + options.valueOf(fDocType));
+        System.out.println("Folder id used as root: " + options.valueOf(fRootFolder));
+        System.out.println("Delete all objects after creation: " + options.valueOf(fCleanup));
+        System.out.println("Number of actions to perform: " + options.valueOf(fCount));
+        System.out.println("Number of threads to start: " + options.valueOf(fThreads));
+        System.out.println("Kind of created content: " + options.valueOf(fContentKindStr));
+    }
+
+    private void createSingleDocument(OptionSet options) {
+        System.out.println();
+        System.out.println("Creating document with parameters:");
+        printParameters(options);
+        int noThreads = options.valueOf(fThreads);
+        if (noThreads <= 1) {
+            createSingleDocument(options.valueOf(fRepoId), options.valueOf(fDocType), options.valueOf(fContentSize),
+                    options.valueOf(fRootFolder), options.valueOf(fCount), options.valueOf(fCleanup));
+        } else {
+            createSingleDocumentMT(noThreads, options.valueOf(fRepoId), options.valueOf(fDocType), options
+                    .valueOf(fContentSize), options.valueOf(fRootFolder), options.valueOf(fCount), options
+                    .valueOf(fCleanup));
+        }
+    }
+
+    private void fillRepository(OptionSet options) {
+        System.out.println();
+        printParameters(options);
+        System.out.println("Creating object tree with folowing parameters: ");
+        System.out.println("Documents per folder: " + options.valueOf(fDocsPerFolder));
+        System.out.println("Folder per folder: " + options.valueOf(fFolderPerFolder));
+        System.out.println("Depth: " + options.valueOf(fDepth));
+        System.out.println("Folder Type: " + options.valueOf(fFolderType));
+
+        int noThreads = options.valueOf(fThreads);
+        if (noThreads <= 1) {
+            fillRepository(options.valueOf(fRepoId), options.valueOf(fDocsPerFolder),
+                    options.valueOf(fFolderPerFolder), options.valueOf(fDepth), options.valueOf(fDocType), options
+                            .valueOf(fFolderType), options.valueOf(fContentSize), options.valueOf(fRootFolder), options
+                            .valueOf(fCleanup));
+        } else {
+            fillRepositoryMT(noThreads, options.valueOf(fRepoId), options.valueOf(fDocsPerFolder), options
+                    .valueOf(fFolderPerFolder), options.valueOf(fDepth), options.valueOf(fDocType), options
+                    .valueOf(fFolderType), options.valueOf(fContentSize), options.valueOf(fRootFolder), options
+                    .valueOf(fCleanup));
+        }
+
+    }
+
+    private void createFolders(OptionSet options) {
+        System.out.println();
+        System.out.println("Creating folder with parameters:");
+        printParameters(options);
+        System.out.println("Folder Type: " + options.valueOf(fFolderType));
+        int noThreads = options.valueOf(fThreads);
+        if (noThreads <= 1) {
+            createFolders(options.valueOf(fRepoId), options.valueOf(fFolderType), options.valueOf(fRootFolder), options
+                    .valueOf(fCount), options.valueOf(fCleanup));
+        } else {
+            createFoldersMT(noThreads, options.valueOf(fRepoId), options.valueOf(fFolderType), options
+                    .valueOf(fRootFolder), options.valueOf(fCount), options.valueOf(fCleanup));
+        }
+    }
+
+    private void createSingleDocument(String repoId, String documentType, int contentSizeInKB, String rootFolderId,
+            int docCount, boolean doCleanup) {
+
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
+                .prepareForCreateDocument(getClientBindings(), repoId, documentType, contentSizeInKB, rootFolderId, docCount,
+                        fContentKind, doCleanup);
+        ObjectGenerator gen = runner.getObjectGenerator();
+        String[] ids = runner.doCreateDocument();
+        System.out.println();
+        System.out.println("Result:");
+        System.out.println("Document creation succeeded.");
+        System.out.println("Folder used as root for creation: " + rootFolderId);
+        System.out.println("Ids of created documents: ");
+        if (null == ids) {
+            System.out.println("<none>");
+        } else {
+            for (int i = 0; i < ids.length; i++) {
+                System.out.println(ids[i]);
+            }
+        }
+        gen.printTimings();
+        gen.resetCounters();
+    }
+
+    private void createSingleDocumentMT(int noThreads, String repoId, String documentType, int contentSizeInKB,
+            String rootFolderId, int docCount, boolean doCleanup) {
+
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
+                .prepareForCreateDocumentMT(noThreads, getClientBindings(), repoId, documentType, contentSizeInKB,
+                        rootFolderId, docCount, fContentKind, doCleanup);
+
+        MultiThreadedObjectGenerator.runMultiThreaded(runners);
+        System.out.println("Document creation succeeded. All threads terminated.");
+    }
+
+    private void createFolders(String repoId, String folderType, String rootFolderId, int noFolders, boolean doCleanup) {
+
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
+                .prepareForCreateFolder(getClientBindings(), repoId, folderType, rootFolderId, noFolders, doCleanup);
+        ObjectGenerator gen = runner.getObjectGenerator();
+        String[] ids = runner.doCreateFolder();
+        System.out.println();
+        System.out.println("Result:");
+        System.out.println("Folder creation succeeded.");
+        System.out.println("Ids of created folders: ");
+        if (null == ids) {
+            System.out.println("<none>");
+        } else {
+            for (int i = 0; i < ids.length; i++) {
+                System.out.println(ids[i]);
+            }
+        }
+        gen.printTimings();
+        gen.resetCounters();
+    }
+
+    private void createFoldersMT(int noThreads, String repoId, String folderType, String rootFolderId, int noFolders,
+            boolean doCleanup) {
+
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
+                .prepareForCreateFolderMT(noThreads, getClientBindings(), repoId, folderType, rootFolderId, noFolders,
+                        doCleanup);
+        MultiThreadedObjectGenerator.runMultiThreaded(runners);
+        System.out.println("Folder creation succeeded.");
+    }
+
+    private void callRepoInfo(String repositoryId, int count) {
+        RepositoryService repSvc = getClientBindings().getRepositoryService();
+        TimeLogger timeLogger = new TimeLogger("RepoInfoTest");
+        RepositoryInfo repoInfo = null;
+        for (int i = 0; i < count; i++) {
+            binding.clearRepositoryCache(repositoryId);
+            timeLogger.start();
+            repoInfo = repSvc.getRepositoryInfo(repositoryId, null);
+            timeLogger.stop();
+        }
+        System.out.println("Root Folder id is: " + (repoInfo == null ? "<unknown>" : repoInfo.getRootFolderId()));
+        timeLogger.printTimes();
+    }
+
+    private void createTypes(OptionSet options) {
+
+        String repoId = options.valueOf(fRepoId);
+        String fileName = options.valueOf(fFileName);
+        System.out.println();
+        System.out.println("Not yet implemented waiting for CMIS 1.1!");
+//        System.out.println("Creating types from file:");
+//        System.out.println("File Name: " + fileName);
+//        System.out.println("Repository Id: " + repoId);
+//
+//        File file = new File(options.valueOf(fFileName));
+//        TypeDefinitionList typeDefs = null;
+//
+//        try {
+//            Unmarshaller u = JaxBHelper.createUnmarshaller();
+//            JAXBElement<CmisTypeDefinitionListType> type = (JAXBElement<CmisTypeDefinitionListType>) u.unmarshal(file);
+//            typeDefs = Converter.convert(type.getValue());
+//        } catch (Exception e) {
+//            System.out.println("Could not load type: '" + fFileName + "': " + e);
+//        }
+//        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator.prepareForCreateTypes(
+//                getBinding(), repoId, typeDefs);
+//        ObjectGenerator gen = runner.getObjectGenerator();
+//        gen.createTypes(typeDefs);
+    }
+        
+    private void repositoryInfo(OptionSet options) {
+        callRepoInfo(options.valueOf(fRepoId), options.valueOf(fCount));
+    }
+
+    private void createFiles(OptionSet options) {
+        ContentStream contentStream = null;
+        String fileNamePattern = options.valueOf(fFileNamePattern);
+        int count = options.valueOf(fCount);
+        int contentSize = options.valueOf(fContentSize);
+        
+        System.out.println("Creating local files with content: ");
+        System.out.println("Kind: " + options.valueOf(fDocsPerFolder));
+        System.out.println("Number of files: " + count);
+        System.out.println("File name pattern: " + fileNamePattern);
+        System.out.println("Kind of content: " + options.valueOf(fContentKindStr));
+        System.out.println("Size of content (text only): " + contentSize);
+        
+        ObjectGenerator objGen = new ObjectGenerator(null, null, null, null, null, fContentKind);
+        objGen.setContentSizeInKB(contentSize);
+        
+        InputStream is = null;
+        FileOutputStream os = null;
+        
+        try {
+            for (int i=0; i<count; i++) {
+                String fileName = String.format(fileNamePattern, i);
+                System.out.println("Generating file: " + fileName);
+                if (contentSize > 0) {
+                    switch (fContentKind) {
+                    case StaticText:
+                        contentStream = objGen.createContentStaticText();
+                        break;
+                    case LoremIpsumText:
+                        contentStream =  objGen.createContentLoremIpsumText();
+                        break;
+                    case LoremIpsumHtml:
+                        contentStream =  objGen.createContentLoremIpsumHtml();
+                        break;
+                    case ImageFractalJpeg:
+                        contentStream =  objGen.createContentFractalimageJpeg();
+                        break;
+                    }
+                }
+
+                // write to a file:
+                is = contentStream.getStream();
+                os = new FileOutputStream (fileName);
+                byte[] b = new byte[64 * 1024];  
+                int read;  
+                while ((read = is.read(b)) != -1)   
+                    os.write(b, 0, read);  
+                is.close();
+                is = null;
+                os.close();
+                os = null;
+            }
+        } catch (Exception e) {
+            System.err.println("Error generating file: " + e);
+            e.printStackTrace();
+        } finally {
+            try {
+                if (null != is)
+                        is.close();
+                if (null != os)
+                    os.close();
+            } catch (IOException e) {
+            }            
+        }
+    }
+
+    private void transferFiles(OptionSet options) {
+        String fileName = options.valueOf(fLocalFile);
+        String dirName = options.valueOf(fLocalDir);
+        String repoId = options.valueOf(fRepoId);
+        
+        if ((null == fileName || fileName.length() == 0) && (null == dirName || dirName.length() == 0)) {
+            System.out.println("Error: You either have to provide a --file or a --dir option to copy file(s).");
+            return;
+        }
+        if (null == fRepoId || repoId.length() == 0) {
+            System.out.println("Error: You have to provide a repository id");
+            return;
+        }
+        System.out.println("Copying files to a repository: ");
+        System.out.println("Repository id is: " + repoId);
+        System.out.println("Folder id used as root: " + options.valueOf(fRootFolder));
+        
+        Map<String, String> parameters = getConnectionParameters(getBinding(), repoId);
+        System.out.println("TODO: Not implemented.");
+//        FileCopy fc = new FileCopy();
+//        fc.connect(parameters);
+//        fc.copyFileToRepository(fileName);
+    }
+        
+    private Map<String, String> getConnectionParameters(String binding, String repoId) {
+        Map<String, String> parameters = new HashMap<String, String>();
+        parameters.put(SessionParameter.REPOSITORY_ID, repoId);
+        parameters.put(SessionParameter.BINDING_TYPE, binding);
+
+        if (binding.equals(BindingType.ATOMPUB.value())) {
+            parameters.put(SessionParameter.ATOMPUB_URL, getAtomPubUrl());
+            filLoginParams(parameters, getUser(), getPassword());
+        } if (binding.equals(BindingType.WEBSERVICES.value())) {
+            fillWSParameters(parameters, getWsUrl(), isPrefix(getWsUrl()), getUser(), getPassword());
+        } else if (binding.equals(BindingType.BROWSER.value())) {
+            parameters.put(SessionParameter.BROWSER_URL, getBrowserUrl());
+            filLoginParams(parameters, getUser(), getPassword());
+        } else {
+            System.out.println("Error unknown binding: " + binding);
+        }
+
+        return parameters;
+    }
+
+    private CmisBinding getClientBindings() {
+        if (binding == null) {
+            if (fBindingType == BindingType.ATOMPUB) {
+                binding = createAtomBinding(getAtomPubUrl(), getUser(), getPassword());
+            } if (fBindingType == BindingType.WEBSERVICES) {
+                String url = getWsUrl();
+                binding = createWSBinding(url, isPrefix(url), getUser(), getPassword()); 
+            } else if (fBindingType == BindingType.BROWSER) {
+                binding = createBrowserBinding(getBrowserUrl(), getUser(), getPassword()); 
+            }
+        }
+        return binding;
+    }
+
+    private static void filLoginParams(Map<String, String> parameters, String user, String password) {
+        if (user != null && user.length() > 0) {
+            parameters.put(SessionParameter.USER, user);
+        }
+        if (user != null && user.length() > 0) {
+            parameters.put(SessionParameter.PASSWORD, password);
+        }
+    }
+
+    private static CmisBinding createAtomBinding(String url, String user, String password) {
+
+        // gather parameters
+        Map<String, String> parameters = new HashMap<String, String>();
+        filLoginParams(parameters, user, password);
+
+        // get factory and create binding
+        CmisBindingFactory factory = CmisBindingFactory.newInstance();
+        parameters.put(SessionParameter.ATOMPUB_URL, url);
+        CmisBinding binding = factory.createCmisAtomPubBinding(parameters);
+        return binding;
+    }
+
+    private static CmisBinding createBrowserBinding(String url, String user, String password) {
+
+        // gather parameters
+        Map<String, String> parameters = new HashMap<String, String>();
+        filLoginParams(parameters, user, password);
+
+        // get factory and create binding
+        CmisBindingFactory factory = CmisBindingFactory.newInstance();
+        parameters.put(SessionParameter.BROWSER_URL, url);
+        CmisBinding binding = factory.createCmisBrowserBinding(parameters);
+        return binding;
+    }
+
+    private static boolean isPrefix(String url) {
+        boolean isPrefix = true;
+        String urlLower = url.toLowerCase();
+
+        if (urlLower.endsWith("?wsdl")) {
+            isPrefix = false;
+        } else if (urlLower.endsWith(".wsdl")) {
+            isPrefix = false;
+        } else if (urlLower.endsWith(".xml")) {
+            isPrefix = false;
+        }
+        return isPrefix;
+    }
+    
+    public static CmisBinding createWSBinding(String url, boolean isPrefix, String username, String password) {
+        Map<String, String> parameters = new HashMap<String, String>();
+        fillWSParameters(parameters, url, isPrefix, username, password);
+        
+        // get factory and create provider
+        CmisBindingFactory factory = CmisBindingFactory.newInstance();
+        CmisBinding binding = factory.createCmisWebServicesBinding(parameters);
+
+        return binding;
+    }
+    
+    public static void fillWSParameters(Map<String, String> parameters, String url, boolean isPrefix, String username, String password) {
+        // gather parameters
+        parameters.put(SessionParameter.USER, username);
+        parameters.put(SessionParameter.PASSWORD, password);
+
+        if (!isPrefix) {
+            parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url);
+        } else {
+            parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url + "RepositoryService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url + "NavigationService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url + "ObjectService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url + "VersioningService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url + "DiscoveryService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url + "RelationshipService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url + "MultiFilingService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url + "PolicyService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url + "ACLService?wsdl");
+        }
+    }
+
+    private static String getBinding() {
+        return System.getProperty(PROP_BINDING, DEFAULT_BINDING);
+    }
+    
+    private static String getAtomPubUrl() {
+        return System.getProperty(PROP_ATOMPUB_URL, DEFAULT_ATOMPUB_URL);
+    }
+
+    private static String getWsUrl() {
+        return System.getProperty(PROP_WS_URL, DEFAULT_WS_URL);
+    }
+
+    private static String getBrowserUrl() {
+        return System.getProperty(PROP_BROWSER_URL, DEFAULT_BROWSER_BINDING_URL);
+    }
+
+    private static String getUser() {
+        return System.getProperty(PROP_USER, DEFAULT_USER);
+    }
+
+    private static String getPassword() {
+        return System.getProperty(PROP_PASSWORD, DEFAULT_PASSWORD);
+    }
+
+    private static void getUrl(String urlStr) {
+        URL url;
+        InputStream is;
+        InputStreamReader isr;
+        BufferedReader r;
+        String str;
+
+        try {
+            System.out.println("Reading URL: " + urlStr);
+            url = new URL(urlStr);
+            is = url.openStream();
+            isr = new InputStreamReader(is);
+            r = new BufferedReader(isr);
+            do {
+                str = r.readLine();
+                if (str != null) {
+                    System.out.println(str);
+                }
+            } while (str != null);
+        } catch (MalformedURLException e) {
+            System.out.println("Must enter a valid URL" + e);
+        } catch (IOException e) {
+            System.out.println("Can not connect" + e);
+        }
+    }
+
+}

Added: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/specexamples/Main.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/specexamples/Main.java?rev=1302466&view=auto
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/specexamples/Main.java (added)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-client/src/main/java/org/apache/chemistry/opencmis/client/specexamples/Main.java Mon Mar 19 14:18:36 2012
@@ -0,0 +1,635 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.chemistry.opencmis.client.specexamples;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.data.Ace;
+import org.apache.chemistry.opencmis.commons.data.Acl;
+import org.apache.chemistry.opencmis.commons.data.CmisExtensionElement;
+import org.apache.chemistry.opencmis.commons.data.ContentStream;
+import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderData;
+import org.apache.chemistry.opencmis.commons.data.ObjectInFolderList;
+import org.apache.chemistry.opencmis.commons.data.Properties;
+import org.apache.chemistry.opencmis.commons.data.PropertyData;
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.enums.BindingType;
+import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
+import org.apache.chemistry.opencmis.commons.enums.VersioningState;
+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;
+import org.apache.chemistry.opencmis.commons.impl.dataobjects.ExtensionDataImpl;
+import org.apache.chemistry.opencmis.commons.spi.AclService;
+import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
+import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
+import org.apache.chemistry.opencmis.commons.spi.DiscoveryService;
+import org.apache.chemistry.opencmis.commons.spi.Holder;
+import org.apache.chemistry.opencmis.commons.spi.MultiFilingService;
+import org.apache.chemistry.opencmis.commons.spi.NavigationService;
+import org.apache.chemistry.opencmis.commons.spi.ObjectService;
+import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
+import org.apache.chemistry.opencmis.commons.spi.VersioningService;
+import org.apache.commons.io.filefilter.WildcardFileFilter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class Main {
+
+    private static final Log LOG = LogFactory.getLog(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 String targetDir = System.getProperty("java.io.tmpdir");// + File.separator;
+
+    private BindingsObjectFactory objFactory = new BindingsObjectFactoryImpl();
+    private BindingType bindingType;
+    private String rootFolderId;
+    private String repositoryId;
+    private ObjectService objSvc;
+    private NavigationService navSvc;
+    private RepositoryService repSvc;
+    private VersioningService verSvc;
+    private MultiFilingService multiSvc;
+    private DiscoveryService discSvc;
+    private AclService aclSvc;
+
+    private static final String[] URLS = {"http://localhost:8080/inmemory/atom", 
+            "http://localhost:8080/inmemory/services", 
+            "http://localhost:8080/inmemory/browser"};
+    private static final BindingType[] BINDINGS = {BindingType.ATOMPUB, BindingType.WEBSERVICES, BindingType.BROWSER};
+
+    public Main() {
+    }
+
+    public void runAllBindings() {
+      for (int i = 0; i < BINDINGS.length; i++) {
+            bindingType = BINDINGS[i];
+            init(URLS[i], BINDINGS[i]);
+            run();
+        }
+        
+    }
+    
+    public void run() {
+        LOG.debug("Generating spec examples for Binding: " + bindingType.value());
+        // Repository Service:
+        getRepositories();
+
+        repositoryId = "A1";
+        getRepositoryInfo();
+
+        getTypeDefinition("cmis:folder");
+        
+        String docId = getTestDocId();
+        String folderId = getTestFolderId();
+
+        getTypeChildren(TOPLEVEL_TYPE);
+
+        // Navigation Service:
+        getChildren(folderId);
+        getDescendants(folderId);
+
+        // 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();
+
+        // Versioning Service
+        String id2 = prepareVersionSeries("VersionedDocument", VERSIONED_TYPE, rootFolderId);
+        checkOut(id2);
+        checkIn(id2, true, "final version in series");
+        getAllVersions(id2);
+
+        // delete all generated objects
+        String[] ids = {id2};
+        
+        cleanup(ids);
+
+        // collect all captured files and store them in a ZIP file
+        String dirs[] = {BindingType.ATOMPUB.value(), BindingType.WEBSERVICES.value(), BindingType.BROWSER.value() };        
+        createZipFile("CMIS-Spec-Examples.zip", dirs);
+    }
+
+    private void init(String url, BindingType bindingType) {
+        LOG.debug("Initializing connection to InMemory server: ");
+        LOG.debug("   Binding: " + bindingType.value());
+        LOG.debug("   URL: " + url);
+
+        Map<String, String> parameters = new HashMap<String, String>();
+        parameters.put(SessionParameter.USER, "admin");
+        parameters.put(SessionParameter.PASSWORD, "admin");
+
+        parameters.put(SessionParameter.BINDING_TYPE, bindingType.value());
+
+        // get factory and create binding
+        CmisBindingFactory factory = CmisBindingFactory.newInstance();
+        CmisBinding binding = null;
+        
+        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);            
+        } else if (bindingType == BindingType.BROWSER) {
+            parameters.put(SessionParameter.BROWSER_URL, url); 
+            binding = factory.createCmisBrowserBinding(parameters);            
+        } else {
+            LOG.error("Unknown binding type: " + bindingType.value());
+            return;
+        }
+        objFactory = binding.getObjectFactory();
+        repSvc = binding.getRepositoryService();
+        objSvc = binding.getObjectService();
+        navSvc = binding.getNavigationService();
+        verSvc = binding.getVersioningService();
+        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);
+        boolean ok = in.mkdir();
+        
+        LOG.debug("creating target directory for files: " + ok);
+        LOG.debug("Initializing done. ");
+    }
+
+    private void getRepositories() {
+        LOG.debug("getRepositories()");
+        List<RepositoryInfo> repositories = repSvc.getRepositoryInfos(null);
+        this.repositoryId = repositories.get(0).getId();
+        renameFiles("getRepositoryInfos");
+        LOG.debug("getRepositoryInfo() done.");
+    }
+
+    private void getRepositoryInfo() {
+        LOG.debug("getting repository info for repository " + repositoryId);
+        // Because the browser binding silently retrieves 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);
+        if (bindingType.equals(BindingType.BROWSER)) {
+            ExtensionDataImpl dummyExt = new ExtensionDataImpl();
+            List<CmisExtensionElement> extList = new ArrayList<CmisExtensionElement>() {{ add(new CmisExtensionElementImpl("foo", "foo", null, "bar")); }};
+            dummyExt.setExtensions(extList);
+            repoInfo = repSvc.getRepositoryInfo(repositoryId, dummyExt);
+        }
+        LOG.debug("repository id is: " + repoInfo.getId());
+        rootFolderId = repoInfo.getRootFolderId();
+        LOG.debug("root folder id is: " + repoInfo.getRootFolderId());
+        renameFiles("getRepositoryInfo");
+        LOG.debug("getRepositoryInfo() done.");
+    }
+
+    private void getObject(String objectId) {
+        LOG.debug("getObject " + objectId);
+        objSvc.getObject(repositoryId, objectId, "*", true /* includeAllowableActions */,
+                IncludeRelationships.NONE /* includeRelationships */, null /* renditionFilter */,
+                false /* includePolicyIds */, true /* includeAcl */, null);
+        renameFiles("getObject");
+        LOG.debug("getObject() done.");
+    }
+
+    private void getChildren(String folderId) {
+        LOG.debug("getChildren " + folderId);
+        navSvc.getChildren(repositoryId, folderId, "*", null /* orderBy */, true /* includeAllowableActions */,
+                IncludeRelationships.NONE, null /* renditionFilter */, true /* includePathSegment */, MAX_ITEMS,
+                SKIP_COUNT, null);
+        renameFiles("getChildren");
+        LOG.debug("getChildren() done.");
+    }
+
+    private void getDescendants(String folderId) {
+        final BigInteger DEPTH = BigInteger.valueOf(3);
+        LOG.debug("getDescendants " + folderId);
+        navSvc.getDescendants(repositoryId, folderId, DEPTH, "*", true /* includeAllowableActions */,
+                IncludeRelationships.NONE, null /* renditionFilter */, true /* includePathSegment */, null);
+        renameFiles("getDescendants");
+        LOG.debug("getDescendants() done.");
+    }
+
+    private void doQuery() {
+        LOG.debug("doQuery ");
+        String statement = "SELECT * from cmis:document WHERE IN_FOLDER('" + rootFolderId + "')";
+        discSvc.query(repositoryId, statement, false /* searchAllVersions */, true /* includeAllowableActions */,
+                IncludeRelationships.NONE, null, MAX_ITEMS, SKIP_COUNT, null);
+        renameFiles("doQuery");
+        LOG.debug("doQuery() done.");
+    }
+
+    private void getTypeChildren(String typeId) {
+        LOG.debug("getTypeChildren " + typeId);
+        repSvc.getTypeChildren(repositoryId, typeId, true /* includePropertyDefinitions */, MAX_ITEMS, SKIP_COUNT, null);
+        renameFiles("getTypeChildren");
+        LOG.debug("getTypeChildren() done.");
+    }
+
+    private String createDocument(String name, String typeId, String folderId, VersioningState versioningState) {
+        LOG.debug("createDocument " + typeId);
+
+        String id = createDocumentIntern(name, typeId, folderId, versioningState);
+        renameFiles("createDocument");
+        LOG.debug("createDocument() done.");
+
+        return id;
+    }
+
+    private String createDocumentIntern(String name, String typeId, String folderId, VersioningState versioningState) {
+        ContentStream contentStream = null;
+        List<String> policies = null;
+        Acl addACEs = null;
+        Acl removeACEs = null;
+        ExtensionsData extension = null;
+
+        List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+        properties.add(objFactory.createPropertyIdData(PropertyIds.NAME, name));
+        properties.add(objFactory.createPropertyIdData(PropertyIds.OBJECT_TYPE_ID, typeId));
+        Properties props = objFactory.createPropertiesData(properties);
+
+        contentStream = createContent();
+
+        String id = null;
+        id = objSvc.createDocument(repositoryId, props, folderId, contentStream, versioningState, policies, addACEs,
+                removeACEs, extension);
+        return id;
+    }
+
+    private ContentStream createContent() {
+        ContentStreamImpl content = new ContentStreamImpl();
+        content.setFileName("data.txt");
+        content.setMimeType("text/plain");
+        int len = 32 * 1024;
+        byte[] b = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a,
+                0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x0c, 0x0a }; // 32
+        // Bytes
+        ByteArrayOutputStream ba = new ByteArrayOutputStream(len);
+        try {
+            for (int i = 0; i < 1024; i++) {
+                ba.write(b);
+            }
+        } catch (IOException e) {
+            throw new RuntimeException("Failed to fill content stream with data", e);
+        }
+        content.setStream(new ByteArrayInputStream(ba.toByteArray()));
+        content.setLength(BigInteger.valueOf(len));
+        return content;
+    }
+
+    private void updateProperties(String id, String propertyId, String propertyValue) {
+        LOG.debug("updateProperties " + id);
+        List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+        properties.add(objFactory.createPropertyStringData(propertyId, propertyValue));
+        Properties newProps = objFactory.createPropertiesData(properties);
+
+        Holder<String> idHolder = new Holder<String>(id);
+        Holder<String> changeTokenHolder = new Holder<String>();
+        objSvc.updateProperties(repositoryId, idHolder, changeTokenHolder, newProps, null);
+        renameFiles("updateProperties");
+        LOG.debug("updateProperties() done.");
+    }
+
+    private void deleteObject(String id) {
+        LOG.debug("deleteObject " + id);
+        objSvc.deleteObject(repositoryId, id, true, null);
+        renameFiles("deleteObject");
+        LOG.debug("deleteObject() done.");
+    }
+
+    private void cleanup (String[] ids) {
+        LOG.debug("cleaning up...");
+        for (String id : ids) {
+            LOG.debug("deleteing object " + id);
+            objSvc.deleteObject(repositoryId, id, true, null);            
+        }
+        LOG.debug("... cleaning up done");
+    }
+    
+    /**
+     * enumerate the children of the root folder and return the id of the first
+     * document
+     * 
+     * @return id of first doc in root folder
+     */
+    private String getTestDocId() {
+        return getTestId(BaseTypeId.CMIS_DOCUMENT);
+    }
+
+    /**
+     * enumerate the children of the root folder and return the id of the first
+     * sub-folder
+     * 
+     * @return id of first doc in root folder
+     */
+    private String getTestFolderId() {
+        return getTestId(BaseTypeId.CMIS_FOLDER);
+    }
+
+    private String getTestId(BaseTypeId baseTypeId) {
+        LOG.debug("getTestDocId()");
+        ObjectInFolderList result = navSvc.getChildren(repositoryId, rootFolderId, "*", 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) {
+            if (baseTypeId.equals(child.getObject().getBaseTypeId()))
+                return child.getObject().getId();
+        }
+        return null;
+    }
+
+    private String prepareVersionSeries(String name, String typeId, String folderId) {
+        String id = createDocumentIntern(name, typeId, folderId, VersioningState.MAJOR);
+        Holder<Boolean> contentCopied = new Holder<Boolean>();
+        Holder<String> idHolder = new Holder<String>(id);
+
+        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.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*/);
+        
+        return idHolder.getValue();
+    }
+    
+    private void checkOut(String id) {
+        LOG.debug("checkOut()");        
+        Holder<String> idHolder = new Holder<String>(id);
+        Holder<Boolean> contentCopied = new Holder<Boolean>(true);
+        verSvc.checkOut(repositoryId, idHolder, null, contentCopied);
+        renameFiles("checkOut");
+        LOG.debug("checkOut done.");
+    }
+
+    private void checkIn(String id, boolean major, String checkinComment) {
+        LOG.debug("checkIn()");
+        List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
+        properties.add(objFactory.createPropertyStringData(VERSIONED_PROP, "updated value"));
+        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*/);
+        renameFiles("checkIn");
+        LOG.debug("checkIn done.");
+    }
+
+    private void getAllVersions(String id) {
+        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);
+
+        // get old ACL first:
+        Acl oldAcl = aclSvc.getAcl(repositoryId, objectId, true, null);
+
+        // create a new ACL for the test doc
+        List<Ace> aces = new ArrayList<Ace>();
+        aces.add(objFactory.createAccessControlEntry("Alice", Collections.singletonList("cmis:read")));
+        aces.add(objFactory.createAccessControlEntry("Bob", Collections.singletonList("cmis:write")));
+        aces.add(objFactory.createAccessControlEntry("admin", Collections.singletonList("cmis:all")));
+        Acl acl = objFactory.createAccessControlList(aces);
+
+        // 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.");
+    }
+
+    private void getTypeDefinition(String typeId) {
+        LOG.debug("getTypeDefinition " + typeId);
+        repSvc.getTypeDefinition(repositoryId, typeId, null);
+        renameFiles("getTypeDefinition");
+        LOG.debug("getTypeDefinition() done.");
+    }
+
+    private void getTypeDescendants(String typeId) {
+        LOG.debug("getTypeDescendants " + typeId);
+        repSvc.getTypeDescendants(repositoryId, typeId, TYPE_DEPTH_ALL, true /* includePropertyDefinitions */, null);
+        renameFiles("getTypeDescendants");
+        LOG.debug("getTypeDescendants() done.");
+    }
+
+    private void getAllowableActions(String objectId) {
+        LOG.debug("getAllowableActions " + objectId);
+        objSvc.getAllowableActions(repositoryId, objectId, null);
+        renameFiles("getAllowableActions");
+        LOG.debug("getAllowableActions() done.");
+    }
+
+    private void renameFiles(String name) {
+        String fileNameInReq = findLastFile(LOGDIR, "*-request.log");
+        String fileNameInResp = findLastFile(LOGDIR, "*-response.log");
+        if (null == fileNameInReq) {
+            LOG.error("Failed to find captured request file for " + name);
+            return;
+        }
+        if (null == fileNameInResp) {
+            LOG.error("Failed to find captured response file for " + name);
+            return;
+        }
+        File in = new File(fileNameInReq);
+        File out = new File(targetDir + File.separator + name + "-request.log");
+        if (out.exists())
+            out.delete();
+        boolean ok = in.renameTo(out);
+        if (ok)
+            LOG.debug("Renaming file " + in.getAbsolutePath() + " to " + out.getAbsolutePath() + " succeeded.");
+        else
+            LOG.warn("Renaming file " + in.getAbsolutePath() + " to " + out.getAbsolutePath() + " failed.");
+
+        in = new File(fileNameInResp);
+        out = new File(targetDir + File.separator + name + "-response.log");
+        if (out.exists())
+            out.delete();
+        ok = in.renameTo(out);
+        if (ok)
+            LOG.debug("Renaming file " + in.getAbsolutePath() + "to " + out.getAbsolutePath() + " succeeded.");
+        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;
+        try {
+            fout = new FileOutputStream(zipFileName);
+            zout = new ZipOutputStream(fout);
+            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);
+            }
+        }
+    }
+    
+    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())
+                {
+                    addDirectory(zout, prefix + File.separator + files[i].getName(), files[i]);
+                } else {
+                    LOG.debug("Create Zip, adding file " + files[i].getName());
+                    byte[] buffer = new byte[65536];
+                    FileInputStream fin = new FileInputStream(files[i]);
+                    String zipEntryName = prefix + File.separator + files[i].getName();
+                    LOG.debug("   adding entry " + zipEntryName);
+                    zout.putNextEntry(new ZipEntry(zipEntryName));
+
+                    int length;
+                    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);
+            boolean ok = dirToDelete.delete();
+            if (ok)
+                LOG.debug("Deleting dir " + dirToDelete.getAbsolutePath() + " succeeded.");
+            else
+                LOG.warn("Deleting dir " + dirToDelete.getAbsolutePath() + " failed.");
+        }
+        LOG.debug("... done.");        
+    }
+    
+    private static void cleanFilesWithFilter(String directoryPath, String wildcardFilter) {
+        File dir = new File(directoryPath);
+        FileFilter fileFilter = new WildcardFileFilter(wildcardFilter);
+        File[] files = dir.listFiles(fileFilter);
+        if (files != null)
+            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);
+        if (files.length == 0)
+            return null;
+        else
+            return files[files.length-1].getAbsolutePath();
+    }
+
+    public static void main(String[] args) {
+        if (args.length > 0 && args[0].equals("-clean")) {
+            LOG.debug("Cleaning up generated files...");
+            Main.clean();
+            LOG.debug("... cleaning up done.");
+        } else {
+            LOG.debug("Starting generating spec examples...");
+            Main main = new Main();
+            main.runAllBindings();
+            LOG.debug("... finished generating spec examples.");
+        }
+    }
+}



Mime
View raw message