Record samples

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

Example of recId:

  • Using UUID -> "28bb0c8b-3701-4457-a81a-fef7bc56ff33";
  • Using path -> "/okm:root/PKI-100200"

Methods

createRecord

Description:

MethodReturn valuesDescription

createRecord(Record record)

Record

Creates a new record and returns as a result an object Record.

The variable path into the parameter record must be initialized. It indicates the folder path into OpenKM.

Record record = new Record();
record.setPath("/okm:root/PKI-100200");

Optionally it can be set a title variable, the other variables of the Record  ( record ) will not take any effect on record creation.

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 { Record record = new Record(); record.path = "/okm:root/PKI-100200"; record.title = "some title"; ws.createRecord(record); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getRecordProperties

Description:

MethodReturn valuesDescription

getRecordProperties(String recId)

Record

Returns the record 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.getRecordProperties("/okm:root/PKI-100200")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

deleteRecord

Description:

MethodReturn valuesDescription

deleteRecord(String recId)

void

Deletes a record.

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.deleteRecord("/okm:root/PKI-100200"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

purgeRecord

Description:

MethodReturn valuesDescription

purgeRecord(String recId)

void

Records are definitely removed from the repository.

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

When a record is purged it will only be able to be restored from a previous repository backup. The purge action removes the record 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.purgeRecord("/okm:trash/okmAdmin/PKI-100200"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

renameRecord

Description:

MethodReturn valuesDescription

renameRecord(String recId, String newName)

void

Renames a record.

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.renameRecord("/okm:root/PKI-100200", "new_name"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

moveRecord

Description:

MethodReturn valuesDescription

moveRecord(String recId, String dstId)

void

Moves a record 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.moveRecord("/okm:root/PKI-100200", "/okm:root/tmp"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

copyRecord

Description:

MethodReturn valuesDescription

copyRecord(String recId, String dstId, String newName)

void

Copies a record 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 record will preserve the same name.

Only the security grants are copied to the destination, the metadata, keywords, etc. of the record are not 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.copyRecord("/okm:root/PKI-100200", "/okm:root/tmp", "new_name"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

isValidRecord

Description:

MethodReturn valuesDescription

isValidRecord(String recId)

Boolean

Returns a boolean that indicates if the node is a record 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 a record:"+ws.isValidRecord("/okm:root/PKI-100200")); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getRecordChildren

Description:

MethodReturn valuesDescription

getRecordChildren(String fldId)

List<Record>

Returns a list of all records which their parent is fldId

The parameter recId 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 (Record rec in ws.getRecordChildren("/okm:root/folder")) { System.Console.WriteLine(rec); } } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

lockRecord

Description:

MethodReturn valuesDescription

lockRecord(String recId)

LockInfo

Locks a record and returns an object with the Lock information

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

A locked record cannot be modified by other users.

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.lockRecord("/okm:root/PKI-100200"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

unlockRecord

Description:

MethodReturn valuesDescription

unlockRecord(String recId)

void

Unlocks a locked record.

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.unlockRecord("/okm:root/PKI-100200"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

forceUnlockRecord

Description:

MethodReturn valuesDescription

forceUnlockRecord(String recId)

void

Unlocks a locked record.

This method allows unlocking any locked record.

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.forceUnlockRecord("/okm:root/PKI-100200"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

setRecordTitle

Description:

MethodReturn valuesDescription

setRecordTitle(String recId, String title)

void

Sets a record title.

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.setRecordTitle("/okm:root/PKI-100200", "some title"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getRecordPath

Description:

MethodReturn valuesDescription

getRecordPath(String uuid)

String

Converts a record UUID to record 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.getRecordPath("28bb0c8b-3701-4457-a81a-fef7bc56ff33")); } catch (Exception e) {                 System.Console.WriteLine(e.ToString()); } } } }