Showing posts with label cmis object type. Show all posts
Showing posts with label cmis object type. Show all posts

Thursday, 25 April 2019

CMIS: Attributes common to all the Object-Type Definitions


Following table summarizes all the attributes that are common to all the object type definitions.

Attribute
Description
Data type
id
Identifies the object-type in the hierarchy
Id
localName
the underlying repository's name for the object-type.
String
localNameSpace
This attribute allows repositories to represent the internal namespace of the underlying repository's
name for the object-type.
String
queryName
Used to query and filter operations on object-types
String
displayName
Used for presentation by application.
String
baseId
Represent the base type of this object type. The base type can be one of document, folder, relationship, policy, item, or secondary base type.
Enum
parentId
The id of the object-type's immediate parent type.
Id
description
Description of this object-type, such as the nature of content, or its intended use.
String
creatable
Indicates whether new objects of this type can be created or not. If the value of this attribute is false, the repository may contain objects of this type already, but must not allow new objects of this type to be created.
Boolean
fileable
Indicates whether or not objects of this type are file-able.
Boolean
queryable
Indicates whether or not this object-type can appear in the FROM clause of a query statement.
Boolean
controllablePolicy
Indicates whether or not objects of this type are controllable via policies.
Boolean
controllableACL
This attribute indicates whether or not objects of this type are controllable by ACL's. Only objects that are controllableACL can have an ACL.
Boolean
fulltextIndexed
Indicates whether objects of this type are indexed for full-text search for querying via the CONTAINS() query predicate. If the value of this attribute is TRUE, the full-text index MUST cover the content and MAY cover the metadata.
Boolean
includedInSupertypeQuery
Indicates whether this type and its subtypes appear in a query of this type's ancestor types.
Boolean
typeMutability.create
Indicates whether new child types may be created with this type as the parent.
Boolean
typeMutability.update
Indicates whether clients may make changes to this type per the constraints defined in this specification.
Boolean
typeMutability.delete
Indicates whether clients may delete this type if there are no instances of it in the repository.
Boolean




Previous                                                 Next                                                 Home

CMIS: Object type hierarchies


CMIS repository must have following two basic types.
         a. cmis:document
         b. cmis:folder

In additon to the above two basic types, a repository may support following base types.

         a. cmis:relationship
         b. cmis:policy
         c. cmis:item
         d. cmis:secondary
        
As per CMIS specification, there must be only 6 base types that are specified above. You can create new types as sub types of these base types.

By using following statements, you can get all the base types that are supported by the repository.
ItemIterable<ObjectType> objTypes = session.getTypeChildren(null, false);

TestCmis.java
package com.sample.util;

import java.util.HashMap;
import java.util.Map;

import org.apache.chemistry.opencmis.client.api.ItemIterable;
import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;

public class TestCmis {

 private static String serverURL = "http://localhost:8080/chemistry-opencmis-server-inmemory-1.1.0/browser";
 private static String repositoryId = "A1";

 public static Session getSession() {
  Map<String, String> parameters = new HashMap<>();
  parameters.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());

  parameters.put(SessionParameter.USER, "");
  parameters.put(SessionParameter.PASSWORD, "");

  parameters.put(SessionParameter.REPOSITORY_ID, repositoryId);
  parameters.put(SessionParameter.BROWSER_URL, serverURL);

  SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
  return sessionFactory.createSession(parameters);
 }


 public static void main(String args[]) {
  Session session = getSession();

  ItemIterable<ObjectType> objTypes = session.getTypeChildren(null, false);
  
  for(ObjectType objectType : objTypes){
   System.out.println(objectType.getId());
  }
 }

}


Output
cmis:secondary
cmis:item
cmis:relationship
cmis:policy
cmis:folder
cmis:document

Points should be noted about object types
a. Other than the 6 base types (cmis:document, cmis:folder, cmis:relationship, cmis:policy, cmis:item, cmis:secondary), no other base type should exists in the repository

b. A base type do not have parent type

c.  A non-base type has one and only one parent type.
Following application prints all the types and their parent types.


