A while back, when I first starting working with OpenKM, I accidentally removed the UserRole role from the root directory. For the longest time, I had know clue how to add the UserRole role back to that folder, or any other folder for that matter. Today, after playing around with the example scripts, I developed the following script that can be run from the Administrators tab:


import com.openkm.api.OKMAuth;
import com.openkm.core.JcrSessionManager;
import com.openkm.bean.Permission;
 
String token = JcrSessionManager.getInstance().getSystemToken();
OKMAuth.getInstance().grantRole(token, "/okm:root", "UserRole", Permission.READ, false);
Categories: BlogJava

1 Comment

Ankur Jain · August 10, 2012 at 6:41 AM

Hi Chris,

I also removed userrole from the security, by mistake,
i also tried your code. but this code is showing error, while i tried to execute this from the administration script section.
Please help me
I am using professional trail version of openkm-6.0.1

Leave a Reply to Ankur Jain Cancel reply

Your email address will not be published. Required fields are marked *