<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ben&#039;s Blog &#187; cross repository copy</title>
	<atom:link href="http://www.benh.co.uk/tag/cross-repository-copy/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.benh.co.uk</link>
	<description></description>
	<lastBuildDate>Thu, 26 Jan 2012 21:39:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Javascript API &#8211; Cross Repository Copy</title>
		<link>http://www.benh.co.uk/alfresco/javascript-api/javascript-api-cross-repository-copy/</link>
		<comments>http://www.benh.co.uk/alfresco/javascript-api/javascript-api-cross-repository-copy/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 17:02:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript API]]></category>
		<category><![CDATA[Alfresco WCM]]></category>
		<category><![CDATA[cross repository copy]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.benh.co.uk/?p=346</guid>
		<description><![CDATA[Recently I have been asked a few times for an example of how to copy content from the DM Alfresco repository into the AVM (WCM) repo, so I thought I would post a simple example using the JavaScript API to help people get started. It can be a little tricky getting the paths etc correct [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I have been asked a few times for an example of how to copy content from the DM Alfresco repository into the AVM (WCM) repo, so I thought I would post a simple example using the JavaScript API to help people get started.  It can be a little tricky getting the paths etc correct if you are new to Alfresco, so hopefully this will assist.</p>
<p>The <a title="3.1 javascript API" href="http://wiki.alfresco.com/wiki/3.1_JavaScript_API#Cross_Repository_Copy" target="_blank">3.1 JavaSccript API</a> wiki page shows the required parameters:<br />
<code><br />
ScriptNode copy(ScriptNode source, ScriptNode destination, String name)</code></p>
<p><strong>Download the example web script <a title="here" href="http://www.benh.co.uk/wp-content/uploads/2009/10/crossRepoCopy.zip" target="_blank">here</a></strong>.  This web script is based on some example code taken from the Alfresco Forge project &#8211; <a title="FlexSpaces" href="http://forge.alfresco.com/projects/flexspaces/" target="_blank">FlexSpaces</a> which contains some great examples of WCM web scripts.</p>
<p><span id="more-346"></span></p>
<p>As you will see from the descriptor file, the required parameters are passed to the JavaScript via the following URL:<br />
<code><br />
/crossRepoCopy?sourcenodeid={sourceAdmNodeId}&amp;targetstoreid={targetAvmStoreId}&amp;targetavmpath={targetAvmPath}<br />
<!--formatted--></code><br />
In a production environment, the required arguments will no doubt be generated programmatically, however for the purpose of a simple example, we will collect them manually.  Firstly, the <strong>sourcenodeid</strong> source i.e. the node id of the source item that you wish to copy from the DM repo.  Using the Node Browser for this example, navigate to the source file and copy the node.  It will look something like:<br />
<code><br />
workspace://SpacesStore/371d692f-46e7-4ca8-84bb-81a032ac1363<br />
</code><br />
Strip out the workspace://SpacesStore/ as the example script adds it as required so you are left with:<br />
<code><br />
371d692f-46e7-4ca8-84bb-81a032ac1363<br />
</code><br />
Next the targetAvmStoreId, so the store that we are going to copy to within the AVM.  This is made up from the web project dns name and the sandbox user name.  Use the node browser once again and look for the store-identifier property.  In my example the store-identifier is:<br />
<code><br />
demo--admin<br />
</code><br />
Finally the targetAvmPath which is the folder path to the location within the sandbox of where the content item will be created.  In my example I would like to copy the content to the root of my web application folder so I use:<br />
<code><br />
/www/avm_webapps/ROOT<br />
</code></p>
<p>With all of the parameters in place, the final request string looks like:<br />
<code></p>
<p>http://localhost:8080/alfresco/service/crossRepoCopy?sourcenodeid=319a5e5c-e921-490d-ac75-12c0a678f92e&#038;targetstoreid=demo--admin&#038;targetavmpath=/www/avm_webapps/ROOT</p>
<p><!--formatted--></code><br />
If the copy was successful, you will see:<br />
<code><br />
Result String - Node was copied<br />
Result Code - true</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.benh.co.uk/alfresco/javascript-api/javascript-api-cross-repository-copy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

