Node samples

Basics

Example of UUID:

  • Using UUID -> "373bcdd0-c082-4e7b-addd-e10ef813946e";

Suggested code sample

First, you must create the webservice object:

OKMWebservices ws = OKMWebservicesFactory.newInstance(host);

Then you should log in using the method "login". You can access the "login" method from the web service object "ws" as shown below:

ws.login(user, password);

Once you are logged in with the web services, the session is kept in the web service object. Then you can use the other API methods.

At this point you can use all the Node methods from "node" class as shown below:

ws.node.getNodeByUuid("29a22996-0e3b-421e-8759-c24ea41c1ebb")

Methods

getVersionHistory

Description:

MethodReturn valuesDescription

getVersionHistory(String uuid)

List<Version>

Returns a list of the version history 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;
using com.openkm.sdk4csharp.impl; namespace OKMRest { public class Program { static void Main(string[] args) { String host = "http://localhost:8080/openkm"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host); try { ws.login(user, password); List<Version> versions = ws.node.getVersionHistory("70ec54af-76ad-4d02-b9c8-8c94c3b6ffc7"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

restoreVersion

Description:

MethodReturn valuesDescription

restoreVersion(String uuid, String versionName)

void

Restore a document to a specific version.

Example:

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.impl; namespace OKMRest { public class Program { static void Main(string[] args) { String host = "http://localhost:8080/openkm"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host); try { ws.login(user, password); ws.node.restoreVersion("70ec54af-76ad-4d02-b9c8-8c94c3b6ffc7","1.0"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

deleteVersion

Description:

MethodReturn valuesDescription

deleteVersion(String uuid, String versionName)

void

Delete a specific version.

Example:

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.impl; namespace OKMRest { public class Program { static void Main(string[] args) { String host = "http://localhost:8080/openkm"; String username = "okmAdmin"; String password = "admin"; OKMWebservice ws = OKMWebservicesFactory.newInstance(host); try { ws.login(user, password); ws.node.deleteVersion("70ec54af-76ad-4d02-b9c8-8c94c3b6ffc7","1.0"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

purgeVersionHistory

Description:

MethodReturn valuesDescription

purgeVersionHistory(String uuid)

void

Purge the version history 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); ws.node.purgeVersionHistory("70ec54af-76ad-4d02-b9c8-8c94c3b6ffc7"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

subscribe

Description:

MethodReturn valuesDescription

subscribe(String uuid)

void

Adds a subscription to a 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); ws.node.subscribe("70ec54af-76ad-4d02-b9c8-8c94c3b6ffc7"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

unsubscribe

Description:

MethodReturn valuesDescription

unsubscribe(String uuid)

void

Deletes a subscription to a 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); ws.node.unsubscribe("70ec54af-76ad-4d02-b9c8-8c94c3b6ffc7"); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

importZip

Description:

MethodReturn valuesDescription

importZip(String uuid, FileStream content)

void

Imports a zip file.

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);
String folderId = "70ec54af-76ad-4d02-b9c8-8c94c3b6ffc7"; FileStream zipFile = new FileStream("D:\\Test.zip", FileMode.Open, FileAccess.Read);
ws.node.importZip(folderId, zipFile);
zipFile.Close(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

exportZip

Description:

MethodReturn valuesDescription

exportZip(List<String> uuids, bool withPath, bool background)

Stream

Exports as a zip file.

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("70ec54af-76ad-4d02-b9c8-8c94c3b6ffc7");
uuids.Add("82555dd1-bcc2-4e64-81cb-5f7c2b0d7801");
// Get strem exportZip
Stream s = ws.node.exportZip(uuids, true, true);
// Save as zip file
FileStream zipFile = new FileStream("D:\\Testing\\Test.zip", FileMode.OpenOrCreate, FileAccess.ReadWrite);
s.CopyTo(zipFile);
zipFile.Close();
s.Close(); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

unZip

Description:

MethodReturn valuesDescription

unZip(String uuid, String dstId)

void

Unzips a file.

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);
String zipFileId = "82555dd1-bcc2-4e64-81cb-5f7c2b0d7801";
String folderId = "70ec54af-76ad-4d02-b9c8-8c94c3b6ffc7"; ws.node.unZip(zipFileId, folderId); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getNodeByUuid

Description:

MethodReturn valuesDescription

getNodeByUuid(String uuid)

Node

Get a node by UUID.

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); Node node = ws.node.getNodeByUuid("82555dd1-bcc2-4e64-81cb-5f7c2b0d7801");
System.Console.WriteLine(node.toString()); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getChildrenNodesPaginated

Description:

MethodReturn valuesDescription

getChildrenNodesPaginated(String uuid, int offset, int limit, String filter, String orderByField, bool orderAsc, List<int> filteredTypes)

SimpleNodeBaseList

Get paginated child nodes.

The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" specifies how many results to skip before beginning to return results.


For example, if your query has 1000 results, but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11 to 20, you should use these values:

  • limit=10
  • offset=10

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<int> filteredTypes = new List<int>();
filteredTypes.Add(1);
String folderId = "82555dd1-bcc2-4e64-81cb-5f7c2b0d7801";
ChildNodeList nodeList = ws.node.getChildrenNodesPaginated(folderId, 0, 10, "", NodesPaginationInfo.ORDER_BY_NAME, true, filteredTypes);
} catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getChildrenNodesPaginated

Description:

MethodReturn valuesDescription

getChildrenNodesPaginated(String uuid, int offset, int limit, String filter, String orderByField, bool orderAsc, List<int> filteredTypes,  String pluginName)

SimpleNodeBaseList

Get paginated child nodes.

The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" says to skip that many results before the beginning to return results.

For example, if your query has 1000 results, but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11 to 20, you should use these values:

  • limit=10
  • offset=10

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<int> filteredTypes = new List<int>();
filteredTypes.Add(1);
String folderId = "82555dd1-bcc2-4e64-81cb-5f7c2b0d7801";
ChildNodeList nodeList = ws.node.getChildrenNodesPaginated(folderId, 0, 10, "", NodesPaginationInfo.ORDER_BY_NAME, true, filteredTypes, "");
} catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getChildrenNodesByCategoryPaginated

Description:

MethodReturn valuesDescription

getChildrenNodesByCategoryPaginated(String uuid, int offset, int limit, String filter, String orderByField, bool orderAsc, List<int> filteredTypes)

SimpleNodeBaseList

Get paginated child nodes by category.


The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" specifies how many results to skip before beginning to return results.

For example, if your query has 1000 results, but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11 to 20, you should use these values:

  • limit=10
  • offset=10
   

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<int> filteredTypes = new List<int>();
filteredTypes.Add(1);
String folderId = "82555dd1-bcc2-4e64-81cb-5f7c2b0d7801";
ChildNodeList nodeList = ws.node.getChildrenNodesByCategoryPaginated(folderId, 0, 10, "", NodesPaginationInfo.ORDER_BY_NAME, true, filteredTypes);
} catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getChildrenNodesByCategoryPaginated

Description:

MethodReturn valuesDescription

getChildrenNodesByCategoryPaginated(String uuid, int offset, int limit, String filter, String orderByField, bool orderAsc, List<int> filteredTypes, String pluginName)

SimpleNodeBaseList

Get paginated child nodes by category.

The parameters "limit" and "offset" allow you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" specifies how many results to skip before beginning to return results.

For example, if your query has 1000 results, but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11 to 20, you should use these values:

  • limit=10
  • offset=10
   

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<int> filteredTypes = new List<int>();
filteredTypes.Add(1);
String folderId = "82555dd1-bcc2-4e64-81cb-5f7c2b0d7801";
ChildNodeList nodeList = ws.node.getChildrenNodesByCategoryPaginated(folderId, 0, 10, "", NodesPaginationInfo.ORDER_BY_NAME, true, filteredTypes, "");
} catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getBreadcrumb

Description:

MethodReturn valuesDescription

getBreadcrumb(String uuid)

List<BreadCrumbItem>

Get breadcrumb.

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);
String folderId = "82555dd1-bcc2-4e64-81cb-5f7c2b0d7801";
List<BreadCrumbItem> list = ws.node.getBreadcrumb(folderId);
} catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

getNodesFiltered

Description:

MethodReturn valuesDescription

getNodesFiltered(List<String> uuids)

List<Node>

Returns a list of nodes.

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("82555dd1-bcc2-4e64-81cb-5f7c2b0d7801");
List<Node> nodes = ws.node.getNodesFiltered(uuids); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

evaluateDownloadZip

Description:

MethodReturn valuesDescription

evaluateDownloadZip(List<String> uuids)

ZipDownloadEvaluationResult

Returns a ZipDownloadEvaluationResult 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);
List<string> uuids = new List<string>();
uuids.Add("82555dd1-bcc2-4e64-81cb-5f7c2b0d7801");
ZipDownloadEvaluationResult zdeResult = ws.node.evaluateDownloadZip(uuids); } catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

restore

Description:

MethodReturn valuesDescription

restore(String uuid)

Node

Restores a 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);
Node node = ws.node.restore("0f6463f3-4d36-4091-b518-4fe7c353ee70");
System.Console.WriteLine(node.toString());
} catch (Exception e) { System.Console.WriteLine(e.ToString()); } } } }

hasNodesLockedByOtherUser

Description:

MethodReturn valuesDescription

hasNodesLockedByOtherUser(String uuid)

bool

Indicates if the node is locked 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);
if(ws.node.hasNodesLockedByOtherUser("1ec49da9-1746-4875-ae32-9281d7303a62"))
{
System.Console.Writeline("Is blocked");
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}

setComment

Description:

MethodReturn valuesDescription

setComment(String uuid, String versionName, String comment)

void

Sets the comment for a specific node version.

Example:

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.impl;

namespace OKMRest
{
public class Program
{
static void Main(string[] args)
{
String host = "http://localhost:8080/openkm";
String username = "okmAdmin";
String password = "admin";
OKMWebservice ws = OKMWebservicesFactory.newInstance(host);

try
{
ws.login(user, password);
ws.node.setComment("4b88cbe9-e73d-45fc-bac0-35e0d6e59e43", "1.5", "Update comment");
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());
}
}
}
}