cancel
Showing results for 
Search instead for 
Did you mean: 

Hiding node from non-admins by removing permissions

jzaruba
Champ in-the-making
Champ in-the-making
Hello

I'm trying to hide a node from all but admins.
    private void setAdminAccessOnly(NodeRef nodeRef)
    {
        permissionService.setInheritParentPermissions(nodeRef, false);

/*      previous attempts:
//      permissionService.deletePermission(nodeRef, null, PermissionService.READ_CHILDREN);
//      permissionService.deletePermission(nodeRef, null, PermissionService.ALL_PERMISSIONS);*/

        permissionService.setPermission(nodeRef, PermissionService.ADMINISTRATOR_AUTHORITY, PermissionService.ALL_PERMISSIONS, true);
        System.out.println(getNodeName(nodeRef) + " is now accessible only to admin");
    }
But I end up with error saying that a node does not exist…

I'm trying to delete a node that has just been uploaded, and because the wizard can't handle such situation I'm trying some workarounds to prevent the file from being reached until I can delete it later. Another approach that lead me to the same error was moving the node to a different store. (Even though I don't know whether that would make that node "unseekable".)
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
It sounds like you are hiding the node from yourself!

Make sure your method is "run as admin".    Or get the order of commands such that you remove your permissions last of all.

jzaruba
Champ in-the-making
Champ in-the-making
Thank you, mrogers. Smiley Happy

Yes, that's most likely what's happening. And now I realize that is actually what I was about to do when the upload happens under non-admin user - I would make the document unreachable for the last page of the wizard, which would again result in the same error… So it seems there's no way for me to "clean" the document right away, I will have to mark it somehow and delete it later.

Which brings me to a question, is there way to tell whether my executeImpl has been triggered via CIFS or whether I'm in the middle of the wizard…? (Within CIFS I could safely clear the document.)