Posts tagged alfresco
Spring Surf meets Clojure
May 23rd

For those who missed it, some time ago the Alfresco guys donated their Surf Platform to SpringSource, giving birth to the now-called SpringSurf, which is thereby described as:
a view composition framework for Spring MVC that plugs into your existing Spring applications. It provides a scriptable and content-centric approach to building web applications.
I’m not going to introduce you how to use this yet-another MVC framework, but Michael Uzquiano provided an awesome blogpost, in case you were interested into learning more about it.
Part of the job of this Spring Surf framework is to provide an easy to use web scripting framework, REST like, that enables you to easily put together a View and, optionally, a Controller to implement a web API, provide them in the classpath together with a small XML descriptor, and your REST API is deployed right away. In the SpringSurf parlance, this is called called WebScript. Again, technical insights about the framework are better explained elsewhere, so no repetitions here. What I think is cool about Spring Surf, and I’m here with you to discuss, is it’s multi-language focus: web script Controllers can be written in Javascript, PHP or Groovy right out of the box, allowing you to choose whichever language you prefer. Moreover, if you just peek at Spring Surf source code, plugging in support for new languages doesn’t look so hard, so I decided to challenge myself and write support for Clojure backed webscripts. You can find the result of my efforts on github, with a sample webscript that proves the concept.
Following the webscript framework praxis, a model map object is passed around that acts as a container for whichever result your computation will produce, that will at the end handed over to a view rendition engine, Freemarker in our case, to build the resulting document. Webscripts are intended to support a number of different output formats, from JSON to XML to plain text, so being generic here is not an option.
Anyway, the first thing you usually do is to populate the model map with a number of objects that will be needed by the rendering engine to build the response. To support this use case, this first implementation of the Clojure backend for Spring Surf webscripts expects your Clojure “script” to yield a map, in Clojure sense. This map will be then forwarded to a Freemarker template and used to build a webpage or whatever the user asked for, i.e. this controller:
(ns web.script.test)
{:foo "bar"}
and this freemarker template:
foo: ${foo}
will provide “foo: bar” back to the client.
This is just an experiment at the moment, and far from being production-quality stuff. Still, it has been instructing to build a Java-to-Clojure integration, and nonetheless it might come in handy when I’ll be trying to put more Clojure in my working life.
(bye)
Handling Microsoft Windows NTP sync
Apr 23rd

This post should raise some eyebrows around, as I’m advocating Linux since ages and I’m not at all into Microsoft stuff for the 99.99% of my time. This story comes out of that (usually negligible) 0.01%.
Why bother with NTP on MS Windows?
The Alfresco implementation I’m working on has to integrate with a fully MS-powered environment, with a Domain Controller pulling the strings of network entities such as users and hosts. As the customer has strict security requirements, no remote access can be granted to their intranet, and since their offices are a bit far away from mine, we decided to replicate their environment locally, providing the minimum set of components such as
- a domain controller (WinServer 2k8)
- a domain host (WinXP Pro SP2)
- the Alfresco server (RHELv5.4)
I was able to build up the whole replicated environment, with a relative limited effort, using virtual machines to host all the different operating system on my laptop. I was so happy that everything worked almost at the first shot that I almost died when it all went wrong after the first reboot of the VMs: I couldn’t log anymore on the WinXP box!
It turned out that all clocks drifted away, making Kerberos auth checks fail because of replication attacks protection. Looked like it was time to strengthen my Win-fu and configure NTP in a proper way. This is what I learned.
WinServer2k8 and clock management
If there’s one thing I enjoyed out of all the time spent on these tasks, the prize goes definitely to w32tm: I had to deal with Windows, and there were no windows involved! As usual, whenever I’m typing into a command line, I feel at home. I’m actually writing this whole blog post to take note of the tricks I learned around w32tm and NTP clock sync. Here we go:
- Configure NTP servers
w32tm /config /manualpeerlist:europe.pool.ntp.org /syncfromflags:manual /reliable:no /update
- Query NTP servers
w32tm /stripchart /computer:europe.pool.ntp.org /samples:5 /dataonly
- Resync clock
w32tm /resync /rediscover
- Allow resync in case of huge drifts
If your clock drifted too far away Windows will refuse to sync. In order to disable such check you have to import the following changes (write them in a reg-keys.reg file and double click it):Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config] "MaxNegPhaseCorrection"=dword:ffffffff "MaxPosPhaseCorrection"=dword:ffffffff
That’s it for now. I hope this will come in handy to somebody else, since I’ll try to avoid any more contact with the Microsoft stacks as long as possible, since without grep, find, awk, sed, vim I feel as uncomfortable as this.
From the grounds up, your Maven powered Alfresco dev box
Jan 14th

