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 with the webservices, 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 com.openkm package, as shown in this Javadoc API summary.
At the main URL http://docs.openkm.com/javadoc/ you can 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 available from the SDK for Java.
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 the 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 mail. For example, create, move or delete a mail. |
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 on a document or a 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 |
OKMStamp |
Manages stamps. |
Yes |
StampImpl.java |
BaseStamp.java |
OKMStats |
General repository statistics. |
No |
||
OKMTask |
Manages tasks. For example, create a new task. |
Yes |
TaskImpl.java | BaseTask.java |
OKMUserConfig |
Manages user home configuration. |
No |
||
OKMWorkflow |
Manages workflows. For example, execute a new workflow. |
Yes |
WorkflowImpl.java |
BaseWorkflow.java |
Class Hierarchy
Packages detail:
Name | Description |
---|---|
com.openkm |
The com.openkm.OKMWebservicesFactory returns an com.openkm.OKMWebservices object which 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. |