Document samples

Basics

On most methods, you'll see the parameter named "docId" and "fldId". The values of this parameter can be a valid document and folder UUID respectively.

Example of docId:

  • Using UUID -> "f123a950-0329-4d62-8328-0ff500fd42db";

Methods

createDocument

Description:

MethodReturn valuesDescription

createDocument(String fldId, FileInfo fi)

Document

Creates a new document and returns an object of type Document.

Parameters:

  • fldId is UUID of the folder where the document will be created.

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);
try {
ws.login(user, password);
  FileInfo fileInfo = new FileInfo("E:\\doc.docx"); ws.createDocument(fldId, fileInfo); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

createDocument

Description:

MethodReturn valuesDescription

createDocument(String fldId, String name, FileStream fs)

Document

Creates a new document and returns and object of type Document

Parameters:

  • fldId is UUID of the folder where the document will be created.
  • name is the name of the document including the extension.

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);
try {
ws.login(user, password); FileStream fileStream = new FileStream("E:\\logo.png", FileMode.Open); ws.createDocument(fldId, "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);
try {
ws.login(user, password); ws.deleteDocument("f123a950-0329-4d62-8328-0ff500fd42db"); } 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);
try {
ws.login(user, password); System.Console.WriteLine(ws.getDocumentProperties("f123a950-0329-4d62-8328-0ff500fd42db").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(docId);
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);
try {
ws.login(user, password); Stream tmpFile = ws.getContent("f123a950-0329-4d62-8328-0ff500fd42db");
FileStream destFile = new FileStream("C:\\test.png", FileMode.OpenOrCreate);
tmpFile.CopyTo(destFile);
destFile.Close();
tmpFile.Close(); } 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(docId);
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);
try {
ws.login(user, password); Stream tmpFile = ws.getContentByVersion("f123a950-0329-4d62-8328-0ff500fd42db","1.1");
FileStream destFile = new FileStream("C:\\test.png", FileMode.OpenOrCreate);
tmpFIle.CopyTo(destFile);
destFile.Close();
tmpFile.Close(); } 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);
try {
ws.login(user, password); foreach (Document doc in ws.getDocumentChildren("f123a950-0329-4d62-8328-0ff500fd42db")) { 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);
try {
ws.login(user, password); Document doc = ws.renameDocument("f123a950-0329-4d62-8328-0ff500fd42db", "new_name.png"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

setProperties

Description:

MethodReturn valuesDescription

 setProperties(String docId, String title, String description, String lang, List<String> keywords, List<String> categories)

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);
try {
ws.login(user, password);
List<string> keywords = new List<string>();
keywords.Add("testA");
keywords.Add("testB");
List<string> categories = new List<string>();
categories.Add("/okm:categories");
ws.setProperties("f123a950-0329-4d62-8328-0ff500fd42db", "anyTitle", "anyDescription", "es-ES", keywords, categories); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

setDocumentNodeClass

Description:

MethodReturn valuesDescription

 setDocumentNodeClass(String docId,  String ncId)

void

Set document node class ID.

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);
try {
ws.login(user, password); ws.setDocumentNodeClass("f123a950-0329-4d62-8328-0ff500fd42db",ncID); } 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);
try {
ws.login(user, password); ws.checkout("f123a950-0329-4d62-8328-0ff500fd42db"); // 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);
try {
ws.login(user, password); // At this point the document is locked for other users except for the user who executed the action ws.cancelCheckout("f123a950-0329-4d62-8328-0ff500fd42db"); // 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);
try {
ws.login(user, password); // At this point the document is locked for other users except for the user who executed the action ws.forceCancelCheckout("f123a950-0329-4d62-8328-0ff500fd42db"); // 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);
try {
ws.login(user, password); System.Console.WriteLine("Is the document checkout:"+ ws.isCheckedOut("f123a950-0329-4d62-8328-0ff500fd42db").ToString()); } 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);
try {
ws.login(user, password); FileStream fs = new FileStream("E:\\logo.png", FileMode.Open); ws.checkin("f123a950-0329-4d62-8328-0ff500fd42db","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);
try {
ws.login(user, password); FileStream fs = new FileStream(@"C:\Desktop\logo.png", FileMode.Open); ws.checkin("f123a950-0329-4d62-8328-0ff500fd42db", "optional some comment", fs, 1); fs.Dispose(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

lockDocument

Description:

MethodReturn valuesDescription

lockDocument(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);
try {
ws.login(user, password); ws.lockDocument("f123a950-0329-4d62-8328-0ff500fd42db"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

unlockDocument

Description:

MethodReturn valuesDescription

unlockDocument(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);
try {
ws.login(user, password); ws.unlockDocument("f123a950-0329-4d62-8328-0ff500fd42db"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

forceUnlockDocument

Description:

MethodReturn valuesDescription

forceUnlockDocument(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);
try {
ws.login(user, password); ws.forceUnlockDocument("f123a950-0329-4d62-8328-0ff500fd42db"); } 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);
try {
ws.login(user, password); System.Console.WriteLine("Is document locked:" + ws.isLocked("f123a950-0329-4d62-8328-0ff500fd42db").ToString()); } 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);
try {
ws.login(user, password); System.Console.WriteLine(ws.getLockInfo("f123a950-0329-4d62-8328-0ff500fd42db")); } 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);
try {
ws.login(user, password); ws.purgeDocument("f123a950-0329-4d62-8328-0ff500fd42db"); } 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);
try {
ws.login(user, password); ws.moveDocument("f123a950-0329-4d62-8328-0ff500fd42db", fldId); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

copyDocument

Description:

MethodReturn valuesDescription

copyDocument(String docId, String fldId, String newName)

Document

Copies a document into a folder or record.

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

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

Only the binary data and the security grants are copied to the 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);
try {
ws.login(user, password); ws.copyDocument("f123a950-0329-4d62-8328-0ff500fd42db", fldId, "name.png"); } 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);

            try
            {
ws.login(user, password);                 long byteCount = ws.getVersionHistorySize(docUUid);
string[] suf = { "B", "KB", "MB", "GB", "TB", "PB", "EB" }; //Longs run out around EB
long bytes = Math.Abs(byteCount);
int place = Convert.ToInt32(Math.Floor(Math.Log(bytes, 1024)));
double num = Math.Round(bytes / Math.Pow(1024, place), 1);
System.Console.WriteLine((Math.Sign(byteCount) * num).ToString() + suf[place]); } 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);
try {
ws.login(user, password); // Return true ws.isValidDocument("f123a950-0329-4d62-8328-0ff500fd42db");
// Return false ws.isValidDocument("/okm:root"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getDocumentPath

Description:

MethodReturn valuesDescription

getDocumentPath(String docId)

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);
             try {
ws.login(user, password); 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 fldId, 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 fldId 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);
             try {
ws.login(user, password);     ws.extendedDocumentCopy("f123a950-0329-4d62-8328-0ff500fd42db", "d1cad1b0-3c4f-4ad3-8ee1-6ad779fa227c", "newDoc.docx", 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);
             try {
ws.login(user, password); System.Console.WriteLine(ws.getExtractedText("f123a950-0329-4d62-8328-0ff500fd42db")); } 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);
             try {
ws.login(user, password); Stream st = ws.getThumbnail("f123a950-0329-4d62-8328-0ff500fd42db", 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);
             try {
ws.login(user, password); ws.setLanguage("f123a950-0329-4d62-8328-0ff500fd42db", "es-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);
try {
ws.login(user, password); ws.setDocumentTitle("f123a950-0329-4d62-8328-0ff500fd42db", "Some title here"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

createDocumentFromTemplate

Description:

MethodReturn valuesDescription

createDocumentFromTemplate(String docId, String fldId, String language, Boolean categories, Boolean keywords, Boolean propertyGroups, Boolean notes, Boolean wiki, Dictionary<String, String> properties)

Document

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

The fldId can be a folder or a record UUID.

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); 
           try {
ws.login(user, password); 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.createFromTemplate("f123a950-0329-4d62-8328-0ff500fd42db", "/okm:root/test.pdf", "en-GB", false, false, true, false, false, properties); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

updateDocumentFromTemplate

Description:

MethodReturn valuesDescription

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

setDocumentDescription

Description:

MethodReturn valuesDescription

setDocumentDescription(String docId, String description) 

void

Sets a document description.

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);
try {
ws.login(user, password); ws.setDocumentDescription("f123a950-0329-4d62-8328-0ff500fd42db", "Some description here"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

setDocumentDispositionStage

Description:

MethodReturn valuesDescription

setDocumentDispositionStage(String docId, long stage) 

void

Sets a document disposition stage.

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);
try {
ws.login(user, password);
 long stage = 1; ws.setDocumentDispositionStage("f123a950-0329-4d62-8328-0ff500fd42db", stage); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

createWizardDocument

Description:

MethodReturn valuesDescription

createWizardDocument(String docId, long stage) 

WizardNode

Create a document with wizard.

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);
try {
ws.login(user, password);
  FileStream fs = new FileStream(LOCAL_DOC, FileMode.Open, FileAccess.Read);
 long nodeClass= 1; WizardNode wizardNode = ws.createWizardDocument("f123a950-0329-4d62-8328-0ff500fd42db","test.docx", nodeClass, fs);
  fs.Close(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

isOCRDataCaptureSupported

Description:

MethodReturn valuesDescription

isOCRDataCaptureSupported(String docId) 

boolean

Check if the node supports an OCR data capture.

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);
try {
ws.login(user, password);
if(ws.isOCRDataCaptureSupported("f123a950-0329-4d62-8328-0ff500fd42db"))
{
System.Console.WriteLine("Yes supported OCR Data capture");
}
else
{
System.Console.WriteLine("No supported OCR Data capture");
} } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

recognize

Description:

MethodReturn valuesDescription

recognize(String docId) 

OCRRecognise

Return an OCRRecognise object.

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);
try {
ws.login(user, password);
OCRRecognise ocr = ws.recognize("f123a950-0329-4d62-8328-0ff500fd42db"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

captureData

Description:

MethodReturn valuesDescription

captureData(String docId,  long templateId) 

void

Proceed to the OCR data capture using OCR template identified by templateId.

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);
try {
ws.login(user, password);
long templateId = 1;
ws.captureData("f123a950-0329-4d62-8328-0ff500fd42db", templateId); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getNumberOfPages

Description:

MethodReturn valuesDescription

getNumberOfPages(String docId) 

int

Get the number of pages 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);
try {
ws.login(user, password);
System.Console.WriteLine("The number of pages is : " + ws.getNumberOfPages("f123a950-0329-4d62-8328-0ff500fd42db").ToString()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getPageAsImage

Description:

MethodReturn valuesDescription

getPageAsImage(String uuid, int pageNumber, int maxWidth, int maxHeight) 

String

Return specific page as an image encoded as a String in b64.

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);
try {
ws.login(user, password);
System.Console.WriteLine(ws.getPageAsImage("f123a950-0329-4d62-8328-0ff500fd42db", 1, 150, 150)); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

mergePdf

Description:

MethodReturn valuesDescription

mergePdf(String destinationUuid, String docName, List<String> uuids) 

void

Merge two or more PDF files.

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);
try {
ws.login(user, password);
List<string> uuids = new List<string>();
uuids.Add("a978f8e6-aa87-4f0f-b7bc-6f44cb090fdf");
uuids.Add("56a6d75f-563e-4ccd-ace6-d07d7860bae5");
string folderUuid = "15e35aef-f1bb-451e-ac86-3b0f7c88ca9f";
ws.mergePdf(folderUuid, "MergePdf.pdf", uuids); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getLiveEditRestrictedMimeTypes

Description:

MethodReturn valuesDescription

getLiveEditRestrictedMimeTypes() 

List<String>

Return a list of mymetypes what can not be used with live edit feature.

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);

try
{
ws.login(user, password);
List<String> mymeTypes = getLiveEditRestrictedMimeTypes();
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}

liveEditCheckin

Description:

MethodReturn valuesDescription

liveEditCheckin(String uuid, String comment, int increment)

void

It does a checkin.

This method should be excuted only if the document has been edited with live edit feature.

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);

try
{
ws.login(user, password);
ws.liveEditCheckin("8b9a32c8-db65-41c8-a2a0-af03761f60b6", "Any comment", 1);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}

liveEditSetContent

Description:

MethodReturn valuesDescription

liveEditSetContent(String uuid, FileStream fs

void

Update the content of the document edited with live edit feature.

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);

try
{
ws.login(user, password);
FileStream fs = new FileStream(@"D:\Test.pdf", FileMode.Open, FileAccess.Read);
ws.liveEditSetContent("1ec49da9-1746-4875-ae32-9281d7303a62", fs);
  fs.Close();
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}