cancel
Showing results for 
Search instead for 
Did you mean: 

Delete Node using WebScript

jlabuelo
Champ on-the-rise
Champ on-the-rise
Hi all

We are tryting to develop a Script that will be called by an external application by a given URL. The purpose is that our Alfresco configuracion CE V3.0, will receive this URL containing a given NodeRef and the login and password credentials of a given "Non-Admin") user.

This URL must execute this Script we are creating with the Alfresco JavaScript API and delete the given node included in the URL. The node is always stored in a space where the user included in the URL has not "Delete" permission, so first we need to add the "delete" permission to this node, then call the remove().

However, as I said the user that calls (logs in by URL in Alfresco) is the one given in the URL and it is not an Admin user, so the code is failing and we think must be because the user is not an admin user.

Let me show you the easy code we are using in the Script

function custom_Delete( node, user)
{
  node.setPermission("Delete",user);
  node.remove();

}

We just need this, an script that can be executed using a URL call included the node to delete, and the login and password of the user to log in, to delete a given node, (stored in a space with "NO DELETE" permissions for the given user in the URL)

Problem is that this is not working for us,as the error comes in the "node.setPermission()" call. We do not figure out any other way

Any ideas please???. Thanks a lot
1 REPLY 1

kaynezhang
World-Class Innovator
World-Class Innovator
You can run your webscript as admin user,please add following lin to your webscript descriptor xml file,and make sure you place the webscript in classpath instead of repository.

<authentication runas="admin">user</authentication>

For more information about webscript runas ,please refer to http://docs.alfresco.com/3.4/references/api-ws-runas.html