Basic concepts
Authentication
First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
Then you should log in using the method "login". You can access the "login" method from the webservice object "ws" as shown below:
ws.login(user, password);
Once you are logged in to the web services, the session is kept in the webservice object. Then you can use the other API methods.
At this point you can use all the Repository methods from the "repository" class as shown below:
ws.repository.getAppVersion();
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;
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.OKMWebservices;
public class Test {
public static void main(String[] args) {
String host = "http://localhost:8080/openkm";
String user = "okmAdmin";
String password = "admin";
OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try {
ws.login(user, password);
System.out.println(ws.repository.getAppVersion());
} catch (RepositoryException e) {
e.printStackTrace();
} catch (DatabaseException e) {
e.printStackTrace();
} catch (UnknowException e) {
e.printStackTrace();
} catch (WebserviceException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Accessing API
OpenKM API classes are under the com.openkm package, as shown in this Javadoc API summary.
At the main URL http://docs.openkm.com/javadoc/ you'll see all available Javadoc documentation.
At the time of writing this page, the current OpenKM version was 7.1.5, which may change over time.
There is a direct correspondence between the classes and methods implemented in the com.openkm.api packages and those available from the Java SDK.
OpenKM API classes:
OpenKM API class | Description | Supported | Implementation | Interface |
---|---|---|---|---|
OKMActivity |
Manages the activity log. |
Yes |
ActivityImpl.java |
BaseActivity.java |
OKMAuth |
Manages security and users. For example, add or remove grants on a node, create or modify users, or get profiles. |
Yes |
AuthImpl.java |
BaseAuth.java |
OKMBookmark |
Manages the user bookmarks. |
Yes |
BookmarkImpl.java | BaseBookmark.java |
OKMDashboard |
Manages all data shown on the dashboard. |
Yes |
DashboardImpl.java | BaseDashboard.java |
OKMDocument |
Manages documents. For example, create, move, or delete a document. |
Yes |
DocumentImpl.java |
BaseDocument.java |
OKMFolder |
Manages folders. For example, create, move, or delete a folder. |
Yes |
FolderImpl.java |
BaseFolder.java |
OKMMail |
Manages mails. For example, create, move, or delete mails. |
Yes |
MailImpl.java |
BaseMail.java |
OKMNode |
Manages general-purpose node actions. |
Yes |
NodeImpl.java |
NodeBase.java |
OKMNote |
Manages 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 |
Manages notifications. For example, add or remove subscriptions to a document or folder. |
Yes |
NotificationImpl.java | BaseNotification.java |
OKMProperty |
Manages categories and keywords. For example, add or remove keywords on a document, folder, mail, or record. |
Yes |
PropertyImpl.java |
BaseProperty.java |
OKMPropertyGroup |
Manages metadata. For example, add a metadata group or set metadata fields. |
Yes |
PropertyGroupImpl.java |
BasePropertyGroup.java |
OKMRecord |
Manages records. For example, create, move, or delete a record. |
Yes |
RecordImpl.java |
BaseRecord.java |
OKMRelation |
Manages relations between nodes. For example, create a relation (parent-child) between two documents. |
Yes |
RelationImpl.java |
BaseRelation.java |
OKMRepository |
Many options related to the repository. For example, get the properties of the main root node (/okm:root). |
Yes |
RepositoryImpl.java |
BaseRepository.java |
OKMReport |
Manages reports. For example, execute reports. |
Yes |
ReportImpl.java |
BaseReport.java |
OKMSearch |
Manages the search feature. For example, manage saved queries or perform a new query on the repository. |
Yes |
SearchImpl.java |
BaseSearch.java |
OKMUserConfig |
Manages user home configuration. |
No |
||
OKMWorkflow |
Manages workflows. For example, execute a new workflow. |
Yes |
WorkflowImpl.java |
BaseWorkflow.java |
Class Hierarchy
Package details:
Name | Description |
---|---|
com.openkm |
The com.openkm.OKMWebservicesFactory returns a com.openkm.OKMWebservices object that implements all interfaces. OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password); |
com.openkm.sdk4j.bean |
Contains all classes resulting from unmarshalling REST objects. |
com.openkm.sdk4j.definition |
All interface classes:
|
com.openkm.sdk4j.impl |
All interface implementation classes:
|
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. |