Saturday 13 April 2019

openCMIS: Policy object


A policy object specifies an administrative policy that can be enforced by a repository. Each policy object holds the text of an administrative policy as a repository-specific string.

Can I create sub types to the policy object type?
Yes, you can create sub types to the policy object type.

Is all repositories support policy objects?
No. You can check whether the repository support policy objects or not by calling the getTypeChildren API.

Below statements are used to check whether the repository supports policy objects or not.

                  ItemIterable<ObjectType> objTypes = session.getTypeChildren(null, false);
                 
                  for(ObjectType objType : objTypes){
                           if("cmis:policy".equals(objType.getId())){
                                    System.out.println("Policy objects are supported by the reposiotry");
                           }
                  }

TestCmis.java
package com.sample.util;

import java.io.IOException;
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";

 private 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[]) throws IOException {

  Session session = getSession();

  ItemIterable<ObjectType> objTypes = session.getTypeChildren(null, false);
  
  for(ObjectType objType : objTypes){
   if("cmis:policy".equals(objType.getId())){
    System.out.println("Policy objects are supported by the reposiotry");
   }
  }

 }

}

Can I create policy object using CMIS?
Yes

Can I apply policy object to a repository object using CMIS?
Yes

Can I remove an applied policy from cmis object?
Yes

What is controllable object?
An object to which a policy is applied is called a controllable object.

Can I apply multiple policies to same controllable object?
Yes, but repository may impose constraints such as only one policy of each kind can be applied to an object

Can a policy is applied to multiple objects?
Yes

How to check whether an object is controllable by policy or not?
Object type definition has ‘controllable’ property, it specifies whether the object is controllable by policy or not.

Below statements are used to check whether a repository object is controlled by policy or not.

                  CmisObject cmisObject = session.getRootFolder();
                  Boolean controllablePolicy = cmisObject.getType().isControllablePolicy();
                 
                  if (controllablePolicy == null){
                           System.out.println("Unknown (noncompliant repository)");
                  }else if(controllablePolicy){
                           System.out.println("Object is controlled by the policy");
                  }else{
                           System.out.println("Object is not controlled by the policy");
                  }
                                   


TestCmis.java
package com.sample.util;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.apache.chemistry.opencmis.client.api.CmisObject;
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";

 private 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[]) throws IOException {

  Session session = getSession();

  CmisObject cmisObject = session.getRootFolder();
  Boolean controllablePolicy = cmisObject.getType().isControllablePolicy();
  
  if (controllablePolicy == null){
   System.out.println("Unknown (noncompliant repository)");
  }else if(controllablePolicy){
   System.out.println("Object is controlled by the policy");
  }else{
   System.out.println("Object is not controlled by the policy");
  }
  
  
  
 }

}

Output
Object is controlled by the policy

Is indirectly (through inheritance) applied policies are covered by CMIS?
Only directly/explicitly applied policies are covered by CMIS. Indirectly applying policy to an object, e.g. through inheritance, is outside the scope of CMIS.

Is policy object having content stream associated with it?
No

Is policy object versionable?
No

Is policy object fileable?
Maybe

Is policy object queryable?
Maybe

Is policy object controllable?
Maybe


Previous                                                 Next                                                 Home

No comments:

Post a Comment