Basic concepts
Authentication
First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.newInstance(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 webservice, 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();
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.exception;
using com.openkm.sdk4csharp.impl;
namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);
try {
ws.login(user, password);
System.Console.WriteLine(ws.repository.getAppVersion().getVersion());
} catch (RepositoryException e) {
System.Console.WriteLine(e.ToString());
} catch (DatabaseException e) {
System.Console.WriteLine(e.ToString());
} catch (UnknowException e) {
System.Console.WriteLine(e.ToString());
} catch (WebserviceException e) {
System.Console.WriteLine(e.ToString());
}
System.Console.ReadKey();
}
}
}
Accessing API
OpenKM API classes are under com.openkm package, as shown at 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 in the com.openkm.api packages and those available in the SDK for .NET.
OpenKM API classes:
| OpenKM API class | Description | Supported | Implementation | Interface |
|---|---|---|---|---|
|
OKMActivity |
Manages the activity log. |
Yes |
ActivityImpl.cs |
BaseActivity.cs |
|
OKMAuth |
Manages security and users. For example, add or remove grants on a node, create or modify users, or get the profiles. |
Yes |
AuthImpl.cs |
BaseAuth.cs |
|
OKMBookmark |
Manages the user bookmarks. |
Yes |
BookmarkImpl.cs |
BaseBookmark.cs |
|
OKMDashboard |
Manages all data shown on the dashboard. |
Yes |
DashboardImpl.cs |
BaseDashboard.cs |
|
OKMDocument |
Manages documents. For example, create, move, or delete a document. |
Yes |
DocumentImpl.cs |
BaseDocument.cs |
|
OKMFolder |
Manages folders. For example, create, move, or delete a folder. |
Yes |
FolderImpl.cs |
BaseFolder.cs |
|
OKMMail |
Manages mail. For example, create, move, or delete a mail. |
Yes |
MailImpl.cs |
BaseMail.cs |
|
OKMNode |
Manages general-purpose node actions. |
Yes |
NodeImpl.cs |
BaseNode.cs |
|
OKMNote |
Manages notes on any node type. For example, create, edit, or delete a note on a document, folder, mail, or record. |
Yes |
NoteImpl.cs |
BaseNote.cs |
|
OKMNotification |
Manages notifications. For example, add or remove subscriptions to a document or a folder. |
Yes |
NotificationImpl.cs |
BaseNotification.cs |
|
OKMProperty |
Manages categories and keywords. For example, add or remove keywords on a document, folder, mail, or record. |
Yes |
PropertyImpl.cs |
BaseProperty.cs |
|
OKMPropertyGroup |
Manages metadata. For example, add a metadata group or set metadata fields. |
Yes |
PropertyGroupImpl.cs |
BasePropertyGroup.cs |
|
OKMRecord |
Manages records. For example, create, move, or delete a record. |
Yes |
RecordImpl.cs |
BaseRecord.cs |
|
OKMRelation |
Manages relations between nodes. For example, create a relation (parent-child) between two documents. |
Yes |
RelationImpl.cs |
BaseRelation.cs |
|
OKMRepository |
A lot of material related to the repository. For example, get the properties of the main root node (/okm:root). |
Yes |
RepositoryImpl.cs |
BaseRepository.cs |
|
OKMReport |
Manages reports. For example, execute reports. |
Yes |
ReportImpl.cs |
BaseReport.cs |
|
OKMSearch |
Manages the search feature. For example, manage saved queries or perform a new query on the repository. |
Yes |
SearchImpl.cs |
BaseSearch.cs |
|
OKMStamp |
Manages stamps. |
Yes |
StampImpl.cs |
BaseStamp.cs |
|
OKMStats |
General repository statistics. |
No |
||
|
OKMTask |
Manages tasks. For example, create a new task. |
Yes |
TaskImpl.cs |
BaseTask.cs |
|
OKMUserConfig |
Manages the user's home configuration. |
No |
UserConfigImpl.cs |
BaseUserConfig.cs |
|
OKMWorkflow |
Manages workflows. For example, execute a new workflow. |
Yes |
WorkflowImpl.cs |
BaseWorkflow.cs |
|
(*) Indicates that REST support exists for it, but it is still not implemented in the SDK.
|
||||
Class Hierarchy
Packages detail:
| Name | Description |
|---|---|
|
com.openkm.sdk4csharp |
The com.openkm.OKMWebservicesFactory that returns a com.openkm.OKMWebservices object which implements all interfaces. OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password); |
|
com.openkm.sdk4csharp.bean |
Contains all classes resulting from unmarshalling REST objects. |
|
com.openkm.sdk4csharp.definition |
All interface classes:
|
|
com.openkm.sdk4csharp.impl |
All interface implementation classes:
|
|
com.openkm.sdk4csharp.util |
A couple of utilities. The class com.openkm.sdk4csharp.util.ISO8601 should be used to set and parse metadata date fields. |
|
com.openkm.sdk4csharp.exception |
All exception classes. |