Automation RevokeAllUsers with "Preserve creator"=false fails
PostPosted:Thu Sep 10, 2015 7:38 am
Hello,
By using Community 6.3 version (Linux), when the automation is fired by Document creation (post), the automation function RevokeAllUsers with the setting "Preserve creator"=false fails. This function does nothing, I mean it does not revoke any user rights.
However with the "Preserve creator"=true setting the function works, and removes the rights for everyone except the owner.
The idea would be to remove all "user" rights, but to keep all "role" rights for uploaded documents, therefore the user should not be able to delete its own files if he has no rights for deleting based on his role.
As an alternative solution I tried to create an ExecuteScripting action for removing all user rights. Apparently this script is not working, so if somebody could point out where the bug is, it would be appreciated.
By using Community 6.3 version (Linux), when the automation is fired by Document creation (post), the automation function RevokeAllUsers with the setting "Preserve creator"=false fails. This function does nothing, I mean it does not revoke any user rights.
However with the "Preserve creator"=true setting the function works, and removes the rights for everyone except the owner.
The idea would be to remove all "user" rights, but to keep all "role" rights for uploaded documents, therefore the user should not be able to delete its own files if he has no rights for deleting based on his role.
As an alternative solution I tried to create an ExecuteScripting action for removing all user rights. Apparently this script is not working, so if somebody could point out where the bug is, it would be appreciated.
Code: Select all
import java.util.Map;
import com.openkm.api.OKMFolder;
import com.openkm.api.OKMRepository;
import com.openkm.api.OKMAuth;
import com.openkm.api.*;
import com.openkm.util.PathUtils;
String path = OKMRepository.getInstance().getNodePath(null, uuid);
OKMAuth oKMAuth = OKMAuth.getInstance();
// All users only will continue having read grants
Map hm = oKMAuth.getGrantedUsers(null, path);
for (String userName : hm.keySet()) {
oKMAuth.revokeUser(null, path, userName, Permission.WRITE, false);
oKMAuth.revokeUser(null, path, userName, Permission.DELETE, false);
oKMAuth.revokeUser(null, path, userName, Permission.SECURITY, false);
}