TestCmis.java
package com.sample.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.chemistry.opencmis.client.api.ObjectType;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.api.Tree;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;

public class TestCmis {

 private static String serverURL = "http://localhost:8080/chemistry-opencmis-server-inmemory-1.1.0/browser";
 private static String repositoryId = "A1";
 private static final String NULL_STRING = null;

 public static Session getSession() {
  Map<String, String> parameters = new HashMap<>();
  parameters.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());

  parameters.put(SessionParameter.USER, "");
  parameters.put(SessionParameter.PASSWORD, "");

  parameters.put(SessionParameter.REPOSITORY_ID, repositoryId);
  parameters.put(SessionParameter.BROWSER_URL, serverURL);

  SessionFactory sessionFactory = SessionFactoryImpl.newInstance();
  return sessionFactory.createSession(parameters);
 }

 public static void printTypeAndParentType(List<Tree<ObjectType>> types) {

  for (Tree<ObjectType> typeTree : types) {
   ObjectType objType = typeTree.getItem();
   ObjectType parentType = objType.getParentType();

   StringBuilder builder = new StringBuilder("type : ").append(objType.getId()).append(" -> ");

   if (parentType == null) {
    builder.append("parentType : ").append(NULL_STRING);
   } else {
    builder.append("parentType : ").append(parentType.getId());
   }

   System.out.println(builder.toString());
   printTypeAndParentType(typeTree.getChildren());
  }

 }

 public static void main(String args[]) {
  Session session = getSession();

  List<Tree<ObjectType>> typeDescendants = session.getTypeDescendants(null, -1, false);

  printTypeAndParentType(typeDescendants);

 }

}


Output
type : cmis:secondary -> parentType : null
type : MySecondaryType -> parentType : cmis:secondary
type : cmis:item -> parentType : null
type : MyItemType -> parentType : cmis:item
type : cmis:relationship -> parentType : null
type : CrossReferenceType -> parentType : cmis:relationship
type : cmis:policy -> parentType : null
type : AuditPolicy -> parentType : cmis:policy
type : cmis:folder -> parentType : null
type : cmis:document -> parentType : null
type : MyDocType1 -> parentType : cmis:document
type : MyDocType1.1 -> parentType : MyDocType1
type : MyDocType1.1.1 -> parentType : MyDocType1.1
type : MyDocType1.1.2 -> parentType : MyDocType1.1
type : MyDocType1.2 -> parentType : MyDocType1
type : MyDocType2 -> parentType : cmis:document
type : MyDocType2.1 -> parentType : MyDocType2
type : MyDocType2.2 -> parentType : MyDocType2
type : MyDocType2.3 -> parentType : MyDocType2
type : MyDocType2.4 -> parentType : MyDocType2
type : MyDocType2.5 -> parentType : MyDocType2
type : MyDocType2.6 -> parentType : MyDocType2
type : MyDocType2.7 -> parentType : MyDocType2
type : MyDocType2.8 -> parentType : MyDocType2
type : MyDocType2.9 -> parentType : MyDocType2
type : ComplexType -> parentType : cmis:document
type : DocumentTopLevel -> parentType : cmis:document
type : DocumentLevel1 -> parentType : DocumentTopLevel
type : DocumentLevel2 -> parentType : DocumentLevel1
type : VersionableType -> parentType : cmis:document
type : BigContentFakeType -> parentType : cmis:document
type : audioFile -> parentType : cmis:document
type : emailDocument -> parentType : cmis:document
type : exifImage -> parentType : cmis:document
type : officeDocument -> parentType : cmis:document
type : pdfDocument -> parentType : officeDocument
type : videoFile -> parentType : cmis:document

You can notify from the above output, for the base types (cmis:secondary, cmis:item, cmis:relationship, cmis:policy, cmis:folder, cmis:document), the parent type is null.

d. The scope of a query on a given object-type is automatically expanded to include all the descendant types of the given object-type.

For example,

If you query on type 'cmis:document', the query will expand to the type 'cmis:document' and all the sub types.


Previous                                                 Next                                                 Home