AnsweredAssumed Answered

cross repo copy

Question asked by naveenkumar on Sep 10, 2007
Latest reply on Sep 11, 2007 by naveenkumar
Hi all,
    For my application i need to copy the xml content outside of the web project, for this i wrote a javacript in process definition.xml file. When i use this able to copy inside the web project, when i try to copy outside getting error.

Here is my Script:

var properties = companyhome.properties;
var rssin = companyhome.childByNamePath("Projects/DML/RssIn");
logger.log("destfreenews" +rssin);      
var args = new Array(1);
args["store"] = avm.stores;               
logger.log("avmStores" +args["store"]);
if(args["store"]!=null)
  { var storeRootNode = avm.lookupStoreRoot(args["store"][0].id);
    logger.log("store root node" +storeRootNode);
    logger.log("store name" +args["store"][0].name);            
    if (storeRootNode != null)
    { var path = storeRootNode.path + "/ROOT/User Guide.doc";
      logger.log(+path);
      var node = avm.lookupNode(path);
      var path1 = storeRootNode.path + "/ROOT/Software/Programming languages";
      var node1 = avm.lookupNode(path1);
      logger.log("node" +node);
      logger.log("node path" +node.path);
      var copy=crossRepoCopy.copy(node,node1,"NAME OF THE CONTENT");//to copy inside web project
      logger.log(copy);
      copy.save();
      var copy1=crossRepoCopy.copy(node,rssin,"NAME OF THE CONTENT");// to copy outside web project.
      logger.log(copy1);
      copy1.save();              
     }
  }

My console:

17:56:02,593 DEBUG [org.alfresco.repo.jscript.ScriptNode] Executing xpath: *[@cm:name=$cm:name0]/*[@cm:name=$cm:name1]/*[@cm:name=$cm:name2]
17:56:02,656 DEBUG [org.alfresco.repo.jscript.ScriptLogger] destfreenewsNode Type: {http://www.alfresco.org/model/content/1.0}folder, Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/application/1.0}uifacets, {http://www.alfresco.org/model/system/1.0}referenceable, {http://www.alfresco.org/model/rule/1.0}rules]
17:56:03,531 DEBUG [org.alfresco.repo.jscript.ScriptLogger] avmStores[Ljava.lang.Object;@1d0fa14
17:56:03,703 DEBUG [org.alfresco.repo.jscript.ScriptLogger] store root nodeAVM Path: DmlCognizant–admin:/www/avm_webapps
Node Type: {http://www.alfresco.org/model/wcmmodel/1.0}avmlayeredfolder
Node Properties: 11
Node Aspects: [{http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable]
17:56:03,703 DEBUG [org.alfresco.repo.jscript.ScriptLogger] store nameDmlCognizant–admin
17:56:03,703 DEBUG [org.alfresco.repo.jscript.ScriptLogger] NaN
17:56:04,312 DEBUG [org.alfresco.repo.jscript.ScriptLogger] nodeAVM Path: DmlCognizant–admin:/www/avm_webapps/ROOT/User Guide.doc
Node Type: {http://www.alfresco.org/model/wcmmodel/1.0}avmplaincontent
Node Properties: 13
Node Aspects: [{http://www.alfresco.org/model/content/1.0}titled, {http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable]
17:56:04,312 DEBUG [org.alfresco.repo.jscript.ScriptLogger] node pathDmlCognizant–admin:/www/avm_webapps/ROOT/User Guide.doc
17:56:07,687 DEBUG [org.alfresco.repo.jscript.ScriptLogger] AVM Path: DmlCognizant–admin:/www/avm_webapps/ROOT/Software/Programming languages/NAME OF THE CONTENT
Node Type: {http://www.alfresco.org/model/wcmmodel/1.0}avmplaincontent
Node Properties: 13
Node Aspects: [{http://www.alfresco.org/model/content/1.0}titled, {http://www.alfresco.org/model/content/1.0}auditable, {http://www.alfresco.org/model/system/1.0}referenceable]
17:56:10,968 DEBUG [org.alfresco.repo.jscript.ScriptNode] Executing xpath: *[@cm:name=$cm:name0]
17:56:10,984 DEBUG [org.alfresco.repo.jscript.ScriptLogger]
17:56:11,000 DEBUG [org.alfresco.repo.jscript.RhinoScriptProcessor] Time to execute script: 8438ms
17:56:11,000 ERROR [org.jbpm.graph.def.GraphElement] action threw exception: Failed to execute supplied script: Failed to execute supplied script: TypeError: Cannot call method "save" of null (AlfrescoScript#1)
org.alfresco.service.cmr.repository.ScriptException: Failed to execute supplied script: Failed to execute supplied script: TypeError: Cannot call method "save" of null (AlfrescoScript#1)
   at org.alfresco.repo.processor.ScriptServiceImpl.executeScriptString(ScriptServiceImpl.java:282)
   at org.alfresco.repo.processor.ScriptServiceImpl.executeScriptString(ScriptServiceImpl.java:256)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:281)

Copy1.save()– Getting error.
Copy1 have nothing.. can anyone tell me why?? Did anyone try to move the content out of web project??

For my application i need to create xml content,so i used web projects. I thought using JCR rmi to get the content directly from the staging sand box http://forums.alfresco.com/viewtopic.php?t=8057&highlight=naveen. I found its not possible. Then i planned to copy the content out of web project.I need few more to clarify.

When author creates a content inside his sandbox, and he started the workflow.During approval process i need to get some information about the content under workflow  through java script
1)name of the content
2)path or Location of the content.
3)Expiration date property

how to get these informations??

Please anyone help me..

Thanks
Naveen

Outcomes