Shard samples

Basics 

Example of UUID:

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

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 webservice object "ws" as shown below:

ws.login(user, password);

Once you are logged in to the web service, 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 Shard methods from the "shard" class as shown below:

ws.shard.getShards()

Methods

getShards

Description:

MethodReturn valuesDescription

getShards()

List<Shard>

Returns a list of all shards.

Example:

using System; using System.Collections.Generic;
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(bean.Shard shard in ws.shard.getShards())
{
Console.WriteLine(shard.ToString());
}
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());

}
}
}
}

setCurrentShard

Description:

MethodReturn valuesDescription

setCurrentShard(long shardId)

void

Changes the current shard.

Example:

using System; using System.Collections.Generic;
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 shardId = 1;
ws.shard.setCurrentShard(shardId);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());

}
}
}
}

changeShard

Description:

MethodReturn valuesDescription

changeShard(String uuid, long shardId)

void

Changes the shardId of the UUID.

 

Example:

using System; using System.Collections.Generic;
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 shardId = 1;
ws.shard.changeShard("e2391b01-ce10-42c7-94a9-b0d6b394048e", shardId);
}
catch (Exception e)
{
System.Console.WriteLine(e.ToString());

}
}
}
}