chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1187960 - in /chemistry/opencmis/trunk: chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemist...
Date Sun, 23 Oct 2011 19:56:46 GMT
Author: jens
Date: Sun Oct 23 19:56:45 2011
New Revision: 1187960

URL: http://svn.apache.org/viewvc?rev=1187960&view=rev
Log:
Prepare ObjectGenerator for later type creation

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/FixtureSetup.java
    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/ObjGenApp.java
    chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java?rev=1187960&r1=1187959&r2=1187960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/DiscoveryServiceTest.java
Sun Oct 23 19:56:45 2011
@@ -52,7 +52,7 @@ public class DiscoveryServiceTest extend
     public void testQuery() {
         log.info("starting testQuery() ...");
 
-        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepositoryId);
+        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepSvc, fRepositoryId);
         gen.setNumberOfDocumentsToCreatePerFolder(3);
         gen.setDocumentTypeId(TEST_DOCUMENT_TYPE_ID);
         gen.setFolderTypeId(TEST_FOLDER_TYPE_ID);
@@ -121,7 +121,7 @@ public class DiscoveryServiceTest extend
 
         String statement;
         ObjectList res;
-        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepositoryId);
+        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepSvc, fRepositoryId);
         gen.setNumberOfDocumentsToCreatePerFolder(3);
         gen.setDocumentTypeId(TEST_DOCUMENT_TYPE_ID);
         gen.setFolderTypeId(TEST_FOLDER_TYPE_ID);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java?rev=1187960&r1=1187959&r2=1187960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/NavigationServiceTest.java
Sun Oct 23 19:56:45 2011
@@ -229,7 +229,7 @@ public class NavigationServiceTest exten
 
     private int createFolderHierachy(int levels, int childrenPerLevel) {
 
-        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepositoryId);
+        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepSvc, fRepositoryId);
         gen.createFolderHierachy(levels, childrenPerLevel, fRootFolderId);
         int objCount = gen.getObjectsInTotal();
         return objCount;

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java?rev=1187960&r1=1187959&r2=1187960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/ObjectServiceTest.java
Sun Oct 23 19:56:45 2011
@@ -440,7 +440,7 @@ public class ObjectServiceTest extends A
     public void testBuildFolderAndDocuments() {
         // Create a hierarchy of folders and fill it with some documents
 
-        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepositoryId);
+        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepSvc, fRepositoryId);
         int levels = 2; // create a hierarchy with two levels
         int childrenPerLevel = 2; // create two folders on each level
 
@@ -566,7 +566,7 @@ public class ObjectServiceTest extends A
     @Test
     public void testDeleteTree() {
         log.info("starting testDeleteTree() ...");
-        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepositoryId);
+        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepSvc, fRepositoryId);
         String rootFolderId = createFolder();
         // Set the type id for all created documents:
         gen.setDocumentTypeId(InMemoryDocumentTypeDefinition.getRootDocumentType().getId());
@@ -950,7 +950,7 @@ public class ObjectServiceTest extends A
         // CMIS_BASE_TYPE_ID
         // ;
         String rootFolderId = createFolder();
-        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepositoryId);
+        ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepSvc, fRepositoryId);
         // Set the type id for all created documents:
         gen.setDocumentTypeId(InMemoryDocumentTypeDefinition.getRootDocumentType().getId());
         // Set the type id for all created folders:

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/FixtureSetup.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/FixtureSetup.java?rev=1187960&r1=1187959&r2=1187960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/FixtureSetup.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-fit/src/test/java/org/apache/chemistry/opencmis/fit/runtime/FixtureSetup.java
Sun Oct 23 19:56:45 2011
@@ -87,7 +87,7 @@ public class FixtureSetup {
         Assert.assertNotNull(this.testRootFolderId);
 
         ObjectGenerator og = new ObjectGenerator(binding.getObjectFactory(), binding.getNavigationService(),
binding
-                .getObjectService(), this.repositoryId);
+                .getObjectService(), binding.getRepositoryService(), this.repositoryId);
 
         og.setContentSizeInKB(10);
         og.setDocumentTypeId(documentTypeId);

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java?rev=1187960&r1=1187959&r2=1187960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java
Sun Oct 23 19:56:45 2011
@@ -19,6 +19,7 @@
 package org.apache.chemistry.opencmis.util.repository;
 
 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
 import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
 import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
 import org.apache.chemistry.opencmis.commons.spi.NavigationService;
