Delete object samples

This is a list with a bunch of examples about how to delete objects in OpenKM using CMIS. For a full specification of CMIS services please visit CMIS documentation  

Delete object

The following samples show how to delete an object.

The "3864027b-f181-4291-8e63-d602ee850a8f" is the unique id - uuid - of an object in OpenKM repository. 

When the object is a document, all versions of the document are deleted.

When the object is a folder and it is not empty, the folder is not deleted an it raises and exception.

// default factory implementation
SessionFactory factory = SessionFactoryImpl.newInstance();
Map<String, String> parameters = new HashMap<String, String>();

// user credentials
parameters.put(SessionParameter.USER, "okmAdmin");
parameters.put(SessionParameter.PASSWORD, "admin");

// connection settings
parameters.put(SessionParameter.BROWSER_URL, "http://localhost:8080/openkm/cmis/browser");
parameters.put(SessionParameter.BINDING_TYPE, BindingType.BROWSER.value());		

// create session
List<Repository> list= factory.getRepositories(parameters);

// List every repository found
for (Repository repository: list) {
    System.out.println("New repository found: " + repository.getId());
    System.out.println("Capabilities: ");
    System.out.println(repository.getCapabilities());	
    // Create session
    Session session = repository.createSession();
    
    // Get the document and move it	
    CmisObject cmisObject = session.getObject("3864027b-f181-4291-8e63-d602ee850a8f");
    cmisObject.delete();
}	
Table of contents [ Hide Show ]