Sunday 21 April 2019

CMIS: Check the content stream updation capability


RepositoryCapabilities interface provides getContentStreamUpdatesCapability, it returns the Content stream updatable capability. Following table summarizes the possible values.
Value
Description
none
The content stream may never be updated.
anytime
The content stream may be updated any time.
pwconly
The content stream may be updated only when checked out.

Example
                  CapabilityContentStreamUpdates capabilityContentStreamUpdates = repoInfo.getCapabilities().getContentStreamUpdatesCapability();

                  if (capabilityContentStreamUpdates == null) {
                           System.out.println("Repository is not providing any value");
                  } else if (capabilityContentStreamUpdates == CapabilityContentStreamUpdates.NONE) {
                           System.out.println("Content stream will not be updated");
                  } else if (capabilityContentStreamUpdates == CapabilityContentStreamUpdates.ANYTIME) {
                           System.out.println("Content stream can be updated at any time");
                  } else if (capabilityContentStreamUpdates == CapabilityContentStreamUpdates.PWCONLY) {
                           System.out.println("Content stream can be updated only when the document is checked out");
                  }

Find the following working application.

TestCmis.java
package com.sample.util;

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

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.data.RepositoryInfo;
import org.apache.chemistry.opencmis.commons.enums.BindingType;
import org.apache.chemistry.opencmis.commons.enums.CapabilityContentStreamUpdates;

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();

  RepositoryInfo repoInfo = session.getRepositoryInfo();

  CapabilityContentStreamUpdates capabilityContentStreamUpdates = repoInfo.getCapabilities()
    .getContentStreamUpdatesCapability();

  if (capabilityContentStreamUpdates == null) {
   System.out.println("Repository is not providing any value");
  } else if (capabilityContentStreamUpdates == CapabilityContentStreamUpdates.NONE) {
   System.out.println("Content stream will not be updated");
  } else if (capabilityContentStreamUpdates == CapabilityContentStreamUpdates.ANYTIME) {
   System.out.println("Content stream can be updated at any time");
  } else if (capabilityContentStreamUpdates == CapabilityContentStreamUpdates.PWCONLY) {
   System.out.println("Content stream can be updated only when the document is checked out");
  }

 }

}

Output
Content stream can be updated at any time




Previous                                                 Next                                                 Home

No comments:

Post a Comment