The target
To start your Alfresco development experience, you need a development environment. Let’s say you’re more into this Maven and you’d rather leverage its capabilities instead of using the default ant based build system provided along with the SDK. In this tutorial, I’ll guide you through the process of setting up from scratch your development environment. And by saying “from scratch”, I really mean it: we’ll start from a fresh installed Linux box and the we will add piece over piece until we’ll be see the Alfresco flower on our browser. This will be a *basic* tutorial, just to put in place the foundation for later improvements.
I’m actually performing these steps in a virtual machine, so that next time a quick&dirty Alfresco PoC is required I might use this very same VM to start right away from a known, dev ready point.
UPDATE: the Maven project structure I end up with at the end of this article can be downloaded directly from GitHub.
Operating System
Ok, I assume you know your stuff and don’t want to get a bore-some lesson on how to install Linux. The whole internet is polluted by billions of guides and tutorial since 199x, anyway, so let’s just say I just completed the install process of Mint7 and I’m at my very first login. I would go for Mint8 if my current connection was fast enough to download it before I finish writing these notes, but whatever, there’s nothing really bad in v7.
Tools
The shopping list here includes a JDK, Maven and… well, that should be it, theoretically. Unfortunately, due to a nasty regression, we’re going to need a db. My choice goes to MySQL.
MySQL
First thing first, let’s install it:
~$ sudo apt-get install mysql-server
When this is done, we have to create the db Alfresco is going to use:
~$ mysql -u root mysql> CREATE DATABASE alf_jetty; mysql> GRANT ALL ON alf_jetty.* TO 'alfresco'@'%' IDENTIFIED BY 'alfresco';
Username and password are the default for the maven stuff we’re going to use.
Java
Java™ 5 has already passed on, let it rest in peace. Instead, go and install Java™ 6:
~$ sudo apt-get install sun-java6-jdk
Maven
Hold on the temptation of installing Maven 3 or to ask apt-get to do this task for you. We’re going to the official download page and following the links to get the latest stable 2.x release. You should end up with something like apache-maven-2.2.1-bin.tar.bz2 on your file system. Then do the following:
~$ cs /opt ~$ sudo tar xvjf apache-maven-2.2.1-bin.tar.bz2 ~$ sudo ln -sfv /opt/apache-maven-2.2.1/bin/mvn /usr/bin/mvn
There are less intrusive ways to bring your downloaded application into your PATH, but this is the quickest possible. Let’s go on to the next step.
Plumbing
We’re almost there, we just have to lay down our projects. Let’s start with the Alfresco repo extension:
~$ mkdir -p development/alfresco-showcase ~$ cd development/alfresco-showcase alfresco-showcase$ wget http://download.skuro.tk/alfresco-showcase/pom.xml alfresco-showcase$ mvn archetype:generate -DarchetypeGroupId=com.sourcesense.alfresco \ -DarchetypeArtifactId=maven-alfresco-extension-archetype \ -DarchetypeVersion=1.9.1 \ -DgroupId=it.sk.alfresco \ -DartifactId=alfresco-showcase-extension \ -Dversion=1.0-SNAPSHOT \ -DarchetypeRepository=http://maven.alfresco.com/nexus/content/repositories/releases \ -DinteractiveMode=false
The POM I’m making available here is just a very basically one, I’m using it here just for you to speed up the process.
UPDATE: as others pointed me out, it looks like you somehow need to download such a pom for the whole thing to stand up. That’s simply not true, I’m just building a more complex dev environment and it’s better if we have some structure in place. This includes having a parent project, along with its parent pom, with nested projects registered as its modules. These will come in the next posts. But that’s just part of the reason for this pom to be here: I also tend to be lazy, so that letting you download it was easier than explaining myself. Note to self: thou shalt not post anything at 2am.
First achievement
Ok, let’s stop here now and see what we’ve done by now. Go to the alfresco-showcase folder and type:
alfresco-showcase$ MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m" \ mvn clean install -Prun
This will start a local jetty instance where Alfresco 3.2 community will be deployed. So, if you now point your browser to http://localhost:8080/alfresco you will finally see that flower we talked about at the beginning of this post.
Next steps
That’s it for now, but other blocks are still missing: what about AMPs? And WCM? And does Share fits in the picture? I’ll cover all the points in the next episodes of this series. See you there!












