Basic concepts

Authentication

The first lines in your Java code should be used to create the Webservices object.

We suggest using this method:

OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.exception.AccessDeniedException;
import com.openkm.sdk4j.exception.DatabaseException;
import com.openkm.sdk4j.exception.RepositoryException;
import com.openkm.sdk4j.exception.UnknowException;
import com.openkm.sdk4j.exception.WebserviceException;

public class Test {
	public static void main(String[] args) {
		String host = "http://localhost:8080/OpenKM";
		String username =  "okmAdmin";
		String password = "admin";
		OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
                 try { System.out.println(ws.getAppVersion()); } catch (RepositoryException e) { e.printStackTrace(); } catch (DatabaseException e) { e.printStackTrace(); } catch (UnknowException e) { e.printStackTrace(); } catch (WebserviceException e) { e.printStackTrace(); } } }

Also is possible doing the same from each API class implementation.

We do not suggest this way.

For example with this method:

RepositoryImpl repositoryImpl = new RepositoryImpl(host, username, password, new BeanHelper());

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.exception.AccessDeniedException;
import com.openkm.sdk4j.exception.DatabaseException;
import com.openkm.sdk4j.exception.RepositoryException;
import com.openkm.sdk4j.exception.UnknowException;
import com.openkm.sdk4j.exception.WebserviceException;
import com.openkm.sdk4j.impl.RepositoryImpl;
import com.openkm.sdk4j.util.BeanHelper;

public class Test {
	public static void main(String[] args) {
		String host = "http://localhost:8080/OpenKM";
		String username =  "okmAdmin";
		String password = "admin";
		RepositoryImpl repositoryImpl = new RepositoryImpl(host, username, password, new BeanHelper());
		
		try {
			System.out.println(repositoryImpl.getAppVersion());
		} catch (RepositoryException e) {
			e.printStackTrace();
		} catch (DatabaseException e) {
			e.printStackTrace();
		} catch (UnknowException e) {
			e.printStackTrace();
		} catch (WebserviceException e) {
			e.printStackTrace();
		}
	}	
}

Accessing API

OpenKM API classes are under com.openkm package, as can shown at this Javadoc API summary.

At main url http://docs.openkm.com/javadoc/ you'll see all available Javadoc documentation.

At the moment of writing this page the actual OpenKM version was 6.3.0 what can change on time.

There is a direct correspondence between the classes and methods into, implemented at com.openkm.api packages and available from SDK for Java.

OpenKM API classes:

OpenKM API classDescriptionSupportedImplementationInterface

OKMAuth

Manage security and users. For example add or remove grants on a node, create or modify users or getting the profiles.

Yes

AuthImpl.java

BaseAuth.java

OKMBookmark

Manage the user bookmarks.

No

   

OKMDashboard

Manage all data shown at dashboard.

No

   

OKMDocument

Manage documents. For example create, move or delete a document.

Yes

DocumentImpl.java

BaseDocument.java

OKMFolder

Manage folders. For example create, move or delete a folder.

Yes

FolderImpl.java

BaseFolder.java

OKMMail

Manage mails. For example create, move or delete a mails.

No

 

 

OKMNote

Manage notes on any node type. For example create, edit or delete a note on a document, folder, mail or record.

Yes

NoteImpl.java

BaseNote.java

OKMNotification

Manage notifications. For example add or remove subscriptions on a document or a folder.

No

 

 

OKMProperty

Manage categories and keywords. For example add or remove keywords on a document, folder, mail or record.

Yes

PropertyImpl.java

BaseProperty.java

OKMPropertyGroup

Manage metadata. For example add metadata group, set metadata fields.

Yes

PropertyGroupImpl.java

BasePropertyGroup.java

OKMRepository

A lot of stuff related with repository. For example get the properties of main root node ( /okm:root ).

Yes

RepositoryImpl.java

BaseRepository.java

OKMSearch

Manage search feature. For example manage saved queries or perform a new query to the repository.

Yes

SearchImpl.java

BaseSearch.java

OKMStats

General stats of the repository.

No

   

OKMUserConfig

Manage user home configuration.

No

   

Class Hierarchy

Packages detail:

NameDescription

com.openkm

The  com.openkm.OKMWebservicesFactory that returns an com.openkm.OKMWebservices object which implements all interfaces.

OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);

com.openkm.sdk4j.bean

Contains all classes result of unmarshalling REST objects.

com.openkm.sdk4j.definition

All interface classes:

  • com.openkm.sdk4j.definition.BaseAuth
  • com.openkm.sdk4j.definition.BaseDocument
  • com.openkm.sdk4j.definition.BaseFolder
  • com.openkm.sdk4j.definition.BaseNote
  • com.openkm.sdk4j.definition.BaseProperty
  • com.openkm.sdk4j.definition.BasePropertyGroup
  • com.openkm.sdk4j.definition.BaseRepository
  • com.openkm.sdk4j.definition.BaseSearch

com.openkm.sdk4j.impl

All interface implementation classes:

  • com.openkm.sdk4j.impl.AuthImpl
  • com.openkm.sdk4j.impl.DocumentImpl
  • com.openkm.sdk4j.impl.FolderImpl
  • com.openkm.sdk4j.impl.NoteImpl
  • com.openkm.sdk4j.impl.PropertyGroupImpl
  • com.openkm.sdk4j.impl.PropertyImpl
  • com.openkm.sdk4j.impl.RepositoryImpl
  • com.openkm.sdk4j.impl.SearchImpl

com.openkm.sdk4j.util

A couple of utilities.

The class com.openkm.sdk4j.util.ISO8601 should be used to set and parse metadata date fields.

com.openkm.sdk4j.exception

All exception classes.