Document samples

Basics

On most methods, you'll see the parameter named "docId". The value of this parameter can be a valid document UUID or path.

Example of docId:

  • Using UUID -> "f123a950-0329-4d62-8328-0ff500fd42db";
  • Using path -> "/okm:root/logo.png"

Methods

createDocumentSimple

Description:

MethodReturn valuesDescription

createDocumentSimple(String docPath, FileStream fs)

Document

Creates a new document and returns as a result an object Document with the properties of the created document.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
using System.IO;

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, username, password);
try { FileStream fileStream = new FileStream("E:\\logo.png", FileMode.Open); ws.createDocumentSimple("/okm:root/logo.png", fileStream); fileStream.Dispose(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

deleteDocument

Description:

MethodReturn valuesDescription

deleteDocument(String docId)

void

Deletes a document.

When a document is deleted it is automatically moved to /okm:trash/userId folder.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { ws.deleteDocument("/okm:root/logo.png"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); }
             System.Console.ReadKey(); } } }

getDocumentProperties

Description:

MethodReturn valuesDescription

getDocumentProperties(String docId)

Document

Returns the document properties.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { System.Console.WriteLine(ws.getDocumentProperties("/okm:root/logo.png").toString()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getContent

Description:

MethodReturn valuesDescription

getContent(String docId)

Stream

Retrieves a document content - binary data - of the actual document version.

In case you sent the file across a Servlet response we suggest setting the content length with:

Document doc = ws.getDocumentProperties("/okm:root/logo.png");
response.setContentLength(new Long(doc.getActualVersion().getSize()).intValue());

We've found wrong size problems while using:

response.setContentLength(is.available());

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using System.IO;

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, username, password);
try { Stream st = ws.getContent("/okm:root/logo.png"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getContentByVersion

Description:

MethodReturn valuesDescription

getContentByVersion(String docId,String versionId)

Stream

Retrieves a document content ( binary data ) of some specific document version.

In case you sent the file across a Servlet response we suggest setting the content length with:

Document doc = ws.getDocumentProperties("/okm:root/logo.png");
response.setContentLength(new Long(doc.getActualVersion().getSize()).intValue());

We've found wrong size problems while using:

response.setContentLength(is.available());

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using System.IO;

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, username, password);
try { Stream st = ws.getContentByVersion("/okm:root/logo.png","1.1"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getDocumentChildren

Description:

MethodReturn valuesDescription

getDocumentChildren(String fldId)

List<Document>

Returns a list of all documents which their parent is fldId.

The parameter fldId can be a folder or a record node.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
try { foreach (Document doc in ws.getDocumentChildren("/okm:root")) { System.Console.WriteLine(doc); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

renameDocument

Description:

MethodReturn valuesDescription

renameDocument(String docId, String newName)

document

Changes the name of a document.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
try { Document doc = ws.renameDocument("f123a950-0329-4d62-8328-0ff500fd42db", "logo_rename.png"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

setProperties

Description:

MethodReturn valuesDescription

 setProperties(Document doc)

void

Changes some document properties.

Variables allowed to be changed:

  • Title
  • Description
  • Language
  • Associated categories
  • Associated keywords

Only not null and not empty variables will be taken on consideration.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
try { Document doc = ws.getDocumentProperties("f123a950-0329-4d62-8328-0ff500fd42db"); doc.description = "some description"; doc.keywords.Add("test"); ws.setProperties(doc); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

checkout

Description:

MethodReturn valuesDescription

 checkout(String docId)

void

Marks the document for the edition.

Only one user can modify a document at the same time.

Before starting edition you must do a check-out action that locks the edition process for other users and allows only to the user who has executed the action.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { ws.checkout("/okm:root/logo.png"); // At this point the document is locked for other users except for the user who executed the action } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

cancelCheckout

Description:

MethodReturn valuesDescription

cancelCheckout(String docId)

void

Cancel a document edition.

This action can only be done by the user who previously executed the checkout action.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { // At this point the document is locked for other users except for the user who executed the action ws.cancelCheckout("/okm:root/logo.png"); // At this point other users are allowed to execute a checkout and modify the document } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

forceCancelCheckout

Description:

MethodReturn valuesDescription

forceCancelCheckout(String docId)

void

Cancels a document edition.

This method allows canceling the edition on any document.

It is not mandatory to execute this action by the same user who previously executed the checkout action.

This action can only be done by a superuser ( user with ROLE_ADMIN ).

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { // At this point the document is locked for other users except for the user who executed the action ws.forceCancelCheckout("/okm:root/logo.png"); // At this point other users are allowed to execute a checkout and modify the document } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

isCheckedOut

Description:

MethodReturn valuesDescription

isCheckedOut(String docId)

Boolean

Returns a boolean that indicates if the document is being edited or not.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { System.Console.WriteLine("Is the document checkout:"+ws.isCheckedOut("/okm:root/logo.png")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

checkin

Description:

MethodReturn valuesDescription

checkin(String docId, String comment, FileStream fs)

Version

Updates a document with a new version and returns an object with new Version values.

Only the user who started the edition - checkout - is allowed to update the document.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using com.openkm.sdk4csharp;

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, username, password);
try { FileStream fs = new FileStream("E:\\logo.png", FileMode.Open); ws.checkin("/okm:root/logo.png","optional some comment",fs); fs.Dispose(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

checkin

Description:

MethodReturn valuesDescription

checkin(String docId, String comment, FileStream fs, int increment)

Version

Updates a document with a new version and returns an object with new Version values.

The value of the increment variable must be 1 or greater.

The valid values of the increment variable depend on the VersionNumberAdapter you have enabled.


Only the user who started the edition - checkout - is allowed to update the document.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using com.openkm.sdk4csharp;

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, username, password);
            try
            {
                FileStream fs = new FileStream(@"C:\Desktop\logo.png", FileMode.Open);
                ws.checkin("/okm:root/logo.png", "optional some comment", fs, 1);
                fs.Dispose();
            } catch (Exception e) {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

getDocumentVersionHistory

Description:

MethodReturn valuesDescription

getDocumentVersionHistory(String docId)

List<Version>

Returns a list of all document versions.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
try { foreach (Version version in ws.getVersionHistory("/okm:root/logo.png")) { System.Console.WriteLine(version); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

lock

Description:

MethodReturn valuesDescription

lock(String docId)

LockInfo

Locks a document and returns an object with the Lock information.

Only the user who locked the document is allowed to unlock.

A locked document cannot be modified by other users.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
try { ws.lockDocument("/okm:root/logo.png"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

unlock

Description:

MethodReturn valuesDescription

unlock(String docId)

void

Unlocks a locked document.

Only the user who locked the document is allowed to unlock.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { ws.unlock("/okm:root/logo.png"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

forceUnlock

Description:

MethodReturn valuesDescription

forceUnlock(String docId)

void

Unlocks a locked document.

This method allows unlocking any locked document.

It is not mandatory to execute this action by the same user who previously executed the checkout lock action.

This action can only be done by a superuser ( user with ROLE_ADMIN ).

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { ws.forceUnlock("/okm:root/logo.png"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

isLocked

Description:

MethodReturn valuesDescription

isLocked(String docId)

Boolean

Returns a boolean that indicates if the document is locked or not.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { System.Console.WriteLine("Is document locked:" + ws.isLocked("/okm:root/logo.png")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getLockInfo

Description:

MethodReturn valuesDescription

getLockInfo(String docId)

LockInfo

Returns an object with the Lock information

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { System.Console.WriteLine(ws.getLockInfo("/okm:root/logo.png")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

purgeDocument

Description:

MethodReturn valuesDescription

purgeDocument(String docId)

void

The document is definitely removed from repository.

Usually, you will purge documents into /okm:trash/userId - the personal trash user locations - but is possible to directly purge any document from the whole repository.

When a document is purged it will only be able to be restored from a previous repository backup. The purge action removes the document definitely from the repository.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { ws.purgeDocument("/okm:trash/okmAdmin/logo.png"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

moveDocument

Description:

MethodReturn valuesDescription

moveDocument(String docId, String dstId)

void

Moves a document into a folder or record.

The values of the dstId parameter should be a folder or record UUID or path.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { ws.moveDocument("/okm:root/logo.png", "/okm:root/test"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

copyDocument

Description:

MethodReturn valuesDescription

copyDocument(String docId, String dstId, String newName)

void

Copies a document into a folder or record.

The values of the dstId parameter should be a folder or record UUID or path.

When parameter newName value is null, the document will preserve the same name.

Only the binary data and the security grants are copied to destination, the metadata, keywords, etc. of the document are not copied.

See "extendedDocumentCopy" method for this feature.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { ws.copyDocument("/okm:root/logo.png", "/okm:root/temp", "new_logo.png"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

restoreVersion

Description:

MethodReturn valuesDescription

restoreVersion(String docId, String versionId)

void

Promotes a previous document version to the current version.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { // Actual version is 2.0 ws.restoreVersion("/okm:root/logo.png", "1.0"); // Actual version is 1.0 } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

purgeVersionHistory

Description:

MethodReturn valuesDescription

purgeVersionHistory(String docId)

void

Purges all document versions except the actual version.

This action compact the version history of a document.

This action cannot be reverted.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { // Version history has version 1.3,1.2,1.1 and 1.0 ws.purgeVersionHistory("/okm:root/logo.png"); // Version history has only version 1.3 } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getVersionHistorySize

Description:

MethodReturn valuesDescription

getVersionHistorySize(String docId)

long

Returns the sum in bytes of all documents into documents history.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);

            try
            {
                String[] UNITS = new String[] { "B", "KB", "MB", "GB", "TB", "PB", "EB" };
                long bytes = ws.getVersionHistorySize("/okm:root/logo.png");
                String value = "";
                                 for (int i = 6; i > 0; i--)                 {                     double step = Math.Pow(1024, i);                     if (bytes > step)                         value = String.Format(Locale.ROOT, "%3.1f %s", bytes / step, UNITS[i]);                 }                                  if (value.Equals(""))                 {                     value = bytes.ToString() + " " + UNITS[0];                 }                                  System.Console.WriteLine(value); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

isValidDocument

Description:

MethodReturn valuesDescription

isValidDocument(String docId)

Boolean

Returns a boolean that indicates if the node is a document or not.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
try { // Return true ws.isValidDocument("/okm:root/logo.png");
// Return false ws.isValidDocument("/okm:root"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getDocumentPath

Description:

MethodReturn valuesDescription

getDocumentPath(String uuid)

String

Converts a document UUID to a document path.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
             try { System.Console.WriteLine(ws.getDocumentPath("e339f14b-4d3a-489c-91d3-05e4575709d2")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

extendedDocumentCopy

Description:

MethodReturn valuesDescription

extendedDocumentCopy(String docId, String dstId, String name, boolean categories, boolean keywords,
            boolean propertyGroups, boolean notes, boolean wiki)

void

Copies a document with associated data into a folder or record.

The values of the dstId parameter should be a folder or record UUID or path.

When parameter newName value is null, the document will preserve the same name.

By default, only the binary data and the security grants, the metadata, keywords, etc. of the document are not copied.

Additional:

  • When the category parameter is true the original values of the categories will be copied.
  • When the keywords parameter is true the original values of the keywords will be copied.
  • When the property groups parameter is true the original values of the metadata groups will be copied.
  • When the notes parameter is true the original values of the notes will be copied.
  • When the wiki parameter is true the original values of the wiki will be copied.

   

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
             try {     ws.extendedDocumnetCopy("/okm:root/logo.png", "/okm:root/tmp", null, true, true, true, true, true); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getExtractedText

Description:

MethodReturn valuesDescription

getExtractedText(String docId)

String

Returns a String with the extracted text by text extractor process.

When a document is uploaded into OpenKM goes into text extraction queue. There's a crontab tab that periodically processes this queue and extracts document contents.

Unfortunately, there is not a direct way to know if a document has been processed or not from the API, because this information is only stored at the database level.

Although this restriction, from API - only administrators users - can be done database queries to retrieve this information. Check Repository samples for accessing database level.

More information at Statistics.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
             try { System.Console.WriteLine(ws.getExtractedText("/okm:root/document.doc")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getThumbnail

Description:

MethodReturn valuesDescription

 getThumbnail(String docId, ThumbnailType type)

Stream

Returns a thumbnail image data.

Available types:

  • ThumbnailType.THUMBNAIL_PROPERTIES ( shown in properties view )
  • ThumbnailType.THUMBNAIL_LIGHTBOX ( shown in light box )
  • ThumbnailType.THUMBNAIL_SEARCH ( shown in search view )

Each thumbnail type has its own image dimensions.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using System.IO;

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, username, password);
             try { Stream st = ws.getThumbnail("/okm:root/document.doc", ThumbnailType.THUMBNAIL_LIGHTBOX); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

setLanguage

Description:

MethodReturn valuesDescription

setLanguage(String docId, String lang)

void

Sets a document language.

The parameter lang must be ISO 691-1 compliant.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;

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, username, password);
             try { ws.setLanguage("/okm:root/document.doc", "es"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

setDocumentTitle

Description:

MethodReturn valuesDescription

setDocumentTitle(String docId, String title)

void

Sets a document title.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
            try
            {
                ws.setDocumentTitle("/okm:root/document.doc", "Some title here");
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

createFromTemplate

Description:

MethodReturn valuesDescription

Document createFromTemplate(String docId, String dstPath, String language, boolean categories, boolean keywords,
            boolean propertyGroups, boolean notes, boolean wiki, List<FormElement> properties)

Document

Creates a new document from template and returns an object Document.

The dstPath can be a folder or a record path.

The parameter language is optional.

When a template uses metadata groups to fill fields into, then these values are mandatory and must be set into properties parameter. 

For more information about Templates and metadata take a look at Creating templates.

Additional:

  • When the category parameter is true the original values of the categories will be copied.
  • When the keywords parameter is true the original values of the keywords will be copied.
  • When the property groups parameter is true the original values of the metadata groups will be copied.
  • When the notes parameter is true the original values of the notes will be copied.
  • When the wiki parameter is true the original values of the wiki will be copied.

Example:

The example below is based on Creating PDF template sample.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
             try { List<FormElement> formElements = new List<FormElement>(); Input name = new Input(); name.name = "okp:tpl.name"; name.value = "Some name"; formElements.Add(name); Input birdDate = new Input(); birdDate.name = "okp:tpl.bird_date"; DateTime date = DateTime.Now; // Value must be converted to String ISO 8601 compliant birdDate.value = ISO8601.formatBasic(date); formElements.Add(birdDate); Select language = new Select(); language.name = "okp:tpl.language"; // With selected option is enought Option option = new Option(); option.value = "java"; option.selected = true; language.options.Add(option); formElements.Add(language); ws.createFromTemplate("/okm:templates/tpl.pdf", "/okm:root/test.pdf", null, false, false, true, false, false, formElements); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

createFromTemplateSimple

Description:

MethodReturn valuesDescription

Document createFromTemplateSimple(String docId, String dstPath, String language, boolean categories,
            boolean keywords, boolean propertyGroups, boolean notes, boolean wiki, Map<String, String> properties)

Document

Creates a new document from a template and returns an object Document.

The dstPath can be a folder or a record path.

The parameter language is optional.

When template use metadata groups to fill fields into, then these values are mandatory and must be set into properties parameter. 

For more information about Templates and metadata take a look at Creating templates.

Additional:

  • When the category parameter is true the original values of the categories will be copied.
  • When the keywords parameter is true the original values of the keywords will be copied.
  • When the property groups parameter is true the original values of the metadata groups will be copied.
  • When the notes parameter is true the original values of the notes will be copied.
  • When the wiki parameter is true the original values of the wiki will be copied.

Example:

The example below is based on Creating PDF template sample.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.util;

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, username, password);            
            try
            {
                Dictionary<String, String> properties = new  Dictionary<String, String>();
                properties.Add("okp:tpl.name", "Some name");
                DateTime date = DateTime.Now;
                // Value must be converted to String ISO 8601 compliant
                properties.Add("okp:tpl.bird_date", ISO8601.formatBasic(date));
                properties.Add("okp:tpl.language", "java");
                ws.createFromTemplateSimple("/okm:templates/tpl.pdf", "/okm:root/test.pdf",null, false, false, true, false, false, properties);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

updateFromTemplate

Description:

MethodReturn valuesDescription

updateFromTemplate(String docId, String dstId, List<FormElement> properties)

Document

Updates a document previously created from a template and returns an object Document.

This method only has a sense when template use metadata groups to fill fields into.

For more information about Templates and metadata take a look at Creating templates.

Example:

The example below is based on Creating PDF template sample.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
using com.openkm.sdk4csharp.bean.form;
using com.openkm.sdk4csharp.util;

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, username, password);            
            try
            {
                List<FormElement> formElements = new List<FormElement>();
                Input name = new Input();
                name.name = "okp:tpl.name";
                name.value = "Some name";
                formElements.Add(name);

                Input birdDate = new Input();
                birdDate.name = "okp:tpl.bird_date";
                DateTime date = DateTime.Now;
                // Value must be converted to String ISO 8601 compliant
                birdDate.value = ISO8601.formatBasic(date);
                formElements.Add(birdDate);

                Select language = new Select();
                language.name = "okp:tpl.language";
                // With selected option is enought
                Option option = new Option();
                option.value = "java";
                option.selected = true;
                language.options.Add(option);
                formElements.Add(language);

                ws.updateFromTemplate("/okm:templates/tpl.pdf", "/okm:root/test.pdf", formElements);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

updateFromTemplateSimple

Description:

MethodReturn valuesDescription

updateFromTemplateSimple(String docId, String dstId, Map<String, String> properties) 

Document

Updates a document previously created from a template and returns an object Document.

This method only has a sense when template use metadata groups to fill fields into.

For more information about Templates and metadata take a look at Creating templates.

Example:

The example below is based on Creating PDF template sample.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.util;

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, username, password);            
            try
            {
                Dictionary<String, String> properties = new  Dictionary<String, String>();
                properties.Add("okp:tpl.name", "Some name");
                DateTime date = DateTime.Now;
                // Value must be converted to String ISO 8601 compliant
                properties.Add("okp:tpl.bird_date", ISO8601.formatBasic(date));
                properties.Add("okp:tpl.language", "java");

                ws.updateFromTemplateSimple("/okm:templates/tpl.pdf", "/okm:root/test.pdf", properties);
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            }
        }
    }
}

getDetectedLanguages

Description:

MethodReturn valuesDescription

getDetectedLanguages()

List<String>

Return a list of available document languages what OpenKM can identify.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
            try
            {
                foreach (String lang in ws.getDetectedLanguages()) 
                {
                    System.Console.WriteLine(lang);
                }
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

getAnnotations

Description:

MethodReturn valuesDescription

getAnnotations(String docId, String verName)

String

Return the document annotations of some document version.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
            try
            {
                System.Console.WriteLine(ws.getAnnotations("2b9721e7-f186-4eea-ad61-42c97353548f", "1.0"));
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

getDifferences

Description:

MethodReturn valuesDescription

getDifferences(String docId, String v1, String v2)

Stream

Return a PDF document with the differences between two document versions.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;
using com.openkm.sdk4csharp.util;

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, username, password);
            try
            {
                BeanHelper beanHelper = new BeanHelper();
                Stream stream = ws.getDifferences("22799885-973f-46dc-a82c-dd11d2c65c65", "1.0", "1.1");
                Byte[] data = beanHelper.ReadToEnd(stream);
                FileStream fileStream = new FileStream(@"C:\Desktop\out.pdf", FileMode.OpenOrCreate, FileAccess.ReadWrite);
                foreach (byte b in data)
                {
                    fileStream.WriteByte(b);
                }
                fileStream.Close();
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

getCheckedOut

Description:

MethodReturn valuesDescription

getCheckedOut()

List<Document>

Return a list of documents checkout by the user.

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
            try
            {
                List<Document> docs =  ws.getCheckedOut();
                foreach (Document doc in docs)
                {
                    System.Console.WriteLine(doc.toString());
                }
            } 
            catch (Exception e)
            {
                System.Console.WriteLine(e.ToString());
            } 
        }
    }
}

stamp

Description:

MethodReturn valuesDescription

stamp(String docId, int type, long stId)

void

Stamp the document.

The parameter type.

  • Value 0 for type text
  • Value 1 for type image 

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
            try
            {
                 long stampId = 1;
int type = 1; // 1 for type image
ws.stamp("22799885-973f-46dc-a82c-dd11d2c65c65", type, stampId); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

stampImage

Description:

MethodReturn valuesDescription

stampImage(String docId, long stId, String range, String exprX, String exprY, FileStream image)

void

Stamp image in a document.


In exprX and exprY input fields, you can put more than a simple number. Currently, the following macros are defined:

  • IMAGE_WIDTH
  • IMAGE_HEIGHT
  • PAGE_WIDTH
  • PAGE_HEIGHT
  • PAGE_CENTER
  • PAGE_MIDDLE

So to center a stamp in the page you can use:

Expr. X

PAGE_CENTER

Expr. Y

PAGE_MIDDLE

Example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using com.openkm.sdk4csharp;
using com.openkm.sdk4csharp.bean;

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, username, password);
            try
            {
                  long stampId = 1;
String exprX = "PAGE_CENTER - IMAGE_WIDTH / 2";
String exprY = "PAGE_MIDDLE - IMAGE_HEIGHT / 2";
FileStream image = new FileStream(@"C:\images\stamp.jpg", FileMode.Open, FileAccess.Read);
ws.stampImage("22799885-973f-46dc-a82c-dd11d2c65c65", stampId, "", exprX, exprY, image);
image.Close(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }