OKMUserConfig

On all methods you'll see parameter named "token". Because the Cron Task are executed in background without authentication, the methods used in this scenario might use the token parameter. From default application execution context you must use "null" value what indicates to the application must use the "user session".

On special cases you might be "promoted as Administrator" using the "administrator token".

String systemToken = DbSessionManager.getInstance().getSystemToken();

Methods

setHome

Description:

MethodReturn valuesDescription

setHome(String token, String nodeId)

void

Sets the user home.

By default user home value is "/okm:root".

Example:

package com.openkm;

import com.openkm.api.OKMUserConfig;
import com.openkm.util.ContextWrapper;

public class Test {

    public static void main(String[] args) {
        try {
            OKMUserConfig okmUserConfig = ContextWrapper.getContext().getBean(OKMUserConfig.class);
            okmUserConfig.setHome(null, "/okm:root/test");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getConfig

Description:

MethodReturn valuesDescription

getConfig(String token)

UserConfig

Return the user configuration.

Returned values are:

  • The userId.
  • The home path.
  • The home type ( folder, document, mail or record ).
  • The home node ( the UUID ).

Example:

package com.openkm;

import com.openkm.api.OKMUserConfig;
import com.openkm.db.bean.UserConfig;
import com.openkm.util.ContextWrapper;

public class Test {

    public static void main(String[] args) {
        try {
            OKMUserConfig okmUserConfig = ContextWrapper.getContext().getBean(OKMUserConfig.class);
            UserConfig uc = okmUserConfig.getConfig(null);
            System.out.println(uc);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Table of contents [ Hide Show ]