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.getInstance(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 webservices, the session is kept in the webservice 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:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Shard;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String username = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(username, password);

            for (Shard shard : ws.shard.getShards()) {
                System.out.println(shard);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

setCurrentShard

Description:

MethodReturn valuesDescription

setCurrentShard(long shardId)

void

Change the current shard.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String username = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(username, password);

            long shardId = 1;
            ws.shard.setCurrentShard(1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

changeShard

Description:

MethodReturn valuesDescription

changeShard(String uuid, long shardId)

void

Change the shard ID of the UUID.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String username = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(username, password);
            
            long shardId = 1;
            ws.shard.changeShard("e2391b01-ce10-42c7-94a9-b0d6b394048e", shardId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}