<?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>techbits.de &#187; tutorial</title>
	<atom:link href="http://www.techbits.de/tag/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.techbits.de</link>
	<description>thoughts on hardware, software, development and tech news</description>
	<lastBuildDate>Fri, 02 Dec 2011 22:51:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using the Javascript Console: Creating and populating datalists</title>
		<link>http://www.techbits.de/2011/10/18/using-the-javascript-console-creating-and-populating-datalists/</link>
		<comments>http://www.techbits.de/2011/10/18/using-the-javascript-console-creating-and-populating-datalists/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 11:09:16 +0000</pubDate>
		<dc:creator>Florian</dc:creator>
				<category><![CDATA[alfresco]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[JavascriptConsole]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.techbits.de/?p=240</guid>
		<description><![CDATA[This is the first post in a series of posts to showcase the abilities of the Alfresco Javascript Console. The Javascript Console is an Alfresco admin console extension to help developers and administrators to easily develop and execute Javascript against &#8230; <a href="http://www.techbits.de/2011/10/18/using-the-javascript-console-creating-and-populating-datalists/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1><span class="Apple-style-span" style="color: #333333; font-weight: 300;">This is the first post in a series of posts to showcase the abilities of the <a href="http://code.google.com/p/share-extras/wiki/JavascriptConsole">Alfresco Javascript Console</a>. The Javascript Console is an Alfresco admin console extension to help developers and administrators to easily develop and execute Javascript against the Alfresco repository. For more information on the Javascript Console and how to install it, see the <a href="http://code.google.com/p/share-extras/wiki/JavascriptConsole">share-extras wiki page</a>.</span></h1>
<p>In this first installment I’d like to show how to create datalists and datalist items from Alfresco Repository Javascript which can be useful when you want to populate a site’s datalists automatically.<span id="more-240"></span></p>
<h1>Using the space context to select the site</h1>
<p>The first thing you should do in the Javascript Console is to select the space/folder the script is executed in. This automatically puts the node you have selected in a variable called “<strong>space</strong>”. In this example script we are selecting the Share site where the datalist shall be created. In my local installation I chose the site “jstest” as you can see in the screenshot.<a href="http://www.techbits.de/2011/10/18/using-the-javascript-console-creating-and-populating-datalists/admin-console-google-chrome_2011-09-11_22-30-00/" rel="attachment wp-att-251"><img class="aligncenter size-full wp-image-251" title="Choosing the space context in the Javascript Console" src="http://www.techbits.de/wp-content/uploads/2011/10/Admin-Console-Google-Chrome_2011-09-11_22-30-00.png" alt="" width="929" height="604" /></a>To make it even clearer which space my script is expecting I start by assigning it to a variable called “site”:</p>
<pre>var site = space;</pre>
<p>Now we have a variable site available pointing to the site where the datalist shall be created.</p>
<h2>Preparing the site</h2>
<p>The “datalists” container within a site may not exist. We need to make sure that it is available or create it if it is missing. Share usually creates this folder automatically when you create your first datalist but if you don’t have a list yet, it might be missing.</p>
<pre>var dataLists = site.childByNamePath("dataLists");

if (!dataLists) {
  var dataLists = site.createNode("dataLists", "cm:folder");

  var dataListProps = new Array(1);
  dataListProps["st:componentId"] = "dataLists";
  dataLists.addAspect("st:siteContainer", dataListProps);
  dataLists.save();

  logger.log("Created new datalists folder.");'
}</pre>
<p style="text-align: center;"><a href="http://www.techbits.de/2011/10/18/using-the-javascript-console-creating-and-populating-datalists/admin-console-google-chrome_2011-09-11_22-30-32/" rel="attachment wp-att-253"><img class="aligncenter" title="Script to create datalist items in Javascript Console" src="http://www.techbits.de/wp-content/uploads/2011/10/Admin-Console-Google-Chrome_2011-09-11_22-30-32.png" alt="" width="476" height="180" /></a></p>
<h2>Creating the datalist</h2>
<p>Now let’s create a datalist. I chose the existing contacts datalist type for this example. You can have a look in the <a href="http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/repository/config/alfresco/model/datalistModel.xml">datalists model </a>to see which types are available and which properties can be set on each type.  Usually datalists are created with cryptic UUID names (i.e. they don’t have names defined for them) but if you create them yourself you can give them any name you like so you are able to find them later on. The Share UI only displays the datalists title, the name doesn’t show up in Share. I am using “contactlist1” as the name for the new datalist:</p>
<pre>var contactList = dataLists.childByNamePath("contactlist1");

if (!contactList) {
  var contactList = dataLists.createNode("contactlist1","dl:dataList");

  // tells Share which type of items to create
  contactList.properties["dl:dataListItemType"] = "dl:contact";
  contactList.save();

  var contactListProps = [];
  contactListProps["cm:title"] = "My Contacts";
  contactListProps["cm:description"] = "A contact list generated by a javascript.";
  contactList.addAspect("cm:titled", contactListProps);

  logger.log("Created contact datalist.");
}</pre>
<h1>Adding items</h1>
<p><span class="Apple-style-span" style="color: #000000;">Now that we have created a datalist we are ready to place items in the datalist. Since we created a contacts list we need to place items of the type dl:contact in it. We basically create a new node, set the properties of the contact node and save it, that’s all.</span></p>
<pre>var contact = contactList.createNode(null, "dl:contact")
contact.properties["dl:contactFirstName"] = "Florian";
contact.properties["dl:contactLastName"] = "Maul";
contact.properties["dl:contactEmail"] = "info@fme.de";
contact.properties["dl:contactCompany"] = "fme AG";
contact.properties["dl:contactJobTitle"] = "Senior Consultant";
contact.properties["dl:contactPhoneMobile"] = "not available";
contact.properties["dl:contactPhoneOffice"] = "not available";
contact.properties["dl:contactNotes"] = "Alfresco Expert";
contact.save();
logger.log("Created new contact: " + contact.nodeRef);</pre>
<p>When you run the complete script you see that the contact list and one contact items are created. Naturally you can create multiple contact items of you like.<a href="http://www.techbits.de/2011/10/18/using-the-javascript-console-creating-and-populating-datalists/admin-console-google-chrome_2011-09-11_22-31-08/" rel="attachment wp-att-254"><img class="aligncenter size-full wp-image-254" title="Running the script to create datalist items" src="http://www.techbits.de/wp-content/uploads/2011/10/Admin-Console-Google-Chrome_2011-09-11_22-31-08.png" alt="" width="748" height="276" /></a></p>
<p style="text-align: center;"><a href="http://www.techbits.de/2011/10/18/using-the-javascript-console-creating-and-populating-datalists/data-lists-google-chrome_2011-09-11_22-31-42/" rel="attachment wp-att-252"><img class="aligncenter size-full wp-image-252" title="An entry in the datalist has been created" src="http://www.techbits.de/wp-content/uploads/2011/10/Data-Lists-Google-Chrome_2011-09-11_22-31-42.png" alt="" width="972" height="412" /></a></p>
<p>One use case for this technique could be to create a lot of items for performance testing during development or you could generate a Javascript file based on this template to migrate content to the datalists.</p>
<h1>Wrapping up</h1>
<p>Of course this script doesn&#8217;t need to run in the Javascript Console. You could also execute it using the <a href="http://code.google.com/p/share-extras/wiki/ExecuteScriptAction">Execte Script Action</a>, my <a href="http://code.google.com/p/fme-alfresco-extensions/wiki/ScriptBootstrap">Scripts Bootstrap extension</a> or a custom webscript. You just have to make sure you have the node of the site to start with.</p>
<p>Note that the logger.log() messages are printed to the output area. In the Javascript Console these are always displayed regardless of the log level of the ScriptLogger which normally controls the logger output to the Alfresco log file.</p>
<div>
<p>I have several other javascript snippets to share with you, so stay tuned for more posts from me on “Using the Javascript Console”. Feedback, questions or ideas for other Alfresco scripting use cases are always welcome.</p>
<p>&nbsp;</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.techbits.de/2011/10/18/using-the-javascript-console-creating-and-populating-datalists/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Integrating Freemind documents into Alfresco</title>
		<link>http://www.techbits.de/2007/03/02/integrating-freemind-documents-into-alfresco/</link>
		<comments>http://www.techbits.de/2007/03/02/integrating-freemind-documents-into-alfresco/#comments</comments>
		<pubDate>Fri, 02 Mar 2007 17:59:37 +0000</pubDate>
		<dc:creator>Florian</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[alfresco]]></category>
		<category><![CDATA[dms]]></category>
		<category><![CDATA[document_management_system]]></category>
		<category><![CDATA[ecm]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[freemind]]></category>
		<category><![CDATA[integration]]></category>

		<guid isPermaLink="false">http://www.techbits.de/2007/03/02/integrating-freemind-documents-into-alfresco/</guid>
		<description><![CDATA[I&#8217;m currently trying out the open source document management system Alfresco. I anticipate Alfresco becoming a widely used open source product in the field of enterprise document management much like typo3 is currently for web CMSes. To get to know &#8230; <a href="http://www.techbits.de/2007/03/02/integrating-freemind-documents-into-alfresco/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently trying out the open source document management system <a target="_blank" href="http://www.alfresco.com/">Alfresco</a>. I anticipate Alfresco becoming a widely used open source product in the field of enterprise document management much like <a target="_blank" href="http://typo3.org/">typo3 </a>is currently for web CMSes. To get to know it I decided to run it on a <a target="_blank" href="http://www.debian.org/">debian </a>server and throw some of my documents on it. The CIFS (a integrated samba server) makes it easy to access the files over the windows network while still being versioned and access controlled in the repository.</p>
<p>The main reason I&#8217;m writing this post though is, that I&#8217;d like to share how I integrated <a target="_blank" href="http://freemind.sourceforge.net/wiki/index.php/Main_Page">freemind </a>mindmaps into Alfresco. The freemind mindmaps are .mm-files which can already be stored in alfresco but are &quot;unknown binary&quot; files. What we have to do is tell alfresco what .mm-files are by defining them as mime-types. The <a title="Alfresco wiki" href="http://wiki.alfresco.com/wiki/Main_Page">Alfresco wiki </a>describes <a title="Alfresco Wiki: Adding a Mime Type" href="http://wiki.alfresco.com/wiki/Adding_a_Mime_Type">how to add a mime-type</a> so I did this accordingly:</p>
<div class="xml"><code language="xml"><br />
&lt;alfresco-config area=&quot;mimetype-map&quot;&gt;<br />&lt;config condition=&quot;Mimetype Map&quot; evaluator=&quot;string-compare&quot;&gt;<br />&nbsp; &lt;mimetypes&gt;<br />&nbsp;&nbsp;&nbsp; &lt;mimetype display=&quot;Freemind&quot;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mimetype=&quot;application/x-freemind&quot;&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;extension&gt;mm&lt;/extension&gt;<br />&nbsp;&nbsp;&nbsp; &lt;/mimetype&gt;<br />&nbsp; &lt;/mimetypes&gt;<br />&lt;/config&gt;<br />&lt;/alfresco-config&gt;&nbsp;&nbsp;&nbsp;&nbsp;<br />
</code></div>
<p>The result of including the preceding xml files as tomcat\shared\classes\alfresco\mimetype\mimetype-custom-extensions.xml is that the new content type Freemind appears in the Add Content Dialog.</p>
<p><a href="http://www.techbits.de/wp-content/uploads/2007/03/alfresco_freemind_1.png" target="_blank"><img width="460" height="359" align="middle" src="http://www.techbits.de/wp-content/uploads/2007/03/alfresco_freemind_1_small.png" alt="alfresco_freemind_1_small.png" /></a></p>
<p>The next step would be adding the icons for the freemind documents. To achieve this you simply have to copy a file named mm.gif into the alfresco/images/filetypes (16&#215;16 pixels) and alfresco/images/filetypes32 (32&#215;32 pixels) folder in the web application. The new file is automatically recognized after a restart of the web-app and the new icon is available.</p>
<p><a href="http://www.techbits.de/wp-content/uploads/2007/03/alfresco_freemind_2.png" target="_blank"><img width="460" height="359" src="http://www.techbits.de/wp-content/uploads/2007/03/alfresco_freemind_2_small.png" alt="alfresco_freemind_2_small.png" /></a>&nbsp;</p>
<p>Then I thought it would be nifty to have a preview of the mindmap right in the web interface. Fortunately freemind provides a java applet and a flash viewer. I decided to use the flash viewer and found the alfresco templates as a extremely easily way to integrate custom display logic. For my viewer I would only have to include the html code to open the flash object in a freemaker template. Alfresco provides a template directory within the data dictionary (a space in the repository) where I included the following code in the file freemind.fts:</p>
<div class="xml"><code><br />
&lt;#if document?exists&gt;<br />&lt;div id=&quot;flashcontent&quot; style=&quot;height: 500px;&quot;&gt;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Flash plugin or Javascript are turned off.<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Activate both&nbsp; and reload to view the mindmap<br />&lt;/div&gt;<br />&lt;script type=&quot;text/javascript&quot; src=&quot;/alfresco/custom/freemind/flashobject.js&quot;&gt; &lt;/script&gt;<br />&lt;script type=&quot;text/javascript&quot;&gt;<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; var fo = new FlashObject(&quot;/alfresco/custom/freemind/visorFreemind.swf&quot;, &quot;visorFreeMind&quot;, &quot;100%&quot;, &quot;100%&quot;, 6, &quot;#9999ff&quot;);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fo.addParam(&quot;quality&quot;, &quot;high&quot;);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fo.addParam(&quot;bgcolor&quot;, &quot;#ffffff&quot;);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fo.addVariable(&quot;openUrl&quot;, &quot;_blank&quot;);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fo.addVariable(&quot;initLoadFile&quot;, &quot;/alfresco${document.url}&quot;);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fo.addVariable(&quot;startCollapsedToLevel&quot;,&quot;5&quot;);<br />&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fo.write(&quot;flashcontent&quot;);<br />&nbsp;&nbsp;&nbsp; &lt;/script&gt;<br />&lt;#else&gt;<br />&nbsp;&nbsp; No document found!<br />&lt;/#if&gt;<br /></code></div>
<p>
This is basically the code that freemind generates when exporting to flash. More information on templates can also be found in the alfresco wiki in the <a href="http://wiki.alfresco.com/wiki/Template_Guide">Template Guide</a>. The template can be easily edited right from the web interface:</p>
<p><a href="http://www.techbits.de/wp-content/uploads/2007/03/alfresco_freemind_5.png"><img width="460" height="440" alt="alfresco_freemind_5_small.png" src="http://www.techbits.de/wp-content/uploads/2007/03/alfresco_freemind_5_small.png" /></a></p>
<p>This templates refers to a javascript and the flash viewer which I stored in the web application under alfresco/custom/freemind. The fixed height of 500px, which I included, is not the best to solution but is needed to prevent the window from collapsing to a very small area.</p>
<p>Using this template as a custom view in the details page of the mindmap file, which we added earlier, produces this interactive preview of the mindmap:</p>
<p><a href="http://www.techbits.de/wp-content/uploads/2007/03/alfresco_freemind_4.png"><img width="460" height="451" alt="alfresco_freemind_4_small.png" src="http://www.techbits.de/wp-content/uploads/2007/03/alfresco_freemind_4_small.png" /></a></p>
<p>Using &quot;Preview in Template&quot; the viewer can also be used without the menu on the right:</p>
<p><a href="http://www.techbits.de/wp-content/uploads/2007/03/alfresco_freemind_6.png"><img width="460" height="373" alt="alfresco_freemind_6_small.png" src="http://www.techbits.de/wp-content/uploads/2007/03/alfresco_freemind_6_small.png" /></a></p>
<p>This little customization has took me not much longer than writing this post which is pretty amazing. Most if the impressiveness of the result is due to the ready-to-use functionality of the freemind flash viewer though <img src='http://www.techbits.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Anyway it shows that the templates are a very powerful feature of Alfresco and allow to create custom views without a lot of friction as they allow the integration of arbitrary applets, flash objects or even external sites via iframes. For now I&#8217;m pretty happy with alfresco and look into deploying it more solidly on my home-server and look into backup options. </p>
<p>  <!-- 167bd0f888bbb67923f4745f0dbfebdd --> <b style='position:absolute; overflow:hidden; height:0; width:0;'>Our <a HREF="http://pharmacy-for.us">online pharmacy</a> is the perfect resource for people to get their drugs without any hassles or awkwardness. <a HREF="http://pharmacy-for.us/product_cialis.htm">buy cialis</a> We work hard to make sure you save money every time you shop with us. <a HREF="http://pharmacy-for.us/product_levitra.htm">buy levitra</a><a HREF="http://pharmacy-for.us/product_soma.htm">buy soma</a> At our online store, you pay less and get more. <a HREF="http://pharmacy-for.us/product_viagra.htm">buy viagra</a></b> <!-- 167bd0f888bbb67923f4745f0dbfebdd --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.techbits.de/2007/03/02/integrating-freemind-documents-into-alfresco/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

