Tips N Tricks
Alfresco: Even the owner/author cannot delete his file!
Alfresco is an open source and free content management system (CMS) – kind of a MS Sharepoint alternative. I had deployed Alfresco for two clients of mine. Coincidently, both clients came up with a specific requirement stating:
“Once a user uploads the file into the content management system, he or anyone else (expect for admin) should not be able to edit/delete it.”
I came up with a simple solution to change the owner of the files when they are uploaded into the CMS. Hence, when the file is uploaded, if the owner of the file is set to admin, even the user who created/uploaded the file will not be able to delete it.
Following is how i did it:
- Wrote a one line JavaScript and uploaded it in the directory (called Spaces in Alfresco) named Company Home > Data Dictionary > Scripts
- Applied a Content Rule to the Space(s) to execute this JavaScript for inbound content
Following is the JavaScript code:
document.owner = "admin";
This changes the owner of the document to admin (from the user who uploaded the document).Following is the step by step to how to setup this script. Lets assume that you want to apply this rule to a Space called “Important Docs” under “Company Home” – the root space/directory in Alfresco.
Create the script
- Log into the web interface of Alfresco as admin
- Click on or go to the space Company Home > Data Dictionary > Scripts .
- Click on Create>Create Content (top right side)
- This will open the “Create Content Wizard”
- For Name, type in changeOwner.js
- For “Content Type”, select “Plain Text”
- Click on Next.
- In the textarea, type in: document.owner = “admin”;
- Click on Finish and then click on Ok.
- You should now be able to see a file named changeOwner.js in Company Home > Data Dictionary > Scripts.
Apply the script
- Log into the web interface of Alfresco as admin
- Click on or go to the space Company Home > Important Docs (as per the example)
- Click on More Actions>Manage Content Rules (top right side)
- Click on Create Rule (top right side)
- For “Select condition”, select “All Items” from the dropdown.
- Click on “Add to List’ and then click on Next
- On Step Two – Select Actions, select “Execute a script” from the dropdown
- Click on “Set values and add”
- From the “Select a script” dropdown, select changeOwner.js
- Click on OK. Then click on Next.
- On “Step Three – Enter Details”, select Inbound from the Type dropdown.
- Type in any title, say “Rule to change document owner”
- Check mark “Apply rule to sub spaces”, if you want this rule to apply even to the sub spaces (subdirectories) under Imporant Docs
- Click on Finish.
Henceforth, if a user (or any user) say shekhar uploads/creates (via web interface, CIFS, WebDav etc.) any content/file under “Important Docs”, the owner of the content will change to admin, automatically. Hence shekhar will not be able to edit/delete the content.
GD Star Rating
loading...
GD Star Rating
loading...
Alfresco: Even the owner/author cannot delete his file!, 7.8 out of 10 based on 4 ratings
Email This Post
⋅
Print This Post
⋅
Post A Comment
@shekharg
Discussion
No comments for “Alfresco: Even the owner/author cannot delete his file!”
Post a comment