The first kilometers of the year

Last saturday it was finally time to do something I’ve been waiting to do. I decided to take my bike for a spin. Ofcourse this couldn’t happen without some maintenance first. My battery died completely so on I went on my quest to get motorcycling again!

After loading the old battery in my car (which is funny in a way since it is a Toyota Auris Hybrid) I drove to Bikexperience where the guys helped me with a brand new battery. When I got home I quickly installed the battery in my motorcyle, put on my protective gear (don’t ride without it!) and on I went.

It was a short ride but I really needed it. There is nothing that can remove stress from my body like riding my motorcycle. I’m in good fortune to live in Monnickendam since it has a lot of dikes in the vicinity. Dikes usually have a lot of corners which is a lot of fun when you are on a motorcycle.

We’ve also started planning 2012 with the MTCW and in looks like it is going to be a great year for me and my motorcycle.

Posted in Prive | Tagged , , , | Leave a comment

Game of Thrones

The Oatmeal added an awesome cartoon about internet piracy. You can view the entire cartoon on his website.

Posted in Fun | Tagged , | Leave a comment

Using CMIS in Alfresco for an image gallery

This will be my first post about something technical. All technical blogs will be written in english.

For my first technical blog I shall give an example on how to use CMIS to build an image gallery. For a customer we have implemented Xopus. Using Xopus the editor can use a button to add an image to the XML-document. The image can be selected from a folder filled with images which is why we need CMIS to gather these images and show them in an understandable way to the editor.

All the images are uploaded in a space called “Images”. This space was added in the Company Home space.

The image gallery will be called like a html page. Therefor we shall build a webscript.  First we create a descriptor file. Name the file image-gallery.desc.xml and add the following content:

  1. <webscript>
  2. <shortname>Image gallery</shortname>
  3. <description>Creates an image gallery based on the files in a specified folder</description>
  4. <url>/imagegallery/image</url>
  5. </webscript>

Now we must gather the data needed for the image gallery. We will do this using CMIS. The first thing we need is the noderef of the folder Images. First click on the details button for the “Images” folder in Company Home.
Images detail button

After that, rightclick the Alfresco Node Reference link and save the link location.
Alfresco Noderef link

Save this link in your editor of choice. We will use this noderef to get the images. Our next step is to get the images from the folder. We will do this using a CMIS query. Create a file called image-gallery.get.js and add the following code:

  1. var selectString =  "SELECT d.*, rn.* FROM cmis:document AS d " +
  2. "JOIN rn:renditioned AS rn on d.cmis:objectId = rn.cmis:objectId " +
  3. "WHERE in_tree(d, 'workspace://SpacesStore/cfdb89df-622b-46c5-b95a-e183f9b885bd')" +
  4. "ORDER BY d.cmis:name"
  5. var cmisQuery = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><cmis:query xmlns:cmis=\"http://docs.oasis-open.org/ns/cmis/core/200908/\"><cmis:statement>" + selectString + "</cmis:statement><cmis:renditionFilter>cmis:thumbnail</cmis:renditionFilter></cmis:query>";
  6. // get the documents for the currently active site
  7. var conn = remote.connect("alfresco");
  8. var result = conn.post(stringUtils.urlEncodeComponent("/cmis/queries?renditionFilter=cmis:thumbnail"), cmisQuery, "application/cmisquery+xml");
  9. model.doc = stringUtils.parseXMLNodeModel(result.getText());

You can see the node reference within the selectString, change this to the reference you have just saved.

Both remote and model variables are supplied by Alfresco. The remote object is used to obtain connections to endpoints that are defined for Alfresco, more information is found in the link. The model object are used to use data in your presentation. By adding objects to the model they can then be read in the presentation where you can use them to show the data to the viewer. In our example we fill the variable doc in the model.

The CMIS query also has some specifics. Alfresco has an built-in method to create thumbnails of images. Ofcourse we want to use that to increase our performance. Therefor we add something to the CMIS query:

  1. <cmis:renditionFilter>cmis:thumbnail</cmis:renditionFilter>

