Working with Types
Getting Type Definitions
CMIS 1.0 CMIS 1.1 Spec 2.1.3
Getting a Specific Type Definition
OpenCMIS (Java)
ObjectType type = session.getTypeDefinition("cmis:document");
if (type instanceof DocumentType) {
DocumentType docType = (DocumentType) type;
boolean isVersionable = docType.isVersionable();
} else if (type instanceof RelationshipType) {
RelationshipType relType = (RelationshipType) type;
} else {
...
}
PortCMIS (C#)
IObjectType type = session.GetTypeDefinition("cmis:document");
if (type is IDocumentType) {
IDocumentType docType = type as IDocumentType;
bool isVersionable = docType.Versionable;
} else if (type is IRelationshipType) {
IRelationshipType relType = type as IRelationshipType;
} else {
...
}
Checking whether a Specific Type Definition Exists
OpenCMIS (Java)
boolean typeExists = true;
try {
session.getTypeDefinition("my:Type");
}
catch (CmisObjectNotFoundException e) {
typeExists = false;
}
PortCMIS (C#)
bool typeExists = true;
try {
session.GetTypeDefinition("my:Type");
}
catch (CmisObjectNotFoundException) {
typeExists = false;
}
Browsing Type Definitions
Creating, Updating, and Deleting Types
CMIS 1.1 Spec 2.1.10
Reading and Writing Type Definitions
The class TypeUtils
in OpenCMIS provides methods to read and write
type defintions from XML and JSON. It also offers methods to check whether
a type defintion is valid and complete.
Creating a Type
OpenCMIS (Java)
TypeDefinition typeDef = ...
ObjectType createdType = session.createType(typeDef);
PortCMIS (C#)
ITypeDefinition typeDef = ...
IObjectType createdType = session.CreateType(typeDef);
Updating a Type
OpenCMIS (Java)
TypeDefinition typeDef = ...
ObjectType updatedType = session.updateType(typeDef);
PortCMIS (C#)
ITypeDefinition typeDef = ...
IObjectType updatedType = session.UpdateType(typeDef);
Deleting a Type
A type can only be deleted if no object of that type exists in the repository.
OpenCMIS (Java)
session.deleteType("my:uselessType");
PortCMIS (C#)
session.DeleteType("my:uselessType");