cancel
Showing results for 
Search instead for 
Did you mean: 

Permission to Write in Reviewer Home Space

joaotpd
Champ on-the-rise
Champ on-the-rise
Hi all!
I'm using alfresco-community-tomcat-2.9.0B on linux…
In a Workflow that I've created I want to send a copy of the file to the reviewer homeFolder.
So I do something like this:



<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
   <script>
      var reviewerSpace = reviewer.properties["cm:homeFolder"];
      var docName = bpm_package.children[0].properties["name"];

      <!– permissions for initiator –>
      reviewerSpace.setPermission("CreateChildren",initiator.properties.userName);

      var docExist = reviewerSpace.childByNamePath(docName);

      if (docExist == null)
      {
         var cpy = bpm_package.children[0].copy(reviewerSpace);
      }

      <!– remove permission –>
      espacoReviewer.removePermission("CreateChildren",initiator.properties.userName);
   </script>
</action>


I get a permission error:


Failed to execute supplied script: Failed to execute supplied script: Wrapped org.alfresco.repo.security.permissions.AccessDeniedException: Access Denied.  You do not have the appropriate permissions to perform this operation.


I already have tried: "Write"; "All", …
IS THIS THE RIGHT WAY TO DO THIS?!! … WHAT I'M DOING WRONG??
Please help!!!
Thanks!!

João Duarte
3 REPLIES 3

joaotpd
Champ on-the-rise
Champ on-the-rise
Hi!! My problem is getting BIGGER…
I didn't pay attention to permissions (I did tests with admin) and now i don't know what to do… Smiley Tongue
I have a lot of scrips, not only in workflows, that need to crate a space or move/copy documents from one place to another… I can't figure out how to give, via script, permissions to the current user to perform these operations… and, in the end, remove that permissions…
Here's one more example:

myscript.js

var noderef = args["noderef"];
var doc = search.findNode(noderef);
docName=doc.name;
var currentUserName = person.properties["cm:userName"];

companyhome.setPermission("CreateChildren",currentUserName);

var myNewSpace = companyhome.childByNamePath("MySpace");

if (myNewSpace == null && companyhome.hasPermission("CreateChildren"))
{
   myNewSpace = companyhome.createFolder("MySpace");
}

var docExist = myNewSpace.childByNamePath(docName);

if (docExist == null)
{
   var mv = doc.move(myNewSpace);
}

I'm getting this ERROR:


org.alfresco.error.AlfrescoRuntimeException: Error during command servlet processing: Access Denied. You do not have the appropriate permissions to perform this operation.
caused by: org.alfresco.repo.security.permissions.AccessDeniedException: Access Denied. You do not have the appropriate permissions to perform this operation.
caused by: net.sf.acegisecurity.AccessDeniedException: Access Denied

With admin user everything works fine, of course…
Anyone?!
Thanks again!!

João Duarte

zaizi
Champ in-the-making
Champ in-the-making
To do this

companyhome.setPermission("CreateChildren",currentUserName);

the current user need to have "ChangePermissions" permission on the current space, which in this case is Company Home. Which might explain why your code is failing.

Don't know what version of code you are using, but you'll need this functionality: https://issues.alfresco.com/jira/browse/ENH-229. The post lists work arounds for what you are trying to do.

joaotpd
Champ on-the-rise
Champ on-the-rise
Hi zaizi!!
Thank you for your fast answer!!! …
I'm not quite follow this:

Now you can use an optional runas attribute on the <authentication> element to declare who the script should be run as. E.g.
<authentication runas="otheruser">user</authentication>
I'm mixed with the user/otheruser… and where do i put this to make the desired effect?! … :s
I'm executing my script like this:

web-client-config-custom.xml

<config>
   <actions>
      <action id="myScript">
         <label>Move File …</label>
         <image>/images/icons/myImage.gif</image>
         <script>/Company Home/Data Dictionary/Scripts/myscript.js</script>
         <params>
            <param name="noderef">#{actionContext.nodeRef}</param>
         </params>
      </action>
   </actions>
</config>

<config evaluator="node-type" condition="my:type">
   <actions>
      <action-group id="document_browse_menu">
         <action idref="myScript" />
      </action-group>
   </actions>
</config>

Can I figure out with this my version code: Version: Community Network - v2.9.0 (B 683)
Thanks again…

João Duarte