You can see in the query that we joined the cmis:document table with the rn:renditioned table. The renditioned table has a lot more renditions of the content that we need, however we only need the thumbnails. By addind the filter we will only retrieve the thumbnails. There are more filters like this one, more info can be found here.

Our final step in creating the files needed for the webscript involves creating a presentation template for our data.  Create a file named image-gallery.get.html.ftl. The following is a snippet of the code, the rest is the standard content for a html page (html, head, body tags).

  1. <table cellpadding="10" cellspacing="0" width="100%">
  2. <tr>
  3. <#list doc.feed.entry as node>
  4. <#if node_index % 3 == 0 && (node_index > 0)></tr><tr></#if>
  5. <td valign="middle" align="center">
  6. <img src="${node["descendant-or-self::*[@rel='alternate']/@href"]}" alt="${node.title}"/>
  7. </td>
  8. <#if !node_has_next></tr></#if>
  9. </#list>
  10. </tr>

As you can see we are looping through the different entries that are provided in the doc variable we created earlier in the .js file. In freemarker there are some variables you can access when using a loop. You can get the index number of the current item in te list using variablename_index. This is done on line 4. There is also a variable which shows if there is next item. This is variablename_has_next. We use this to finish our table.

In order to view the gallery copy the three files to {alfresco-install-dir}\tomcat\shared\classes\alfresco\web-extension\site-webscripts
After that you have to refresh the webscripts. Go to {localurl}:{portnumber}/share/service/index.html and hit the refresh button.
Now go to {localurl}:{portnumber}/share/page/imagegallery/image and observe your gallery like mine:

CMIS Image Gallery result

If the gallery won’t show it is probably because you are not logged in into /share or /alfresco. Try logging in and then refreshing the page.

Posted in Technical | Tagged , , , | 3 Comments

Schaatsen

Het doet iets met Nederlanders als het een tijdje goed vriest. In eerste instantie klaagt iedereen dat het zo koud is. Vervolgens blijkt dat schaatsen op natuurijs mogelijk is en worden de meeste mensen intens gelukkig. Als dan blijkt dat er serieus nagedacht wordt over een elfstedentocht dan zijn de meeste mensen al helemaal niet meer te houden.

Zelf geniet ik er ook altijd van. Gisteren ben ik dan ook samen met mijn broertje, Peter en Dorinda een stuk wezen schaatsen. Lekker twee uurtjes op het ijs gestaan en van de ene koek en zopie naar de volgende. In Broek in Waterland kwamen we nog een hoop bekenden tegen en dat is altijd leuk, zeker als er ook Jägermeister geserveerd wordt.

Aangezien ik vandaag vrij was gelijk maar weer de schaatsen ondergebonden. In de regio kan je een heerlijk rondje schaatsen van ongeveer 10km. Vanavond nog even ijshockeyen met mijn broertje op de sloot achter bij mijn ouders en dan morgen weer een lange werkdag waarbij ik helaas niet kan schaatsen, toch jammer.

Posted in Prive | Tagged , | Leave a comment

Mannenvoer in spandex

Gisteren was het dan zover, we gingen de Royal Rumble kijken die afgelopen zondag was geweest. Samen met Rik, Wesley, twee gegrillde kippen en een bak gewokte sperziebonen voor de buis. Zoals altijd blijft dat toch fantastisch om te doen. Met zijn drieen weer genoten van de worstelaars die opkomen en gelachen om de debiele dingen die er gebeuren tijdens de show.

Je kan zeggen wat je wilt maar dit blijft entertainment van de bovenste plank. Het is dan wel geen echte sport, maar het zijn wel echte atleten en ze raken regelmatig geblesseerd door het bizarre schema wat ze erop nahouden.

Dit weekend is het echter tijd voor echte sporten (al is de entertainment value daar ook enorm). Morgen is UFC 143 waarin Nick Diaz het op gaat nemen tegen Carlos Condit. Zondag is de Superbowl waarin de New York Giants gaan proberen om te winnen van de New England Patriots. Ik ben blij dat ik maandag vrij ben.

Posted in Prive, Sport | Tagged , , , | 1 Comment