UserConfig 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.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 web services, the session is kept in the webservice object. Then you can use the other API methods.

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

ws.userConfig.getConfig();

Methods

getConfig

Description:

MethodReturn valuesDescription

getConfig()

UserConfig

Returns the user settings.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Node;
import com.openkm.sdk4j.bean.UserConfig;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

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

        try {
            ws.login(user, password);
            UserConfig userConfig = ws.userConfig.getConfig();
            Node node = ws.node.getNodeByUuid(userConfig.getHomeNode());
            System.out.println("User: " + userConfig.getUser());
            System.out.println("Home: " + node.getPath());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

setHome

Description:

MethodReturn valuesDescription

setHome(String uuid)

void

Sets the user's home node.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Node;
import com.openkm.sdk4j.bean.UserConfig;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

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

        try {
            ws.login(user, password);
            ws.userConfig.setHome("53751cb7-c462-4320-ba46-4cc33e4667ae");

            UserConfig userConfig = ws.userConfig.getConfig();
            Node node = ws.node.getNodeByUuid(userConfig.getHomeNode());
            System.out.println("Home: " + node.getPath());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}