Record samples
On most methods you'll see 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:
Method | Return values | Description |
---|---|---|
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 initializated. It indicates the folder path into OpenKM.
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
purgeRecord(String recId) |
void |
Records is definitely removed from 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 remove 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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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, record will preservate the same name. Only the security grants are copied to 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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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 can not 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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
forceUnlockRecord(String recId) |
void |
Unlocks a locked record. |
This method allows to unlock 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 super user ( 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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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());
}
}
}
}