@@ -28,7 +29,7 @@ import org.apache.chemistry.opencmis.com
 public class MultiThreadedObjectGenerator {
 
     public static enum Action {
-        CreateDocument, CreateTree, CreateFolders
+        CreateDocument, CreateTree, CreateFolders, CreateTypes
     }
 
     private MultiThreadedObjectGenerator() {
@@ -41,6 +42,7 @@ public class MultiThreadedObjectGenerato
         private int fFoldersPerFolders;
         private int fDepth;
         private int fCount;
+        private TypeDefinitionList fTypeDefList;
 
         public ObjectGeneratorRunner(ObjectGenerator objGen, Action action) {
             fObjGen = objGen;
@@ -54,6 +56,8 @@ public class MultiThreadedObjectGenerato
                 doCreateTree();
             } else if (fAction == Action.CreateFolders) {
                 doCreateFolder();
+            } else if (fAction == Action.CreateTypes) {
+                doCreateTypes();
             }
         }
 
@@ -69,6 +73,10 @@ public class MultiThreadedObjectGenerato
         public String[] doCreateFolder() {
             return fObjGen.createFolders(fRootFolderId, fCount);
         }
+        
+        public void doCreateTypes() {
+            fObjGen.createTypes(fTypeDefList);
+        }
 
         public ObjectGenerator getObjectGenerator() {
             return fObjGen;
@@ -83,8 +91,9 @@ public class MultiThreadedObjectGenerato
         BindingsObjectFactory objectFactory = binding.getObjectFactory();
         NavigationService navSvc = binding.getNavigationService();
         ObjectService objSvc = binding.getObjectService();
-
-        ObjectGenerator gen = new ObjectGenerator(objectFactory, navSvc, objSvc, repoId);
+        RepositoryService repSvc = binding.getRepositoryService();
+        
+        ObjectGenerator gen = new ObjectGenerator(objectFactory, navSvc, objSvc, repSvc,
repoId);
         gen.setUseUuidsForNames(true);
         gen.setNumberOfDocumentsToCreatePerFolder(docsPerFolder);
         // Set the type id for all created documents:
@@ -198,6 +207,16 @@ public class MultiThreadedObjectGenerato
         return runners;
     }
 
+    public static ObjectGeneratorRunner prepareForCreateTypes(CmisBinding provider, String
repoId, TypeDefinitionList typeDefList) {
+
+        ObjectGenerator objGen = createObjectGenerator(provider, repoId, 0, 0, 0, null, null,
0, null,
+                false);
+
+        ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateTypes);
+        gen.fTypeDefList = typeDefList;
+        return gen;
+    }
+
     public static void runMultiThreaded(ObjectGeneratorRunner[] runner) {
         int threadCount = runner.length;
         Thread[] threads = new Thread[threadCount];

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjGenApp.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjGenApp.java?rev=1187960&r1=1187959&r2=1187960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjGenApp.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjGenApp.java
Sun Oct 23 19:56:45 2011
@@ -19,6 +19,7 @@
 package org.apache.chemistry.opencmis.util.repository;
 
 import java.io.BufferedReader;
+import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -27,6 +28,9 @@ import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+
 import joptsimple.OptionParser;
 import joptsimple.OptionSet;
 import joptsimple.OptionSpec;
@@ -34,8 +38,14 @@ 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.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.chemistry.opencmis.commons.impl.Converter;
+import org.apache.chemistry.opencmis.commons.impl.JaxBHelper;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionListType;
+import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisTypeDefinitionType;
 import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
 import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
 
@@ -62,6 +72,7 @@ public class ObjGenApp {
     private static final String CLEANUP = "Cleanup";
     private static final String ROOTFOLDER = "RootFolder";
     private static final String THREADS = "Threads";
+//    private static final String FILE = "File";
 
     private static final String BINDING_ATOM = "AtomPub";
     private static final String BINDING_WS = "WebService";
@@ -83,7 +94,8 @@ public class ObjGenApp {
     OptionSpec<Boolean> fCleanup;
     OptionSpec<String> fRootFolder;
     OptionSpec<Integer> fThreads;
-
+    OptionSpec<String> fFileName;
+    
     public static void main(String[] args) {
 
         ObjGenApp app = new ObjGenApp();
@@ -126,6 +138,7 @@ public class ObjGenApp {
                 "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");
 
         OptionSet options = parser.parse(args);
 
@@ -151,6 +164,8 @@ public class ObjGenApp {
             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("GetUrl")) {
             getUrl(getConfiguredUrl());
         } else {
@@ -381,6 +396,32 @@ public class ObjGenApp {
         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));
     }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java?rev=1187960&r1=1187959&r2=1187960&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java
Sun Oct 23 19:56:45 2011
@@ -21,7 +21,6 @@ package org.apache.chemistry.opencmis.ut
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.StringReader;
 import java.math.BigInteger;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -39,6 +38,8 @@ import org.apache.chemistry.opencmis.com
 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.definitions.TypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.TypeDefinitionList;
 import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
 import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
 import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
@@ -47,6 +48,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
 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.util.content.LoreIpsum;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -64,10 +66,12 @@ public class ObjectGenerator {
     private final BindingsObjectFactory fFactory;
     NavigationService fNavSvc;
     ObjectService fObjSvc;
+    RepositoryService fRepSvc;
     private final String fRepositoryId;
     private final TimeLogger fTimeLoggerCreateDoc;
     private final TimeLogger fTimeLoggerCreateFolder;
     private final TimeLogger fTimeLoggerDelete;
+    private final TimeLogger fTimeLoggerCreateType;
     private boolean fCleanup;
     List<String> fTopLevelDocsCreated; // list of ids created on first level
     List<String> fTopLevelFoldersCreated; // list of ids created on first level
@@ -133,11 +137,12 @@ public class ObjectGenerator {
     private boolean fUseUuids;
 
     public ObjectGenerator(BindingsObjectFactory factory, NavigationService navSvc, ObjectService
objSvc,
-            String repositoryId) {
+            RepositoryService repSvc, String repositoryId) {
         super();
         fFactory = factory;
         fNavSvc = navSvc;
         fObjSvc = objSvc;
+        fRepSvc = repSvc;
         fRepositoryId = repositoryId;
         // create an empty list of properties to generate by default for folder
         // and document
@@ -148,6 +153,7 @@ public class ObjectGenerator {
         fTimeLoggerCreateDoc = new TimeLogger("createDocument()");
         fTimeLoggerCreateFolder = new TimeLogger("createFolder()");
         fTimeLoggerDelete = new TimeLogger("Delete");
+        fTimeLoggerCreateType = new TimeLogger("createType()");
         fCleanup = false;
         fTopLevelDocsCreated = new ArrayList<String>();
         fTopLevelFoldersCreated = new ArrayList<String>();
@@ -655,4 +661,12 @@ public class ObjectGenerator {
         log.info(""); // add empty line
     }
 
+    public void createTypes(TypeDefinitionList typeDefList) {
+        
+        fTimeLoggerCreateType.reset();         
+        for (TypeDefinition td : typeDefList.getList()) {
+            // TODO: enable this if available!
+//            fRepSvc.createTypeDefinition(fRepositoryId, td);
+        }
+    }
 }



Mime
View raw message