You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2013/08/08 10:40:27 UTC
svn commit: r1511617 [4/5] - in
/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src:
main/java/org/apache/chemistry/opencmis/inmemory/
main/java/org/apache/chemistry/opencmis/inmemory/query/
main/java/org/apache/c...
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=1511617&r1=1511616&r2=1511617&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 Thu Aug 8 08:40:26 2013
@@ -50,9 +50,18 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.data.Properties;
import org.apache.chemistry.opencmis.commons.data.PropertyData;
import org.apache.chemistry.opencmis.commons.data.RenditionData;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableFolderTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableItemTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutablePolicyTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableRelationshipTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableSecondaryTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableTypeDefinition;
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
import org.apache.chemistry.opencmis.commons.enums.Action;
+import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
import org.apache.chemistry.opencmis.commons.enums.ContentStreamAllowed;
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
import org.apache.chemistry.opencmis.commons.enums.UnfileObject;
@@ -64,6 +73,7 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.exceptions.CmisNameConstraintViolationException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.BulkUpdateObjectIdAndChangeTokenImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
@@ -71,13 +81,9 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.spi.Holder;
import org.apache.chemistry.opencmis.inmemory.storedobj.impl.ContentStreamDataImpl;
import org.apache.chemistry.opencmis.inmemory.storedobj.impl.DocumentImpl;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryFolderTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryItemTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryPolicyTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryRelationshipTypeDefinition;
-import org.apache.chemistry.opencmis.inmemory.types.InMemorySecondaryTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
+import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
import org.apache.chemistry.opencmis.util.repository.ObjectGenerator;
import org.junit.After;
import org.junit.Before;
@@ -115,9 +121,9 @@ public class ObjectServiceTest extends A
public static final String TEST_DOCUMENT_MY_SUB_INT_PROP_ID = "MyInheritedIntProp";
public static final String TEST_ITEM_TYPE_ID = "MyItemType";
public static final String ITEM_STRING_PROP = "ItemStringProp";
- private static final String DOCUMENT_TYPE_ID = InMemoryDocumentTypeDefinition.getRootDocumentType().getId();
+ private static final String DOCUMENT_TYPE_ID = DocumentTypeCreationHelper.getCmisDocumentType().getId();
private static final String DOCUMENT_ID = "Document_1";
- private static final String FOLDER_TYPE_ID = InMemoryFolderTypeDefinition.getRootFolderType().getId();
+ private static final String FOLDER_TYPE_ID = DocumentTypeCreationHelper.getCmisFolderType().getId();
private static final String FOLDER_ID = "Folder_1";
private static final String MY_CUSTOM_NAME = "My Custom Document";
private static final int MAX_SIZE = 100;
@@ -614,9 +620,9 @@ public class ObjectServiceTest extends A
ObjectGenerator.CONTENT_KIND.LoremIpsumText);
String rootFolderId = createFolder();
// Set the type id for all created documents:
- gen.setDocumentTypeId(InMemoryDocumentTypeDefinition.getRootDocumentType().getId());
+ gen.setDocumentTypeId(DocumentTypeCreationHelper.getCmisDocumentType().getId());
// Set the type id for all created folders:
- gen.setFolderTypeId(InMemoryFolderTypeDefinition.getRootFolderType().getId());
+ gen.setFolderTypeId(DocumentTypeCreationHelper.getCmisFolderType().getId());
gen.setNumberOfDocumentsToCreatePerFolder(2); // create two documents in
// each folder
gen.createFolderHierachy(1, 1, rootFolderId);
@@ -1511,12 +1517,12 @@ public class ObjectServiceTest extends A
ObjectGenerator gen = new ObjectGenerator(fFactory, fNavSvc, fObjSvc, fRepSvc, fRepositoryId,
ObjectGenerator.CONTENT_KIND.LoremIpsumText);
// Set the type id for all created documents:
- gen.setDocumentTypeId(InMemoryDocumentTypeDefinition.getRootDocumentType().getId());
+ gen.setDocumentTypeId(DocumentTypeCreationHelper.getCmisDocumentType().getId());
// Set the type id for all created folders:
gen.setNumberOfDocumentsToCreatePerFolder(1); // create one document in
// each folder
gen.createFolderHierachy(3, 2, rootFolderId);
- gen.setFolderTypeId(InMemoryFolderTypeDefinition.getRootFolderType().getId());
+ gen.setFolderTypeId(DocumentTypeCreationHelper.getCmisFolderType().getId());
gen.dumpFolder(fRootFolderId, propertyFilter);
Holder<String> holder = new Holder<String>();
String sourceIdToMove = gen.getFolderId(rootFolderId, 2, 1);
@@ -1678,6 +1684,8 @@ public class ObjectServiceTest extends A
public static class ObjectTestTypeSystemCreator implements TypeCreator {
+ static final TypeDefinitionFactory typeFactory = DocumentTypeCreationHelper.getTypeDefinitionFactory();
+
/**
* create root types and a sample type for folder and document
*
@@ -1686,188 +1694,207 @@ public class ObjectServiceTest extends A
@Override
public List<TypeDefinition> createTypesList() {
List<TypeDefinition> typesList = new LinkedList<TypeDefinition>();
- InMemoryDocumentTypeDefinition cmisDocumentType = new InMemoryDocumentTypeDefinition(TEST_DOCUMENT_TYPE_ID,
- "My Document Type", InMemoryDocumentTypeDefinition.getRootDocumentType());
+
+ try {
+ MutableTypeDefinition cmisDocumentType;
+ cmisDocumentType = typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_DOCUMENT_TYPE_ID);
+ cmisDocumentType.setDisplayName("My Document Type");
+ cmisDocumentType.setDescription("InMemory test type definition " + TEST_DOCUMENT_TYPE_ID);
+
+ MutableFolderTypeDefinition cmisFolderType;
+ cmisFolderType = typeFactory.createFolderTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisFolderType().getId());
+ cmisFolderType.setId(TEST_FOLDER_TYPE_ID);
+ cmisFolderType.setDisplayName("My Folder Type");
+ cmisFolderType.setDescription("InMemory test type definition " + TEST_FOLDER_TYPE_ID);
+ // create a simple string property type and
+ // attach the property definition to the type definition for
+ // document and folder type
+ Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ PropertyStringDefinitionImpl prop = PropertyCreationHelper.createStringDefinition(
+ TEST_DOCUMENT_STRING_PROP_ID, "Sample Doc String Property", Updatability.READWRITE);
+ propertyDefinitions.put(prop.getId(), prop);
+ cmisDocumentType.addPropertyDefinition(prop);
+
+ propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ prop = PropertyCreationHelper.createStringDefinition(TEST_FOLDER_STRING_PROP_ID,
+ "Sample Folder String Property", Updatability.READWRITE);
+ propertyDefinitions.put(prop.getId(), prop);
+ cmisFolderType.addPropertyDefinition(prop);
+
+ DocumentTypeDefinition customDocType = createCustomTypeWithStringIntProperty();
+ TypeDefinition noContentType = createCustomTypeNoContent();
+ TypeDefinition mustHaveContentType = createCustomTypeMustHaveContent();
+ TypeDefinition relType = createRelationshipType();
+ TypeDefinition relTypeRestricted = createRelationshipTypeRestricted();
+ TypeDefinition verType = createVersionableType();
+ TypeDefinition polType = createPolicyType();
+
+ // add type to types collection
+ typesList.add(cmisDocumentType);
+ typesList.add(cmisFolderType);
+ typesList.add(customDocType);
+ typesList.add(noContentType);
+ typesList.add(mustHaveContentType);
+ typesList.add(createCustomInheritedType(customDocType));
+ typesList.add(createDocumentTypeWithDefault());
+ typesList.add(createFolderTypeWithDefault());
+ typesList.add(createItemType());
+ typesList.add(createSecondaryType());
+ typesList.add(relType);
+ typesList.add(relTypeRestricted);
+ typesList.add(verType);
+ typesList.add(polType);
+ return typesList;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Failed to create types.", e);
+ }
+ }
- InMemoryFolderTypeDefinition cmisFolderType = new InMemoryFolderTypeDefinition(TEST_FOLDER_TYPE_ID,
- "My Folder Type", InMemoryFolderTypeDefinition.getRootFolderType());
- // create a simple string property type and
- // attach the property definition to the type definition for
- // document and folder type
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- PropertyStringDefinitionImpl prop = PropertyCreationHelper.createStringDefinition(
- TEST_DOCUMENT_STRING_PROP_ID, "Sample Doc String Property", Updatability.READWRITE);
- propertyDefinitions.put(prop.getId(), prop);
- cmisDocumentType.addCustomPropertyDefinitions(propertyDefinitions);
-
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- prop = PropertyCreationHelper.createStringDefinition(TEST_FOLDER_STRING_PROP_ID,
- "Sample Folder String Property", Updatability.READWRITE);
- propertyDefinitions.put(prop.getId(), prop);
- cmisFolderType.addCustomPropertyDefinitions(propertyDefinitions);
-
- InMemoryDocumentTypeDefinition customDocType = createCustomTypeWithStringIntProperty();
- InMemoryDocumentTypeDefinition noContentType = createCustomTypeNoContent();
- InMemoryDocumentTypeDefinition mustHaveContentType = createCustomTypeMustHaveContent();
- InMemoryRelationshipTypeDefinition relType = createRelationshipType();
- InMemoryRelationshipTypeDefinition relTypeRestricted = createRelationshipTypeRestricted();
- InMemoryDocumentTypeDefinition verType = createVersionableType();
- InMemoryPolicyTypeDefinition polType = createPolicyType();
-
- // add type to types collection
- typesList.add(cmisDocumentType);
- typesList.add(cmisFolderType);
- typesList.add(customDocType);
- typesList.add(noContentType);
- typesList.add(mustHaveContentType);
- typesList.add(createCustomInheritedType(customDocType));
- typesList.add(createDocumentTypeWithDefault());
- typesList.add(createFolderTypeWithDefault());
- typesList.add(createItemType());
- typesList.add(createSecondaryType());
- typesList.add(relType);
- typesList.add(relTypeRestricted);
- typesList.add(verType);
- typesList.add(polType);
- return typesList;
- }
-
- private static InMemoryDocumentTypeDefinition createCustomTypeWithStringIntProperty() {
- InMemoryDocumentTypeDefinition cmisDocumentType = new InMemoryDocumentTypeDefinition(
- TEST_CUSTOM_DOCUMENT_TYPE_ID, "My Custom Document Type", InMemoryDocumentTypeDefinition
- .getRootDocumentType());
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ private static DocumentTypeDefinition createCustomTypeWithStringIntProperty() throws InstantiationException, IllegalAccessException {
+ MutableDocumentTypeDefinition cmisDocumentType;
+ cmisDocumentType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_CUSTOM_DOCUMENT_TYPE_ID);
+ cmisDocumentType.setDisplayName("My Custom Document Type");
+ cmisDocumentType.setDescription("InMemory test type definition " + TEST_CUSTOM_DOCUMENT_TYPE_ID);
+
PropertyStringDefinitionImpl prop = PropertyCreationHelper.createStringDefinition(
TEST_DOCUMENT_MY_STRING_PROP_ID, "My String Property", Updatability.READWRITE);
prop.setIsRequired(false);
prop.setMaxLength(BigInteger.valueOf(20)); // max len to 20
- propertyDefinitions.put(prop.getId(), prop);
+ cmisDocumentType.addPropertyDefinition(prop);
PropertyIntegerDefinitionImpl prop2 = PropertyCreationHelper.createIntegerDefinition(
TEST_DOCUMENT_MY_INT_PROP_ID, "My Integer Property", Updatability.READWRITE);
prop2.setIsRequired(true);
prop2.setMinValue(BigInteger.valueOf(-10000));
prop2.setMaxValue(BigInteger.valueOf(10000));
- propertyDefinitions.put(prop2.getId(), prop2);
- cmisDocumentType.addCustomPropertyDefinitions(propertyDefinitions);
+ cmisDocumentType.addPropertyDefinition(prop2);
return cmisDocumentType;
}
- private static InMemoryDocumentTypeDefinition createCustomInheritedType(InMemoryDocumentTypeDefinition baseType) {
- InMemoryDocumentTypeDefinition cmisDocumentType = new InMemoryDocumentTypeDefinition(
- TEST_INHERITED_CUSTOM_DOCUMENT_TYPE_ID, "My Custom Document Type", baseType);
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ private static TypeDefinition createCustomInheritedType(DocumentTypeDefinition baseType) throws InstantiationException, IllegalAccessException {
+ MutableTypeDefinition cmisDocumentType;
+ cmisDocumentType = typeFactory.createChildTypeDefinition(baseType, TEST_INHERITED_CUSTOM_DOCUMENT_TYPE_ID);
+ cmisDocumentType.setDisplayName("My Custom Document Type");
+ cmisDocumentType.setDescription("InMemory test type definition " + TEST_INHERITED_CUSTOM_DOCUMENT_TYPE_ID);
+
PropertyStringDefinitionImpl prop = PropertyCreationHelper.createStringDefinition(
TEST_DOCUMENT_MY_SUB_STRING_PROP_ID, "Subtype String Property", Updatability.READWRITE);
prop.setIsRequired(false);
- propertyDefinitions.put(prop.getId(), prop);
+ cmisDocumentType.addPropertyDefinition(prop);
PropertyIntegerDefinitionImpl prop2 = PropertyCreationHelper.createIntegerDefinition(
TEST_DOCUMENT_MY_SUB_INT_PROP_ID, "Subtype", Updatability.READWRITE);
prop2.setIsRequired(true);
- propertyDefinitions.put(prop2.getId(), prop2);
- cmisDocumentType.addCustomPropertyDefinitions(propertyDefinitions);
+ cmisDocumentType.addPropertyDefinition(prop2);
return cmisDocumentType;
}
- private static InMemoryDocumentTypeDefinition createDocumentTypeWithDefault() {
- InMemoryDocumentTypeDefinition cmisDocumentType = new InMemoryDocumentTypeDefinition(
- TEST_DOC_TYPE_WITH_DEFAULTS_ID, "Document Type With default values", InMemoryDocumentTypeDefinition
- .getRootDocumentType());
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ private static TypeDefinition createDocumentTypeWithDefault() throws InstantiationException, IllegalAccessException {
+ MutableTypeDefinition cmisDocumentType;
+ cmisDocumentType = typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_DOC_TYPE_WITH_DEFAULTS_ID);
+ cmisDocumentType.setDisplayName("Document Type With default values");
+ cmisDocumentType.setDescription("InMemory test type definition " + TEST_DOC_TYPE_WITH_DEFAULTS_ID);
+
PropertyStringDefinitionImpl prop = PropertyCreationHelper.createStringMultiDefinition(
TEST_DOCUMENT_MY_MULTI_STRING_PROP_ID, "Test Multi String Property", Updatability.READWRITE);
prop.setIsRequired(false);
List<String> defValS = new ArrayList<String>() {{ add("Apache"); add("CMIS"); }};
prop.setDefaultValue(defValS);
- propertyDefinitions.put(prop.getId(), prop);
+ cmisDocumentType.addPropertyDefinition(prop);
PropertyIntegerDefinitionImpl prop2 = PropertyCreationHelper.createIntegerDefinition(
TEST_DOCUMENT_MY_INT_PROP_ID, "Test Integer Property", Updatability.READWRITE);
prop2.setIsRequired(false);
List<BigInteger> defVal = new ArrayList<BigInteger>() {{ add(BigInteger.valueOf(100)); }};
prop2.setDefaultValue(defVal);
- propertyDefinitions.put(prop2.getId(), prop2);
+ cmisDocumentType.addPropertyDefinition(prop2);
PropertyIntegerDefinitionImpl prop3 = PropertyCreationHelper.createIntegerDefinition(
TEST_DOCUMENT_MY_INT_PROP_ID_MANDATORY_DEFAULT, "Test Integer Property Mandatory default", Updatability.READWRITE);
prop3.setIsRequired(true);
List<BigInteger> defVal2 = new ArrayList<BigInteger>() {{ add(BigInteger.valueOf(100)); }};
prop3.setDefaultValue(defVal2);
- propertyDefinitions.put(prop3.getId(), prop3);
-
- cmisDocumentType.addCustomPropertyDefinitions(propertyDefinitions);
+ cmisDocumentType.addPropertyDefinition(prop3);
return cmisDocumentType;
}
- private static InMemoryDocumentTypeDefinition createCustomTypeNoContent() {
- InMemoryDocumentTypeDefinition cmisDocumentType = new InMemoryDocumentTypeDefinition(
- TEST_CUSTOM_NO_CONTENT_TYPE_ID, "No Content Document Type", InMemoryDocumentTypeDefinition
- .getRootDocumentType());
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- cmisDocumentType.addCustomPropertyDefinitions(propertyDefinitions);
+ private static TypeDefinition createCustomTypeNoContent() throws InstantiationException, IllegalAccessException {
+ MutableDocumentTypeDefinition cmisDocumentType;
+ cmisDocumentType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_CUSTOM_NO_CONTENT_TYPE_ID);
+ cmisDocumentType.setDisplayName("No Content Document Type");
+ cmisDocumentType.setDescription("InMemory test type definition " + TEST_CUSTOM_NO_CONTENT_TYPE_ID);
cmisDocumentType.setContentStreamAllowed(ContentStreamAllowed.NOTALLOWED);
return cmisDocumentType;
}
- private static InMemoryDocumentTypeDefinition createCustomTypeMustHaveContent() {
- InMemoryDocumentTypeDefinition cmisDocumentType = new InMemoryDocumentTypeDefinition(
- TEST_CUSTOM_MUST_CONTENT_TYPE_ID, "Must Have Content Document Type", InMemoryDocumentTypeDefinition
- .getRootDocumentType());
+ private static TypeDefinition createCustomTypeMustHaveContent() throws InstantiationException, IllegalAccessException {
+ MutableDocumentTypeDefinition cmisDocumentType;
+ cmisDocumentType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_CUSTOM_MUST_CONTENT_TYPE_ID);
+ cmisDocumentType.setDisplayName("Must Have Content Document Type");
+ cmisDocumentType.setDescription("InMemory test type definition " + TEST_CUSTOM_MUST_CONTENT_TYPE_ID);
+ cmisDocumentType.setContentStreamAllowed(ContentStreamAllowed.NOTALLOWED);
cmisDocumentType.setContentStreamAllowed(ContentStreamAllowed.REQUIRED);
return cmisDocumentType;
}
- private static InMemoryFolderTypeDefinition createFolderTypeWithDefault() {
- InMemoryFolderTypeDefinition cmisFolderType = new InMemoryFolderTypeDefinition(
- TEST_FOLDER_TYPE_WITH_DEFAULTS_ID, "Folder Type With default values", InMemoryFolderTypeDefinition.
- getRootFolderType());
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ private static TypeDefinition createFolderTypeWithDefault() throws InstantiationException, IllegalAccessException {
+ MutableFolderTypeDefinition cmisFolderType;
+ cmisFolderType = typeFactory.createFolderTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisFolderType().getId());
+ cmisFolderType.setId(TEST_FOLDER_TYPE_WITH_DEFAULTS_ID);
+ cmisFolderType.setDisplayName("Folder Type With default values");
+ cmisFolderType.setDescription("InMemory test type definition " + TEST_FOLDER_TYPE_WITH_DEFAULTS_ID);
+
PropertyStringDefinitionImpl prop = PropertyCreationHelper.createStringMultiDefinition(
TEST_FOLDER_MY_MULTI_STRING_PROP_ID, "Test Multi String Property", Updatability.READWRITE);
prop.setIsRequired(false);
List<String> defValS = new ArrayList<String>() {{ add("Apache"); add("CMIS"); }};
prop.setDefaultValue(defValS);
- propertyDefinitions.put(prop.getId(), prop);
+ cmisFolderType.addPropertyDefinition(prop);
PropertyIntegerDefinitionImpl prop2 = PropertyCreationHelper.createIntegerDefinition(
TEST_FOLDER_MY_INT_PROP_ID, "Test Integer Property", Updatability.READWRITE);
prop2.setIsRequired(false);
List<BigInteger> defVal = new ArrayList<BigInteger>() {{ add(BigInteger.valueOf(100)); }};
prop2.setDefaultValue(defVal);
- propertyDefinitions.put(prop2.getId(), prop2);
+ cmisFolderType.addPropertyDefinition(prop2);
PropertyIntegerDefinitionImpl prop3 = PropertyCreationHelper.createIntegerDefinition(
TEST_FOLDER_MY_INT_PROP_ID_MANDATORY_DEFAULT, "Test Integer Property Mandatory default", Updatability.READWRITE);
prop3.setIsRequired(true);
List<BigInteger> defVal2 = new ArrayList<BigInteger>() {{ add(BigInteger.valueOf(100)); }};
prop3.setDefaultValue(defVal2);
- propertyDefinitions.put(prop3.getId(), prop3);
-
- cmisFolderType.addCustomPropertyDefinitions(propertyDefinitions);
+ cmisFolderType.addPropertyDefinition(prop3);
return cmisFolderType;
}
- private InMemoryRelationshipTypeDefinition createRelationshipType() {
- InMemoryRelationshipTypeDefinition cmisRelType = new InMemoryRelationshipTypeDefinition(
- TEST_RELATION_TYPE_ID, "MyRelationshipType");
+ private TypeDefinition createRelationshipType() throws InstantiationException, IllegalAccessException {
+ MutableRelationshipTypeDefinition cmisRelType;
+ cmisRelType = typeFactory.createRelationshipTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisRelationshipType().getId());
+ cmisRelType.setId(TEST_RELATION_TYPE_ID);
+ cmisRelType.setDisplayName("MyRelationshipType");
+ cmisRelType.setDescription("InMemory test type definition " + TEST_RELATION_TYPE_ID);
+ DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisRelType);
+ cmisRelType.setIsFileable(false);
+
// create a single String property definition
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(REL_STRING_PROP,
"CrossReferenceType", Updatability.READWRITE);
- propertyDefinitions.put(prop1.getId(), prop1);
- cmisRelType.addCustomPropertyDefinitions(propertyDefinitions);
+ cmisRelType.addPropertyDefinition(prop1);
return cmisRelType;
}
- private InMemoryRelationshipTypeDefinition createRelationshipTypeRestricted() {
- InMemoryRelationshipTypeDefinition cmisRelType = new InMemoryRelationshipTypeDefinition(
- TEST_RESTRICTED_RELATION_TYPE_ID, "RestrictedRelationshipType");
+ private TypeDefinition createRelationshipTypeRestricted() throws InstantiationException, IllegalAccessException {
+ MutableRelationshipTypeDefinition cmisRelType;
+ cmisRelType = typeFactory.createRelationshipTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisRelationshipType().getId());
+ cmisRelType.setId(TEST_RESTRICTED_RELATION_TYPE_ID);
+ cmisRelType.setDisplayName("RestrictedRelationshipType");
+ cmisRelType.setDescription("InMemory test type definition " + TEST_RESTRICTED_RELATION_TYPE_ID);
+ DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisRelType);
+ cmisRelType.setIsFileable(false);
List<String> allowedTypeIds = Collections.singletonList(TEST_CUSTOM_DOCUMENT_TYPE_ID);
cmisRelType.setAllowedSourceTypes(allowedTypeIds);
@@ -1875,75 +1902,76 @@ public class ObjectServiceTest extends A
return cmisRelType;
}
- private static InMemoryItemTypeDefinition createItemType() {
+ private static TypeDefinition createItemType() throws InstantiationException, IllegalAccessException {
//CMIS 1.1 create an item item type
-
- InMemoryItemTypeDefinition cmisItemType = new InMemoryItemTypeDefinition(TEST_ITEM_TYPE_ID, "MyItemType");
- // create a single String property definition
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(ITEM_STRING_PROP,
- "Item String Property", Updatability.READWRITE);
- propertyDefinitions.put(prop1.getId(), prop1);
- cmisItemType.addCustomPropertyDefinitions(propertyDefinitions);
- // add type to types collection
- return cmisItemType;
+ MutableItemTypeDefinition cmisItemType;
+ cmisItemType = typeFactory.createItemTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisItemType().getId()); // ??? DocumentTypeCreationHelper.getCmisItemType());
+ cmisItemType.setId(TEST_ITEM_TYPE_ID);
+ cmisItemType.setDisplayName("MyItemType");
+ cmisItemType.setDescription("Builtin InMemory type definition " + TEST_ITEM_TYPE_ID);
+ DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisItemType);
+
+ // create a single String property definition
+ PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(ITEM_STRING_PROP,
+ "Item String Property", Updatability.READWRITE);
+ cmisItemType.addPropertyDefinition(prop1);
+ // add type to types collection
+ return cmisItemType;
}
- private static InMemorySecondaryTypeDefinition createSecondaryType() {
+ private static TypeDefinition createSecondaryType() throws InstantiationException, IllegalAccessException {
//CMIS 1.1 create an item item type
+ MutableSecondaryTypeDefinition cmisSecondaryType;
+ cmisSecondaryType = typeFactory.createSecondaryTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisSecondaryType().getId());
+ cmisSecondaryType.setId(TEST_SECONDARY_TYPE_ID);
+ cmisSecondaryType.setDisplayName("MySecondaryType");
+ cmisSecondaryType.setDescription("InMemory test type definition " + TEST_SECONDARY_TYPE_ID);
+ DocumentTypeCreationHelper.setDefaultTypeCapabilities(cmisSecondaryType);
+ cmisSecondaryType.setIsFileable(false);
- InMemorySecondaryTypeDefinition cmisSecondaryType = new InMemorySecondaryTypeDefinition(TEST_SECONDARY_TYPE_ID,
- "MySecondaryType");
// create a single String property definition
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(SECONDARY_STRING_PROP,
"Secondary String Property", Updatability.READWRITE);
- propertyDefinitions.put(prop1.getId(), prop1);
+ cmisSecondaryType.addPropertyDefinition(prop1);
+
PropertyIntegerDefinitionImpl prop2 = PropertyCreationHelper.createIntegerDefinition(SECONDARY_INTEGER_PROP,
"Secondary Integer Property", Updatability.READWRITE);
prop2.setIsRequired(true);
- propertyDefinitions.put(prop2.getId(), prop2);
- cmisSecondaryType.addCustomPropertyDefinitions(propertyDefinitions);
-
+ cmisSecondaryType.addPropertyDefinition(prop2);
+
return cmisSecondaryType;
}
- private static InMemoryDocumentTypeDefinition createVersionableType() {
+ private static TypeDefinition createVersionableType() throws InstantiationException, IllegalAccessException {
// create a complex type with properties
- InMemoryDocumentTypeDefinition verType = new InMemoryDocumentTypeDefinition(
- TEST_VERSION_DOCUMENT_TYPE_ID, "VersionedType", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- // create a String property definition
+ MutableDocumentTypeDefinition verType;
+ verType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), TEST_VERSION_DOCUMENT_TYPE_ID);
+ verType.setDisplayName("VersionedType");
+ verType.setDescription("InMemory test type definition " + TEST_VERSION_DOCUMENT_TYPE_ID);
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
+ verType.setIsVersionable(true); // make it a versionable type;
+ // create a String property definition
PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(TEST_VER_PROPERTY_ID,
"Sample String Property", Updatability.WHENCHECKEDOUT);
- propertyDefinitions.put(prop1.getId(), prop1);
-
- verType.addCustomPropertyDefinitions(propertyDefinitions);
- verType.setIsVersionable(true); // make it a versionable type;
+ verType.addPropertyDefinition(prop1);
return verType;
}
- private static InMemoryPolicyTypeDefinition createPolicyType() {
-
- InMemoryPolicyTypeDefinition polType = new InMemoryPolicyTypeDefinition(
- TEST_POLICY_TYPE_ID, "Audit Policy", InMemoryPolicyTypeDefinition.getRootPolicyType());
-
+ private static TypeDefinition createPolicyType() throws InstantiationException, IllegalAccessException {
+ MutablePolicyTypeDefinition polType;
+ polType = typeFactory.createPolicyTypeDefinition(CmisVersion.CMIS_1_1, DocumentTypeCreationHelper.getCmisPolicyType().getId());
+ polType.setId(TEST_POLICY_TYPE_ID);
+ polType.setDisplayName("Audit Policy");
+ polType.setDescription("InMemory type definition " + TEST_POLICY_TYPE_ID);
+ DocumentTypeCreationHelper.setDefaultTypeCapabilities(polType);
+ polType.setIsFileable(false);
+
// create a String property definition
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
PropertyStringDefinitionImpl prop1 = PropertyCreationHelper.createStringDefinition(TEST_POLICY_PROPERTY_ID,
"Audit Kind Property", Updatability.READWRITE);
- propertyDefinitions.put(prop1.getId(), prop1);
-
- polType.addCustomPropertyDefinitions(propertyDefinitions);
+ polType.addPropertyDefinition(prop1);
return polType;
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.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/RepositoryServiceMutabilityTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceMutabilityTest.java Thu Aug 8 08:40:26 2013
@@ -32,28 +32,25 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
import org.apache.chemistry.opencmis.commons.data.Properties;
import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
-import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.enums.Updatability;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisNotSupportedException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
-import org.apache.chemistry.opencmis.commons.spi.Holder;
-import org.apache.chemistry.opencmis.inmemory.server.InMemoryObjectServiceImpl;
-import org.apache.chemistry.opencmis.inmemory.server.InMemoryRepositoryServiceImpl;
import org.apache.chemistry.opencmis.inmemory.server.InMemoryServiceFactoryImpl;
-import org.apache.chemistry.opencmis.inmemory.storedobj.api.StoreManager;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Temporary test class until CMIS 1.1 bindings are completed. Until then
@@ -84,7 +81,6 @@ public class RepositoryServiceMutability
InMemoryServiceFactoryImpl factory = new InMemoryServiceFactoryImpl();
factory.init(parameters);
- StoreManager storeManager = factory.getStoreManger();
}
@Override
@@ -158,7 +154,7 @@ public class RepositoryServiceMutability
String repositoryId = getRepositoryId();
// test illegal type id
- InMemoryDocumentTypeDefinition typeDefRef = createTypeForAddingAtRuntime();
+ MutableDocumentTypeDefinition typeDefRef = createTypeForAddingAtRuntime();
typeDefRef.setId(typeDefRef.getId() + "!!!");
TypeDefinition typeDefNew = fRepSvc.createType(repositoryId, typeDefRef, null);
assertEquals(TYPE_ID_MUTABILITY + "___", typeDefNew.getId());
@@ -214,7 +210,7 @@ public class RepositoryServiceMutability
String repositoryId = getRepositoryId();
// test null property id
- InMemoryDocumentTypeDefinition typeDef = createTypeForAddingAtRuntime();
+ DocumentTypeDefinition typeDef = createTypeForAddingAtRuntime();
PropertyStringDefinitionImpl pd = getPropertyDefinitionImpl(typeDef);
pd.setId(null);
checkAddingType(repositoryId, typeDef, CmisInvalidArgumentException.class);
@@ -341,31 +337,34 @@ public class RepositoryServiceMutability
}
private PropertyStringDefinitionImpl getPropertyDefinitionImpl(TypeDefinition typeDef) {
- @SuppressWarnings("unchecked")
PropertyStringDefinitionImpl pd = (PropertyStringDefinitionImpl) typeDef.getPropertyDefinitions().get(PROPERTY_ID_TITLE);
return pd;
}
- private InMemoryDocumentTypeDefinition createTypeForAddingAtRuntime() {
-
- InMemoryDocumentTypeDefinition cmisLaterType = new InMemoryDocumentTypeDefinition(TYPE_ID_MUTABILITY,
- "Type with two properties", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
- PropertyIntegerDefinitionImpl prop1 = PropertyCreationHelper.createIntegerDefinition(PROPERTY_ID_NUMBER,
- "Sample Int Property", Updatability.READWRITE);
- propertyDefinitions.put(prop1.getId(), prop1);
+ private MutableDocumentTypeDefinition createTypeForAddingAtRuntime() {
+ try {
+ MutableDocumentTypeDefinition cmisLaterType;
+ cmisLaterType = DocumentTypeCreationHelper.createDocumentTypeDefinitionWithoutBaseProperties(DocumentTypeCreationHelper.getCmisDocumentType());
+ cmisLaterType.setId(TYPE_ID_MUTABILITY);
+ cmisLaterType.setDisplayName("Type with two properties");
+ cmisLaterType.setDescription("Builtin InMemory type definition " + TYPE_ID_MUTABILITY);
+
+
+ PropertyIntegerDefinitionImpl prop1 = PropertyCreationHelper.createIntegerDefinition(PROPERTY_ID_NUMBER,
+ "Sample Int Property", Updatability.READWRITE);
+ cmisLaterType.addPropertyDefinition(prop1);
+
+ PropertyStringDefinitionImpl prop2 = PropertyCreationHelper.createStringDefinition(PROPERTY_ID_TITLE,
+ "Sample String Property", Updatability.READWRITE);
+ cmisLaterType.addPropertyDefinition(prop2);
- PropertyStringDefinitionImpl prop2 = PropertyCreationHelper.createStringDefinition(PROPERTY_ID_TITLE,
- "Sample String Property", Updatability.READWRITE);
- propertyDefinitions.put(prop2.getId(), prop2);
-
- cmisLaterType.addCustomPropertyDefinitions(propertyDefinitions);
-
- return cmisLaterType;
+ return cmisLaterType;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+ }
}
+
String createDoc(String name, String folderId, String typeId) {
ContentStream contentStream = null;
List<String> policies = null;
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.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/RepositoryServiceTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/RepositoryServiceTest.java Thu Aug 8 08:40:26 2013
@@ -165,7 +165,7 @@ public class RepositoryServiceTest exten
log.info("Found type: " + typeDef.getId() + ", display name is: " + typeDef.getDisplayName());
log.info(" Base type is: " + typeDef.getBaseTypeId());
Map<String, PropertyDefinition<?>> propDefs = typeDef.getPropertyDefinitions();
- log.info(" Property definitions (must be empty): " + propDefs);
+ log.info(" Property definitions (must be null): " + propDefs);
assertTrue(propDefs.isEmpty());
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.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/TypeValidationTest.java?rev=1511617&r1=1511616&r2=1511617&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/TypeValidationTest.java Thu Aug 8 08:40:26 2013
@@ -23,9 +23,7 @@ import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import junit.framework.TestCase;
@@ -33,11 +31,14 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.data.Properties;
import org.apache.chemistry.opencmis.commons.data.PropertyData;
import org.apache.chemistry.opencmis.commons.definitions.Choice;
+import org.apache.chemistry.opencmis.commons.definitions.DocumentTypeDefinition;
+import org.apache.chemistry.opencmis.commons.definitions.MutableDocumentTypeDefinition;
import org.apache.chemistry.opencmis.commons.definitions.PropertyDefinition;
import org.apache.chemistry.opencmis.commons.definitions.TypeDefinition;
import org.apache.chemistry.opencmis.commons.enums.Cardinality;
import org.apache.chemistry.opencmis.commons.enums.Updatability;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.BindingsObjectFactoryImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ChoiceImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyBooleanDefinitionImpl;
@@ -49,8 +50,9 @@ import org.apache.chemistry.opencmis.com
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyStringDefinitionImpl;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyUriDefinitionImpl;
import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
-import org.apache.chemistry.opencmis.inmemory.types.InMemoryDocumentTypeDefinition;
+import org.apache.chemistry.opencmis.inmemory.types.DocumentTypeCreationHelper;
import org.apache.chemistry.opencmis.inmemory.types.PropertyCreationHelper;
+import org.apache.chemistry.opencmis.server.support.TypeDefinitionFactory;
import org.apache.chemistry.opencmis.server.support.TypeManager;
import org.apache.chemistry.opencmis.server.support.TypeValidator;
import org.junit.Test;
@@ -74,6 +76,8 @@ public class TypeValidationTest extends
private static final String STRING_PROP_TYPE_SUPER = "StringPropSuper";
private static final String STRING_PROP_TYPE_SUB = "StringPropSub";
private static final BindingsObjectFactory FACTORY = new BindingsObjectFactoryImpl();
+ static TypeDefinitionFactory typeFactory = DocumentTypeCreationHelper.getTypeDefinitionFactory();
+
private static List<PropertyData<?>> createPropertiesWithNameAndTypeId(String typeId) {
List<PropertyData<?>> properties = new ArrayList<PropertyData<?>>();
@@ -463,308 +467,334 @@ public class TypeValidationTest extends
*
* @return type definition of sample type
*/
- private static InMemoryDocumentTypeDefinition buildMyType() {
+ private static DocumentTypeDefinition buildMyType() {
// always add CMIS default types
- InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(MY_DOC_TYPE,
- "Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- // create a boolean property definition
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
-
- PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition("BooleanProp",
- "Sample Boolean Property", Updatability.READONLY);
- ((PropertyBooleanDefinitionImpl) prop).setIsRequired(true);
- propertyDefinitions.put(prop.getId(), prop);
-
- prop = PropertyCreationHelper.createBooleanMultiDefinition("BooleanPropMV",
- "Sample Boolean multi-value Property", Updatability.READONLY);
- propertyDefinitions.put(prop.getId(), prop);
-
- PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition("DateTimeProp",
- "Sample DateTime Property", Updatability.READONLY);
- propertyDefinitions.put(prop2.getId(), prop2);
-
- prop2 = PropertyCreationHelper.createDateTimeMultiDefinition("DateTimePropMV",
- "Sample DateTime multi-value Property", Updatability.READONLY);
- propertyDefinitions.put(prop2.getId(), prop2);
-
- PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalProp",
- "Sample Decimal Property", Updatability.READONLY);
- propertyDefinitions.put(prop3.getId(), prop3);
-
- prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalPropMV", "Sample Decimal multi-value Property",
- Updatability.READONLY);
- propertyDefinitions.put(prop3.getId(), prop3);
-
- PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlProp",
- "Sample Html Property", Updatability.READONLY);
- propertyDefinitions.put(prop4.getId(), prop4);
-
- prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlPropMV", "Sample Html multi-value Property",
- Updatability.READONLY);
- propertyDefinitions.put(prop4.getId(), prop4);
-
- PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition("IdProp", "Sample Id Property",
- Updatability.READONLY);
- propertyDefinitions.put(prop5.getId(), prop5);
-
- prop5 = PropertyCreationHelper.createIdDefinition("IdPropMV", "Sample Id Html multi-value Property",
- Updatability.READONLY);
- propertyDefinitions.put(prop5.getId(), prop5);
-
- PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition("IntProp",
- "Sample Int Property", Updatability.READONLY);
- propertyDefinitions.put(prop6.getId(), prop6);
-
- prop6 = PropertyCreationHelper.createIntegerDefinition("IntPropMV", "Sample Int multi-value Property",
- Updatability.READONLY);
- propertyDefinitions.put(prop6.getId(), prop6);
-
- PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition("StringProp",
- "Sample String Property", Updatability.READONLY);
- propertyDefinitions.put(prop7.getId(), prop7);
-
- PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp", "Sample Uri Property",
- Updatability.READONLY);
- propertyDefinitions.put(prop8.getId(), prop8);
-
- prop8 = PropertyCreationHelper.createUriDefinition("UriPropMV", "Sample Uri multi-value Property",
- Updatability.READONLY);
- propertyDefinitions.put(prop8.getId(), prop8);
-
- PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
- "Sample Pick List Property", Updatability.READONLY);
-
- PropertyCreationHelper.addElemToPicklist(prop9, "red");
- PropertyCreationHelper.addElemToPicklist(prop9, "green");
- PropertyCreationHelper.addElemToPicklist(prop9, "blue");
- PropertyCreationHelper.addElemToPicklist(prop9, "black");
- PropertyCreationHelper.setDefaultValue(prop9, "blue");
-
- cmisType.setPropertyDefinitions(propertyDefinitions);
-
- return cmisType;
- }
-
- private static InMemoryDocumentTypeDefinition buildTypeWithStringProp() {
- InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(STRING_DOC_TYPE,
- "String Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- // create a String property definition
-
- PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE,
- "Sample String Property", Updatability.READONLY);
- propDef.setMaxLength(BigInteger.valueOf(10));
- propertyDefinitions.put(propDef.getId(), propDef);
-
- cmisType.setPropertyDefinitions(propertyDefinitions);
-
- return cmisType;
- }
-
- private static InMemoryDocumentTypeDefinition buildTypeWithIntegerProp() {
- InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(INT_DOC_TYPE,
- "Int Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- // create a String property definition
-
- PropertyIntegerDefinitionImpl propDef = PropertyCreationHelper.createIntegerDefinition(INT_PROP_TYPE,
- "Sample Integer Property", Updatability.READONLY);
- propDef.setMinValue(BigInteger.valueOf(-1));
- propDef.setMaxValue(BigInteger.valueOf(1));
- propertyDefinitions.put(propDef.getId(), propDef);
-
- cmisType.setPropertyDefinitions(propertyDefinitions);
-
- return cmisType;
- }
-
- private static InMemoryDocumentTypeDefinition buildTypeWithDecimalProp() {
- InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(DECIMAL_DOC_TYPE,
- "Decimal Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- // create a String property definition
-
- PropertyDecimalDefinitionImpl propDef = PropertyCreationHelper.createDecimalDefinition(DECIMAL_PROP_TYPE,
- "Sample Decimal Property", Updatability.READONLY);
- propDef.setMinValue(BigDecimal.valueOf(-1.5));
- propDef.setMaxValue(BigDecimal.valueOf(1.5));
- propertyDefinitions.put(propDef.getId(), propDef);
-
- cmisType.setPropertyDefinitions(propertyDefinitions);
-
- return cmisType;
- }
-
- public static InMemoryDocumentTypeDefinition buildTypeWithPickList(Cardinality cardinality) {
- InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(PICK_LIST_DOC_TYPE,
- "PickList Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- // create a String property definition
-
- PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
- "Sample PickList (choice) Property", Updatability.READONLY);
- List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
- ChoiceImpl<String> elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("red"));
- elem.setDisplayName("Red");
- choiceList.add(elem);
- elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("green"));
- elem.setDisplayName("Green");
- choiceList.add(elem);
- elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("blue"));
- elem.setDisplayName("Blue");
- choiceList.add(elem);
- elem = new ChoiceImpl<String>();
- elem.setValue(Collections.singletonList("black"));
- elem.setDisplayName("Black");
- choiceList.add(elem);
- propDef.setChoices(choiceList);
- propDef.setDefaultValue(Collections.singletonList("blue"));
- propDef.setCardinality(cardinality);
- propertyDefinitions.put(propDef.getId(), propDef);
- cmisType.setPropertyDefinitions(propertyDefinitions);
-
- return cmisType;
- }
-
- public static InMemoryDocumentTypeDefinition buildTypeWithMultiPickList() {
- InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(PICK_LIST_DOC_TYPE,
- "PickList Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- // create a String property definition
-
- PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
- "Sample PickList (choice) Property", Updatability.READONLY);
- List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
- ChoiceImpl<String> elem = new ChoiceImpl<String>();
- List<String> valueList = new ArrayList<String>();
- valueList.add("red");
- valueList.add("green");
- valueList.add("blue");
- elem.setValue(valueList);
- elem.setDisplayName("RGB");
- choiceList.add(elem);
-
- elem = new ChoiceImpl<String>();
- valueList = new ArrayList<String>();
- valueList.add("cyan");
- valueList.add("magenta");
- valueList.add("yellow");
- valueList.add("black");
- elem.setValue(valueList);
- elem.setDisplayName("CMYK");
- choiceList.add(elem);
-
- propDef.setChoices(choiceList);
- // propDef.setDefaultValue(...);
- propDef.setCardinality(Cardinality.MULTI);
- propertyDefinitions.put(propDef.getId(), propDef);
- cmisType.setPropertyDefinitions(propertyDefinitions);
-
- return cmisType;
- }
-
- public static InMemoryDocumentTypeDefinition buildTypeWithHierachicalPickList(Cardinality cardinality) {
- InMemoryDocumentTypeDefinition cmisType = new InMemoryDocumentTypeDefinition(PICK_LIST_DOC_TYPE,
- "PickList Document Type for Validation", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- // create a String property definition
-
- // Create a two-level pick list with an outer property list state and an
- // inner
- // list of city
- PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
- "Sample PickList (choice) Property", Updatability.READONLY);
- List<Choice<String>> choiceListOuter = new ArrayList<Choice<String>>();
-
- ChoiceImpl<String> elemOuter = new ChoiceImpl<String>();
- elemOuter.setDisplayName("Bavaria");
- List<Choice<String>> choiceListInner = new ArrayList<Choice<String>>();
- ChoiceImpl<String> elemInner = new ChoiceImpl<String>();
- elemInner.setDisplayName("Munich");
- elemInner.setValue(Collections.singletonList("munich"));
- choiceListInner.add(elemInner);
- elemInner = new ChoiceImpl<String>();
- elemInner.setDisplayName("Ingolstadt");
- elemInner.setValue(Collections.singletonList("ingolstadt"));
- choiceListInner.add(elemInner);
- elemInner = new ChoiceImpl<String>();
- elemInner.setDisplayName("Passau");
- elemInner.setValue(Collections.singletonList("passau"));
- choiceListInner.add(elemInner);
- elemOuter.setChoice(choiceListInner);
- choiceListOuter.add(elemOuter);
-
- elemOuter = new ChoiceImpl<String>();
- elemOuter.setDisplayName("Baden Wurtemberg");
- choiceListInner = new ArrayList<Choice<String>>();
- elemInner = new ChoiceImpl<String>();
- elemInner.setDisplayName("Stuttgart");
- elemInner.setValue(Collections.singletonList("stuttgart"));
- choiceListInner.add(elemInner);
- elemInner = new ChoiceImpl<String>();
- elemInner.setDisplayName("Karlsruhe");
- elemInner.setValue(Collections.singletonList("karlsruhe"));
- choiceListInner.add(elemInner);
- elemInner = new ChoiceImpl<String>();
- elemInner.setDisplayName("Walldorf");
- elemInner.setValue(Collections.singletonList("walldorf"));
- choiceListInner.add(elemInner);
- elemOuter.setChoice(choiceListInner);
- choiceListOuter.add(elemOuter);
-
- propDef.setChoices(choiceListOuter);
- propDef.setCardinality(cardinality);
- propertyDefinitions.put(propDef.getId(), propDef);
- cmisType.setPropertyDefinitions(propertyDefinitions);
+ try {
+ MutableDocumentTypeDefinition cmisType;
+ cmisType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), MY_DOC_TYPE);
+ cmisType.setDisplayName("Document Type for Validation");
+ cmisType.setDescription("InMemory test type definition " + MY_DOC_TYPE);
+
+ // create a boolean property definition
+
+ PropertyDefinition<Boolean> prop = PropertyCreationHelper.createBooleanDefinition("BooleanProp",
+ "Sample Boolean Property", Updatability.READONLY);
+ ((PropertyBooleanDefinitionImpl) prop).setIsRequired(true);
+ cmisType.addPropertyDefinition(prop);
+
+ prop = PropertyCreationHelper.createBooleanMultiDefinition("BooleanPropMV",
+ "Sample Boolean multi-value Property", Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop);
+
+ PropertyDateTimeDefinitionImpl prop2 = PropertyCreationHelper.createDateTimeDefinition("DateTimeProp",
+ "Sample DateTime Property", Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop2);
+
+ prop2 = PropertyCreationHelper.createDateTimeMultiDefinition("DateTimePropMV",
+ "Sample DateTime multi-value Property", Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop2);
+
+ PropertyDecimalDefinitionImpl prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalProp",
+ "Sample Decimal Property", Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop3);
+
+ prop3 = PropertyCreationHelper.createDecimalDefinition("DecimalPropMV", "Sample Decimal multi-value Property",
+ Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop3);
+
+ PropertyHtmlDefinitionImpl prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlProp",
+ "Sample Html Property", Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop4);
+
+ prop4 = PropertyCreationHelper.createHtmlDefinition("HtmlPropMV", "Sample Html multi-value Property",
+ Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop4);
+
+ PropertyIdDefinitionImpl prop5 = PropertyCreationHelper.createIdDefinition("IdProp", "Sample Id Property",
+ Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop5);
+
+ prop5 = PropertyCreationHelper.createIdDefinition("IdPropMV", "Sample Id Html multi-value Property",
+ Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop5);
+
+ PropertyIntegerDefinitionImpl prop6 = PropertyCreationHelper.createIntegerDefinition("IntProp",
+ "Sample Int Property", Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop6);
+
+ prop6 = PropertyCreationHelper.createIntegerDefinition("IntPropMV", "Sample Int multi-value Property",
+ Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop6);
+
+ PropertyStringDefinitionImpl prop7 = PropertyCreationHelper.createStringDefinition("StringProp",
+ "Sample String Property", Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop7);
+
+ PropertyUriDefinitionImpl prop8 = PropertyCreationHelper.createUriDefinition("UriProp", "Sample Uri Property",
+ Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop8);
+
+ prop8 = PropertyCreationHelper.createUriDefinition("UriPropMV", "Sample Uri multi-value Property",
+ Updatability.READONLY);
+ cmisType.addPropertyDefinition(prop8);
+
+ PropertyStringDefinitionImpl prop9 = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
+ "Sample Pick List Property", Updatability.READONLY);
+
+ PropertyCreationHelper.addElemToPicklist(prop9, "red");
+ PropertyCreationHelper.addElemToPicklist(prop9, "green");
+ PropertyCreationHelper.addElemToPicklist(prop9, "blue");
+ PropertyCreationHelper.addElemToPicklist(prop9, "black");
+ PropertyCreationHelper.setDefaultValue(prop9, "blue");
+ cmisType.addPropertyDefinition(prop9);
+
+ return cmisType;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+ }
+ }
+
+ private static DocumentTypeDefinition buildTypeWithStringProp() {
+ try {
+ MutableDocumentTypeDefinition cmisType;
+ cmisType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), STRING_DOC_TYPE);
+ cmisType.setDisplayName("String Document Type for Validation");
+ cmisType.setDescription("InMemory test type definition " + STRING_DOC_TYPE);
+
+ // create a String property definition
+ PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE,
+ "Sample String Property", Updatability.READONLY);
+ propDef.setMaxLength(BigInteger.valueOf(10));
+ cmisType.addPropertyDefinition(propDef);
+
+ return cmisType;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+ }
+ }
+
+ private static DocumentTypeDefinition buildTypeWithIntegerProp() {
+ try {
+ MutableDocumentTypeDefinition cmisType;
+ cmisType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), INT_DOC_TYPE);
+ cmisType.setDisplayName("Int Document Type for Validation");
+ cmisType.setDescription("InMemory test type definition " + INT_DOC_TYPE);
+
+ // create a String property definition
+
+ PropertyIntegerDefinitionImpl propDef = PropertyCreationHelper.createIntegerDefinition(INT_PROP_TYPE,
+ "Sample Integer Property", Updatability.READONLY);
+ propDef.setMinValue(BigInteger.valueOf(-1));
+ propDef.setMaxValue(BigInteger.valueOf(1));
+ cmisType.addPropertyDefinition(propDef);
+
+ return cmisType;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+ }
+ }
+
+ private static DocumentTypeDefinition buildTypeWithDecimalProp() {
+ try {
+ MutableDocumentTypeDefinition cmisType;
+ cmisType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), DECIMAL_DOC_TYPE);
+ cmisType.setDisplayName("Decimal Type for Validation");
+ cmisType.setDescription("InMemory test type definition " + DECIMAL_DOC_TYPE);
+
+ // create a String property definition
+
+ PropertyDecimalDefinitionImpl propDef = PropertyCreationHelper.createDecimalDefinition(DECIMAL_PROP_TYPE,
+ "Sample Decimal Property", Updatability.READONLY);
+ propDef.setMinValue(BigDecimal.valueOf(-1.5));
+ propDef.setMaxValue(BigDecimal.valueOf(1.5));
+ cmisType.addPropertyDefinition(propDef);
+
+ return cmisType;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+ }
+ }
+
+ public static DocumentTypeDefinition buildTypeWithPickList(Cardinality cardinality) {
+ try {
+ MutableDocumentTypeDefinition cmisType;
+ cmisType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), PICK_LIST_DOC_TYPE);
+ cmisType.setDisplayName("PickList Type for Validation");
+ cmisType.setDescription("InMemory test type definition " + PICK_LIST_DOC_TYPE);
+
+ // create a String property definition
+ PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
+ "Sample PickList (choice) Property", Updatability.READONLY);
+ List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
+ ChoiceImpl<String> elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("red"));
+ elem.setDisplayName("Red");
+ choiceList.add(elem);
+ elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("green"));
+ elem.setDisplayName("Green");
+ choiceList.add(elem);
+ elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("blue"));
+ elem.setDisplayName("Blue");
+ choiceList.add(elem);
+ elem = new ChoiceImpl<String>();
+ elem.setValue(Collections.singletonList("black"));
+ elem.setDisplayName("Black");
+ choiceList.add(elem);
+ propDef.setChoices(choiceList);
+ propDef.setDefaultValue(Collections.singletonList("blue"));
+ propDef.setCardinality(cardinality);
+ cmisType.addPropertyDefinition(propDef);
+
+ return cmisType;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+ }
+ }
+
+ public static DocumentTypeDefinition buildTypeWithMultiPickList() {
+ try {
+ MutableDocumentTypeDefinition cmisType;
+ cmisType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), PICK_LIST_DOC_TYPE);
+ cmisType.setDisplayName("MDocument Type for Validation");
+ cmisType.setDescription("PickList test type definition " + PICK_LIST_DOC_TYPE);
+
+ // create a String property definition
+ PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
+ "Sample PickList (choice) Property", Updatability.READONLY);
+ List<Choice<String>> choiceList = new ArrayList<Choice<String>>();
+ ChoiceImpl<String> elem = new ChoiceImpl<String>();
+ List<String> valueList = new ArrayList<String>();
+ valueList.add("red");
+ valueList.add("green");
+ valueList.add("blue");
+ elem.setValue(valueList);
+ elem.setDisplayName("RGB");
+ choiceList.add(elem);
+
+ elem = new ChoiceImpl<String>();
+ valueList = new ArrayList<String>();
+ valueList.add("cyan");
+ valueList.add("magenta");
+ valueList.add("yellow");
+ valueList.add("black");
+ elem.setValue(valueList);
+ elem.setDisplayName("CMYK");
+ choiceList.add(elem);
+
+ propDef.setChoices(choiceList);
+ // propDef.setDefaultValue(...);
+ propDef.setCardinality(Cardinality.MULTI);
+ cmisType.addPropertyDefinition(propDef);
+
+ return cmisType;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+ }
+ }
+
+ public static DocumentTypeDefinition buildTypeWithHierachicalPickList(Cardinality cardinality) {
+ try {
+ MutableDocumentTypeDefinition cmisType;
+ cmisType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), PICK_LIST_DOC_TYPE);
+ cmisType.setDisplayName("PickList Type for Validation");
+ cmisType.setDescription("InMemory test type definition " + PICK_LIST_DOC_TYPE);
+
+ // create a String property definition
+
+ // Create a two-level pick list with an outer property list state and an
+ // inner
+ // list of city
+ PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(PICK_LIST_PROP_DEF,
+ "Sample PickList (choice) Property", Updatability.READONLY);
+ List<Choice<String>> choiceListOuter = new ArrayList<Choice<String>>();
+
+ ChoiceImpl<String> elemOuter = new ChoiceImpl<String>();
+ elemOuter.setDisplayName("Bavaria");
+ List<Choice<String>> choiceListInner = new ArrayList<Choice<String>>();
+ ChoiceImpl<String> elemInner = new ChoiceImpl<String>();
+ elemInner.setDisplayName("Munich");
+ elemInner.setValue(Collections.singletonList("munich"));
+ choiceListInner.add(elemInner);
+ elemInner = new ChoiceImpl<String>();
+ elemInner.setDisplayName("Ingolstadt");
+ elemInner.setValue(Collections.singletonList("ingolstadt"));
+ choiceListInner.add(elemInner);
+ elemInner = new ChoiceImpl<String>();
+ elemInner.setDisplayName("Passau");
+ elemInner.setValue(Collections.singletonList("passau"));
+ choiceListInner.add(elemInner);
+ elemOuter.setChoice(choiceListInner);
+ choiceListOuter.add(elemOuter);
+
+ elemOuter = new ChoiceImpl<String>();
+ elemOuter.setDisplayName("Baden Wurtemberg");
+ choiceListInner = new ArrayList<Choice<String>>();
+ elemInner = new ChoiceImpl<String>();
+ elemInner.setDisplayName("Stuttgart");
+ elemInner.setValue(Collections.singletonList("stuttgart"));
+ choiceListInner.add(elemInner);
+ elemInner = new ChoiceImpl<String>();
+ elemInner.setDisplayName("Karlsruhe");
+ elemInner.setValue(Collections.singletonList("karlsruhe"));
+ choiceListInner.add(elemInner);
+ elemInner = new ChoiceImpl<String>();
+ elemInner.setDisplayName("Walldorf");
+ elemInner.setValue(Collections.singletonList("walldorf"));
+ choiceListInner.add(elemInner);
+ elemOuter.setChoice(choiceListInner);
+ choiceListOuter.add(elemOuter);
+
+ propDef.setChoices(choiceListOuter);
+ propDef.setCardinality(cardinality);
+ cmisType.addPropertyDefinition(propDef);
- return cmisType;
+ return cmisType;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+ }
}
private static TypeManager buildInheritedTypes() {
+ try {
- TypeManagerImpl tm = new TypeManagerImpl();
- tm.initTypeSystem(null); // create CMIS default types
+ TypeManagerImpl tm = new TypeManagerImpl();
+ tm.initTypeSystem(null, true); // create CMIS default types
- // create super type
- InMemoryDocumentTypeDefinition cmisSuperType = new InMemoryDocumentTypeDefinition(DOC_TYPE_SUPER,
- "Document Type With a child", InMemoryDocumentTypeDefinition.getRootDocumentType());
-
- Map<String, PropertyDefinition<?>> propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- // create a String property definition
- PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE_SUPER,
- "Sample String Property SuperType", Updatability.READONLY);
- propDef.setMaxLength(BigInteger.valueOf(10));
- propertyDefinitions.put(propDef.getId(), propDef);
- cmisSuperType.setPropertyDefinitions(propertyDefinitions);
-
- // create sub type
- InMemoryDocumentTypeDefinition cmisSubType = new InMemoryDocumentTypeDefinition(DOC_TYPE_SUB,
- "Document Type With a parent", cmisSuperType);
-
- propertyDefinitions = new HashMap<String, PropertyDefinition<?>>();
- // create a String property definition
- propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE_SUB, "Sample String Property Subtype",
- Updatability.READONLY);
- propDef.setMaxLength(BigInteger.valueOf(20));
- propertyDefinitions.put(propDef.getId(), propDef);
- cmisSubType.setPropertyDefinitions(propertyDefinitions);
+ // create super type
+ MutableDocumentTypeDefinition cmisSuperType;
+ cmisSuperType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(DocumentTypeCreationHelper.getCmisDocumentType(), DOC_TYPE_SUPER);
+ cmisSuperType.setDisplayName("Document Type With a child");
+ cmisSuperType.setDescription("InMemory test type definition " + DOC_TYPE_SUPER);
+
+ // create a String property definition
+ PropertyStringDefinitionImpl propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE_SUPER,
+ "Sample String Property SuperType", Updatability.READONLY);
+ propDef.setMaxLength(BigInteger.valueOf(10));
+ cmisSuperType.addPropertyDefinition(propDef);
+
+ tm.addTypeDefinition(cmisSuperType, false);
+
+ // create sub type
+ MutableDocumentTypeDefinition cmisSubType;
+ cmisSubType = (MutableDocumentTypeDefinition) typeFactory.createChildTypeDefinition(cmisSuperType, DOC_TYPE_SUB);
+ cmisSubType.setDisplayName("Document Type With a parent");
+ cmisSubType.setDescription("InMemory test type definition " + DOC_TYPE_SUB);
+
+ // create a String property definition
+ propDef = PropertyCreationHelper.createStringDefinition(STRING_PROP_TYPE_SUB, "Sample String Property Subtype",
+ Updatability.READONLY);
+ propDef.setMaxLength(BigInteger.valueOf(20));
+ cmisSubType.addPropertyDefinition(propDef);
- tm.addTypeDefinition(cmisSuperType);
- tm.addTypeDefinition(cmisSubType);
+ tm.addTypeDefinition(cmisSubType, false);
- return tm;
+ return tm;
+ } catch (Exception e) {
+ throw new CmisRuntimeException("Error when creating built-in InMemory types.", e);
+ }
}
}