cancel
Showing results for 
Search instead for 
Did you mean: 

Problem while crossrepocopy through WCM submit workflow

amarpalkaur
Champ in-the-making
Champ in-the-making
Hi

I am customizing WCM submit workflow to add some behavior to task transitions. In customized workflow, when content gets approved and content creator clicks on ‘task done’, I am trying to copy the newly created or modified content to ‘companyhome/HDS’ folder. For fulfilling this, I am making a call to crossrepocopy.copy(). But my problem is this whole java script code works fine when creator is ‘admin’ where as in case of user with role ‘content contributor’, crossrepocopy.copy throws org.alfresco.service.cmr.avm.AVMNotFoundException: Path not found exception. I am not able to find out the cause of the problem.

Here is my java script action used in workflow :-


<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>

/* Path of WCM file to copy in ECM  */
var nodepaths = ml.getNodepath();

/* As there may be multiple documents in the workflow*/
var downloadFrom = new Array(nodepaths.length);

for(var x=0; nodepaths.length >x;x++)
{
              
if(nodepaths[x]!=null)
{
/* Creating actual path of file from staging sandbox */
             
var nodepath = nodepaths[x];
var inx = nodepath.indexOf(":");
nodepath =nodepath.substring(inx+1);
                  
/* Get the source node to be copied */
var srcnode = avm.lookupNode(“hds–"+person.properties["cm:userName"]+nodepath);
/* Here path is like “hds—admin:/www/avm_webapps/ROOT/filename.xml” */

/* Getting the folder structure (to find the destination in ECM) */
var rootindx = nodepath.indexOf("ROOT");
nodepath   = nodepath.substring(rootindx+5);
var slashindx = nodepath.lastIndexOf("/");
nodepath   = nodepath.substring(0, slashindx);
                                    
/* Find the destination folder in ECM */       
if(nodepath.length>0)
{
nodepath = "HDS/"+nodepath;
}
else
{
       nodepath = "HDS";
}   

var destFolder = companyhome.childByNamePath(nodepath);
java.lang.System.out.println(srcnode.name);      /*Till here the script executes*/ 
crossRepoCopy.copy(srcnode,destFolder,"File to copy");
               
var ts = new java.util.Date();
var appendtoname = ts.toString().replace(':','_');      
/* Rename the copied node to include current time stamp (Versioning alternative) */
destFolder = companyhome.childByNamePath(nodepath);
destChild = destFolder.children;   
for(var i = 0; destChild.length > i; i++)
   {             
      if(srcnode.name.equals(destChild.name))
   {
      var tkens = (destChild.properties.name).split(".");                  
                destChild.properties.name = tkens[0]+"_"+appendtoname+"."+tkens[1];         
                destChild.save();
      existingNode = destChild;
                              
   }
   }                  
                  
</script>
</action>

Please provide some clue to solve the issue.
Thanks in advance

Amarpal Kaur
2 REPLIES 2

pmonks
Star Contributor
Star Contributor
I might be wrong, but I believe the CrossRepositoryCopyService only supports copying from DM to WCM, not the reverse direction.  Best to check the code to be 100% sure.

Cheers,
Peter

amarpalkaur
Champ in-the-making
Champ in-the-making
Hi peter,

Thanks for replying..

I referred other forum topics like http://forums.alfresco.com/en/viewtopic.php?f=4&t=8055&hilit=crossrepocopy
and alfresco wiki documentation for crossrepocopy root level object http://wiki.alfresco.com/wiki/JavaScript_API#Cross_Repository_Copy
all says that crossrepocopy.copy() is used to copy between DM spaces and WCM spaces.
Moreover the same script works fine for 'content Manager' login, but it fails to copy in case of content contributor.

Am i missing something ?

Thanks,
Amarpal Kaur