OKMUserConfig
On all methods you'll see a parameter named "token". Because cron tasks are executed in the background without authentication, the methods used in this scenario might use the token parameter. From the default application execution context, you must use the value "null", which indicates that the application must use the "user session".
In special cases you might be "promoted to Administrator" using the "administrator token".
String systemToken = DbSessionManager.getInstance().getSystemToken();
Methods
setHome
Description:
Method | Return values | Description |
---|---|---|
setHome(String token, String nodeId) |
void |
Sets the user's home. |
By default, the 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:
Method | Return values | Description |
---|---|---|
getConfig(String token) |
UserConfig |
Returns the user configuration. |
Returned values are:
|
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();
}
}
}